akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    switch (N % 10)
    {
    case (2):
    case (4):
    case (5):
    case (7):
    case (9):
        cout << "hon\n";
        break;
    case (1):
    case (6):
    case (8):
    case (0):
        cout << "pon\n";
        break;
    default:
        cout << "bon";
    }
}



Measured memory_bytes: 3564
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int n=0,x=0;
	string s;
	cin>>s;
	n=s.size();
	for (int i = 0; i < n; ++i)
	{
		if(s[i]=='1')
			x++;
	}
	cout<<x;

}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline


class DiGraph:
    def __init__(self, n, decrement=True, destroy=False, edges=[]):
        """
        incs[p]: 頂点 p に流入するリンク数
        """
        self.n = n
        self.decrement = decrement
        self.destroy = destroy
        self.edges = [set() for _ in range(self.n)]
        self.incs = [0]*self.n
        for x, y in edges:
            self.add_edge(x,y)

    def add_edge(self, x, y):
        if self.decrement:
            x -= 1
            y -= 1
        self.edges[x].add(y)
        self.incs[y] += 1

    def topological_sort(self):
        next_set = {p for p, inc in enumerate(self.incs) if inc == 0}
        res = []
        while next_set:
            p = next_set.pop()
            res.append(p+self.decrement)
            for q in self.edges[p]:
                self.incs[q] -= 1
                if self.incs[q] == 0:
                    next_set.add(q)
        return res

    def draw(self):
        """
        :return: グラフを可視化
        """
        import matplotlib.pyplot as plt
        import networkx as nx

        G = nx.DiGraph()
        for x in range(self.n):
            for y in self.edges[x]:
                G.add_edge(x + self.decrement, y + self.decrement)

        pos = nx.spring_layout(G)
        nx.draw_networkx(G, pos)
        plt.axis("off")
        plt.show()


################################################################################

def main():
    N, M = map(int, input().split())

    M = N - 1 + M
    graph = DiGraph(N, decrement=True, destroy=True)
    for _ in range(M):
        A, B = map(int, input().split())
        graph.add_edge(A, B)

    res = [0]*N
    for p in graph.topological_sort():
        for q in graph.edges[p-1]:
            res[q] = p
    print(*res, sep="\n")

if __name__ == '__main__':
    main()


Measured memory_bytes: 114160
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;
int tosi = 2019;

int main()
{
	int n; cin >> n;
	int a = n / 1000, b = n / 100 % 10, c = n / 10%10, d = n % 10;
	string s[8] = { "+++","++-","+-+","-++","+--","-+-","--+","---" };
	int flag = 0;
	rep(i, 8) {
		int sum = a;
		sum += (s[i][0] == '+') ? b : -b;
		sum += (s[i][1] == '+') ? c : -c;
		sum += (s[i][2] == '+') ? d : -d;
		if (sum == 7) { flag = i; break; }
	}

	cout << a << s[flag][0] << b << s[flag][1] << c << s[flag][2] << d << "=7" << endl;

	return 0;
}


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

using namespace std;

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

int h[20];

int main(){
	int a=read(),b=read();
	if(a>8){
		printf(":(");
	}
	else if(b>8){
		printf(":(");
	}
	else {
		printf("Yay!");
	}
	return 0;
}


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

using namespace std; 

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int n;
	cin >> n;

	vector<int> a(2*n);
	for(int i = 0; i < 2*n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for(int i = 0; i < 2*n; i += 2) {
		ans += a[i];
	}

	cout << ans;

	return 0; 
} 


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
VL arr;
ll n;

ll call(ll b)
{
    ll sum=0;
    fr(i,0,n)
    {
        sum+=abs(arr[i]-(b+i+1));
    }
    return sum;
}
void solve()
{
    //ll n;
    cin>>n;
    arr.assign(n,0);
    fr(i,0,n)
        cin>>arr[i];
    ll low=-1e9,high=1e9,ans=0;
    while(low<=high)
    {
        ll v=(high-low)/3;
        //cout<<low<<" "<<high<<endl;
        if(call(low+v)<call(high-v))
        {
            ans=low+v;
            high=high-v-1;
        }
        else
        {
            low=low+v+1;
        }
    }
    //cout<<ans<<endl;
    cout<<call(ans)<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 4768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  string a,b,c;
  cin >> a >> b >> c;
  cout << (char)(a[0] + ('A' - 'a')) << (char)(b[0] + ('A' - 'a')) << (char)(c[0] + ('A' - 'a')) << endl;
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}

int nextInt() {
  int x; scanf("%d", &x); return x;
}

ll t[512][512];
ll acm[512][512];

