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

using namespace std;

const int N = 1e6+5;

int dist[N];
vector < pair <int, int> > g[N];
vector <int> new_g[N], all[N];
int was[N];
int x[N];
int ptr[N];

template<typename Ty>
bool read1n(Ty &x)
{
    char ch; bool neg=false;
    for(ch=getchar();ch<'0'||'9'<ch;ch=getchar())
        if(ch=='-')
            neg=true;
        else if(ch==-1)return false;
    for(x=0;'0'<=ch&&ch<='9';ch=getchar())
        x=(x<<1)+(x<<3)+ch-'0';
    if(neg) x=-x;
    return true;
}

int main() {
  int n, m;
  while(1){
    if(!read1n(n))break;
    read1n(m);
    memset(dist,0,sizeof(dist));
    memset(x,0,sizeof(x));
    for(int i=0;i<N;i++){
        all[i].clear();
    }
    for(int i=0;i<n;i++)g[i].clear();
  for (int i = 0; i < m; i++) {
    int foo, bar, qwe;
    read1n(foo);
    read1n(bar);
    read1n(qwe);
    foo--; bar--;
    g[foo].push_back(make_pair(qwe, bar));
    g[bar].push_back(make_pair(qwe, foo));
    all[qwe].push_back(foo);
    all[qwe].push_back(bar);
  }
  for (int i = 0; i < n; i++) {
    sort(g[i].begin(), g[i].end());
    ptr[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    was[i] = -1;
  }
  int new_n = n;
  for (int i = 0; i < N; i++) {
    new_g[i].clear();
  }
  for (int color = 0; color < N; color++) {
    if (all[color].empty()) {
      continue;
    }
    for (int it = 0; it < all[color].size(); it++) {
      int v = all[color][it];
      if (was[v] == color) {
        continue;
      }
      int b = 0, e = 1;
      x[0] = v;
      was[v] = color;
      while (b < e) {
        while (ptr[x[b]] <  g[x[b]].size()) {
          int c = g[x[b]][ptr[x[b]]].first;
          if (c != color) {
            break;
          }
          int u = g[x[b]][ptr[x[b]]].second;
          if (was[u] != color) {
            was[u] = color;
            x[e] = u;
            e++;
          }
          ptr[x[b]]++;
        }
        b++;
      }
      for (int i = 0; i < e; i++) {
        new_g[x[i]].push_back(new_n);
        new_g[new_n].push_back(x[i]);
      }
      new_n++;
    }
  }
  for (int i = 0; i < new_n; i++) {
    dist[i] = -2;
  }
  int b = 0, e = 1;
  x[0] = 0;
  dist[0] = 0;
  while (b < e) {
    for (int j = 0; j <  new_g[x[b]].size(); j++) {
      int u = new_g[x[b]][j];
      if (dist[u] == -2) {
        dist[u] = dist[x[b]] + 1;
        x[e] = u;
        e++;
      }
    }
    b++;
  }
  printf("%d\n", dist[n - 1] / 2);
  }
  return 0;
}


Measured memory_bytes: 105728
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,ans;
    long long x,y;
    cin>>x>>y;

    if(x*4<y) cout<<"No"<<endl;
    else if(x*2>y) cout<<"No"<<endl;
    else if(y%2!=0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

}


Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;    
int main()
{
    char a;
    int s=0;
    while(cin>>a)
    {
        if(a=='C')
        {
            s++;
            break;
        }    
    }
    while(cin>>a)
    {
        if(a=='F')
        {
            s++;
            break;
        }    
    }
    if(s==2)
    {
        cout<<"Yes";
        return 0;
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        char c = sc.next().charAt(0);
        if(c == 'A'){
            System.out.println('T');
        }else if(c == 'T'){
            System.out.println('A');
        }else if(c == 'G'){
            System.out.println('C');
        }else{
            System.out.println('G');
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 21204
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

min_ = min(A)+min(B)

for i in range(m):
  x, y, c = map(int, input().split())
  x, y = x-1, y-1
  if A[x]+B[y]-c <= min_:
    min_ =  A[x]+B[y]-c
    
print(min_)

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

 using namespace std;
 int main()
 {
     int t;
     int m;
     cin>>t>>m;
     long long k=0;
     while(t--)
     {
         long long a,b,sum=0;
         cin>>a>>b;
         sum=ceil(1.0*sqrt(a*a+b*b));
         if(sum<=m)k++;
         //cout<<sum<<endl;
     }
     cout<<k;
 }


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const int MAX_LOG = (int)(335 + 5);

string s;

int n;
int doubling[MAX_LOG][MAX_N];

map<int, vector<int>> mp;

string binexp = "100100100100110101101001001011001010011000011011111010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";

void make_doubling() {
  int dp[2][MAX_N];

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'R') {
      dp[0][i] = i + 1;
    } else {
      dp[0][i] = i - 1;
    }
  }

  for (int i = 0; i < n; ++i) {
    mp[0].push_back(dp[0][i]);
  }

  for (int i = 1; i < binexp.size(); ++i) {
    int cur = i % 2;
    int last = (i - 1) % 2;

    for (int j = 0; j < n; ++j) {
      int fst = dp[last][j];
      int snd = dp[last][fst];
      dp[cur][j] = snd;
    }

    if (binexp[i] == '1') {
      for (int j = 0; j < n; ++j) {
        mp[i].push_back(dp[cur][j]);
      }
    }
  }
}

int after[MAX_N];

int ans[MAX_N];

int main(void) {
  // Here your code !
  cin >> s;

  n = s.size();

  reverse(binexp.begin(), binexp.end());

  make_doubling();

  for (int i = 0; i < n; ++i) {
    after[i] = i;
  }

  for (int i = 0; i < binexp.size(); ++i) {
    if (binexp[i] == '0') continue;

    for (int j = 0; j < n; ++j) {
      after[j] = mp[i][j];
    }
  }

  for (int i = 0; i < n; ++i) {
    ans[after[i]] += 1;
  }

  for (int i = 0; i < n; ++i) {
    printf("%d ", ans[i]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 12920
#include <iostream>
#include <string>
//#include <cstring>
//#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
//#include <stack>
//#include <queue>
//#include <chrono>
//#include <numeric>
//#include <set>
//#define _USE_MATH_DEFINES
//#include <cmath>
//#include <math.h>
//#include <iomanip>
//#include <list>
//#include <limits>

using namespace std;
const int infty = static_cast <int> (pow(256, sizeof(int)) / 2 - 1);

int knapsackProblem(int n, int w, vector<pair<int,int>> &vvw)
{
	vector<vector<int>> vvc;
	vvc = vector<vector<int>>(vvw.size(), vector<int>(w + 1, 0));

	for (int i = 0; i <= w; ++i)
		vvc[0][i] = 0;

	for (int i = 0; i <= n; ++i)
		vvc[i][0] = 0;

	for(int i = 1; i <=n; ++i)
	{
		for (int j = 1; j <= w; ++j)
		{
			int vm = 0;
			for (int k = 1; k <= i; ++k)
			{
				if (j - vvw[k].second >= 0)
					vm = max(vm, vvw[k].first + vvc[i][j-vvw[k].second]);
			}
			if (vm > vvc[i - 1][j])
				vvc[i][j] = vm;
			else
				vvc[i][j] = vvc[i - 1][j];
		}
	}

	//for(int i = 0; i <= n; ++i)
	//{
	//	for(int j = 0; j <= w; ++j)
	//	{
	//		cout << vvc[i][j] << " ";
	//	}
	//	cout << endl;
	//}

	return vvc[n][w];
}

int main()
{
	//ifstream fin("DPL_1_B_in20.txt");
	//ifstream fin("test.txt");
	//if (!fin.is_open())
	//{
	//	cout << "File not found." << endl;
	//	return 0;
	//}

	//fin.tie(0);
	//ios::sync_with_stdio(false);

	//int n,w;
	//fin >> n >> w;
	//fin.ignore();

	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, w;
	cin >> n >> w;
	cin.ignore();

	int a, b;
	vector<pair<int, int>> vvw;

	vvw.push_back(pair<int,int>(0,0));

	for (int i = 0; i < n; ++i)
	{
		cin >> a >> b;
		//fin >> a >> b;
		vvw.push_back(pair<int,int>(a,b));
	}

	cout << knapsackProblem(n,w,vvw) << endl;

	return 0;
}

Measured memory_bytes: 6828
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;

ll d[100000], INF=1e17;
vector<P> g[100000];


int main() {
    int n, m, k;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a, b;
        ll c;
        cin>>a>>b>>c;
        a--;
        b--;
        g[a].push_back(P(c, b));
        g[b].push_back(P(c, a));
    }
    cin>>m>>k;
    k--;
    priority_queue<P> q;
    fill(d, d+n, INF);
    d[k]=0;
    q.push(P(0, k));
    while(!q.empty()){
        P p=q.top();
        q.pop();
        int v=p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<g[v].size();i++){
            int w=g[v][i].second;
            ll c=g[v][i].first;
            if(d[w]>d[v]+c){
                d[w]=d[v]+c;
                q.push(P(d[w], w));
            }
        }
    }
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        cout<<d[x]+d[y]<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 11120
#include<stdio.h>

int main(){
   int K,A,B;
     scanf("%d",&K);
     scanf("%d %d",&A,&B);
     int i; 
for ( i = A; i <= B; i++){
   
    if (i % K == 0)
    {
     printf("OK");
     break;
    }
}
if(i>B){
printf("NG");
}


return 0;
}

Measured memory_bytes: 1724
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

#define rep(i,n) for (long long int i = 0; i < (n); i++)

using namespace std;

int main(int argc, char* argv[]){
  long long int S, W;
  cin >> S >> W;

  if(S <= W){
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define double long double
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define td(v) v.begin(),v.end()
#define tdr(v) v.rbegin(),v.rend()
#define endl "\n"
#define Matrix vector<vector<int> >
using namespace std;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int INF = 2e18;

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

inline long long mod(long long n, long long m){
    long long ret = n%m;
    if(ret < 0) ret += m;
    return ret;
}

int exp(int a, int b, int m){
    int result = 1;
    while (b > 0){
        if (b & 1)
            result = mod(result*a,m);
 
        b >>= 1;
        a = mod(a*a,m);
    }
    return result;
}
void solve(){
    int n,k; cin>>n>>k;
    int aux = n%k;
    cout<<min(aux,abs(k-aux))<<endl;
}
main(){
    fastio;
    // int q; cin>>q;
    // while(q--)
        solve();
}

Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun %test (s first)
  (loop for i from 1 below (- (length s) 1)
        thereis (and (not (and (char= (aref s (- i 1))
                                      (aref s (+ i 1)))))
                     (not (%test (concatenate 'simple-base-string
                                              (subseq s 0 i)
                                              (subseq s (+ i 1) (length s)))
                                 (not first))))))

(defun main ()
  (let* ((s (read-line)))
    (write-line
     (if (char= (aref s 0) (aref s (- (length s) 1)))
         (if (evenp (length s))
             "First"
             "Second")
         (if (oddp (length s))
             "First"
             "Second")))))

#-swank(main)


Measured memory_bytes: 18272
#include <bits/stdc++.h>
using namespace std;
int main () {
    
    long a, b, k;
    
    cin >> a >> b >> k;
    
    for (int i = 1; i <= k; i++)
        if (i % 2 != 0)
            if (a % 2 == 0) {a /= 2; b += a;}
            else {a -= 1; a /= 2; b += a;}
        else
            if (b % 2 == 0) {b /= 2; a += b;}
            else {b -= 1; b /= 2; a += b;}
    
    cout << a << " " << b << endl;
    
    return 0;
}

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

using namespace std;

typedef long long int ll;

#define FOR(i,l,r) for(i=l;i<r;i++)

#define REP(i,n) FOR(i,0,n)

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

#define P pair<ll,ll>

#define F first

#define S second

#define VEC vector

#define V VEC<ll>

signed main(){

  ll N,K,ans,MOD=1000000007;cin>>N>>K;

  ans=(N-K+2)%MOD*(2+(N+1)*(N+K+1)%MOD)%MOD*500000004%MOD;
  
  ans-=((N+1)*(N+2)%MOD*(2*N+3)%MOD-K*(K-1)%MOD*(2*K-1)%MOD)%MOD*166666668%MOD;
  
  ans%=MOD;
  
  if(ans<0)ans+=MOD;

  cout<<ans%MOD<<endl;

  return 0;

}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int f(LL a, LL b) {
    string s = to_string(a);
    string t = to_string(b);
    return (int)max(s.size(), t.size());
}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    LL n;cin >> n;
    int mi = 10000000;
    for(LL a=1;a*a<=n;a++){
        if(n%a != 0) continue;
        LL b = n/a;
        mi = min(mi, f(a, b));
    }
    cout << mi << 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 A=sc.nextInt();
    int B=sc.nextInt();
    int C=sc.nextInt();
    int remain=A-B;
    int a=remain%C;
    System.out.println(a);
  }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

ll gcd(ll a, ll b)
{
	return b ? gcd(b, a%b) : a;
}

int main()
{
	int m;
	while(scanf("%d", &m), m){
		int dist[10], velo[10];
		rep(i, m){
			int a, b;
			scanf("%d%d", &a, &b);
			dist[i] = a / gcd(a, b);
			velo[i] = b / gcd(a, b);
		}
		
		ll n=dist[0], d=velo[0];
		reps(i, 1, m){
			ll nn = n * dist[i];
			ll nd = gcd(n*velo[i], d*dist[i]);
			n = nn / gcd(nn, nd);
			d = nd / gcd(nn, nd);
		}
		rep(i, m){
			printf("%d\n", (n/dist[i])*(velo[i]/d));
		}
	}
	return 0;
}

Measured memory_bytes: 1028
<?php
list($k, $x) = explode(' ', trim(fgets(STDIN)));

$min = $x - ($k - 1);
$max = $x + ($k - 1);

if ($min < -1000000) {
    $max += (-1000000 - $min);
} elseif ($max > 1000000) {
    $min -= ($max - 1000000);
}

for ($i = $min; $i <= $max; $i++) {
    echo $i . PHP_EOL;
}


Measured memory_bytes: 4728
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(a,b) memset(a,b,sizeof(a))
#define msn(a,n,b) for(int i=0;i<=n;i++)a[i]=b
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define fi first
#define se second
using namespace std;
mt19937 rng_32(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef double db;
const int mod=1e9+7;
const int seed=233;
const double PI=acos(-1.0);
const double eps=1e-7;
const int inf=0x3f3f3f3f;
const int max_n=100005;
ll ceil(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?(x+y-1)/y:-x/y;}
ll floor(ll x,ll y){if(x==0)return 0;if(y<0)x=-x,y=-y;bool sign=x>0;x=abs(x);return sign?x/y:-(x+y-1)/y;}
namespace {
    inline int Add(int x,int y){return (x+=y)>=mod?x-mod:x;}
    inline int Sub(int x,int y){return (x-=y)<0?x+mod:x;}
    inline int Mul(int x,int y) {return 1ll*x*y%mod;}
    inline int Pow(int x,int y=mod-2){if(y==0)return 1;int res=1;while(y){if(y&1)res=1ll*res*x%mod;x=1ll*x*x%mod;y>>=1;}return res;}
}
/**********************head************************/
int n,m;
char s[105][105];
int dp[105][105];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf(" %s",s[i]+1);
    dp[1][1]=s[1][1]=='#';
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i==1&&j==1)continue;
            dp[i][j]=1e9;
            if(i>=2)dp[i][j]=min(dp[i][j],dp[i-1][j]+(s[i-1][j]=='.'&&s[i][j]=='#'));
            if(j>=2)dp[i][j]=min(dp[i][j],dp[i][j-1]+(s[i][j-1]=='.'&&s[i][j]=='#'));
        }
    }
    printf("%d\n",dp[n][m]);
    return 0;
}

Measured memory_bytes: 256
h,w=gets.split.map &:to_i

def f(a)
	a.max-a.min
end

if h%3==0||w%3==0
p 0
else
p [
f([(h/3)*w,(h/3)*w,(h-h/3-h/3)*w]),
f([(h/3)*w,(h/3+1)*w,(h-h/3-h/3-1)*w]),
f([(w/3)*h,(w/3)*h,(w-w/3-w/3)*h]),
f([(w/3)*h,(w/3+1)*h,(w-w/3-w/3-1)*h]),
f([(h/3)*w,(h-(h/3))*(w/2),(h-(h/3))*(w-w/2)]),
f([(h/3+1)*w,(h-(h/3+1))*(w/2),(h-(h/3))*(w-w/2)]),
f([(w/3)*h,(w-(w/3))*(h/2),(w-(w/3))*(h-h/2)]),
f([(w/3+1)*h,(w-(w/3+1))*(h/2),(w-(w/3+1))*(h-h/2)])
].min
end

Measured memory_bytes: 1788
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;
    vector<ll> a(3 * n);
    rep(i, 3 * n) {
        cin >> a[i];
    }
    sort(ALL(a));
    ll ans = 0;
    for(int i = n; i < 3 * n; i += 2) {
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
//P4557 闵可夫斯基+二维凸包 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define db double
#define For(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
inline ll read(){
	ll x=0;char ch=getchar();bool f=0;
	for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=1;
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return f?-x:x;
}
void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>=10) write(x/10);putchar(x%10+'0');
}
void writeln(ll x){write(x);puts("");}
void writep(ll x){write(x);putchar(' ');}

