akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define each(it,o) for(auto it= (o).begin(); it != (o).end(); ++ it)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define inrep int t;cin>>t; while(t--)
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii > vpii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll > vpll; 
typedef vector<string> vs;
typedef long double ld;
const ll MOD = 1e9+7;
template<typename T> istream& operator>> ( istream &in,vector<T> &v ) {

    for ( unsigned   i=0; i<v.size(); i++ )
        in>>v[i];
    return in;
}
long long int y[100001][4];
long long int gain(long long int a[][3],long long int n,long long int k)
{
	if(y[n][k]!=-1)
	{
		return y[n][k];
	}
	if(n==1)
	{
	for(int i=0;i<3;i++)
	{
		if(i==k)
			continue;
    	y[n][k] = max(y[n][k],a[1][i]);
	}
		return y[n][k];
	}
	for(int i=0;i<3;i++)
	{
		if(i==k)
			continue;
        y[n][k]=max(y[n][k],a[n][i] + gain(a,n-1,i));
	}
     return  y[n][k];
	}
int main()
{
     // #ifndef ONLINE_JUDGE
     // freopen("input.txt","r",stdin);
     // freopen("output.txt","w",stdout);
     // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    long long int a[n+1][3];
    for(int i=1;i<=n;i++)
    {
    	for(int j=0;j<3;j++)
    	{
    		cin>>a[i][j];
    	}
    }
    memset(y,-1,sizeof(y));
    long long int f = gain(a,n,3);
    cout<<f;
    // #ifndef ONLINE_JUDGE
    //     cout<<"\nTime Elapsed : "<< 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    // #endif
    
    return 0;
}

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

int main(){
string a, b;
cin >> a >> b;

int sum =stoi(a + b);

for(int i = 1; i < 10000; i++){ 
     int k = i * i;
     if(sum == k){
         cout << "Yes" << endl;
         return 0; 
     }
}

cout << "No" << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int N, A, B, C, D;
string S;

bool judge(int start, int goal)
{
    bool dp[N + 1];
    dp[0] = true;
    dp[start] = true;
    dp[start + 1] = (S[start] == '.')? true : false;

    FOR(i, start + 1, goal) {
        if (S[i] == '#') dp[i + 1] = false;
        else {
            if (dp[i] || dp[i - 1]) dp[i + 1] = true;
            else dp[i + 1] = false;
        }
    }
    return dp[goal];
}

int main(int argc, char **argv)
{
    cin >> N >> A >> B >> C >> D >> S;

    if (C < D) {
        bool fa = judge(A, C);
        bool fb = judge(B, D);
        if (fa && fb) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        bool fb = judge(B, D);

        bool f = true;
        FOR(i, B - 2, D - 1) {
            if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
                S[i + 1] = '#';
                f = false;
                break;
            }
        }
        if (f) {
            cout << "No" << endl;
        }
        else {
            bool fa = judge(A, C);
            if (fa && fb) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 772
use std::collections::BTreeMap;
#[allow(dead_code)]
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)*}
    };
}

#[allow(dead_code)]
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)*}
    };
}

#[allow(dead_code)]
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")
    };
}

fn main() {
    input! {
        n: usize
    }

    let mut m: BTreeMap<(usize, usize), Vec<usize>> = BTreeMap::new();
    for i in 1..n + 1 {
        let key = parse_first_last(&i);
        if key.0 == 0 || key.1 == 0 {
            continue;
        }
        if m.contains_key(&key) {
            let v = m.get_mut(&key).unwrap();
            v.push(i);
        } else {
            m.insert(key, vec![i]);
        }
    }

    let result = {
        let mut sum = 0;
        for (&(first, last), v1) in m.iter() {
            if let Some(v2) = m.get(&(last, first)) {
                sum += v1.len() * v2.len();
            }
        }
        sum
    };


    println!("{}", result);
}


fn parse_first_last(n: &usize) -> (usize, usize) {
    let last = n % 10;
    let mut n = n.clone();
    while n >= 10 {
        n /= 10;
    }
    let first = n;
    (first, last)
}


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll k, n;
    cin >> k >> n;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    vector<ll> sub(n);
    REP(i, n-1) sub[i] = v[i+1] - v[i];
    sub[n-1] = k - (v[n-1] - v[0]);

    cout << k - MAX(sub) << endl;

    
    return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;