int H, W, h, w;

ll range(int r1, int c1, int r2, int c2) {
  return acm[r2][c2] - acm[r1][c2] - acm[r2][c1] + acm[r1][c1];
}

bool check() {
  memset(acm, 0, sizeof(acm));
  REP(i, H) REP(j, W) {
    acm[i+1][j+1] = -acm[i][j] + acm[i+1][j] + acm[i][j+1] + t[i][j];
  }
  if (range(0, 0, H, W) <= 0) return false;
  REP(i, H - h + 1) REP(j, W - w + 1) {
    if (range(i, j, i + h, j + w) >= 0) return false;
  }
  return true;
}

int main2() {
  H = nextInt();
  W = nextInt();
  h = nextInt();
  w = nextInt();

  if (h * w == 1) {
    cout << "No" << endl;
    return 0;
  }

  ll BIG = (ll)(1e9 - 1);
  memset(t, -1, sizeof(t));
  REP(i, H) REP(j, W) {
    ll p = h * w - 1;
    t[i][j] = -((BIG + 1 + p - 1) / p);
  }

  for (int i = 0; i < H; i += h) {
    for (int j = 0; j < W; j += w) {
      t[i][j] = BIG;
    }
  }
  if (check()) {
    cout << "Yes" << endl;
    REP(i, H) {
      REP(j, W) {
        if (j > 0) printf(" ");
        printf("%d", t[i][j]);
      }
      printf("\n");
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define DIM 100007
#define INF 1000000000000000007
//#define endl "\n"
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<long long, long long>  pairll;

ll n,m,h,w;
ll i,j,res,sum;
pairll a[DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for(i=1; i<=n; i++){
        cin >>a[i].first>> a[i].second;
    }
    sort(a+1,a+n+1);
    for(i=1; i<=n; i++){
        if(m==0) break;
        if(a[i].second<=m) {
            res+=(a[i].second*a[i].first);
            m-=a[i].second;
        }
        else{
        res+=m*a[i].first;
        m=0;

    }

    }
    cout << res << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}

ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


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

  int n;
  cin >> n;
  YesorNo(n%digsum(n) == 0);
}

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

#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define pfis(a) printf("%d ",a);
#define pfls(a) printf("%lld ",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb(a) push_back(a);
#define mp(a,b) make_pair(a,b)
#define ll long long

const ll mod=1e9+7;

int main()
{
    int n,k;
    sfi(n)
    sfi(k)

    int arr[n];
    f(i,0,n)
    	sfi(arr[i])

    bool dp[k+1]={false};

    f(i,0,k+1)
    {
    	if(dp[i]==false)
    	{
    		f(j,0,n)
    		{
    			int idx=i+arr[j];
    			if(idx<=k)
	    		{
	    			dp[idx]=true;
	    		}
	    		else
	    			break;
    		}
    	}

    }

    if(dp[k]==true)
    	printf("First\n");
    else
    	printf("Second\n");

    return 0;
}

Measured memory_bytes: 384
from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(bb(n, m, g))


def bb(n: int, m: int, g: List[Tuple[int, int]]):
    ret = 0
    for i in range(m):
        v = set()
        w = [1]
        while w:
            now = w.pop()
            v.add(now)
            for j, node in enumerate(g):
                if j == i:
                    continue
                if node[0] == now and node[1] not in v:
                    w.append(node[1])
                elif node[1] == now and node[0] not in v:
                    w.append(node[0])
        if len(v) != n:
            ret += 1
    return ret


if __name__ == '__main__':
    main()


Measured memory_bytes: 10272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AdditionAndMultip solver = new AdditionAndMultip();
        solver.solve(1, in, out);
        out.close();
    }

    static class AdditionAndMultip {
        int k;
        int n;

        int rec(int cur, int times) {
            if (times == n) return cur;
            int ans = Integer.MAX_VALUE;
            ans = Math.min(ans, rec(cur * 2, times + 1));
            ans = Math.min(ans, rec(cur + k, times + 1));
            return ans;
        }

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            n = in.nextInt();
            k = in.nextInt();
            out.println(rec(1, 0));
        }

    }

    static class FastReader {
        BufferedReader reader;
        StringTokenizer st;

        public FastReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

    }
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N + 5);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &A[i]);
  }
  int cur = 1;
  int ans = 0;
  while (cur != 2 and ans < N + 5) {
    cur = A[cur];
    ++ans;
  }
  printf("%d\n", cur == 2 ? ans : -1);
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int odd = 0;
        for(int i=0; i<N; i++){
            int tmp = sc.nextInt();
            if(tmp%2==1)odd++;
        }
        if(odd%2==1){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 32548
#include<stdio.h>
int main()
{
  int a,b;
  scanf("%d %d",&a,&b);
  int start = b+1-a;
  for(int i =1 ;i<=(a-1)*2 + 1;i++)
  {
    printf("%d ",start++);
    if(i!=(a-1)*2+1)
      printf(" ");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
  int n, i, j, k;
  double v;
  while(scanf("%lf", &v) != EOF) {
    v /= 9.8;
    double y = 4.9 * v * v;
    y += 5;
    if((int)(y / 5) == y / 5.0) printf("%d\n", (int)(y / 5));
    else printf("%d\n", (int)(y / 5 + 1));
  }
  return 0;
}


Measured memory_bytes: 2664
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

signed main(){
    ll n;
    cin >> n;
    ll a[n] = {};
    ll cnt[200010] = {};
    rep(i,0,n){
        cin >> a[i];
        cnt[a[i]]++;
    }

    ll sum = 0;
    rep(i,0,200010){
        sum += cnt[i]*(cnt[i]-1)/2;
    }


    rep(i,0,n){
        ll ans = sum;
        ans -= cnt[a[i]]*(cnt[a[i]]-1)/2;
        ans += (cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n, m = sc.nextInt()

    val students = new Array[(Int, Int)](n)
    val points = new Array[(Int, Int)](m)

    for (i <- 0 until n) {
      val a, b = sc.nextInt()
      students(i) = (a, b)
    }

    for (i <- 0 until m) {
      val c, d = sc.nextInt()
      points(i) = (c, d)
    }

    for (i <- students.indices) {
      var ans = 0
      var distance = Long.MaxValue
      val (a, b) = students(i)

      for (j <- m - 1 to 0 by -1) {
        val (c, d) = points(j)
        if (distance >= (math.abs(a - c) + math.abs(b - d))) {
          ans = j
          distance = math.abs(a - c) + math.abs(b - d)
        }
      }

      println(ans + 1)
    }
  }
}

Measured memory_bytes: 25540
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
k=int(input())
a,b=list(map(int,input().split()))

for i in range(a,b+1):
    if i%k==0:
        print("OK")
        exit()

print("NG")

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef string str;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;

//0~nの範囲操作
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//1~nの範囲操作
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
//n~0を後ろから範囲操作
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
//出力後改行を
#define fin(ans) cout << (ans) << endl;
//出力後空白を
#define blank(ans) cout << (ans) << " ";
//２つの値をセットに\
sort -> p -> q
#define mp(p, q) make_pair(p, q)
//３つ以上の値をセットに(3より多いときはカッコ内を増やす)\
sort -> p -> q -> r
#define mt(p, q, r) make_tuple(p, q, r)
//配列全操作
#define all(a) a.begin(), a.end()

template <typename T, typename U>
void V2(T &n, U &m)
{
  for (ll i = 0; i < n.size(); i++)
  {
    cin >> n[i] >> m[i];
  }
}

void Main()
{
  ll n, m;
  cin >> n >> m;
  vll a(n), b(n);
  V2(a, b);
  vpll c(n);
  rep(i, n) c[i] = mp(a[i], b[i]);
  sort(all(c));
  ll flag = 0, value = 0;
  ll i = 0;
  while (1)
  {
    if(flag + c[i].second <= m)
    {
      value += c[i].first * c[i].second;
      flag += c[i].second;
    }
    else
    {
      value += c[i].first * (m - flag);
      break;
    }
    i++;
  }
  fin(value);  
  return;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

Measured memory_bytes: 3456
n = int(input())
if n%1.08 == 0:
    print(int(n//1.08))
else:
    if (n+1)%1.08 == 0:
        print(':(')
        
    elif (n+1)//1.08 == n//1.08:
        print(':(')
    else:
        print(int((n+1)//1.08))

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

int main(){ 
    int A, B;
  cin >> A >> B;
  
  cout << (A-1) * (B-1) << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include<set>
#include<map>
using namespace std;

int main()
{
	long long N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> cnt(100001);
	long long sum=0;
	for (int i = 0; i < N; ++i) 
	{
		cin >> A[i];
		sum += A[i];
		++cnt[A[i]];
	}
	
	int Q;
	cin >> Q;
	vector<long long> ans(Q);
	for (int i = 0; i < Q; ++i)
	{
		long long B, C;
		cin >> B >> C;

		if (cnt[B] == 0)
		{
			ans[i] = sum;
			continue;
		}

		sum -= (B * cnt[B] + C * cnt[C]);
		cnt[C] += cnt[B];
		cnt[B] = 0;
		sum += C * cnt[C];
		ans[i] = sum;
	}

	for (int i = 0; i < Q; ++i) cout << ans[i] << endl;
}

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

typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    ll i,n, a, b;
    cin >> n >> a >> b;
    vector<ll> Vect(n,0);
    for(i=0;i<a;i++)
        Vect[i]++;
    for(ll j = 0;j<b;j++)
        Vect[(j+a)%n]++;
    ll ans = 0;
    for(ll i =0;i<n;i++)
        ans += (Vect[i]==2);
    cout << min(a,b) << ' ' << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
 using namespace std;
  int num,num_r; 
  int ans=0;
  void conversion()
  {	stack<int >s;	while(num)	{		s.push(num%num_r);   //除R取余
   		num=num/num_r;       	}	while(!s.empty())	{		int e=s.top();		if(e>9)		{			char c='A'+e-10; 
		   //转换为16进制，A,B,··· 		
		   	ans++;		}			else 			ans++;		s.pop();	}		}
int main()
{
	cin>>num>>num_r;
	conversion();
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const  long double eps = 1e-2;
const long double pi = acos(-1.0);
using namespace std;


ll get(int mask, string s){
    vector <int> pos;
    ll res = 0;
    for (int i = 0; i < 10; i++) if (mask & (1 << i)) pos.pb(i);
    pos.pb(s.length() - 1);
    string st = "";
    int ind = 0;
    for (int i = 0; i < s.length(); i++){
        st.pb(s[i]);
        if (i == pos[ind]){
            ind++;
            res += atoll(st.c_str());
            st = "";
        }
    }
    return res;
}

void solve(){   
    string s;
    cin >> s;
    int n = s.length() - 1;
    ll ch = 0;
    for (int mask = 0; mask < (1 << n); mask++){
        ll res = get(mask, s);
        ch += res;
        
    }    
    cout << ch << endl;
}
int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(3);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
  for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>

#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

struct St
{
	int a;
	int d;
	St(int a, int d)
	{
		this->a = a;
		this->d = d;
	}
};

int N, M;
list<St> L[100001];
list<St> R[100001];
int table[100001];
bool is_set[100001];

void func(int n)
{
	for (St& st : L[n])
	{
		if (is_set[st.a])
		{
			int t = table[n] + st.d;
			if (t != table[st.a])
			{
				cout << "No" << endl;
				exit(0);
			}
		}
		else
		{
			table[st.a] = table[n] + st.d;
			is_set[st.a] = true;
			func(st.a);
		}
	}
	for (St& st : R[n])
	{
		if (is_set[st.a])
		{
			int t = table[n] - st.d;
			if (t != table[st.a])
			{
				cout << "No" << endl;
				exit(0);
			}
		}
		else
		{
			table[st.a] = table[n] - st.d;
			is_set[st.a] = true;
			func(st.a);
		}
	}
}

signed main()
{
	cin >> N >> M;
	REP(i, M)
	{
		int l, r, d;
		cin >> l >> r >> d;
		L[l].push_back(St(r, d));
		R[r].push_back(St(l, d));
	}

	for (int i = 1; i <= N; i++)
	{
		if (!is_set[i])
		{
			is_set[i] = true;
			table[i] = 0;
			func(i);
		}
	}

	cout << "Yes" << endl;
}






Measured memory_bytes: 28544
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin >> n >> k;
	if (k >= n) {
		return cout << 0, 0;
	}
	vi h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(all(h));
	reverse(all(h));
	ll ans = 0;
	for (int i = k; i < n; i++) {
		ans += h[i];
	}
	cout << ans;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        //int n = stdIn.nextInt();
        String s = stdIn.next();
        String ss = stdIn.next();
        
        char c[] = s.toCharArray();
        char cc[] = ss.toCharArray();
        int count = 0;
        
        for(int i = 0; i < s.length(); i++){
            if(c[i] != cc[i]){
                count++;
            }
        }
        //boolean flag = false;
        //int a[] = new int[n];
        
        //for(int i = 0; i < n; i++){
        //    a[i] = stdIn.nextInt();
        //}
        
        //if(flag){
            System.out.println(count);
        //}else{
        //    System.out.println();
        //}
    }
}


Measured memory_bytes: 41876
#include<bits/stdc++.h>
#define N 200005
#define LL long long
using namespace std;
const int mo=1e9+7;
int n,m,a,b,fc[N],xf[N],ans;
LL fpm(LL x,LL y){ LL s=1; while(y){ if(y&1) s=(s*x)%mo; y>>=1,x=(x*x)%mo;} return s;}
LL C(int n,int m){ return 1LL*fc[n]*xf[m]%mo*xf[n-m]%mo;}
int main()
{
	int i;
	scanf("%d %d %d %d",&n,&m,&a,&b);
	fc[0]=xf[0]=1;
	for(i=1;i<=n+m;i++)
		fc[i]=(1LL*fc[i-1]*i)%mo,xf[i]=fpm(fc[i],mo-2);
	ans=C(n+m-2,n-1);
	for(i=1;i<=b;i++)
		ans=(ans-C(n-a-1+i-1,i-1)*C(a-1+m-i,a-1)%mo+mo)%mo;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

struct edge{
    int from,to,cost;
    bool operator<(const edge& o) const{
        return cost<o.cost;
    }
};

int main(){
    int v,e;cin>>v>>e;
    vector<edge> G;
    rep(i,e){
        int a,b,c;cin>>a>>b>>c;
        G.push_back({a,b,c});
    }
    UnionFind uf(v);
    sort(G.begin(),G.end());
    int ans=0;
    for(auto au:G){
        if(uf.find(au.from)!=uf.find(au.to)){
            uf.unite(au.from,au.to);
            ans+=au.cost;
        }
    }
    cout<<ans<<endl;
}
    


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

int main(){
  vector<vector<int> > cave(2000,vector<int>(2000,1e6+1));
  vector<int> xp(1e6+1);
  vector<int> yp(1e6+1);
  int l=1;
  int x=1000;
  int y=1000;
  xp[1]=x;
  yp[1]=y;
  cave[x][y]=1;

  for(int i=2;i<1e6+1;i++){
    for(int j=0;j<l;j++){
      x++;
      cave[x][y]=i;
      xp[i]=x;
      yp[i]=y;
      i++;
      if(i>1e6+1)break;
    }
    if(i>1e6+1)break;
    for(int j=0;j<l;j++){
      y--;
      cave[x][y]=i;
      xp[i]=x;
      yp[i]=y;
      i++;
      if(i>1e6+1)break;
    }
    if(i>1e6+1)break;
    l++;
    for(int j=0;j<l;j++){
      x--;
      cave[x][y]=i;
      xp[i]=x;
      yp[i]=y;
      i++;
      if(i>1e6+1)break;
    }
    if(i>1e6+1)break;
    for(int j=0;j<l;j++){
      y++;
      cave[x][y]=i;
      xp[i]=x;
      yp[i]=y;
      if(j!=l-1)i++;
      if(i>1e6+1)break;
    }
    if(i>1e6+1)break;
    l++;
  }

  /*
  for(int i=1490;i<1510;i++){
    for(int j=1490;j<1510;j++){
      cout<<cave[j][i]<<" ";
    }
    cout<<endl;
  }
  */

  vector<int> prime(1e6+2,1);
  prime[1e6+1]=0;
  prime[1]=0;
  for(int i=2;i<prime.size();i++){
    if(prime[i]){
      for(int j=i+i;j<prime.size();j+=i)prime[j]=0;
    }
  }

  //for(int i=0;i<1e6;i++)if(prime[i])cout<<i<<" ";


  while(1){
    int m,n;
    cin>>m>>n;
    if(m==0&&n==0)break;
    vector<vector<int> > bfs(2000,vector<int>(2000,0));
    vector<int> used(1e6+1,1);
    queue<int> q;
    q.push(n);
    while(!q.empty()){
      int np=q.front();
      //cout<<np<<endl;
      q.pop();
      if(used[cave[xp[np]-1][yp[np]+1]]&&cave[xp[np]-1][yp[np]+1]<=m){
        q.push(cave[xp[np]-1][yp[np]+1]);
        used[cave[xp[np]-1][yp[np]+1]]=0;
      }
      if(used[cave[xp[np]][yp[np]+1]]&&cave[xp[np]][yp[np]+1]<=m){
        q.push(cave[xp[np]][yp[np]+1]);
        used[cave[xp[np]][yp[np]+1]]=0;
      }
      if(used[cave[xp[np]+1][yp[np]+1]]&&cave[xp[np]+1][yp[np]+1]<=m){
        q.push(cave[xp[np]+1][yp[np]+1]);
        used[cave[xp[np]+1][yp[np]+1]]=0;
      }
      bfs[xp[np]][yp[np]]=max(bfs[xp[np]-1][yp[np]-1],max(bfs[xp[np]][yp[np]-1],bfs[xp[np]+1][yp[np]-1]))+prime[np];
      //if(prime[np])bfs[xp[np]][yp[np]]++;
    }

    /*
    for(int i=995;i<1005;i++){
      for(int j=995;j<1005;j++){
        cout<<bfs[j][i]<<" ";
      }
      cout<<endl;
    }
    */

    int ans=0;
    int id=0;
    for(int i=0;i<=m;i++){
      //cout<<i<<" "<<bfs[xp[i]][yp[i]]<<endl;
      if(ans<bfs[xp[i]][yp[i]]&&prime[i]){
        ans=bfs[xp[i]][yp[i]];
        id=cave[xp[i]][yp[i]];
      }
      if(ans!=0&&ans==bfs[xp[i]][yp[i]]&&prime[i]){
        ans=bfs[xp[i]][yp[i]];
        id=max(id,cave[xp[i]][yp[i]]);
      }
    }
    cout<<ans<<" "<<id<<endl;
  }

}



Measured memory_bytes: 49900
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a <= x && x < b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int p[45], t[45], dp[45][45][4];
signed main(void) {
  while (true) {
    int n;
    cin >> n;
		if(!n) break;
    REP(i, n) cin >> p[i] >> t[i];

    //?????????????????????????????????
		if(p[0] > t[0]) {
			cout << "NG " << 1 << endl;
			continue;
		}
		//INF??§?????????
		REP(i, 45) REP(j, 45) REP(k, 4) dp[i][j][k] = INF;
		dp[0][0][1] = p[0];

		bool ok;
		int ans;
    FOR(i, 1, n) {
			//cout << "i:" << i << endl;
			ok = false;
      for(int k=4; k>=1; --k) {
				//cout << "k:" << k << endl;
        if (dp[i - 1][i - 1][k - 1] != INF) {
					//cout << "c" << endl;
          //?????????????¬????????????????????????????
          if (k <= 3 && abs(p[i] - p[i - 1]) * (k) <= abs(t[i] - t[i - 1])) {
						//cout << "a" << endl;
            dp[i][i][k] = min(dp[i][i][k], dp[i-1][i-1][k-1] + abs(p[i] - p[i-1]));
						ok = true;
          }
          //??????????????????????¬????????????????????????????
          if (p[i - 1] * (k) + p[i] <= abs(t[i] - t[i - 1])) {
						//cout << "b" << dp[i-1][i-1][k-1] << " " << p[i-1] << " " <<  p[i] << endl;
            dp[i][i][1] = min(dp[i][i][1], dp[i-1][i-1][k-1] + p[i-1] + p[i]);
						ok = true;
          }
        }
      }
			if(!ok) {
				ans = i + 1;
				break;
			}
    }

		/*REP(i, n) {
			REP(k, 4) {
				cout << dp[t[i]][p[i]][k] << " ";
			}
			cout << endl;
		}*/

		if(ok) {
			int ans = INF;
			REP(k, 4) {
				if(k > 0) dp[n-1][n-1][k] += p[n-1];
				//cout << dp[t[n-1]][p[n-1]][k] << endl;
				ans = min(ans, dp[n-1][n-1][k]);
			}
			cout << "OK " << ans << endl;
		} else cout << "NG " << ans << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    const int inf=(1<<30);
    int n;
    cin >> n;
    int a=inf;
    int b=-inf;
    int c=inf;
    int d=-inf;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin >> x >> y;
        a=min(a,x-y);
        b=max(b,x-y);
        c=min(c,x+y);
        d=max(d,x+y);
    }
    cout << max(b-a,d-c) << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <ctype.h>
#include <set>
#include <map>
#include <list>
#include <stack>

using namespace std;
char s[100500];
int main()
{
    scanf("%s",s);
	int ans=0;
	int zhen=0;
	int len=strlen(s);
	while(zhen<len)
	{
		ans++;
		int tmp=s[zhen];
		while(s[zhen]==tmp)
		{
			zhen++;
		}
	}
	printf("%d\n",ans-1);
	return 0;
}

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

char str[20];

void dfs( int n, int maxi, int idx ){
    if( idx == n ){
        printf("%s\n", str);
        return;
    }

    for( int i = 0; i <= maxi+1; i++ ){
        int prevmaxi = maxi;
        maxi = max( maxi, i );
        
        str[idx] = i + 'a';
        dfs( n, maxi, idx+1 );

        maxi = prevmaxi;
    }
}

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

    memset(str, 0, sizeof(str));
    dfs( n, -1, 0 );

    return 0;
}

Measured memory_bytes: 1536
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int a[8][8][8],n,m,p;
int y[400],x[400];
int dz[13] = {0,0,1,0,0,1,1,1,1,1,1,1,1};
int dy[] = {0,1,0,1,1,0,0,1,-1,1,1,-1,-1};
int dx[] = {1,0,0,1,-1,1,-1,0,0,1,-1,1,-1};

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	while(cin>>n>>m>>p && n){
		memset(a,-1,sizeof(a));
		rep(i,p){
			cin>>y[i]>>x[i];
			y[i]--;x[i]--;
		}
		rep(i,p){
			int z=0;
			while(a[z][y[i]][x[i]] != -1) z++;
			a[z][y[i]][x[i]] = i%2;
			rep(sz,n)rep(sy,n)rep(sx,n)rep(d,13){
				int z = sz, y = sy, x = sx, ok = 1;
				rep(j,m){
					if(z>=n || y<0 || y>=n || x<0 || x>=n || a[z][y][x] != i%2){
						ok=0;break;
					}
					z+=dz[d],y+=dy[d],x+=dx[d];
				}
				if(ok){
					cout<<(i%2==0 ? "Black":"White")<<" "<<i+1<<endl;
					goto end;
				}
			}
		}
		cout<<"Draw"<<endl;
		end:;
	}
}

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

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

int main() {
	int N; cin >> N;
	int ans = 0;
	if (N >= 64) ans = 64;
	else if (N >= 32) ans = 32;
	else if (N >= 16) ans = 16;
	else if (N >= 8) ans = 8;
	else if (N >= 4) ans = 4;
	else if (N >= 2) ans = 2;
	else if (N >= 1) ans = 1;

	cout << ans << endl;

	return 0;
}

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


int main(void) {

  int n;
  cin >> n;
  vector< vector<int> > a(4, vector<int>(13, 0));
  for(int i=0; i<n; i++){
    char s;
    int tmp;
    cin >> s >> tmp;
    if( s == 'S' ) a[0][tmp-1]++;
    if( s == 'H' ) a[1][tmp-1]++;
    if( s == 'C' ) a[2][tmp-1]++;
    if( s == 'D' ) a[3][tmp-1]++;
  }

  for(int i=0; i<4; i++){
    for(int j=0; j<13; j++){
      if( a[i][j] == 0 ){
        if( i == 0 ) cout << 'S' << " " << j+1 << endl;
        if( i == 1 ) cout << 'H' << " " << j+1 << endl;
        if( i == 2 ) cout << 'C' << " " << j+1 << endl;
        if( i == 3 ) cout << 'D' << " " << j+1 << endl;
      }
    }
  }


  return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
long long n,k,q;
int main(){
    cin>>n>>k>>q;
    int a[n]={0};
    int b;for(int i=0;i<q;i++){cin>>b;a[b-1]++;}
    for(int i=0;i<n;i++)cout<<((k-q+a[i]>0)?"Yes":"No")<<endl;
}


Measured memory_bytes: 1024
/**
	* Author   : Sriram M
	* Date     : 
	* Semester : 5
	* SSN College of Engineering Chennai
    Aug Challenge
**/

#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    #ifndef ONLINE_JUDGE 
  
        // For getting input from input.txt file 
        freopen("input.txt", "r", stdin); 
      
        // Printing the Output to output.txt file 
        freopen("output.txt", "w", stdout); 
      
    #endif

    long long int n, x, t;
    long time = 0;
    cin >> n >> x >> t;
    
    while (n > 0){
        time += t;
        n -= x;
    }

    cout << time;
    return 0;
}


Measured memory_bytes: 3640
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

class Info:
    def __init__(self,arg_node_id,arg_sum_cost):
        self.node_id = arg_node_id
        self.sum_cost = arg_sum_cost


V = int(input())
ADJ = [[] for i in range(V)]

for loop in range(V):
    input_str = list(map(int,input().split()))
    node_id = input_str[0]-1
    for i in range(input_str[1]):
        ADJ[node_id].append(input_str[2+i]-1)

visited = [False]*V
visited[0] = True

min_dist = [-1]*V
min_dist[0] = 0

Q = deque()
Q.append((Info(0,0)))

while len(Q) > 0:
    info = Q.popleft()
    for next_node in ADJ[info.node_id]:
        if visited[next_node] == True:
            continue
        visited[next_node] = True
        min_dist[next_node] = info.sum_cost+1
        Q.append((Info(next_node,min_dist[next_node])))

for i in range(V):
    print("%d %d"%(i+1,min_dist[i]))





Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; 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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;
ll const MAXVAL = 1e6;

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

  vector<ll> table(n+1);
  for(ll i=1; i*i <= n; i++) {
    for(ll j=i; i*j <= n; j++) {
      if (i==j) table[i*j]++;
      else table[i*j] += 2;
    }
  }

  ll ans = 0;
  reps1(i, n) ans+= table[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11168
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node treeMinimum(Node x);
Node treeMaximum(Node x);
Node treeSearch(Node u, int k);
Node treeSuccessor(Node x);
void treeDelete(Node z);
void insert(int k);
void inorder(Node u);
void preorder(Node u);

int main(){
  int n, i, m;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "find") == 0 ){
      scanf("%d", &m);
      Node t = treeSearch(root, m);
      if ( strcmp(com, "findMin") == 0 ){
	Node minn = treeMinimum(t);
	printf("%d\n", minn->key);
      } else if ( strcmp(com, "findMax") == 0 ){
	Node maxn = treeMaximum(t);
	printf("%d\n", maxn->key);
      } else {
	if ( t != NIL ) printf("yes\n");
	else printf("no\n");
      }
    } else if ( com[0] == 'i' ){
      scanf("%d", &m);
      insert(m);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( strcmp(com, "delete") == 0 ){
      scanf("%d", &m);
      treeDelete(treeSearch(root, m));
    }
  }

  return 0;
}

Node treeMinimum(Node x){
  while( x->left != NIL ) x = x->left;
  return x;
}
Node treeMaximum(Node x){
  while( x->right != NIL ) x = x->right;
  return x;
}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key ){
    if ( k < u->key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node treeSuccessor(Node x){
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node y = x->parent;
  while( y != NIL && x == y->right ){
    x = y;
    y = y->parent;
  }
  return y;
}

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

  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);
  if ( y->left != NIL ) x = y->left;
  else x = y->right;

  if ( x != NIL ) x->parent = y->parent;

  if ( y->parent == NIL ){
    root = x;
  } else {
    if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
  }

  if ( y != z ){
    z->key = y->key;
  }

  free(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);
}



Measured memory_bytes: 25140
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=100005,mod=998244353;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
int base=Pow(10,18);
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n;
vi a[N],b[N],c[N];
int sa[N],sb[N],sc[N];
void get(vi *e,int *s){
	static int vis[N],sg[N],tc=0;
	int m=read();
	while (m--){
		int x=read(),y=read();
		if (x>y)
			swap(x,y);
		e[x].pb(y);
	}
	clr(sg);
	Fod(i,n,1){
		tc++;
		for (auto j : e[i])
			vis[sg[j]]=tc;
		while (vis[sg[i]]==tc)
			sg[i]++;
		Add(s[sg[i]],Pow(base,i));
	}
}
int main(){
	n=read();
	get(a,sa),get(b,sb),get(c,sc);
	int ans=0;
	For(i,0,1000)
		For(j,0,1000)
			Add(ans,(LL)sa[i]*sb[j]%mod*sc[i^j]%mod);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 13056
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int Mod=998244353;
void add(int& x,int y)
{
	x+=y;
	if(x>=Mod)x-=Mod;
	return ;
}
int f[3010];
int main()
{
	int n,S;
	scanf("%d %d",&n,&S);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int x;scanf("%d",&x);
		for(int j=S;j>=x;j--)
			add(f[j],f[j-x]);
		if(x<=S)add(f[x],i);
		add(ans,f[S]);
	}
	printf("%d\n",ans);
	return 0;
}

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


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

  string a;
  cin>>a;
  if(a=="ABC")
    cout<<"ARC";
  else
    cout<<"ABC";

}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
ll n,m;
int main() {
    cin >> n >> m;
    ll ans = 0;
    if(m > 2*n) cout << n+(m-2*n)/4 << endl;
    else cout << m/2 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		sc.close();

		double ret = getProcess(R);

		System.out.println(ret);
	}

	public static double getProcess(int R){
		double ret = 2 * Math.PI * R ;

		return ret;
	}


}

Measured memory_bytes: 27032
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		if(A==B){

			if(B==C){
				System.out.println("Yes");

			}
			else{
				System.out.println("No");
			}
			}
			else{
				System.out.println("No");
			}
	}
}

Measured memory_bytes: 21460
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N=1e5+6;
const long double pi=3.14159265358979323;

void solve(){


	long double r ;
	cin>>r;
	r=2*pi*r;
	cout<<setprecision(6)<<fixed;
	cout<<r<<'\n';







}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll t=1;
//	cin>>t;
    for (int i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}





Measured memory_bytes: 3812
A,B,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=10**5+1,10**5+1
for i in a:
    if i<p:
        p=i
for i in b:
    if i<q:
        q=i
r=p+q
for i in range(m):
    x,y,c=map(int,input().split())
    s=a[x-1]+b[y-1]-c
    if r>s:
        r=s
print(r)

Measured memory_bytes: 18736