akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] lines = br.readLine().split(" ");
        long a=Long.parseLong(lines[0]);
        long b=Long.parseLong(lines[1]);
        System.out.println(gcd(a,b));
    }
    static long gcd(long x,long y){
       if(x<y){
           long temp=x;
           x=y;
           y=temp;
       }
       if(y >0){
           return gcd(y,x%y);
       }else{
           return x;
       }
    }
}
      

Measured memory_bytes: 24444
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    vector<long long> divisor(long long n) {
        vector<long long> ret;
        for (long long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                ret.emplace_back(i);
                if (i * i != n) ret.emplace_back(n / i);
            }
        }
        sort(ret.begin(), ret.end()); // 昇順に並べる
        return ret;
    }

    ll GetDigit(ll num){
        return to_string(num).length();
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        vl A=divisor(n);
        ll res=INF;
        rep(i,(Size(A)+1)/2){
            chmin(res,GetDigit(n/A[i]));
        }
        cout<<res<<endl;
    }

Measured memory_bytes: 3724
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

int main(void){
	setp(10);
	ld r;
	cin >> r;
	co(2 * r * PI);
	return 0;
}


Measured memory_bytes: 3792
#include <stdio.h>
#define N 100
int main(){
  int n,i,j,u,k,v,M[N][N];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++)
    {
      for(j=0 ; j<n ; j++)
	{
	  M[i][j] = 0;
	}
    }

  for(i=0 ; i<n ; i++)
    {
      scanf("%d",&u);
      scanf("%d",&k);
      for(j=0 ; j<k ; j++)
	 {
	  scanf("%d",&v);
	  M[u-1][v-1] = 1;
	}
    }

    for(i=0 ; i<n ; i++)
    {
      for(j=0 ; j<n-1 ; j++)
	{
	  printf("%d ",M[i][j]);
	}
      printf("%d",M[i][n-1]);
      printf("\n");
    }
  
  return 0;
}



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

using namespace std;

int findInt(int query, vector<int> ints) {
	for (int i = 0; i < ints.size(); i++) {
		if (ints.at(i) == query) {
			return i;
		}
	}
	return -1;
}


int main() {
	int X, N;
	cin >> X >> N;
	vector<int> p;
	for (int i = 0; i < N; i++) {
		int pi;
		cin >> pi;
		p.push_back(pi);
	}
	int diff = 0;
	while (findInt(X + diff, p) != -1) {
		if (diff < 0) {
			diff *= -1;
		} else if (diff >= 0) {
			diff *= -1;
			diff--;
		}
	}
	cout << X + diff << endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
   string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == N - 1) {
       cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
x = input()
ans = len(x)
cs = 0
T = False

for i in x:
  if i == 'S':
    if T:
      T = False
    cs += 1
  else:
    if not T:
      T = True
    if cs > 0:
      cs -= 1
      ans -= 2
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
const ld pi = acos(-1);
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    string s, t; cin >> s >> t;
    SORT(s);
    rSORT(t, greater<char>());
    cout << (s < t ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
n = gets.to_i

xy = []
n.times do
    a = gets.to_i
    xy << []
    a.times {xy[-1] << gets.split.map(&:to_i)}
end

ans = 0
(2 ** n).times do |b|
    re = catch do |tag|
        xy.each_with_index do |e, i|
            next if b[i] == 0

            e.each do |k, v|
                throw(tag, false) if b[k-1] != v
            end
        end
        true
    end

    if re
        t = sprintf("%0*b", n, b).count("1")
        ans = t if ans < t
    end
end

puts ans

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

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  double s = x/a;
  double rad;
  if (s >= a*b/2) {
    double h = (a*b-s)*2/a;
    rad = atan2(h,a);
  } else {
    double w = s*2/b;
    rad = atan2(b,w);
  }
  double PI = acos(-1);
  double deg = rad/(2*PI)*360;
  printf("%.10f\n", deg);
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    sort(s.begin(), s.end());
    if (s == "abc")
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,m,count=0;
	double v;
	cin>>n>>m;
	vector<int> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	v=accumulate(a.begin(),a.end(),0)/(4.0*m);
	for(int i=0;i<n;i++){
		if(a[i]>=v)
		count++;
	}
	if(count>=m)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import collections
n = int(input())
s = []
for i in range(n):
	s.append(input())
m = int(input())
t = []
for i in range(m):
	t.append(input())
cs = collections.Counter(s)
ct = collections.Counter(t)
ans = []
for i in range(len(cs)):
	for j in range(len(ct)):
		if cs.most_common()[i][0] == ct.most_common()[j][0]:
			ans.append([cs.most_common()[i][1] - ct.most_common()[j][1], cs.most_common()[i][0]])
			break
	if cs.most_common()[i][0] not in ct.keys():
		ans.append([cs.most_common()[i][1], cs.most_common()[i][0]])
ans.sort(reverse=True)
if ans[0][0] <= 0:
	print(0)
else:
	print(ans[0][0])

Measured memory_bytes: 3316
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    private static long ans = 0, low = 0;

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

        long n = in.nextInt();
        while (n > 0) {
            ans = 0;
            low = 0;
            long d = 2 * n;
            for (int i = 1; i * i <= d; i++) {
                if (d % i != 0) continue;

                calc(i, d / i);
                calc(d / i, i);
            }
            out.println(low + " " + ans);

            n = in.nextInt();
        }
        out.flush();
    }

    private static void calc(long x, long y) {
        //System.out.println("x=" + x + " y=" + y);
        if ((x - y + 1) % 2 != 0 || (x + y - 1) % 2 != 0) return;
        long b = (x + y - 1) / 2, a = (x - y + 1) / 2;
        if (b < 1 || a < 1) return;
        //System.out.println("a=" + a + " b=" + b);
        if (b - a + 1 > ans) {
            ans = b - a + 1;
            low = a;
        }
    }

}