int const N=1e5+3;
int top,n,m,cnt,sta[N];
struct point{
	db x,y;
    point operator - (point A) const{return (point){x-A.x,y-A.y};}
    point operator + (point A) const{return (point){x+A.x,y+A.y};}
    void print(){printf("%.10lf %.10lf\n",x,y);}
}A,B,C,c[N],p1[N],p2[N];

point operator *(db x,point A){return (point){x*A.x,x*A.y};}
db CJ(point A,point B){return A.x*B.y-B.x*A.y;}//叉积 
db DJ(point A,point B){return A.x*B.x+A.y*B.y;}//点积 
db dis(point A){return sqrt(A.x*A.x+A.y*A.y);}//向量长度 
bool cmp(point A,point B){return (CJ(A,B)>0 || CJ(A,B)==0 && dis(A)<dis(B));}//按极角排序 
void Convex(point *A,int &n){//求凸包 
	for (int i=1;i<=n;i++)
	  if (A[i].y<A[1].y || A[i].y==A[1].y && A[i].x<A[1].x) swap(A[i],A[1]);
    point base=A[1];top=0;
	for (int i=1;i<=n;i++) A[i]=A[i]-base;
	sort(A+2,A+n+1,cmp);
	sta[++top]=1;
	for (int i=2;i<=n;sta[++top]=i,i++)
	  while (top>1 && CJ(A[i]-A[sta[top-1]],A[sta[top]]-A[sta[top-1]])>=0) top--;
	for (int i=1;i<=top;i++) A[i]=A[sta[i]]+base;
	n=top;A[n+1]=A[1];
}
void Minkowski(point A[],point B[]){//闵可夫斯基（凸包合并） 
	for (int i=1;i<=n;i++) p1[i]=A[i+1]-A[i];
	for (int i=1;i<=m;i++) p2[i]=B[i+1]-B[i];
	int i=1,j=1;c[cnt=1]=A[1]+B[1];
	while (i<=n && j<=m)
	  if (CJ(p1[i],p2[j])>=0) cnt++,c[cnt]=c[cnt-1]+p1[i++];
	  else cnt++,c[cnt]=c[cnt-1]+p2[j++];
	while (i<=n) cnt++,c[cnt]=c[cnt-1]+p1[i++];
	while (j<=m) cnt++,c[cnt]=c[cnt-1]+p2[j++];	
}
int check(point p){//判断一个点是否在凸包内 
	if (CJ(p,c[2])>0 || CJ(c[cnt],p)>0) return 0;
	int pos=lower_bound(c+1,c+cnt+1,p,cmp)-c-1;
	return CJ(c[pos%cnt+1]-c[pos],p-c[pos])>=0; 
}

