akhauriyash/Code-Regression huggingface dataset:
N, K = gets.split(' ').map(&:to_i)
ans = 0
(K + 1).upto(N) do |b|
  if K >= 1
    ans += (b - K) * (N / b) + [0, N % b - (K - 1)].max
  else
    ans += N
  end
end
puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	ll x, y;
	cin >> x >> y;
	ll cnt = 0;
	while (x <= y) {
		x *= 2;
		cnt++;
	}
	cout << cnt << endl;
}



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

int main() {
  long long a,b;
  cin >> a >> b;
  
  if (a > 0){
    cout << "Positive" << endl;
  }
  else if (a * b <= 0){
    cout << "Zero" << endl;
  }
  else if ((b - a + 1) % 2 == 0){
    cout << "Positive" << endl;
  }
  else {
    cout << "Negative" << endl;
  }
}





Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"YES\n"
#define no cout<<"NO\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int t[]={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 a;
	cin>>a;
	cout<<t[a-1]<<endl;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b;
    rep(i,1)cin>>a;
    rep(i,1)cin>>b;
    if(a*b==2){
        cout<<3<<endl;
    }
    else if(a*b==3){
        cout<<2<<endl;
    }
    else if(a*b==6){
        cout<<1<<endl;
    }

}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int d[n];
    d[0] = s[n-1] - '0';
    int t = 1;
    for(int i=1; i<n; i++){
        t *= 10;
        t %= 2019;
        d[i] = d[i-1] + (s[n-1-i]-'0')*t;
        d[i] %= 2019;
    }
    long long cnt[2019];
    fill(cnt,cnt+2019,0);
    for(int i=0; i<n; i++) cnt[d[i]]++;
    cnt[0]++;
    long long ans = 0;
    for(int i=0; i<2019; i++){
        ans += cnt[i]*(cnt[i]-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int main(){
  int n, m, X, Y; cin >> n >> m >> X >> Y;
  int x[n], y[m];
  REP(i, n) cin >> x[i];
  REP(i, m) cin >> y[i];

  sort(x, x+n);
  sort(y, y+m);

  FOR(i, X+1, Y+1){
    if(x[n-1] < i && i <= y[0]){
      cout << "No War" << endl;
      return 0;
    }
  } 

  cout << "War" << endl;

  return 0;
}



















Measured memory_bytes: 256
x = int(input())


def is_prime(n, i=2):
    if (n == 2):
        return True
    elif (n % i == 0):
        return False
    elif (i * i > n):
        return True

    return is_prime(n, i + 1)


while(is_prime(x) == False):
    x += 1

print(x)

Measured memory_bytes: 3188
fun main() {
    val S = readLine()!!
    val S_start = S.substring(0, (S.count() - 1) / 2).toList()
    val S_end = S.substring((S.count() + 1) / 2).toList()
    val S_start_rev = S_start.reversed()
    val S_end_rev = S_end.reversed()

    if (S_start == S_end && S_end == S_end_rev) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 36148
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, m, v, p = LI()
A = LI()
A.sort()
def bi(x):
    if A[x] + m < A[-p]:
        return 0
    if x + p >= v:
        return 1
    ret = (x + p) * m
    l = x + 1
    r = n - p + 1
    for i in range(l, r):
        ret += A[x] + m - A[i]
        if ret >= v * m:
            return 1
    return 0


ok = n - p
ng = -1
while ok > ng + 1:
    mid = (ok + ng) // 2
    if bi(mid):
        ok = mid
    else:
        ng = mid


print(n - ok)

Measured memory_bytes: 57328
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079&lang=jp

#include <stdio.h>
#include <complex>
#include <cmath>
#include <cstdio>
using namespace std;
typedef complex<double> xy_t;
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

xy_t P[110];

int main() {
  // 入力例 読み込んだ点の個数を N とする
 int N=0;
 double x, y;
 while (scanf("%lf,%lf", &x, &y)!=EOF) {
   P[N++] = xy_t(x,y);
 }
 // 面積計算
  double sum = 0.0;
  for (int i=0; i+2<N; ++i) {
    xy_t a=P[0], b=P[i+1], c=P[i+2];
    sum += cross_product(b-a,c-a)/2; // 三角形 abc の面積を加算
  }
  printf("%.6f\n", abs(sum));
}



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

int main(){

    int N;
    cin >> N;

    int H[N];
    int d[N];
    for (size_t i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    for (size_t i = 0; i < N-1; i++)
    {
        d[i]=H[i+1]-H[i];
    }

    int m=0;
    int n=0;

    for (size_t i = 0; i < N-1; i++)
    {
        if(d[i]<=0){
            n++;
            m=max(m,n);
        }else {
            n=0;
        }
    }
    
    cout << m <<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int n, m, a, b, c[1000000];
int main() {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) { cin >> a >> b; c[a]++; c[b]++; }
	for (int i = 1; i <= n; i++)cout << c[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int a, b;
    int count=0;
    scanf("%d%d", &a, &b);
    for(int i = a; i <= b; i++){
        int n[5];
        n[0] = i %10;
        n[1] = i /10%10;
        n[2] = i /100%10;
        n[3] = i /1000%10;
        n[4] = i /10000;
        if(n[0] == n[4] && n[1] == n[3]) count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 128
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;

struct Sphere
{
  double x;
  double y;
  double z;
  double r;
}

struct Edge
{
  int left;
  int right;
  double len;
}

class UnionFind
{
  uint[] par;
  this(int n)
  {
    par = new uint[n];
    foreach (i, ref p; par)
    {
      p = cast(uint) i;
    }
  }

  uint Find(uint x)
  {
    if (par[x] == x)
    {
      return x;
    }
    else
    {
      return par[x] = Find(par[x]);
    }
  }

  bool Same(uint x, uint y)
  {
    return Find(x) == Find(y);
  }

  void Union(uint x, uint y)
  {
    x = Find(x);
    y = Find(y);
    if (x == y)
    {
      return;
    }

    par[x] = y;
  }
}

double dist(Sphere left, Sphere right)
{
  return max(0, ((cast(double)(left.x - right.x).pow(2) + (left.y - right.y)
      .pow(2) + (left.z - right.z).pow(2)).sqrt - left.r - right.r));
}

void main()
{
  for (;;)
  {
    int n = readln.chomp.to!int;
    if (n == 0)
    {
      break;
    }
    Sphere[] list;
    foreach (i; 0 .. n)
    {
      auto v = readln.chomp.split(" ").map!(to!double);
      Sphere s;
      s.x = v[0];
      s.y = v[1];
      s.z = v[2];
      s.r = v[3];
      list ~= s;
    }
    Edge[] atoms;
    foreach (i; 0 .. n)
    {
      foreach (j; i + 1 .. n)
      {
        auto left = list[i];
        auto right = list[j];
        Edge edge;
        edge.left = i;
        edge.right = j;
        edge.len = dist(left, right);
        atoms ~= edge;
      }
    }
    auto uf = new UnionFind(n);
    double acm = 0;
    atoms.sort!((a, b) => a.len < b.len);
    foreach (edge; atoms) {
      if (uf.Same(edge.left, edge.right)){
        continue;
      }
      uf.Union(edge.left, edge.right);
      acm += edge.len;
    }
    writefln("%.3f", acm);
  }
}

Measured memory_bytes: 4632
while True:
    (m, f, r) = [int(i) for i in input().split()]
    if m == f == r == -1:
        break

    mf = m + f

    if m == -1 or f == -1 or mf < 30:
        print('F')

    elif mf < 50 and r < 50:
        print('D')

    elif mf < 65:
        print('C')

    elif mf < 80:
        print('B')

    elif mf >= 80:
        print('A')

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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; }


int main(void){
    int N;
    cin>>N;
    vector<pair<int,int>> p;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        /*cout<<a<<" "<<b<<endl;*/
        p.push_back(make_pair(b,-1*a));
    }
    sort(p.begin(),p.end());
    int sum=0;
    bool ok=true;
    for(int i=0;i<N;i++){
        sum+=(-1)*p[i].second;
        if(sum>p[i].first) ok=false;
        /*cout<<sum<<endl;*/
    }
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 2420
function Main(input){
	input = input.split("");
	input.pop();
	if(input.length%2==1) input.pop();
	var ans = 2;
	while(input.length!=0){
	  //  console.log(input.join(""))
	   // console.log(input.join("").substr(input.length/2),input.join("").substr(-1*(input.length/2)))
		if(input.join("").substr(0,input.length/2)==input.join("").substr(input.length/2)){
			ans = input.length;
			break;
		}else{
			input.pop();
			input.pop();
		}
	}
	console.log(ans)
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 7624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N;
  if(N%2){
    cout<<"No"<<endl;
    return 0;
  }
  vec v(N);
  string s;
  cin>>s;
  rep(i,N/2){
    if(s[i]!=s[i+N/2]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fill fill_n
#define pb push_back
ll n,W;
ll v[105],w[105];
ll dp[105][100005];
ll f(int i,ll we){
    if(we<0) return -1234445349999;
    if(i==0){
    if(w[0]>we) dp[i][we]=0;
    else dp[i][we]=v[i];
    return dp[i][we];
    }
    if(dp[i][we]!=-1) return dp[i][we];
    dp[i][we]=max(v[i]+f(i-1,we-w[i]),f(i-1,we));
    return dp[i][we];
    
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>n>>W;
	
	for(ll i=0;i<n;i++){
	    cin>>w[i]>>v[i];
	}
	cout<<f(n-1,W)<<"\n";
// 	for(int i=0;i<n;i++){
// 	    for(int j=0;j<)
// 	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 82304
from heapq import heappush, heappop

N, M = map(int, input().split())
AB = []

for i in range(N):
  a, b = map(int, input().split())
  AB.append((a,b))

AB.sort()
index = 0
result = 0
queue = []

for limit in range(1, M+1):
  while index < N and AB[index][0] <= limit:
    a, b = AB[index]
    heappush(queue, -b)
    index += 1

  if queue:
    result += -heappop(queue)

print(result)

Measured memory_bytes: 20792
def FibArray(n):
    FA = [0]*n
    FA[0] = 2
    FA[1] = 1
    for i in range(2,n):
        FA[i] = (FA[i-1]+FA[i-2])
    return(FA)

def Fib(n):
    return(FibArray(n+1)[n])

print(Fib(int(input())))

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
vector<int> yoc;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    yoc.push_back(a);
  }
  sort(yoc.begin(),yoc.end());
  int a1=0;
  for(int i=0;i<n-1;i++) a1+=yoc[i];
  cout<<(a1>yoc[n-1]?"Yes":"No")<<'\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n; std::cin >> n;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::map<long long, int> cnt;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += cnt[-a[i] + i];
        cnt[a[i] + i]++;
    }
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 27548
import java.util.*;


public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int n = sc.nextInt();

        int count = 0;
        for(int i = 0; i <= a; i++){
            for(int j = 0; j <= b; j++){
                for(int k = 0; k <= c; k++){
                    if(i*500 + j*100 + k*50 == n){
                        count++;
                    }
                }
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23252
def main():
    k = int(input())
    lst = [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]

    print(lst[k - 1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
# B
import math
N, D = map(int,input().split())
X = [[int(i) for i in input().split()] for i in range(N)] 

answer = 0

def distance(x, a, b):
    list = []
    for d in range(D):
        list.append((x[a][d] - x[b][d])**2)
    r = math.sqrt(sum(list))
    return r


# 整数判定
def isinteger(x):
    if isinstance(x, float):
        return x == int(x)

for j in range(N):
    for i in range(j+1,N):
        # print(j, i)
        # print(distance(X, i, j))
        if isinteger(distance(X, i, j)):
            answer = answer + 1

print(answer)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
  int newnum[8] = {0,1,2,3,5,7,8,9};
  long input_num;

  int count_num;
  while(cin >> input_num && input_num != 0){
    //    output_num = 0;
    count_num = 0;
  long output_num[13]={0};
    while(input_num != 0){
      output_num[count_num] = newnum[input_num % 8];
      //      input_num /= 8;
      input_num = (input_num-input_num % 8)/8;
      //      cout << output_num << " " ;
      count_num++;
    }
    /*
    for(int j=count_num-1;j>0;j--){
      output_num[j-1] += output_num[j] * 10;
      //      cout << output_num[j] << " ";
    }
    cout << output_num[0];
    */

    for(int j=count_num-1;j>=0;j--){
      cout << output_num[j] ;
    }
    

    cout << endl;
  }

}

Measured memory_bytes: 0
#pragma warning(disable: 4996)
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;


int N;
int A[101];
int main() {
	cin >> N ;
	int total = 0;

	for(int i = 0; i < N; i++) {
		cin >> A[i];
		total += A[i];
	}

	int answer = 1000000;

	int temp = 0;
	for(int i = 0; i < N; i++) {
		temp += A[i];
		int b = total - temp;
		answer = min(answer, abs(b - temp));
	}
	
	cout << answer;

	return 0;
}




Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var r, D, x2000 int
	fmt.Scan(&r, &D, &x2000)

	x := x2000
	for i := 1; i <= 10; i++ {
		y := r*x - D
		fmt.Println(y)
		x = y
	}
}


Measured memory_bytes: 512
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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

def main():
  n=I()
  a=[]
  b=[]
  c=[]
  for _ in range(n):
    x,y,z=LI()
    a.append(x)
    b.append(y)
    c.append(z)

  dp=[[0]*114514 for _ in range(3)]
  for i in range(1,n+1):
    dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i-1]
    dp[1][i]=max(dp[2][i-1],dp[0][i-1])+b[i-1]
    dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i-1]

  return max(dp[0][n],dp[1][n],dp[2][n])

# main()
print(main())


Measured memory_bytes: 88540
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int gcd(int a, int b) {
  if(a<b) swap(a,b);
  int c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
  
int main() {
  int N;
  cin >> N;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vi GCDL(N),GCDR(N);
  GCDL[0] = A[0];
  srep(i,1,N) {
    GCDL[i] = gcd(GCDL[i-1],A[i]);
  }
  GCDR[N-1] = A[N-1];
  for(int i = N-2;i >=0;i--) {
    GCDR[i] = gcd(GCDR[i+1],A[i]);
  }
  int ans = -INF;
  ans = max(ans,GCDR[1]);
  ans = max(ans,GCDL[N-2]);
  srep(i,1,N-1) {
    ans = max(ans,gcd(GCDL[i-1],GCDR[i+1]));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

vector<pair<ll, ll>> primeFactorize(ll N)
{
    vector<pair<ll, ll>> res;
    for (ll a = 2; a * a <= N; ++a)
    {
        if (N % a != 0)
            continue;
        ll ex = 0;

        while (N % a == 0)
        {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1)
        res.push_back({N, 1});
    return res;
}

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

    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
    }
    vector<int> pp(n);
    pp = p;
    std::sort(pp.begin(), pp.end());
    int count = 0;
    if (q == p)
    {
        cout << 0 << "\n";
        return 0;
    }
    int a = 0, b = 0;
    while (next_permutation(pp.begin(), pp.end()))
    {
        count++;
        if (pp == p)
        {
            a = count;
        }
        if (pp == q)
        {
            b = count;
        }
        if (a != 0 && b != 0)
        {
            break;
        }
    }

    cout << abs(a - b) << "\n";
    return 0;
}


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

using namespace std;
//nは0から10までなので10個あることに注意☆
int dp[20][1000];
void Init(){
  for(int i=0;i<=10;i++)for(int j=0;j<1000;j++)dp[i][j]=0;
 
  for(int i=0;i<=9;i++){
    dp[0][i]++;	
    for(int j=0;j<=9;j++){
      if(i == j)continue;
      dp[1][i+j*2]++;
      for(int k=0;k<=9;k++){
	if(k==i||k==j)continue;
	dp[2][i+j*2+k*3]++;
	for(int l=0;l<=9;l++){
	  if(l==i||l==j||l==k)continue;
	  dp[3][i+j*2+k*3+l*4]++;
	  for(int m=0;m<=9;m++){
	    if(m==i||m==j||m==k||m==l)continue;
	    dp[4][i+j*2+k*3+l*4+m*5]++;
	    for(int n=0;n<=9;n++){
	      if(n==i||n==j||n==k||n==l||n==m)continue;
	      dp[5][i+j*2+k*3+l*4+m*5+n*6]++;
	      for(int o=0;o<=9;o++){
		if(o==i||o==j||o==k||o==l||o==m||o==n)continue;
		dp[6][i+j*2+k*3+l*4+m*5+n*6+o*7]++;
		for(int p=0;p<=9;p++){
		  if(p==i||p==j||p==k||p==l||p==m||p==n||p==o)continue;
		  dp[7][i+j*2+k*3+l*4+m*5+n*6+o*7+p*8]++;
		  for(int q=0;q<=9;q++){
		    if(q==i||q==j||q==k||q==l||q==m||q==n||q==o||q==p)continue;
		    dp[8][i+j*2+k*3+l*4+m*5+n*6+o*7+p*8+q*9]++;
		    for(int r=0;r<=9;r++){
		      if(r==i||r==j||r==k||r==l||r==m||r==n||r==o||r==p ||r==q)continue;
		      dp[9][i+j*2+k*3+l*4+m*5+n*6+o*7+p*8+q*9+r*10]++;
		    }
		  }
		}
	      }
	    }
	  }
	}
      }
    }
  }
  // cout << maxx << endl;
}

int main(){
  int n,s;
  Init();
    while(cin >> n >> s){
      if(n == 0){
	if(s == 0)cout << "1" << endl;
	else cout << "0" << endl;
      }
      else cout << dp[n-1][s] << endl;
    }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>

int main() {
    long n, l, r, res=0;
    std::cin >> n;
    for ( long i=0; i<n; ++i) {
        std::cin >> l >> r;
        res += r - l + 1;
    }
    std::cout << res << std::endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
for i in range(m):
    st = list(map(int, input().split()))
    s.append(st[1 :])
p = list(map(int, input().split()))

ans = 0
for i in range(1 << n):
    al = True
    v = [bool(i & (1 << x)) for x in range(n)]
    for j in range(m):
        num = 0
        for t in s[j]:
            num += v[t - 1]
        if p[j] != num % 2:
            al = False
    ans += al
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
int n, m, a, b, c[100000], D[100000], E[100000];
map<vector<int>, tuple<vector<int>, vector<int>, vector<int>>>M;
void make(int n) {
	queue<vector<int>>Q; for (int i = 1; i <= n; i++) { vector<int>ichi; ichi.push_back(i); Q.push(ichi); }
	while (Q.size() > 1) {
		vector<int>b1 = Q.front(); Q.pop();
		vector<int>b2 = Q.front(); Q.pop();
		vector<int>b3 = Q.front(); Q.pop();
		vector<int>sum;
		for (int i = 0; i < b1.size(); i++)sum.push_back(b1[i]);
		for (int i = 0; i < b2.size(); i++)sum.push_back(b2[i]);
		for (int i = 0; i < b3.size(); i++)sum.push_back(b3[i]);
		sort(sum.begin(), sum.end());
		M[sum] = make_tuple(b1, b2, b3); Q.push(sum);
	}
	Q.pop();
}
int solve(vector<int>vec, int border) {
	if (vec.size() == 1) {
		if (c[vec[0]] < border && c[vec[0]] >= 1)return 10000000;
		if (c[vec[0]] >= border && c[vec[0]] >= 1)return 0;
		return 1;
	}
	int s[3] = { solve(get<0>(M[vec]), border),solve(get<1>(M[vec]), border),solve(get<2>(M[vec]), border) };
	sort(s, s + 3);
	return s[0] + s[1];
}
int main() {
	cin >> n >> m; for (int i = 0; i < m; i++) { cin >> a >> b; c[b] = a; D[i] = a; }
	for (int i = m; i < n; i++) { cin >> a; D[i] = a; E[i - m] = a; }
	sort(D, D + n); sort(E, E + n - m);
	make(n);
	int maxn = 0;
	vector<int>Ball; for (int i = 1; i <= n; i++)Ball.push_back(i);
	
	//--------------------------------------------Binary Search------------------------------------
	int L = 0, R = n, M;
	while (true) {
		bool Y1 = false, Y2 = false;
		M = (L + R) / 2;
		if (M < n) {
			int F = solve(Ball, D[M]);
			int pos1 = lower_bound(E, E + n - m, D[M] - 1) - E;
			pos1 = (n - m) - pos1;
			if (F <= pos1)Y1 = true;
		}
		if (M < n - 1) {
			int F = solve(Ball, D[M + 1]);
			int pos2 = lower_bound(E, E + n - m, D[M + 1] - 1) - E;
			pos2 = (n - m) - pos2;
			if (F <= pos2)Y2 = true;
		}
		if (Y1 == true && Y2 == false) { maxn = D[M]; break; }
		if (Y1 == false) { R = M; }
		if (Y2 == true) { L = M; }
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 25912
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 2e5+6;
string s[N];
int n; 
int dp[N][5][5][5];
int go(int idx, int a, int b, int c){
	if(idx==n){
		return dp[idx][a][b][c] = 1;
	}
	int ret = dp[idx][a][b][c];
	if(ret!=-1)return ret;
	ret = 0;
	if(s[idx]=="AB"){
		if(a)ret = max(ret,go(idx+1,a-1,b+1,c));
		if(b)ret = max(ret,go(idx+1,a+1,b-1,c));
	}
	if(s[idx]=="AC"){
		if(a)ret = max(ret,go(idx+1,a-1,b,c+1));
		if(c)ret = max(ret,go(idx+1,a+1,b,c-1));		
	}
	if(s[idx]=="BC"){
		if(c)ret = max(ret,go(idx+1,a,b+1,c-1));
		if(b)ret = max(ret,go(idx+1,a,b-1,c+1));
	}
///	cout<<idx<<" "<<a<<" "<<b<<" "<<c<<" "<<ret<<endl;
	return dp[idx][a][b][c] = ret;
}
void gogo(int idx, int a, int b, int c){
	if(idx==n)return ;
	if(s[idx]=="AB"){
		if(a and dp[idx][a][b][c] == dp[idx+1][a-1][b+1][c]){
			cout<<"B"<<endl;
			gogo(idx+1,a-1,b+1,c);
			return ;
		}
		if(b and dp[idx][a][b][c] == dp[idx+1][a+1][b-1][c]){
			cout<<"A"<<endl;
			gogo(idx+1,a+1,b-1,c);
			return ;
		}
	}
	if(s[idx]=="AC"){
		if(a and dp[idx][a][b][c] == dp[idx+1][a-1][b][c+1]){
			cout<<"C"<<endl;
			gogo(idx+1,a-1,b,c+1);
			return ;
		}
		if(c and dp[idx][a][b][c] == dp[idx+1][a+1][b][c-1]){
			cout<<"A"<<endl;
			gogo(idx+1,a+1,b,c-1);
			return ;
		}
	}
	if(s[idx]=="BC"){
		if(c and dp[idx][a][b][c] == dp[idx+1][a][b+1][c-1]){
			cout<<"B"<<endl;
			gogo(idx+1,a,b+1,c-1);
			return ;
		}
		if(b and dp[idx][a][b][c] == dp[idx+1][a][b-1][c+1]){
			cout<<"C"<<endl;
			gogo(idx+1,a,b-1,c+1);
			return ;
		}
	}
}
void solve(){
	memset(dp,-1,sizeof dp);
	int a,b,c;
	cin>>n>>a>>b>>c;
	a = min(a,2); 
	b = min(b,2); 
	c = min(c,2); 
	for(int i=0;i<n;i++)cin>>s[i];
	int ans = go(0,a,b,c);
	if(ans==0){
		cout<<"No"<<endl;
		return ;
	}
	cout<<"Yes"<<endl;
	gogo(0,a,b,c);
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


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

using namespace std;

typedef vector<int>::iterator ITE;
int n,k,m;

int main(){

  while(cin >> n >> k >> m && n+k+m){
    
    vector<int> V;
    ITE ite;
    int pos;

    for(int i = 1; i <= n; i++) V.push_back(i);
    
    ite = (ITE)&V[m-1];
    pos = m-1;
    
    while(1){
      if(V.size() == 1) break;
      //cout << "removed " << *ite  << endl;
      V.erase(ite);
      pos = (pos+k-1)%V.size();
      ite = (ITE)&V[pos];
    }
    cout << V[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 1324
n = gets.to_i


map = {}

('a'..'y').to_a.each_with_index do |alp, i|
  map[i + 1] = alp
end

map[0] = 'z'

ans = ''
loop do
  ans =  map[n % 26] + ans
  n -= 1 if n % 26 == 0
  n /= 26
  break if n == 0
end

puts ans


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

using namespace std;

int N, M;
bool MapData[501][501];

void solve() {
	int sum;
	bool used[501];

	memset(used, false, sizeof(used));
	for (int i = 2; i <= N; ++i) {
		if (!MapData[1][i]) {
			continue;
		}
		used[i] = true;
		for (int j = 2; j <= N; ++j) {
			if (!MapData[i][j]) {
				continue;
			}
			used[j] = true;
		}
	}

	sum = 0;
	for (int i = 2; i <= N; ++i) {
		if (used[i]) {
			++sum;
		}
	}
	cout << sum << endl;
}

int main() {
	int a, b;

	while (cin >> N, N) {
		memset(MapData, false, sizeof(MapData));
		cin >> M;
		for (int i = 0; i < M; ++i) {
			cin >> a >> b;
			MapData[a][b] = MapData[b][a] = true;
		}
		solve();
	}

	return 0;
}


Measured memory_bytes: 3292
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

/**
 * @author sutoh
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int a,b,c;


		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();

		List<Integer> list=new ArrayList<Integer>();

		list.add(a+b);
		list.add(a+c);
		list.add(b+c);

		Collections.sort(list);

		System.out.println(list.get(0));


	}

}


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

int main() {
  int kazua=0;
  int kazub=0;
  int kazuc=0;
  int kazud=0;
  for(int i=0;i<6;i++){
    int a;
    cin >>a;
    if(a==1)kazua++;
    else if(a==2)kazub++;
    else if(a==3)kazuc++;
    else kazud++;
  }
  if(kazua>2||kazub>2||kazuc>2||kazud>2)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
  return 0;
}

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

int A, B;
char ans[100][101];

int main(){
	cin >> A >> B;
	fill(ans[0], ans[100], '.');
	fill(ans[0], ans[2 * (A / 50 + 1)], '#');
	for(int i = 0; i < A - 1; i++){
		ans[i / 50 * 2][i % 50 * 2] = '.';
	}
	for(int i = 0; i < B - 1; i++){
		ans[2 * (A / 50 + 1) + i / 50 * 2 + 1][i % 50 * 2 + 1] = '#';
	}
	cout << 100 << " " << 100 << endl;
	for(int i = 0; i < 100; i++){
		for(int j = 0; j < 100; j++){
			cout << ans[i][j];
			if(j == 99) cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==10||n==100||n==1000||n==10000||n==100000){
    cout<<10;
  }else{
    int c=0;
    while(true){
      if(n!=0){
        c+=n%10;
        n/=10;
      }else{
        cout<<c;
        return 0;
      }
    }
  }
}

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

using namespace std;

int a, b, c, n;
long long dp[100100][3];

int main(){
    cin >> n;
    for (int i=1; i<=n; i++){
        cin >> a >> b >> c;
        dp[i][0] = (long long)(max(dp[i-1][1], dp[i-1][2])) + (long long)(a);
        dp[i][1] = (long long)(max(dp[i-1][2], dp[i-1][0])) + (long long)(b);
        dp[i][2] = (long long)(max(dp[i-1][0], dp[i-1][1])) + (long long)(c);
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
    return 0;
}


Measured memory_bytes: 2560
x,y=map(int,input().split())
X=abs(x)
Y=abs(y)
if X<Y:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=y-(-x)+1      
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=(-y)-x+1

else:
    if x<y:
        if x*y>=0:
            p=y-x
        else:
            p=(-y)-x+1
    else:
        if x*y>0:
            p=(-y)-(-x)+2
        else:
            p=y-(-x)+1
print(p)

Measured memory_bytes: 38384
#include <iostream>
#define int long long
using namespace std;

int N;

int tltle(int N) {
	int ans = 0;
	for (int k = 2; k <= N; k++) {
		int n = N;
		while (n >= k) {
			if (n % k == 0) n /= k;
			else n -= k;
		}
		if (n == 1) ans++;
	}
	return ans;
}

int tle(int N) {
	int ans = 0;
	for (int k = 2; k <= N; k++) {
		int n = N;
		while (n % k == 0) n /= k;
		if (n % k == 1) ans++;
	}
	return ans;
}

int wa(int N) {
	int ans = 0;
	for (int k = 2; k * k <= N; k++) {
		int n = N;
		while (n % k == 0) n /= k;
		if (n % k == 1) ans++;
	}
	
	//k進数で、(a 1)
	for (int a = 1; a * a <= N; a++) {
		if ((N - 1) % a != 0) continue;
		int k = (N - 1) / a;
		if (k < 1e+7 && k * k <= N) continue;	//こ↑こ↓ オーバーフローしてたｗｗｗｗ
		if (a >= k) continue;
		ans++;
	}
	
	//(1 0), K = N
	ans++;
	
	return ans;
}

signed main() {
	int N;
	cin >> N;
	cout << wa(N) << endl;
	return 0;
}

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

bool dblsame(double l, double r) {return abs(l-r) < abs(l) * 1e-10 + 1e-10;}

struct Vec{
 double x,y;
 Vec(double xx, double yy) : x(xx),y(yy) {}
 Vec operator+() const {return Vec(x,y);}
 Vec operator-() const {return Vec(-x,-y);}
 Vec operator+(const Vec& r) const {return Vec(x+r.x,y+r.y);}
 Vec operator-(const Vec& r) const {return Vec(x-r.x,y-r.y);}
 Vec operator*(double r) const {return Vec(x*r,y*r);}
 Vec operator/(double r) const {return Vec(x/r,y/r);}
 Vec& operator+=(const Vec& r) {*this=*this+r; return *this;}
 Vec& operator-=(const Vec& r) {*this=*this-r; return *this;}
 Vec& operator*=(double r) {*this=*this*r; return *this;}
 Vec& operator/=(double r) {*this=*this/r; return *this;}
 bool operator==(const Vec& r) const {return dblsame(x,r.x)&&dblsame(y,r.y);}
 bool operator!=(const Vec& r) const {return !(*this==r);} 
 double operator*(const Vec& r) const {return x*r.x+y*r.y;}
 double abs() const {return sqrt(x*x+y*y);}
 double abs_squared() const {return x*x+y*y;}
 double product(const Vec& r) const {return x*r.y-y*r.x;}
};

Vec InputVec(){
 double x,y; scanf("%lf%lf",&x,&y);
 return Vec(x,y);
}

void PrintVec(Vec tg){
 printf("%.10f %.10f",tg.x,tg.y);
}

int main() {
 UL T; scanf("%u", &T);
 rep(t,T) {
  Vec A = InputVec() - InputVec();
  Vec B = InputVec() - InputVec();
  A/=A.abs();
  B/=B.abs();
  double dot = A*B;
  if(dblsame(dot,0.0)) printf("1\n");
  else if(dblsame(abs(dot),1.0)) printf("2\n");
  else printf("0\n");
 }
 return 0;
}



Measured memory_bytes: 3244
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n := readInt()
	s := readString()
	max := 0
	for i := 0; i < n; i++ {
		left := make(map[string]bool)
		right := make(map[string]bool)
		for j := 0; j < n; j++ {
			if j <= i {
				left[string(s[j])] = true
			} else {
				right[string(s[j])] = true
			}
		}
		cnt := 0
		for k := range left {
			if left[k] == right[k] {
				cnt++
			}
		}
		if max < cnt {
			max = cnt
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 896
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		sc.close();

		Arrays.sort(s);
		Arrays.sort(t);
		t = new StringBuilder().append(t).reverse().toString().toCharArray();
		for (int i = 0; i < t.length; i++) {
			if (i == s.length || s[i] < t[i]) {
				System.out.println("Yes");
				return;
			}
			if (s[i] > t[i]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("No");
	}
}


Measured memory_bytes: 21844
import sys

def digits_sum(x):
    return sum(map(int, str(x)))

def solve(n):
    ans = sys.maxsize
    for a in range(1, n):
        b = n - a
        ans = min(ans, digits_sum(a) + digits_sum(b))

    return ans

if __name__ == '__main__':
    n = int(input())
    print(solve(n))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m,cnt=0,a,b;
    cin>>n>>m;
    long long int h[n];
    bool bo[n]={0};
    for(int i=0;i<n;i++){
    	cin>>h[i];
	}
	for(int i=0;i<m;i++){
		cin>>a>>b;
		if(h[a-1]==h[b-1]){
			bo[a-1]=1;
			bo[b-1]=1;
		}
		else if(h[a-1]<h[b-1]){
			bo[a-1]=1;
		}
		else{
			bo[b-1]=1;
		}
	}
	for(int i=0;i<n;i++){
		if(bo[i]==0){
			cnt++;
		}
	}
	cout<<cnt;
    
//system("pause");
return 0;

}


Measured memory_bytes: 4520
#include <vector>
#include <numeric>
#include <algorithm>

class unionfind {
private:
	int size_;
	std::vector<int> parent;
	std::vector<int> rank;
public:
	unionfind() : size_(0), parent(std::vector<int>()), rank(std::vector<int>()) {};
	unionfind(int size__) : size_(size__), parent(std::vector<int>(size_)), rank(std::vector<int>(size_, 0)) {
		std::iota(parent.begin(), parent.end(), 0);
	}
	int size() { return size_; }
	int root(int x) {
		if (parent[x] == x) return x;
		return parent[x] = root(parent[x]);
	}
	bool same(int x, int y) {
		return root(x) == root(y);
	}
	void unite(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) parent[x] = y;
		else if (rank[x] > rank[y]) parent[y] = x;
		else parent[y] = x, rank[x]++;
	}
};

#include <cstdio>
int N, Q, tp, x, y;
int main() {
	scanf("%d%d", &N, &Q);
	unionfind uf(N);
	while (Q--) {
		scanf("%d%d%d", &tp, &x, &y);
		if (tp == 0) uf.unite(x, y);
		else printf("%d\n", uf.same(x, y));
	}
	return 0;
}

Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

pii m[30];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  m[0] = mp(14, 16);
  m[1] = mp(15, 16);
  m[2] = mp(14, 18);
  m[3] = mp(15, 18);
  m[4] = mp(16, 18);
  m[5] = mp(15, 20);
  m[6] = mp(16, 20);
  m[7] = mp(16, 21);
  m[8] = mp(18, 20);
  m[9] = mp(18, 21);
  m[10] = mp(18, 22);
  m[11] = mp(20, 21);
  m[12] = mp(20, 22);
  m[13] = mp(21, 22);
  m[14] = mp(20, 24);
  m[15] = mp(21, 24);
  m[16] = mp(22, 24);
  m[17] = mp(22, 25);
  m[18] = mp(22, 26);
  m[19] = mp(24, 25);
  m[20] = mp(24, 26);
  m[21] = mp(25, 26);
  m[22] = mp(25, 27);
  m[23] = mp(26, 27);
  m[24] = mp(26, 28);
  m[25] = mp(27, 28);
  m[26] = mp(12, 14);
  m[27] = mp(12, 15);
  m[28] = mp(12, 16);
  m[29] = mp(14, 15);
  int n;
  cin >> n;
  if(n == 3){
    cout << "2 3 25" << endl;
    return 0;
  }
  ll s = 0;
  FOR(i, 1, 30001){
    if(i%2 && i%3 && i%5) continue;
    cout << i << " ";
    s += i;
    n--;
    if(n == 2){
      pii r = m[(30-s%30)%30];
      i = i/30*30+30;
      cout << i + r.fi << " " << i + r.se << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h> 
using namespace std; 
int main() {
  int N; 
  scanf("%d\n", &N);
  int AC = 0, WA = 0, TLE= 0, RE = 0; 
  string S; 
  for (int i = 0; i < N; i ++) {
    cin >> S; 
    if (S == "AC")
      AC ++; 
    else if (S == "WA")
      WA ++; 
    else if (S == "TLE")
      TLE ++; 
    else if (S == "RE")
      RE ++; 
  }
  printf("AC x %d\n", AC); 
  printf("WA x %d\n", WA); 
  printf("TLE x %d\n", TLE); 
  printf("RE x %d\n", RE);
  return 0; 
  
}

Measured memory_bytes: 3784
N,K = map(int, input().split())
S = input()

if S[K-1] == 'A':
    box = S[:K-1] + 'a' + S[K:]
    # S[K-1] = 'a'
elif S[K-1] == 'B':
    box = S[:K-1] + 'b' + S[K:]
    # S[K-1] = 'b'
else:
    box = S[:K-1] + 'c' + S[K:]
    # S[K-1] = 'c'
print(box)

Measured memory_bytes: 3060
'use strict'

function Main(input) {
    const age = parseInt(input)
    const output = ['YES', 'NO'][isValid(age) ? 0 : 1]
    console.log(output)
}

function isValid(age) {
    return [3, 5, 7].indexOf(age) !== -1
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
vector<bool>seen;
using Graph = vector<vector<int>>;
void dfs(const Graph& G, int v) {
	seen[v] = true; // v を訪問済にする

	// v から行ける各頂点 next_v について
	for (auto next_v : G[v]) {
		if (seen[next_v]) continue; // next_v が探索済だったらスルー
		dfs(G, next_v); // 再帰的に探索
	}
}
int main() {
	int n;
	cin >> n;
	long long int dp[9][9];
	vector<pair<int, int>>k;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		k.push_back(make_pair(a, b));
	}
	long long int number = 1;
	long double ans = 0;
	for (int i = 1; i <= n; i++) {
		number = number * i;
	}
	long long int kazu = (n - 1) * n;
	for(int i = 0;i < n;i++){ 
		for (int j = 0; j < n; j++) {
			if (i != j) {
				ans = ans + pow((k[i].first-k[j].first)* (k[i].first - k[j].first)+ (k[i].second - k[j].second) * (k[i].second - k[j].second), 0.5);
			}
		}
	}
	cout << fixed << setprecision(10) << ans / n;
}

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

double a[200];

signed main(){

  int n; cin >> n;
  double ave = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    ave += a[i];
  }
  ave /= n;

  int ans = 0;
  double res = a[0];
  for(int i = 0; i < n; i++){
    double t = abs(ave - a[i]);
    if(res > t){
      ans = i;
      res = t;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
menu=[]
menu << _a=gets.to_i
menu << _b=gets.to_i
menu << _c=gets.to_i
menu << _d=gets.to_i
menu << _e=gets.to_i

time=0

menu.map{|i| i%10}.sort.each{|a|
    if a.nonzero?
        time=a-10
        break
    end
}

time+=menu.map{|i| (i.to_f/10).ceil*10}.inject(:+)

puts time

Measured memory_bytes: 1788