Measured memory_bytes: 30564
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

const int N=3e6;
const int mod=998244353;
int n,k,ans,fac[N+5],inv[N+5],infac[N+5];

void init()
{
	int i;scanf("%d%d",&n,&k);
	fac[0]=1;for(i=1;i<=N;++i) fac[i]=1LL*fac[i-1]*i%mod;
	inv[1]=1;for(i=2;i<=N;++i) inv[i]=1LL*inv[mod%i]*(mod-mod/i)%mod;
	infac[0]=1;for(i=1;i<=N;++i) infac[i]=1LL*infac[i-1]*inv[i]%mod;
}

int C(int x,int y)
{
	if(y>x) return 0;
	return 1LL*fac[x]*infac[y]%mod*infac[x-y]%mod;
}

void calc(int x,int y,int T)
{
	if(T<=0) return;
	int ret=C(x+y,x);
	if(T<=y) ret-=C(x+y,y-T);
	if(ret<0) ret+=mod;
	ans+=ret;if(ans>=mod) ans-=mod;
}

void work()
{
	int i,j;
	for(i=0,j=k;i<=k;++i,--j)
	{
		if(i<j) continue;
		else if(i==j) calc(i,j-1,i-n+1);
		else calc(i,j,i-n+1);
	}
	printf("%d\n",ans);
}

int main()
{
//	freopen("ball.in","r",stdin);
//	freopen("ball.out","w",stdout);
	init();
	work();
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, p, w, g, y;
  string Si;
  p = 0;
  w = 0;
  g = 0;
  y = 0;
  cin >> N;
  
  for (i == 0; i < N; i++) {
    cin >> Si;
   if (Si == "P" && p == 0) {
   p += 1;
   }
    
   else if (Si == "W" && w == 0) {
   w += 1;
   }
    
   else if (Si == "G" && g == 0) {
   g += 1;
   }
    
   else if (Si == "Y" && y == 0) {
   y += 1;
   }
  }
  if (p + w + g + y == 3) {
  cout << "Three" << endl;
  }
  else if (p + w + g + y == 4) {
  cout << "Four" << endl;
  }
}    
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,dist;
  cin>>n;
  dist=0;
  vector<int> a(n+2);
  a[0]=0;a[n+1]=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    dist+=abs(a[i]-a[i-1]);
  }
  dist+=abs(a[n]);
  for(int i=1;i<=n;i++){
    if(a[i-1]<=a[i]&&a[i]<=a[i+1]){cout<<dist<<endl;}
    else if(a[i-1]>=a[i]&&a[i]>=a[i+1]){cout<<dist<<endl;}
    else{cout<<dist-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1])<<endl;}
  }
}


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