void CGL_1_A(){//点在直线上的投影点
	scanf("%lf%lf%lf%lf",&A.x,&A.y,&B.x,&B.y);
	db d=dis(B-A);
	for (int q=read();q;q--){
		scanf("%lf%lf",&C.x,&C.y);
		(A+(DJ(C-A,B-A)/d/d*(B-A))).print();
	}
}

signed main(){
    CGL_1_A();
	return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REP1(i, n) for(int i = 1; i <= (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

// すべての約数を列挙する
template <class T> vector<T> get_divisors(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
			if(i * i != n)
				ret.push_back(n / i);
		}
	}
	sort(ALL(ret));
	return ret;
}

// 1-sqrt(N)までの約数を列挙する
template <class T> vector<T> get_divisors2(T n)
{
	vector<T> ret;
	for(T i = 1; i * i <= n; i++){
		if(n % i == 0){
			ret.push_back(i);
		}
	}
	return ret;
}

int F(ll A, ll B)
{
	return LEN(to_string(max(A, B)));
}

int main()
{
	double R;
	cin >> R;

	printf("%.3f\n", 2 * PI * R);

	return 0;
}


Measured memory_bytes: 3724
# from math import factorial,sqrt,ceil
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
a,b = map(int,input().split())

if b%a ==0:
    print(a+b)
else:
    print(b-a)

# print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int h[10];
	for(int i=0;i<10;i++){
	cin>>h[i];
	}
	for(int i=0;i<10;i++){
		for(int j=i+1;j<10;j++){
			if(h[i]>h[j]){
			swap(h[i],h[j]);
			}
		}
	}
	cout<<h[9]<<endl<<h[8]<<endl<<h[7]<<endl;
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>

struct maximize{
	int num;
	int suuti;
};

int main(){
	int N;
	std::cin >> N;
	int A[N];
	maximize max;
	int submax;
	max.suuti = 0;
	max.num = -1;
	submax = 0;
	for(int i = 0;i < N;i++){
		std::cin >> A[i];
		if(max.suuti < A[i]){
			submax = max.suuti;
			max.suuti = A[i];
			max.num = i;
		}else if(submax < A[i]){
			submax = A[i];
		}
	}
	//std::cout << max.suuti << " " << submax << "\n";
	for(int i = 0;i < N;i++){
		if(i == max.num){
			std::cout << submax << "\n";
		}else{
			std::cout << max.suuti << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
string a,b,c;
int n,w;
unordered_map<char,int> m[100];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> a >> b >> c;
	for (int i=0;i<n;++i){
		++m[i][a[i]];
		++m[i][b[i]];
		++m[i][c[i]];
		w+=m[i].size()-1;
	}
	cout << w;
}

Measured memory_bytes: 3612
def Class(x):
	if x<=48.0:
		print("light fly")
	elif 48.0<x<=51.0:
		print("fly")
	elif 51.0<x<=54.0:
		print("bantam")
	elif 54.0<x<=57.0:
		print("feather")
	elif 57.0<x<=60.0:
		print("light")
	elif 60.0<x<=64.0:
		print("light welter")
	elif 64.0<x<=69.0:
		print("welter")
	elif 69.0<x<=75.0:
		print("light middle")
	elif 75.0<x<=81.0:
		print("middle")
	elif 81.0<x<=91.0:
		print("light heavy")
	else:
		print("heavy")

while True:
	try:
		x=float(input())
		Class(x)
	except EOFError:
		break

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

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int fpow (int a, int b) {
	int ret = 1;
	while (b) {
		if (b & 1) ret = 1ll * ret * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return ret;
}

int f[N], invf[N];

void predeal (int n = N - 1) {
	f[0] = 1;
	for (int i = 1; i <= n; i++)
		f[i] = 1ll * f[i - 1] * i % mod;
	invf[n] = fpow(f[n], mod - 2);
	for (int i = n - 1; i >= 0; i--)
		invf[i] = 1ll * invf[i + 1] * (i + 1) % mod;
}

int C (int a, int b) {
  return (a >= b) ? 1ll * f[a] * invf[b] % mod * invf[a - b] % mod : 0;
}

int add (int a, int b) { a += b; return a >= mod ? a - mod : a; }
int sub (int a, int b) { a -= b; return a < 0 ? a + mod : a; }
int mul (long long a, int b) { return a * b % mod; }

int a[N];

int main (void) {
	predeal();

	int n, k;
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++) if (a[i] < 0)
		a[i] = sub(0, - a[i]);

	int ans = 0;
	for (int i = k; i <= n; i++)
		ans = add(ans, mul(C(i - 1, k - 1), a[i]));
	for (int i = 1; i <= n - k + 1; i++)
		ans = sub(ans, mul(C(n - i, k - 1), a[i]));
	printf("%d\n", ans);
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  string s;
  cin >> s;
  int n = s.size();

  int ans0=0,ans1=0;

  rep(i,n){
    if(i%2 == 0){
      if(s[i] == '1')ans0++;
    }else{
      if(s[i] == '0')ans0++;
    }
  }

  rep(i,n){
    if(i%2 == 0){
      if(s[i] == '0')ans1++;
    }else{
      if(s[i] == '1')ans1++;
    }
  }

  cout << min(ans0,ans1) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int n,a=0,b=0,flag=0;
    string s;    
    cin >> n;
    cin >> s;
    for (int i=0;i<n;i++){
       if (s[i]==')') {
              if (flag==0)  ++a;
                  else --flag;
          }
          if (s[i]=='(') ++flag;
                 
    }
    flag=0;
    for (int i=n-1;i>=0;i--){
         
          if (s[i]=='(') {
              if (flag==0)  ++b;
                  else --flag;
          }
          if (s[i]==')') ++flag;
                 
    }
   for (int i=0;i<a;i++) cout << '(' ;
   cout <<s;
   for (int i=0;i<b;i++) cout << ')';
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    ll ans=1000;
    ll kabu=0;
    rep(i,n-1){
        if(a[i]<a[i+1]){
            kabu=ans/a[i];
            ans=ans%a[i];
            ans+=kabu*a[i+1];
        }
//        cout<<ans<<" "<<kabu<<endl;
    }
//    ans+=kabu*a[n-1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int a;
	string s;

	cin >> a >> s;

	if(a>=3200)
	{
		cout << s;
	}
	else
		cout << "red";
	cout << endl;
	return 0;
}



Measured memory_bytes: 764
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N;
  cin >> N;
  int result = 0, prev = 0, h;
  for (int i = 0; i < N; i++) {
    cin >> h;
    if (prev < h) {
      result += h - prev;
    }
    prev = h;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

while line = gets
  n, s = line.chomp.split.map(&:to_i)
  break if n == 0 && s == 0
  puts a.combination(n).select { |x| s == x.inject(:+) }.size
end

Measured memory_bytes: 8812
#!/bin/env python3
"""
1つ飛ばしで各ダムのsumを
"""
def main():
  n = int(input())
  a = list(map(int,input().split()))
  res = [0] * n
  sum_a = sum(a) #total rain 
  sum_odd = 0
  sum_even = 0
  for i in range(n):
    if i%2 == 1:
      sum_odd += a[i]
    else:
      sum_even += a[i]
  for i in range(n):
    if i == 0:
      res[i] = sum_a - (sum_even - a[i])*2
    else:
      res[i] = a[i]*2-res[i-1]
  for i in range(n):
    print(res[(i+n-1)%n],end=" ")
  print()
main() 


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

using namespace std;

#define W 10000  //W represents the max total weight of items
#define N 100  //N represents the max total number of items
#define V 1000 //V represents the max weight of an item

int value[N], weight[N];
int n, m;  //n represents the total number of items,m represents the total weight of items
		   //value[N],weight[W] represent the value and weight of items respectively

void input();  //input the information of items 
void max_value(); //calculate the max value

int main()
{
	input();
	return 0;
}

void input()     //input the information of items 
{
	while (1)
	{
		cin >> n >> m;
		if (n<1 || n>N || m<1 || m>W)
		{
			cin.clear();
		}
		else
			break;
	}
	int i;
	for (i = 0; i<n; i++)
	{
		value[i] = 0;
		weight[i] = 0;
	}
	i = 0;
	while (1)
	{
		for (; i<n; i++)
		{
			cin >> value[i] >> weight[i];
			if (value[i]<1 || value[i]>V || weight[i]<1 || weight[i]>V)
			{
				cin.clear();
				break;
			}
		}

		if (i >= n)
			break;
	}
	max_value();
}

void max_value()
{
	vector<vector<int> > c(n + 1, vector<int>(m + 1));  //the max value matrix
	int i, w;

	for (i = 0; i <= n; i++)     //initialize the 
		c[i][0] = 0;
	for (w = 1; w <= m; w++)
		c[0][w] = 0;

	for (i = 1; i <= n; i++)
	{
		for (w = 1; w <= m; w++)
		{
			if (w < weight[i - 1])
			{
				c[i][w] = c[i - 1][w];
			}
			else
			{
				int x = c[i - 1][w];
				int y = c[i - 1][w - weight[i - 1]] + value[i - 1];
				c[i][w] = x < y ? y : x;
			}
		}
	}
	cout << c[n][m] << "\r\n";
}

Measured memory_bytes: 6812
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

  int N, D;
  cin >> N >> D;
  long long X[N], Y[N];
  for (int i=0; i<N; i++)
    cin >> X[i] >> Y[i];

  int res=0;
  for (int i=0; i<N; i++){
    if (sqrt((X[i]*X[i]) + (Y[i]*Y[i])) <= D){
      res++;
    }
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 6284
// i hope i get better                                                           
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=5e5+9;
int n,q;
int t,p,l,r;
char c;
string s;
set<int> pos[30];

int main(){
	cin>>n>>s>>q;
	for(int i=0;i<s.size();i++){
		int u=s[i]-'a';
		pos[u].insert(i);
	}
	while(q--){
		cin>>t;
		if(t==1){
			cin>>p>>c;
			p--;
			int O=s[p]-'a';
			int N=c-'a';
			pos[O].erase(p);
			pos[N].insert(p);
			s[p]=c;
		}else{
			cin>>l>>r;
			l--;r--;
			int ans=0;
			for(int i=0; i < 26; ++i){
				auto it=pos[i].lower_bound(l);
				if(it==pos[i].end()) continue;
				auto val=*it;
				if(val>r) continue;
				else ans++;
			}
			cout<<ans<<'\n';
		}
	}
    return 0;
}

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


string S;
int cnt;

int main(void) {
  cin >> S;

  cnt = 0;
  REP(i, 0, S.length()) {
    char a = i % 2 == 0 ? 'g' : 'p';
    char b = S[i];
    if(a == 'g' && b == 'p') cnt--;
    if(a == 'p' && b == 'g') cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a[3];
    for(int i=0;i<3;i++)
        cin >> a[i];
    sort(a,a+3);
    for(int i=0;i<3;i++)
    {
        if(i==2)
            cout<<a[i]<<endl;
        else
            cout <<a[i] <<" ";
    }
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    ll check=-1;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0){
            check=i;
        }
    }
    ll Ans=N/check;
    string S=to_string(Ans);
    cout<<S.size()<<endl;
}


Measured memory_bytes: 256
from collections import Counter
import math
def combination2(n):
    return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))

N = int(input())
l = []
for _ in range(N):
    tmp = input()
    tmp = sorted(tmp)
    l.append(''.join(tmp))

l = Counter(l)
ans = 0
for key, value in l.items():
    if value >= 2:
        ans += combination2(value)
print(ans)




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

int main(){
  int N;
  int l, r;
  int pNum = 0;
  
  cin >> N;
  
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    pNum += r - l + 1;
  }
  
  cout << pNum << endl;

}

Measured memory_bytes: 3536
#ifdef MY_LOCAL
#define MY_NAMESPACE(ns) namespace ns {
#define MY_NAMESPACE_    }
#define MY_DEBUG(s)      s
#else
#define MY_NAMESPACE(ns) 
#define MY_NAMESPACE_    
#define MY_DEBUG(s)      
#endif

#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define EPS (1e-7)

MY_NAMESPACE(ABC169D)
vector<pll> prime_factorize(ll number)
{
	vector<pll> res;
	for (ll divisor = 2; divisor * divisor <= number; divisor++)
	{
		if (number % divisor != 0)
			continue;
		ll exponent = 0;
		while (number % divisor == 0)
		{
			number /= divisor;
			exponent++;
		}
		res.push_back({ divisor, exponent });
	}
	if (number != 1)
		res.push_back({ number, 1 });
	return res;
}

int main()
{
	ll n;
	cin >> n;
	auto div_exps = prime_factorize(n);
	int res = 0;
	for (auto div_exp : div_exps)
	{
		ll exponent = div_exp.second;
		int i = 1;
		while (exponent > 0)
		{
			exponent -= i++;
			if (exponent >= 0)
				res++;
		}
	}
	cout << res << "\n";
	return 0;
}
MY_NAMESPACE_

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>

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

using namespace std;

enum{TOP=0,FRONT,RIGHT,LEFT,BACK,BOTTOM}; 
#define rotate_swap(x,a,b,c,d) swap(x.m[a],x.m[b]);swap(x.m[b],x.m[c]);swap(x.m[c],x.m[d]);
  
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, 1, 0, -1};
 