int main ()
{
    int a,b,num;
    cin >> a >> b;
    num = a / b;
    if(a % b == 0)
        cout  << num << endl;
    else
        cout << num+1 << endl;

    return 0;

}


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

int main() {
  int a, b, d, r;
  double f;

  cin >> a >> b;

  d = a / b;
  r = a % b;
  f = a / (double)b;

  cout << d << " " << r << " ";
  printf("%.5f\n", f);

  return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

#define mod 1000000007;

using namespace std;

int main()
{
    int N, R;

    cin >> N >> R;

    if (N < 10) cout << R + 100 * (10 - N);
    else cout << R;

    return 0;
}

Measured memory_bytes: 256
def answer(s):
    dic = {
        'left' : { 'W': 0, 'E': 0 },
        'right' : { 'W': 0, 'E': 0 } 
    }
    for i in range(1, len(s)):
        dic['right'][s[i]] += 1
    leader = s[0]
    _min = dic['right']['E']
    for i in range(1, len(s)):
        leader = s[i]
        dic['left'][s[i-1]] += 1
        dic['right'][leader] -= 1
        _min = min(_min, dic['left']['W']+dic['right']['E'])
    return _min

n = int(input())
s = input()
print(answer(s))
        

Measured memory_bytes: 41696
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

using namespace std;

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

    if      (n <= 111) { cout << 111 << endl; }
    else if (n <= 222) { cout << 222 << endl; }
    else if (n <= 333) { cout << 333 << endl; }
    else if (n <= 444) { cout << 444 << endl; }
    else if (n <= 555) { cout << 555 << endl; }
    else if (n <= 666) { cout << 666 << endl; }
    else if (n <= 777) { cout << 777 << endl; }
    else if (n <= 888) { cout << 888 << endl; }
    else               { cout << 999 << endl; }

    return 0;
}

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

int main() {
	int n;

	//入力
	cin >> n;
	vector<ll> a(n);
	for (ll i=0;i<n;++i) {
		int m;
		cin >> m;
		a[i] = m - i-1;
	}
	//sort
	sort(a.begin(), a.end());

	//a[i]の中央値
	ll c = a[n / 2];

	//答え
	ll ans = 0;
	for (int i = 0;i < n;++i) {
		ans += abs(a[i] - c);
	}

	//答え
	std::cout << ans << endl;
}


Measured memory_bytes: 4808
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = False

n = INT()
ab = [LIST() for _ in range(n)]
ab.sort(key=lambda x:x[1])
tim = 0
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    if tim + a > b:
        print('No')
        exit()
    tim += a
print('Yes')

Measured memory_bytes: 104536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<vector<int> > a(n, vector<int>(n));
  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> a[i][j];
  const int mod = 1000000007;
  vector<int> f(1<<n, 0);
  f[0] = 1;
  for(int i = 0; i < 1<<n; i++){
  	int who = __builtin_popcount(i);
    for(int j = 0; j < n; j++) if(!(i>>j&1)) {
      if(a[who][j]){
        int ni = i | (1<<j);
        f[ni] += f[i];
        if(f[ni] >= mod) f[ni] -= mod;
      }
    }
  }
  cout << f[(1<<n) - 1] << endl;
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <iostream>
#include <string> 
using namespace std;
int main(){
  int A[3];
  cin >> A[0] >> A[1] >> A[2];
  int n = 3;
    for(int i = 0; i < n; i++) {
    for(int j = n - 1; j > i; j--) {
      if(A[j] < A[j - 1]) {
        swap(A[i],A[j]);
      }
    }
    }
  cout << A[0] << " " << A[1] << " " << A[2] << endl;
}


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


using namespace std;
typedef long long ll;

ll n, m;

bool test(ll x) {
	if (x*n<=m) {
		cout<<x<<endl;
		return true;
	}
	else return false;
}