int main() {
  int a, b, c,d;
  cin >> a;
  
  b = a / 100;
  c = (a % 100) / 10;
  d = (a % 100) % 10;
  
  cout << b + c + d << endl;
}

Measured memory_bytes: 256
from itertools import permutations 
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=list(p)
l.sort()
pp,qq='',''
for i in range(n):
  pp+=str(p[i])
  qq+=str(q[i])
ll=permutations(l)
arr=[]
for i in ll:
  x=''
  for j in i:
    x+=str(j)
  arr.append(x)
print(abs(arr.index(pp)-arr.index(qq)))


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

int main() {
  char a,b,c; 
  cin >>a>>b>>c;
    if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o'){
 
    cout<<"vowel"<<endl;}
  else{
 cout<<"consonant"<<endl;}
}


Measured memory_bytes: 256
class ReversePopHeap
  attr_accessor :nodes, :size
  def initialize(n)
    @nodes = Array.new(n)
    @size = 0
  end

  def push(x)
    current_index = @size
    @size += 1
    while current_index > 0 do
      parent_index = (current_index - 1)>>1
      parent_value = @nodes[parent_index]
      break if parent_value >= x
      @nodes[current_index] = parent_value
      current_index = parent_index
    end
    @nodes[current_index] = x
  end

  def pop
    top = @nodes[0]
    current_node_index = 0
    current_node_value = @nodes[0] = @nodes[@size - 1]
    @nodes[@size - 1] = nil
    @size -= 1

    while
      child_node_index_r = (current_node_index + 1) << 1
      child_node_index_l = child_node_index_r - 1
      return top unless child_node_index_l < @size
      child_node_value_l = @nodes[child_node_index_l]
      child_node_value_r = @nodes[child_node_index_r]
      if child_node_value_r&.>child_node_value_l
        max_child_value = child_node_value_r
        max_child_index = child_node_index_r
      else
        max_child_value = child_node_value_l
        max_child_index = child_node_index_l
      end
      return top unless max_child_value > current_node_value
      change(current_node_index, max_child_index)
      current_node_index = max_child_index
    end
  end

  private

  def change(index_i, index_j)
    @nodes[index_i], @nodes[index_j] = @nodes[index_j], @nodes[index_i]
  end
end

n, m = gets.split.map(&:to_i)

values = []
n.times do
  values << gets.split.map(&:to_i)
end
values.sort_by!(&:first)

rhp = ReversePopHeap.new(n)
ans = 0
ite = 0
1.step(m) do |limit_day|
  while true
    day, fee = values[ite]
    break unless day == limit_day
    rhp.push(fee)
    ite += 1
  end
  ans += rhp.pop.to_i if rhp.size > 0
end

puts ans

Measured memory_bytes: 12664
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int x,a;
	cin>>x>>a;
	cout<<(x<a?0:10)<<endl;
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL) root=z;
  else if(z->key<y->key) y->left=z;
  else y->right=z;
}
			   

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    /*if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      } */
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      }*/
  }

  return 0;
}



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

int main()
{
	int N;
	cin >> N;
	rep(i,N)
	{
		string s;
		cin >> s;
		a.insert(s);
	}
	cout << a.size() << endl;
	return 0;
}

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

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1 << 29)
#define LLINF (1LL << 60)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;