class Dice{
public:
  int y, x;
  string m[6];
  Dice(){
    y = x = 0;
  }
  bool operator<(const Dice &a)const{
    rep(i,6)if (m[i] != a.m[i])return m[i] < a.m[i];
    return false;
  }
  bool operator==(const Dice &a)const{
    rep(i,6)if (m[i] != a.m[i])return false;
    return true;
  }
};
 
void rotate_r(Dice &x){
  x.x++;
  rotate_swap(x,TOP,LEFT,BOTTOM,RIGHT);
}
  
void rotate_l(Dice &x){
  x.x--;
  rotate_swap(x,TOP,RIGHT,BOTTOM,LEFT);
}
  
void rotate_f(Dice &x){
  x.y--;
  rotate_swap(x,TOP,BACK,BOTTOM,FRONT);
}
  
void rotate_b(Dice &x){
  x.y++;
  rotate_swap(x,TOP,FRONT,BOTTOM,BACK);
}
  
void rotate_cw(Dice &x){
  rotate_swap(x,BACK,LEFT,FRONT,RIGHT);
}
  
void rotate_ccw(Dice &x){
  rotate_swap(x,BACK,RIGHT,FRONT,LEFT);
}
  
vector<Dice> generate_all(Dice x){
  vector<Dice> res;
  rep(i,6){
    rep(j,4){
      res.push_back(x);
      rotate_cw(x);
    }
    if (i%2 == 0)rotate_r(x);
    else rotate_f(x);
  }
  return res;
}