int main() {
	cin>>n>>m;
	ll t=sqrt(m+0.5);
	for(int i=1; i<=t; i++) {
		if (m%i) continue;
		if (test(m/i)) return 0;
	}

	for(int i=t; i>=1; i--) {
		if (m%i) continue;
		if (test(i)) return 0;
	}



	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    long double rs = 0;
    long double  n;
    cin >> n;
    rs = ceil(n / 2) / n ;
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3252
N=int(input().strip())
a=[]
for i in range(N):
    array=list(map(int,input().strip().split()))
    a.append(array)
b=sorted(a, key=lambda x:x[1])
n,t,f=0,0,0
while True:
    t+=b[n][0]
    if t>b[n][1]:
        f=1
        break
    n+=1
    if n==N:
        break
if f==1:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 55260
/*
                ____________    ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    __________
          /  /\     /  /\             /  /\  /_______  /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/
       
          A FAN OF FIZZYDAVID
           
*/

#include<bits/stdc++.h>

#define HEAP priority_queue
#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,n) for(int i=(n)-1;i>=0;i--)
#define forn(i,l,r) for(int i=(l);i<=(r);i++)
#define nrof(i,r,l) for(int i=(r);i>=(l);i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-20
#define pi 3.1415926535897932384626433832795
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define debug puts("OK");
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int iinf=1e9+7;
const LL linf=1ll<<60;
const flt dinf=1e10;

template <typename T>
inline void scf(T &x)
{
	bool f=0; x=0; char c=getchar();
	while((c<'0' || c>'9') && c!='-') c=getchar();
	if(c=='-') { f=1; c=getchar(); }
	while(c>='0' && c<='9') { x=x*10+c-'0'; c=getchar(); }
	if(f) x=-x; return;
}

template <typename T1,typename T2>
void scf(T1 &x,T2 &y) { scf(x); return scf(y); }

template <typename T1,typename T2,typename T3>
void scf(T1 &x,T2 &y,T3 &z) { scf(x); scf(y); return scf(z); }

#ifdef ONLINE_JUDGE
#else
#define DEBUG
#endif

//---------------------------head----------------------------

const int N=23333;

int n;
int a[N],b[N],p[N];

orz yjz()
{
	scf(n);
	forn(i,1,n) scf(p[i]);
	a[1]=1; forn(i,2,n) a[i]=a[i-1]+n;
	b[n]=1; nrof(i,n-1,1) b[i]=b[i+1]+n;
	forn(i,2,n) a[p[i]]+=i-1;
	forn(i,1,n) printf("%d%c",a[i],i==n?'\n':' ');
	forn(i,1,n) printf("%d%c",b[i],i==n?'\n':' ');
	fizzydavid ak la
}

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

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

        
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var h = input[0];
            var w = input[1];
            var s = new char[h][];
            for (int i = 0; i < h; i++)
            {
                s[i] = Console.ReadLine().ToCharArray();
            }

            var dx = new long[8] { -1, -1, -1, 0, 0, 1, 1, 1 };
            var dy = new long[8] { -1, 0, 1, -1, 1, -1, 0, 1 };
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    var count = 0;
                    if (s[i][j] == '.')
                    {
                        for (int k = 0; k < 8; k++)
                        {
                            var ni = i + dx[k];
                            var nj = j + dy[k];
                            if (-1 < ni && ni < h && -1 < nj && nj < w&&s[ni][nj]=='#')
                                count++;
                        }
              
                        s[i][j] = (char)('0' + count);
                    }
                    
                }
            }

            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                { 
                    Console.Write(s[i][j]);
                }
                Console.WriteLine();
            }
            
         


            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
bool check(int m)
{
	vector<pair<int,int> > v;
	for (int i=2;i<=n;i++)
	{
		if (a[i]<=a[i-1])
		{
			while (!v.empty() && v.back().first>a[i])
			v.pop_back();
			int tmp=a[i];
			while (!v.empty() && v.back().first==tmp && v.back().second==m)
			{
				v.pop_back();
				tmp--;
			}
			if (!tmp)
			return 0;
			if (v.empty() || v.back().first!=tmp)
			v.push_back({tmp,2});
			else
			v[v.size()-1].second++;
		}
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	bool one=1;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		one&=(a[i]>a[i-1]);
	}
	if (one)
	{
		printf("1");
		return 0;
	}
	int st=2,en=n;
	while (st!=en)
	{
		int mid=(st+en)/2;
		if (check(mid))
		en=mid;
		else
		st=mid+1;
	}
	printf("%d",st);
}