string to_string(string s) { return s; }
template <class S>
string to_string(unordered_set<S> s);
template <class S>
string to_string(set<S> s);
template <class S, class T>
string to_string(map<S, T> m);
template <class T>
string to_string(vector<T> v);

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S>
string to_string(set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x) + ",";
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x) + ",";
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < (int)v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

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

  ll N, A, B;
  cin >> N >> A >> B;
  if (abs(A - B) % 2 == 0) {
    cout << abs(A - B) / 2 << endl;
  } else {
    if (A - 1 > N - B) {
      ll wt = N - B;
      cout << wt + 1 + (B - A - 1) / 2 << endl;
    } else {
      ll wt = A - 1;
      cout << wt + 1 + (B - A - 1) / 2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
ll fn(ll a)
{
    if (a)
    {
        return -1;
    }
    return 1;
}
ll power(ll a, ll b, ll m = mod)
{
    if (b == 0)
    {
        return 1 % m;
    }
    ll u = power(a, b / 2, m);
    u = (u * u) % m;
    if (b % 2 == 1)
    {
        u = (u * a) % m;
    }
    return u;
}
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, cnt = 0;
    vll ans(2, 0);
    cin >> n;
    string a;
    cin >> a;
    fr(i, 0, n)
    {
        if (a[i] - '0')
        {
            cnt++;
        }
    }
    cnt++;
    for (int i = n - 1; i >= 0; i--)
    {
        ans[0] = (ans[0] + ((a[i] - '0') * power(2, n - i - 1, cnt)) % cnt) % cnt;
    }
    if (cnt > 2)
    {
        cnt -= 2;
        for (int i = n - 1; i >= 0; i--)
        {
            ans[1] = (ans[1] + ((a[i] - '0') * power(2, n - i - 1, cnt)) % cnt) % cnt;
        }
        cnt += 2;
    }
    fr(i, 0, n)
    {
        if (cnt - 2 * (a[i] - '0') == 0)
        {
            cout << 0 << "\n";
            continue;
        }
        ll tp = (ans[a[i] - '0'] + fn(a[i] - '0') * power(2, n - i - 1, cnt - 2 * (a[i] - '0'))) % (cnt - 2 * (a[i] - '0')), an = 1;
        if (tp < 0)
        {
            tp += (cnt - 2 * (a[i] - '0'));
        }
        while (tp != 0)
        {
            an++;
            tp %= __builtin_popcount(tp);
        }
        cout << an << "\n";
    }
    return 0;
}

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

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

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

}
int main(){
  
  string S;
  cin>>S;
    vector<vector<ll>>dp(S.size()+1,vector<ll>(13));

  dp[0][0]=1;
  
  ll num=1;
rep(i,S.size()){
if(S[S.size()-1-i]=='?'){
  rep(j,10){
    rep(k,13){
    dp[i+1][(j*num+k)%13]+=dp[i][k];
      dp[i+1][(j*num+k)%13]%=mod;
    }
  }
}

  else{
    ll j=S[S.size()-1-i]-'0';
     rep(k,13){
dp[i+1][(j*num+k)%13]+=dp[i][k];//上と同じ要領でi文字までであまりがkのものをi+1に引き継ぐ
    dp[i+1][(j*num+k)%13]%=mod;
  }
}
      
      num*=10;//下から桁を見ていくため
      num%=13;
    }
cout<<dp[S.size()][5]<<endl;
  
  }
      
    