int main() {
  while (true) {
    int n;
    cin >> n; 
    if (n == 0) break;
    vector<vector<Dice> > v;
    rep (i, n) {
      Dice dice;
      cin >> dice.m[TOP];
      cin >> dice.m[FRONT];
      cin >> dice.m[RIGHT];
      cin >> dice.m[LEFT];
      cin >> dice.m[BACK];
      cin >> dice.m[BOTTOM];
      v.push_back(generate_all(dice));
    }
    int res = 0;
    rep (i, n) {
      rep (j, i) rep (ii, 24) rep (jj, 24) {
	if (v[i][ii] == v[j][jj]) {
	  ++res;
	  goto next;
	}
      }
    next:;
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG
 
// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
 
const int MOD = 1000000007;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep_(i,n) for(int i=0;i<(int)(n-1);i++)
#define rep__(i,n) for(int i=n-1;i>=0;i--)
 
int main(void) {
    ulint n, a, b;
    cin >> n >> a >> b;
    
    if(a == 0) {
        cout << 0;
    } else if(b == 0) {
        cout << n;
    } else if(a + b <= n) {
        ulint tmp = n / (a + b);
        if(n % (a + b) == 0) {
            cout << tmp * a;
        } else {
            if(n - tmp * (a + b) >= a) {
                cout << tmp * a + a;
            } else {
                cout << tmp * a + n - tmp * (a + b);
            }
        }
    } else {
        if(a >= n) cout << n;
        else cout << a;
    }
    
    return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
co = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

for i in range(h):
    s = nn()
    if 'snuke' in s:
        j = s.index('snuke')
        print(co[j]+str(i+1))
        exit()

Measured memory_bytes: 3064
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do(): 
    a=INT()
    print(a+a**2+a**3)
if __name__ == '__main__':
    do()

Measured memory_bytes: 9136
n,m=map(int,input().split())
ac_count=[0]*n
wa_count=[0]*n
ac=0
wa=0
for i in range(m):
  p,s=input().split()
  p=int(p)-1
  if s=="AC" and ac_count[p]==0:
    ac_count[p]=1
    ac+=1
    wa+=wa_count[p]
  elif s[0]=="W":
      wa_count[p]+=1
print(ac,wa)

Measured memory_bytes: 4596
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - DDCC Finals
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int x, y;
  scanf("%d%d", &x, &y);

  int sum = 0;
  if (x < 4) sum += (4 - x) * 100000;
  if (y < 4) sum += (4 - y) * 100000;
  if (x == 1 && y == 1) sum += 400000;

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


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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n),b(n);
  rep(i,0,n)cin>>a[i];
  rep(i,0,n)cin>>b[i];
  vector<ll>x(n),y(n);
  rep(i,0,n){
    x[i]=a[i];y[i]=b[i];
  }
  sort(ALL(x));sort(ALL(y));
  map<ll,ll>bidx;
  rep(i,0,n)bidx[y[i]]=i;
  map<ll,ll>aidx;
  rep(i,0,n)aidx[a[i]]=i;
  bool cross=false;
  rep(i,0,n){
    if(x[i]>y[i])judge=false;
    if(i!=n-1&&x[i+1]<=y[i])cross=true;
  }
  bool trans=false;
  buf=0;
  ll cnt=0;
  if(!cross)
  while(1){
    cnt++;
    buf=aidx[x[bidx[b[buf]]]];
    if(buf==0)break;
  }
  //cout<<cnt<<endl;
  ans1(judge&&(cnt<n||cross));
  return 0;
}

Measured memory_bytes: 15872