Measured memory_bytes: 4584
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (ll i = 0; i < (n); ++i)
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> k(10000005,2);
    for (ll i = 2; i < 5000002; i++)
    {
        ll l = 2;
        while(i*l<10000005){
            k[i*l]++;l++;
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= n; ++i){ans+=i*k[i];}
    cout<<ans-1<<endl;   
    return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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


int main(void){
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int ans;
  if (N %2 == 0){ans = N/2;}
  else ans = N/2 + 1;
  cout << ans << endl;



  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define VAR(v, i) __typeof( i) v=(i)
#define forit(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
 
using namespace std;
 
const int maxn = (int)1e5 + 10;
const int maxM = (int)1.5e7 + 100;
const int mod = (int)1e9 + 7;
const int P = (int) 1e6 + 7; 
const double pi = acos(-1.0);
 
#define inf mod
 	
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;   
typedef vector<ll> Vll;               
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;                        
typedef array<int, 3> triple;

void go(int a, int b, int c, int k){
	if(k == -1) return;
	if(b > a && c > b){
		puts("Yes");
		exit(0);
	}
	go(a + a, b, c, k - 1);
	go(a, b + b, c, k - 1);
	go(a, b, c + c, k - 1);
}
void solve(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	go(a, b, c, k);
	puts("No");
}

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

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A==1 && B==2)
    printf("3");
    else if(A==1 && B==3)
    printf("2");
    else if(A==2 && B==3)
    printf("1");
    else if(A==2 && B==1)
    printf("3");
    else if(A==3 && B==1)
    printf("2");
    else if(A==3 && B==2)
    printf("1");
    return 0;
}

Measured memory_bytes: 1616
#include<stdio.h>
#include<string.h>
int main()
{
    int n,t,o;
	int l[200008],r[200008];
	while(~scanf("%d%d",&n,&t))
	{
		o=0;
		memset(l,0,sizeof(l));
		memset(r,0,sizeof(r));
		int temp1,temp2;
		for(int i=0;i<t;i++)
		{
			scanf("%d%d",&temp1,&temp2);
			if(temp1>temp2)
               {
                   int x;
                   x=temp1;
                   temp1=temp2;
                   temp2=x;
               }
			if(temp1==1&&temp2!=n)
                l[temp2]++;
            else if(temp2==n&&temp1!=1)
                r[temp1]++;
		}

		for(int i=1;i<=n;i++)
		{
		    if(l[i]&&r[i])
            {
                o=1;
                break;
            }
		}
		if(o!=1) printf("IMPOSSIBLE\n");
		else printf("POSSIBLE\n");
	}
	return 0;
 }


Measured memory_bytes: 1664
n = int(input())
wl = [input() for i in range(n)]
ans = 'Yes'
if len(wl)!=len(set(wl)):
    ans = 'No'