Measured memory_bytes: 13696
#include<bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
int main(){  
    int n,d;
    cin>>n>>d;
    int count=0;
    int tree[100];
    for (int i = 0; i < n; i++)
    {
        tree[i]=0;
    }
    
    for (int i = 0; i < n; i++)
    {
        if(tree[i]==0){
            for (int j = i; j <=i+2*d; j++)
            {
                tree[j]=1;
            }
            count++;            
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define MOTO 8002

int tatedp[2][16003];
int yokodp[2][16003];

int main()
{
	REP(i,2)REP(j,16003)
	{
		tatedp[i][j] = yokodp[i][j] = -1;
	}
	
	string str;cin >> str;
	str = str;
	int x,y;cin >> x >> y;
	
	vector<int> tate;
	vector<int> yoko;
	
	int cou = 0;
	int chan = 0;
	REP(i,str.size())
	{
		if(str[i] == 'F')
		{
			cou++;
		}
		else
		{
			if(chan)
			{
				tate.PB(cou);
			}
			else
			{
				yoko.PB(cou);
			}
				
			chan = 1-chan;
			cou = 0;
		}
	}
	
	if(cou != 0)
	{
		if(chan)
		{
			tate.PB(cou);
		}
		else
		{
			yoko.PB(cou);
		}
	}

		
	yokodp[1][yoko[0]+MOTO] = 1;
	tatedp[0][0+MOTO] = 0;
	
//	SHOW1d(tate,tate.size());
//	SHOW1d(yoko,yoko.size());
	
	for(int i = 1;i < yoko.size();i++)
	{
		REP(j,16003)
		{
			if(yokodp[i%2][j] == i)
			{
				
	//			cout << "!!!" << j << endl;
				yokodp[(i+1)%2][j+yoko[i]] = i+1;
				yokodp[(i+1)%2][j-yoko[i]] = i+1;
	//			cout << j+yoko[i] << ' ' << j-yoko[i] << endl;
			}
		}
	}
	
	REP(i,tate.size())
	{
		REP(j,16003)
		{
			if(tatedp[i%2][j] == i)
			{
	//			cout << "!!" << j << endl;
				tatedp[(i+1)%2][j+tate[i]] = i+1;
				tatedp[(i+1)%2][j-tate[i]] = i+1;
			}
		}
	}
	
	REP(i,16003)
	{
		tatedp[0][i] = max(tatedp[0][i],tatedp[1][i]);
		yokodp[0][i] = max(yokodp[0][i],yokodp[1][i]);
	}
	
//	cout << y+MOTO << ' ' << x+ MOTO <<  endl;
//	cout << tatedp[0][y+MOTO] << ' ' <<  tate.size() << ' ' <<  yokodp[0][x+MOTO] << ' ' <<  yoko.size() << endl;
	if(tatedp[0][y+MOTO] == tate.size() && yokodp[0][x+MOTO] == yoko.size())
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long

using namespace std;
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main()
{
    int k;  cin >> k;
    cout << a[k - 1];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long X;
  cin>>X;
  int ans=0;
  for(int i=X;;i++){
    ans=0;
    for(int j=2;j<i;j++){
      if(i%j==0){
        ans=1;
        continue;
      }
    }
    if(ans==0){
      cout<<i<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int seat[17] = {0};
	int X = 0;
	int stop[100] = {0};
	int time = 0;
	queue<int> Q;
	while(X < 100){
		int x;
		if(time%5 == 0 && time < 500){
			Q.push(time/5);
		}
		while(1){
			if(Q.size())x = Q.front();
			else x = -1;
			bool f = false;
			
			if(~x){
				int people = (x%5==1?5:2);
				int use = 19 + 3 * (x%3) + 17 * (x%2);
				rep(i,17-people+1){
					bool flag = true;
					rep(j,people){
						flag &= seat[i+j] == 0;
					}
					if(flag){
						rep(j,people){
							seat[i+j] = use;
						}
						f = true;
						break;
					}
				}
			}
			if(f){	
				stop[x] = time - x * 5;
				Q.pop();
				X++;
			}
			if(!f)break;
		}
		rep(i,17){
			seat[i] = max(0,seat[i]-1);
		}
		time++;
	}
	int n,c=0;
	
	while(cin >> n){
		if(n == 2)c++;
		cout << stop[n] << endl;
	}
	int a = 0;
	while(c>=1){cout << a/a << endl;};
	
}

Measured memory_bytes: 0
x, n = map(int,input().split())
if n == 0:
    print(x)
else:
    pls = list(map(int,input().split()))
    i = 0
    while 0 < 1:
        if x + i not in pls:
            if x - i not in pls:
                print(x - i)
                break
            else:
                print(x + i)
                break
        elif x - i not in pls:
            print(x - i)
            break
        else:
            i += 1


Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator^(const ll& t)const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

//////////////////////////
ll N;
vector<vector<ll>> g;

vector<ll> ans;

void dfs(ll u,ll v) {
    ll c = 0;
    for (ll w : g[v]) {
        if (w == u) { continue; }

        dfs(v, w);
        if (ans[w] == 1) { c++; }
        if (ans[w] == 3) { ans[v] = 3; return; }
    }

    if (c == 0) { ans[v] = 1; }
    else if (c == 1) { ans[v] = 2; }
    else { ans[v] = 3; }
    return;
}

int main() {
    cin >> N;
    g.resize(N + 1);

    repn(i, N - 1) {
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    ans.assign(N + 1, 0);

    dfs(0, 1);

    if (ans[1] == 2) { cout << "Second"; }
    else { cout << "First"; }
   

	system("PAUSE");
}

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

using namespace std;

int main()
{
    int n;
    double t, a, h;

    cin >> n >> t >> a;
    
    int p = 0;
    double near = 10000000;
    for(int i = 0; i < n; i++){
        cin >> h;
        double diff = abs(a - (t - h * 0.006));
        if(diff < near){
            near = diff;
            p = i + 1;
        }
    }

    cout << p << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import deque

def bfs(maze, visited, sy, sx):
  queue = deque([[sy, sx]])
  visited[sy][sx] = 0
  #　返り値
  va = 0
  while queue:
    y,x = queue.popleft()
    #　返り値に関する条件
    if visited[y][x] > va :
      va = visited[y][x]
    for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
      new_y, new_x = y+j, x+k
      if maze[new_y][new_x] == "." and visited[new_y][new_x] == -1:
        #　移動回数の計算
        visited[new_y][new_x] = visited[y][x] + 1
        queue.append([new_y, new_x])
  return va

h,w = map(int,input().split())
wall = ''
for i in range(w+2):
  wall += '#'
maze = [wall]
for i in range(h) :
  m1 = input()
  maze.append('#'+m1+'#')
maze .append(wall)

ans = []
for sy in range(1,h+1) :
  for sx in range(1,w+1):
    if maze[sy][sx] == '#' :
      continue
    visited = [[-1]*(w+2) for _ in range(h+2)]
    ans.append(bfs(maze, visited, sy, sx))

print(max(ans))


Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	h, w, k := io.NextInt(), io.NextInt(), io.NextInt()
	c := make([]string, h)
	for i := 0; i < h; i++ {
		c[i] = io.Next()
	}
	ans := solve(h, w, k, c)
	io.Println(ans)
}

func solve(h, w, k int, c []string) (ans int) {
	for i, iMax := 0, 1<<h; i < iMax; i++ {
		ignoreRows := map[int]struct{}{}
		for shift := 0; shift < h; shift++ {
			if i>>shift&1 == 1 {
				ignoreRows[shift] = struct{}{}
			}
		}
		for j, jMax := 0, 1<<w; j < jMax; j++ {
			ignoreCols := map[int]struct{}{}
			for shift := 0; shift < w; shift++ {
				if j>>shift&1 == 1 {
					ignoreCols[shift] = struct{}{}
				}
			}
			cnt := count(c, ignoreRows, ignoreCols)
			if cnt == k {
				ans++
			}
		}
	}
	return ans
}

func count(c []string, ignoreRows, ignoreCols map[int]struct{}) int {
	ret := 0
	for i, row := range c {
		if _, ok := ignoreRows[i]; ok {
			continue
		}
		for j, char := range row {
			if _, ok := ignoreCols[j]; ok {
				continue
			}
			if char == '#' {
				ret++
			}
		}
	}
	return ret
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
 

vector <int > H;
int N; 
  
int main()
{
  cin >> N;
  H.resize(N);
  REP(i,N){
    cin >> H[i];
  }
  int a = H[0];
  FOR(i,1,N){
    if(H[i]>a){
      a = H[i] - 1;
    } else if(H[i] < a){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N, K;
    cin >> N >> K;
    vector <long long> x(N);
    ll inp;
    REP(i, N){
        cin >> inp;
        x[i] = inp;
    }

    ll _min = 1 << 30;
    ll sum;
    REP(left, N - K + 1){
        sum = 0;
        ll right = left + K - 1;
        if(x[left]*x[right] < 0){
            sum = x[right] - x[left] + min(x[right], abs(x[left]));
        }
        else{
            sum = max(abs(x[left]), abs(x[right]));
        }
        if(sum < _min)
            _min = sum;
    }
    cout << _min << endl;

    return 0;
}


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

vector<int> dp;

int n, m;
vector<int> costs;
vector<int> masks;

void rec(int pos, int cnt, int mask)
{
    if (cnt == 0)
    {
        for (int i = 0; i != m; ++i)
            dp[mask | masks[i]] = min(dp[mask | masks[i]], dp[mask] + costs[i]);
        
        return;
    }
    
    if (pos == n)
        return;
    
    rec(pos + 1, cnt, mask);
    rec(pos + 1, cnt - 1, mask | (1 << pos));
}

void solve()
{
    cin >> n >> m;
    
    dp.resize(1 << n, 2000000000);
    dp[0] = 0;
    costs.resize(m);
    masks.resize(m);
    
    for (int i = 0; i != m; ++i)
    {
        int a, b;
        cin >> a >> b;
        costs[i] = a;
        int mask = 0;
        for (int j = 0; j != b; ++j)
        {
            int c;
            cin >> c;
            mask |= 1 << (c - 1);
        }
        masks[i] = mask;
    }
    
    for (int i = 0; i != n; ++i)
        rec(0, i, 0);
    
    if (dp.back() == 2000000000)
        cout << -1 << '\n';
    else
        cout << dp.back() << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby
def qq_print
  j = 1
  i = 1
  while j < 10 and i < 10 do
    puts "#{ i }x#{ j }=#{ i * j }"
    j < 9 ? (j += 1 ) : (i += 1 and j = 1)
  end
end

qq_print

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    string s;
    cin>>s;
    int ans = 0;
    REP(i,3) if (s[i] == '1') ans++;
    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef map<ll,ll> mll;

#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
// #define mod 998244353
#define mod 1000000007 

#define trace1(x)                       cerr<<#x<<": "<<x<<endl
#define trace2(x, y)                    cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)                 cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(x, y, z , t)             cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<endl
#define trace5(x, y, z , t , u)         cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<endl
#define trace6(x, y, z , t , u , v)     cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#t<<": "<<t<<" | "<<#u<<": "<<u<<" | "<<#v<<": "<<v<<endl

#define repa(i,sta,end,inc) for(int i = sta ; i <= end ; i += inc)
#define repb(i,sta,end,inc) for(int i = sta ; i >= end ; i -= inc)

ll power(ll x , ll y , ll z){ll res = 1;x %= z;while(y){if(y&1){res = res * x % z;}x = x*x % z;y /= 2;}return res%z;}
ll gcd(ll a , ll b){return (b == 0 ? a : gcd(b , a % b));}

const int N = 2 * 100000 + 1;
const int inf = (1<<30);

void solve(){
    int n;
    cin >> n;
    ll ans = 0;
    repa(i,1,n,1){
        if(i % 3 > 0 && i % 5 > 0){
            ans += (ll)i;
        }
    }
    cout << ans << endl;
}


int main(){
    FIO;
    int T = 1;
    // cin >> T;
    repa ( i , 1 , T , 1){
        solve();
    }
    return 0;
}


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

int asc(const void *a,const void *b){
	return *(int *)a-*(int *)b;
}

int main(void){
	int N,K,i,j;
	scanf("%d %d",&N,&K);
	
	int h[N];
	
	for(i=0;i<N;++i){
	scanf("%d",&h[i]);
	}
	
	qsort(h,sizeof(h)/sizeof(int),sizeof(int),asc);
	
	int inter=K-1,min=h[inter]-h[0],sa;
	for(i=0;i<N-inter;++i){			
			sa=h[i+inter]-h[i];
			if(sa<min) min=sa;
			if(min==0) break;
		}
		
	printf("%d\n",min);
	return 0;
}
	

	
	
	

	

Measured memory_bytes: 892
#include<iostream>
#include<math.h>
#define _USE_MATH_DEFINES
# define M_PI  3.14159265358979323846 
using namespace std;

int main(){
	double n;
	cin>>n;
	double x;
	x=2*M_PI*n;
	cout<<x<<endl;
	
	
}


Measured memory_bytes: 3788
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<algorithm>

using namespace std;
int main()
{
	int n,ac=0,tle=0,wa=0,re=0; cin>>n;
	string s;
	for(int i = 0;i <= n ; ++i)
	{

		getline(cin,s);
		if(s=="AC")
			ac++;
		else if(s=="WA")
			wa++;
		else if(s=="TLE")
			tle++;
		else if(s=="RE") re++;

	}
	cout<< "AC x "<< ac<<endl;
	cout<< "WA x "<< wa<<endl;
	cout<< "TLE x "<< tle<<endl;
	cout<< "RE x "<< re<<endl;






	return 0;
}



Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define SIZE 5005
using namespace std;
typedef long long int ll;
 
int main(){
    ios::sync_with_stdio(false);
    ll x,d;
 
    cin>>x>>d;
    d=d*d;
    ll ans=0;
    while(x--){
        ll a,b;
        cin>>a>>b;
        if(a*a+b*b<=d){
            ans++;
        }
    }
    cout<<ans;
 
}

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

using namespace std;

const int NMAX = 100009;

long long h, w, n, f[15], d = 0;
long long dx[9] = {-2, -2, -2, -1, -1, -1, 0, 0, 0};
long long dy[9] = {-2, -1,  0, -2, -1,  0,-2,-1, 0};

struct Node{
    long long x, y;
} squ[10*NMAX];

//vector<Node> squ;


bool cmp(Node a, Node b){
    if(a.x == b.x) return a.y < b.y;
    return a.x < b.x;
}

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

    cin >> h >> w >> n;
    long long u, v, x, y;
    while(n--){
        cin >> u >> v;
        for(long long i = 0; i < 9; i++){
            x = u + dx[i];
            y = v + dy[i];
            if(x > 0 && x <= h-2 && y > 0 && y <= w-2)
                squ[d++] = {x, y};
        }
    }

    sort(squ, squ+d, cmp);

    long long dem = 0;
    u = -1, v = -1;
    for(long long i = 0; i < d; i++){
        if(squ[i].x == u && squ[i].y == v) dem++;
        else{
            if(dem != 0) f[dem]++;
            dem = 1;
            u = squ[i].x, v = squ[i].y;
        }
    }
    if(dem != 0) f[dem]++;
    f[0] = (h-2)*(w-2);
    for(long long i = 1; i <= 9; i++) f[0] -= f[i];
    for(long long i = 0; i <= 9; i++)
        cout << f[i] << endl;
}


Measured memory_bytes: 14592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int tmp;
		int num = 1;

		while ((tmp = sc.nextInt()) != 0) {
			System.out.println("Case " + num + ": " + tmp);
			num++;
		}
	}
}


Measured memory_bytes: 42768
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,num;
  vector<P> ans;
  cin >> n>>k;
  if(k>((n-1)*(n-2))/2){
    cout <<"-1\n";
    return 0;
  }
  num = ((n-1)*(n-2))/2-k;
  for(int i=2;i<=n;i++){
    ans.push_back(P(1,i));
  }
  if(num!=0){
    for(int i=2;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        ans.push_back(P(i,j));
        num--;
        if(num==0){
          break;
        }
      }
      if(num==0){
        break;
      }
    }
  }
  cout << ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout << ans[i].first<<" "<<ans[i].second<<endl;
  }
}


Measured memory_bytes: 512
#include <stdio.h>

int main() {
	int n, i, j=0, n4=0, n2=0, n1=0;
	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%d", &j);
		if (j % 4 == 0) { n4++; }
		else if (j % 2 == 0) { n2++; }
		else { n1++; }
	}

	if (n2 != 0) {
		n2 = 0;
		n1++;
	}

	if ((n1 + n4) % 2 == 1) {
		if (n4 - n1 >= -1) { printf("Yes"); }
		else { printf("No"); }
	}
	else {
		if (n4 - n1 >= 0) { printf("Yes"); }
		else { printf("No"); }
	}
	
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <map>

int main() {
  size_t N, T;
  scanf("%zu %zu", &N, &T);

  std::vector<intmax_t> A(N);
  for (auto& ai: A) scanf("%jd", &ai);

  intmax_t INF = 1e14;
  intmax_t min = INF;
  intmax_t max = -INF;

  std::map<intmax_t, int> res;  

  for (auto ai: A) {
    if (min > ai) {
      min = ai;
      max = ai;
    }
    if (max < ai) {
      max = ai;
      ++res[max-min];
    }
  }

  printf("%d\n", (--res.end())->second);
}


Measured memory_bytes: 7296
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int maxn = 1e9;
int main(){
    int tam;
    int dp[110000 + 5];
    int arr[110000 + 5];
    cin>>tam;
    for(int y = 0; y <= tam;y++){
        dp[y] = maxn;
    }
    for(int y = 0; y < tam;y++)
        cin>>arr[y];
    dp[0] = 0;
    for(int y = 0; y < tam; y++){
        if( y + 1 < tam ) 
            dp[y + 1] = min(dp[y + 1] , abs(arr[y] - arr[y + 1]) + dp[y]);
        if(y + 2 < tam)
            dp[y + 2] = min(dp[y + 2] , abs(arr[y] - arr[y + 2]) + dp[y]);
    }
    cout<<dp[tam - 1]<<"\n";
return 0;
}



Measured memory_bytes: 4352