else:
    for i in range(n-1):
        if wl[i][-1]!=wl[i+1][0]:
            ans = 'No'
            break
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC150_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            var ans = 0;
            for (int i = 0; i < n - 2; i++)
            {
                if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


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

int main()
{
	int N;cin >> N;
	vector<int> A(N);
	for (int i=0;i<N;i++) cin >> A[i];
	int q;cin >> q;
	vector<int> ans(2001,0);
	int value=0;
	for (int i=0;i<1<<N;i++)
	{
		value=0;
		for (int r=0;i>>r>0;r++)
		{
			if ((i>>r)&1) value+=A[r];
		}
		if (value<=2000) ans[value]=1;
	}
	int m;
	for (int i=0;i<q;i++)
	{
		cin >> m;
		if (ans[m]==1) cout << "yes" << endl;
		else cout << "no" << endl;
 	}
	return 0;
}


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const ll inf = 1e18 + 7;
const int N = 3e5 + 17;

int n, m;
ll dp[2][50 * 50 + 10][51];
int a[N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	memset(dp, -1, sizeof(dp));
	dp[0][0][0] = 1;
	int k = 1;
	for (int i = 0; i < n; i++, k ^= 1) {
		for (int s = 0; s <= 50 * 50; s++)
			for (int j = 0; j <= i + 1; j++) {
				ll fi = (s >= a[i] && j) ? dp[k ^ 1][s - a[i]][j - 1] : -1;
				ll se = dp[k ^ 1][s][j];
				if (se > fi) swap(fi, se);
				if (fi > 0) {
					dp[k][s][j] = fi;
					if (se > 0) dp[k][s][j] += se;
				}
            }
    }
    ll ans = 0;
   	k ^= 1;
   	for (int s = 0; s <= 50 * 50; s++)
   		for (int j = 1; j <= n; j++)
   			if (dp[k][s][j] > 0 && m * j == s) {
   				ans += dp[k][s][j];
   			}
	cout << ans;   				  			
}


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;


ull gcd(ull a,ull b){
	if(!b) return a;
	return gcd(b,a%b);
}


int main(){
	int n;
	cin >> n;
	int t,x,y,pre_x = 0,pre_y = 0,pre_t = 0;
	
	rep(i,0,n){
		cin >> t >> x >> y;
		if(abs(pre_x - x) + abs(pre_y - y) > t-pre_t){
			cout << "No" << endl;
			return 0;
		}
		else if(abs(pre_x - x) + abs(pre_y - y) < t-pre_t){
			if((abs(pre_x - x) + abs(pre_y - y) - t-pre_t) % 2){
				cout << "No" << endl;
				return 0;
			}
		}
		pre_x = x;
		pre_y = y;
		pre_t = t;
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    l,r,d=map(int, readline().rstrip().split())
    ans=0
    for i in range(l,r+1):
        if i%d==0:
            ans+=1
    print(ans)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 16196
(function main(){
  let lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n");
  let [n, k] = lines.shift().split(' ').map(Number);
  let w = lines.map(Number);

  const canAllStack = (p) => {
    let cnt = 0;
    for (let i = 0; i < k; i++)
      for (let sum = 0; sum + w[cnt] <= p;){
        sum += w[cnt++]
        if (cnt === n) return true;
      }
    return false;
  };

  let p = Math.floor(w.reduce((a, b) => a + b) / k - 1);
  while (!canAllStack(++p));
  console.log(p);
})();



Measured memory_bytes: 32396
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)


int main() {
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  
  cout << b+c-d << " " << c+d-a << " " << a+b-d << " " << b+c-a << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
ll fact[200005];
#define eps 1e-9
#define INF 1e18
#define N 200005
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int k,a,b; cin>>k>>a>>b;
        int flag=0;
        for(int i=a;i<=b;++i)if(i%k==0)flag=1;
        if(flag)cout<<"OK";
    else cout<<"NG";
        return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++){
        cin >> S[i];
    }
    bool p, w, g, y;
    p = w = g = y = false;

    for (int i = 0; i < N; i++){
        if (S[i] == "P"){
            p = true;
        }else if (S[i] == "W"){
            w = true;
        }else if (S[i] == "G"){
            g = true;
        }else{
            y = true;
        }
    }
    if (p == w == g == y == true){
        cout << "Four" << endl;
    }else{
        cout << "Three" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  a -= b;
  int ans = max(0, c - a);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include "algorithm"


using namespace std;
#define fori0(G) for(int i=0;i<G;i++)
#define fori1(G) for(int i=1;i<=G;i++)
#define forj0(G) for(int j=0;j<G;j++)
#define forj1(G) for(int j=1;j<=G;j++)
#define fork0(G) for(int k=0;k<G;k++)
#define fork1(G) for(int k=1;k<=G;k++)
int dx[] = { -1,0,1,0 ,0 }, dy[] = { 0,1,0,-1,0 };
#define nxnycon (0<=nx&&nx<h&&0<=ny&&ny<w) 


#define lo long long int



int main() {
	int h,w,s[52][52];
	char c;
	int p = 0;
	cin >> h >> w;
	fori0(h + 1) {
		s[i][0] = 0;
		s[i][w + 1] = 0;
	}
	fori0(w + 1) {
		s[0][i] = 0;
		s[h+1][i] = 0;
	}
	fori1(h)forj1(w) {
		cin >> c;
		if (c == '.') { s[i][j] = 0; }
		else { s[i][j] = 1; }
	}
	fori1(h)forj1(w) {
		if (s[i][j] && !(s[i - 1][j] || s[i + 1][j] || s[i][j - 1] || s[i][j + 1])) {
			p = 1;
		}
	}
	if (p) { cout << "No"; }
	else { cout << "Yes"; }
	
	//system("pause");
	return 0;

}



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

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

  vector<vector<int>> vec(m);
  rep(i,m){
    int k; cin >> k;
    vec[i].resize(k);
    for(int j = 0; j < k; ++j){
      cin >> vec[i][j];
      --vec[i][j];
    }
  }
  vector<int> p(m);
  rep(i,m) cin >> p[i];
  int ans = 0;
  for(int i = 0; i < (1<<n); ++i){
    bool ok = true;
    rep(j,m){
      int c = 0;
      for(int id : vec[j]){
        if((i >> id) & 1){
          ++c;
        }
      }
      c%=2;
      if(c!=p[j]) ok = false;
    }
    if(ok) ++ans;
  }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                998244353
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15

struct ppp{
    ll a,b,c;
};

struct lex_compare {
    bool operator() (ppp p1, ppp p2){
        if(p1.a == p2.a){
            if(p1.b == p2.b) return p1.c < p2.c;
            else return p1.b < p2.b;
        }else{
            return p1.a < p2.a;
        }
    }
};
ll dp[200004+1];

ll dfs(ll i,set<ll> &s, ll n){
    if(i == n){
        return 1;
    }
    if(dp[i] != -1) return dp[i];
    ll ans = 0;
    for(auto j : s){
        if(i + j <= n){
            ans += dfs(i+j, s, n);
            ans %= mod;
        }else{
            break;
        }
    }
    return dp[i] = ans;
}


int main(){
    FIO;
    ll n,k; cin >> n >> k;
    set<ll> s;
    pp(ll) arr[k];
    forn(i,0,k){
        cin >> arr[i].ff >> arr[i].ss;
    }
    sort(arr, arr+k);
    ll ans = 0;

    memset(dp, 0, sizeof(dp));
    dp[n] = 1;
    ll presum[n+5] = {0};
    presum[n] = 1;
    for(int i = n-1;i>0;i--){
        ll ind = i;
        ll temp = 0;
        for(int j = 0;j<k;j++){
            if(ind+arr[j].ff <= n){
                temp += (presum[ind+arr[j].ff] - presum[min(n+1, ind+arr[j].ss+1)] + mod)%mod;
            }else{
                break;
            }
        }
        //dbg2(i,temp);
        presum[i] = (temp + presum[i+1])%mod;
    }
    //dbgArr(presum, n+3);
    cout << (presum[1]-presum[2] +mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll m[3000];
void solve()
{
	string s;
	cin>>s;
	ll n=s.length();
	ll p=1;
	m[0]=1;
	ll a=0;
	for(ll i=n-1;i>=0;i--)
	{
		ll x=(ll)(s[i]-'0');
		x*=p;
		a+=x;
		a%=2019;
		m[a]++;
		p*=10;
		p%=2019;
	}
	ll ans=0;
	for(ll i=0;i<2019;i++)
	{
		ans+=(m[i]*(m[i]-1))/2;
	}
	cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
using data = pair<string, int>;
auto init(data & temp){
    temp.first = "";
    temp.second = 0;
}
int main(){
    string s; cin >>s;
    vector<data>split;
    string temp,last;
    data sbstr;
    for(int i = 0; i < s.size(); i++){
        temp.push_back(s[i]);
        if(temp == "egg" or temp == "chicken"){
            if (last ==  temp){
                split.push_back(sbstr);
                sbstr.first = temp;sbstr.second = 1;
            } else {
                sbstr.first += temp;
                sbstr.second += 1;
            }
            last = temp;
            temp.clear();
        }
    }
    if(sbstr.first.size())split.push_back(sbstr);
    data maxim; maxim.first =""; maxim.second = 0;
    for(auto && s : split){
        if (maxim.second < s.second)
            maxim = s;
    }
    string ans ="";
    reverse(maxim.first.begin(), maxim.first.end());
    /*
    for(auto && d : split){
        cout << d.first << " " << d.second << endl;
    }
     */
    for(auto && chr : maxim.first){
        ans.push_back(chr);
        string temp = ans;
        reverse(temp.begin(), temp.end());
        if (temp == "egg" or temp == "chicken"){
            cout << temp << endl;
            return 0;
        }
    }
}



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

int main()
{
  long long N;
  cin >> N;
  vector<long long> v(N);

  for (long long i = 0; i < N; i++)
  {
    cin >> v[i];
  }

  bool frag = true;

  for (long long i = N - 1; i > 0; i--)
  {
    if((v[i-1] - v [i]) >= 2)
    {
      frag = false;
      break;
    }
    else if ((v[i-1] - v[i]) == 1)
    {
      v[i - 1] = v[i - 1] - 1;
    }
  }

  if (frag)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

const int Dim = 1e5 + 5;

long long n, a, s, ans;
map <long long, long long> ap;

int main ( ) {
    cin >> n;
    ap[ 0 ] = 1;
    for (int i = 1; i <= n; ++ i) {
        cin >> a;
        s += a;
        ans += ap[ s ];
        ++ap[ s ];
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define itn int
#define gI gi

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int pp, m, f[5], a[200003], bj = 1;
string s, t, q;
ll n;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = gl();
	if (n & 1) {puts("0"); return 0;}
	ll numm = 0, num = 0;
    ll o = n, q = 5;
    n >>= 1;
    while (n >= q)
    {
		numm = numm + n / q;
		q = q * 5;
	}
	printf("%lld\n", numm);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
 
using namespace std;
 
int dp[35];
 
int main(){
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    for(int i=3;i<31;i++){
        dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    }
     
    int n;
    while(cin>>n && n){
        cout<<dp[n]/3650+(dp[n]%3650!=0)<<endl;
    }
}

Measured memory_bytes: 1160
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
ll x[20][20];
int main()
{
    ll n,d,ans=0;
    cin>>n>>d;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<d;j++)
        {
            cin>>x[i][j];
        }
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            ll s=0;
            for(ll k=0;k<d;k++)
            {
                s+=(x[j][k]-x[i][k])*(x[j][k]-x[i][k]);
            }
            if((ll)sqrt(s)*(ll)sqrt(s)==s)
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

#define FOR(i, j, k) for(int i = j; i <= k; i++)
#define SZ 110000
#define PB push_back
#define MEM(n, val) memset((n), val, sizeof(n))
#define INF 1000000000
#define F first
#define S second
#define MP make_pair

int n;
int ara[100010];

int le[100010], ri[100010];

int main()  {
//    freopen("in.txt", "r", stdin);

    cin >> n;
    FOR(i, 1, n)    {
        cin >> ara[i];
    }

    le[1] = ara[1];
    FOR(i, 2, n)   {
        le[i] = __gcd(le[i - 1], ara[i]);
    }

    ri[n] = ara[n];
    for(int i = n - 1; i >= 1; i--)   {
        ri[i] = __gcd(ri[i + 1], ara[i]);
    }

    int mx = 0;

    FOR(i, 1, n)   {
        int cand = __gcd(le[i - 1], ri[i + 1]);
        if(i == 1)    {
            cand = ri[i + 1];
        }
        else if(i == n)   {
            cand = le[i - 1];
        }
        mx = max(mx, cand);
    }

    cout << mx << "\n";

    return 0;
}
/**
*/


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm> // sort
#include <map> // pair
#include <utility>
#include <functional>
#define rep(i,N) for(int i=0;i<N;i++)
using namespace std;

int main() {
	char in[120];
	pair<pair<string, int>, int> p[110];
	int N; cin >> N;
	rep(i, N) {
		int t; cin >> in >> t;
		string tmp = in;
		p[i] = make_pair(make_pair(in, -t), i);
	}
	sort(p, p + N);
	rep(i, N) {
		cout << p[i].second + 1 << endl;
	}

	return 0;
}

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

int main()
{
	string S;
	cin >> S;
	int n = S.size();
	int b[26] = {0};
	for (int i = 0; i < n; i++) {
		b[S[i] - 'a']++;
	}
	char s = 'A';
	for (int i = 0; i < 26; i++) {
		if (b[i] == 0) {
			s = 'a' + i;
			break;
		}
	}
    if (s == 'A') {
        cout << "None" << endl;
    }
    else {
        cout << s << endl;
    }
}

Measured memory_bytes: 512
n, y = map(int, input().split())
ans1 = -1
ans2 = -1
ans3 = -1
for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i + 5000*j + (n-(i+j))*1000 == y:
            ans1 = i
            ans2 = j
            ans3 = n-(i+j)
            break
print(ans1, ans2, ans3)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int table[1000000];

int main() {
  int x, y;
  while(cin >> x >> y, x||y) {
    memset(table, -1, sizeof(table));
    int cnt = 0;
    while(1) {
      if (x == 0) {
        cout << cnt << " 0" << endl;
        break;
      }
      if (table[x] != -1) {
        cout << table[x] << " "<< cnt-table[x] << endl;
        break;
      }
      table[x] = cnt++;
      x *= 10;
      x %= y;
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	
	long int a[2];
	long int b[40] = {0};
	long int i, j, k;
	long int sum = 0;
	long int goukei;
	
	scanf("%ld%ld", &a[0], &a[1]);
	
	if(a[0] % 2 == 0) {
		if(a[1] % 2 == 0) {
			b[0] = ( (a[1] - a[0]) / 2 ) % 2;
			for(i = 0; i < 40; i++) {
				goukei = 1;
				for(j = 0; j < i; j++) {
					goukei *= 2;
				}
				
				if( (a[1] % (goukei * 2)) >= goukei) {
					b[i]++;
				}
			}
			
			for(i = 0; i < 40; i++) {
				if(b[i] % 2 == 1) {
					goukei = 1;
					for(j = 0; j < i; j++) {
						goukei *= 2;
					}
					sum += goukei;
				}
			}
			printf("%ld\n", sum);
			return 0;
		} else {
			printf("%ld\n", ( (a[1] - a[0] + 1) / 2 ) % 2);
			return 0;
		}
	} else {
		if(a[1] % 2 == 0) {
			b[0] = ( (a[1] - (a[0] + 1)) / 2 ) % 2;
			for(i = 0; i < 40; i++) {
				goukei = 1;
				for(j = 0; j < i; j++) {
					goukei *= 2;
				}
				
				if( (a[0] % (goukei * 2)) >= goukei) {
					b[i]++;
				}
			}
			for(i = 0; i < 40; i++) {
				goukei = 1;
				for(j = 0; j < i; j++) {
					goukei *= 2;
				}
				
				if( (a[1] % (goukei * 2)) >= goukei) {
					b[i]++;
				}
			}
			for(i = 0; i < 40; i++) {
				if(b[i] % 2 == 1) {
					goukei = 1;
					for(j  = 0; j < i; j++) {
						goukei *= 2;
					}
					sum += goukei;
				}
			}
			printf("%ld\n", sum);
			return 0;
		} else {
			b[0] = ( (a[1] - (a[0] + 1) + 1) / 2 ) % 2;
			if(b[0] % 2 == 0) {
				if(a[0] % 2 == 0) {
					printf("%ld\n", a[0]);
					return 0;
				} else {
					printf("%ld\n", a[0]);
					return 0;
				}
			} else {
				if(a[0] % 2 == 0) {
					printf("%ld\n", a[0]);
					return 0;
				} else {
					printf("%ld\n", a[0] - 1);
					return 0;
				}
			}
		}
	}
	printf("%ld\n", sum);
	
	return 0;
}

Measured memory_bytes: 128