akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	stack<int> s1;
	stack<pair<int, int>> s2;

	string s;
	cin >> s;
	
	int sum = 0;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '\\') {
			s1.push(i);
		}
		else if (s[i] == '/' && s1.size() != 0) {
			int j = s1.top(); s1.pop();
			sum += i - j;
			int a = i - j;
			while (s2.size() != 0 && s2.top().first > j) {
				a += s2.top().second; s2.pop();
			}
			s2.push(make_pair(j, a));
		}
	}

	vector<int> ans;
	while (s2.empty() != 1) {
		ans.push_back(s2.top().second); s2.pop();
	}
	cout << sum << endl;
	cout << ans.size();
	for (int i = ans.size() - 1; i >= 0; --i) {
		cout << " " << ans[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 3304
#include<iostream>
#include<string>

using namespace std;

int main(void){

  int n, ans = 1;
  char tmp;
  string str;
  
  cin >> n;
  cin >> str;
  
  tmp = str[0];
  
  for(int i = 0;i < n;i++){
    if(tmp != str[i]){
      ans++;
      tmp = str[i];
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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

template <typename T>
T dijkstra(int s,int g,vector<vector<T> > & G){     
  using Pa = pair<T, int>;
  vector<T> D(1010,LINF);//----------------
  priority_queue<Pa,vector<Pa>,greater<Pa> > q;
  D[s]=0;
  q.emplace(D[s],s);//最短距離、ゴール頂点番号

  while(!q.empty()){
    T spath=q.top().first;
    int v=q.top().second;
    q.pop();

    if(D[v]<spath) continue;
    for(int i=0;i<siz(G[v]);i++){
      int u=i;//頂点番号
      T c=G[v][i];//最短距離
      if(D[u]>D[v]+c){
        D[u]=D[v]+c;
        q.emplace(D[u],u);
      }
    }
  }
  return D.at(g);
}

signed main(){
   int n;
   vector<tuple<ll,ll,ld>> v(1010);

   rep(i,0,2){
      ll x,y;cin>>x>>y;
      v[i]=make_tuple(x,y,0);
   }

   cin>>n;
   vector<vector<ld>> e(n+2,vector<ld>(n+2,0));//nの後に

   rep(i,2,n+2){
      ll x,y; ld r;
      cin>>x>>y>>r;
      v[i]=make_tuple(x,y,r);
   }

   rep(i,0,n+2){
      rep(j,i+1,n+2){
         ll xi=get<0>(v[i]),yi=get<1>(v[i]),
         xj=get<0>(v[j]),yj=get<1>(v[j]);
         ld ri=get<2>(v[i]),rj=get<2>(v[j]);
         ld dis=sqrt(pow(xi-xj,2)+pow(yi-yj,2))-ri-rj;
         e[i][j]=e[j][i]=max((ld)0,dis);
      }
   }

   cout<<fixed<<setprecision(20)<<(ld)dijkstra(0,1,e)<<endl;


}

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

const ll MAXN = 200000;
const ll INF = 1001001001;

ll N, ans=0;
map<ll,ll> A;
set<ll> B;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        A[a]++;
        B.insert(a);
    }
    for(map<ll,ll>::iterator itr=A.begin(); itr!=A.end();itr++) {
        pair<ll,ll> p = *itr;
        //cout << p.first << " " << p.second << endl;
        if(p.second>0) {
            if(p.second==1) ans++;            
            for(int i=2;i*p.first<=1000000;i++) {
                if(B.find(i*p.first)!=B.end()) {
                    A[i*p.first] = 0;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25416
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define PI acos(-1)
using namespace std;

int main(){
	int HH,MM,jiao,a,b;
	double ans;
	scanf("%d%d%d%d",&a,&b,&HH,&MM);
        int jiao2=MM*6,jiao1;
        if(MM%2!=0)
        {
            jiao1=2*(HH%12)*30+MM;
            jiao=abs(jiao1-2*jiao2);
            int x=jiao<=360?jiao:720-jiao;
            ans=x/2.0;
            ans=ans/180*PI;
        }
        else
        {
            jiao1=(HH%12)*30+MM/2;
            jiao=abs(jiao1-jiao2);
            ans=jiao<=180?jiao:360-jiao;
            ans=ans/180*PI;
        }

    double c=sqrt((double)a*a+(double)b*b-2*a*b*cos(ans));
    printf("%.20lf\n",c);
	return 0;
}


Measured memory_bytes: 4216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#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()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

// 「SとS[i:|S|-1]の最長共通接頭辞の長さ」を記録した配列AをO(|S|)で構築する
// aaabaaaab
// 921034210
vector<ll> Zalgo(string s) {
    vector<ll> v(s.size());
    v[0] = s.size();
    int i = 1, j = 0;
    while (i < s.size()) {
        while (i+j < s.size() && s[j] == s[i+j]) ++j;
        v[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i+k < s.size() && k+v[k] < j) v[i+k] = v[k], ++k;
        i += k; j -= k;
    }
    return v;
}

// ans[i] = (i番目の頂点v, swapできる頂点をまとめたときにvが何番目か)
vector<PII> tsort(vector<vector<ll>> g) {
    const int n = g.size();
    vector<ll> h(n, 0);
    REP(i, n) for(int j: g[i]) h[j]++;

    stack<PII> st;
    REP(i, n) if(h[i] == 0) st.push({i, 0});

    vector<PII> ans;
    while(st.size()) {
        PII p = st.top(); st.pop();
        ans.push_back(p);
        for(auto& j: g[p.first]) {
            h[j]--;
            if(h[j] == 0) st.push({j, p.second+1});
        }
    }

    return ans;
}

int main(void) {
    string s, t;
    cin >> s >> t;
    const ll n = s.size(), m = t.size();

    FOR(i, n, n+m) s += s[i%n];

    // s[i…i+m-1] == t の判定
    string str = t + '$' + s;
    auto v = Zalgo(str);
    dump(str);
    dump(v);
    vector<vector<ll>> g(n);
    FOR(i, m+1, n+m+1) if(v[i] >= m) g[i-m-1].push_back((i-1)%n);

    dump(g);

    if((ll)tsort(g).size() != n) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> dp(n, -1);
    function<ll(ll)> dfs = [&](ll v) {
        if(dp[v] != -1) return dp[v];
        ll ret = 0;
        for(auto to: g[v]) {
            chmax(ret, dfs(to)+1);
        }
        return dp[v] = ret;
    };

    ll ret = 0;
    REP(i, n) chmax(ret, dfs(i));
    cout << ret << endl;

    dump(dp);

    return 0;
}

Measured memory_bytes: 79156
import sys
read = sys.stdin.read
mod = 10 ** 9 + 7
r1, c1, r2, c2 = map(int, read().split())

def prepare(n, MOD):

    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs


fac, finv = prepare(2 * 10**6 + 10, mod)


def comb(n, k, mod=mod, fac=fac, finv=finv):
    '''
    二項係数の計算

    Parameters
    n : int
        元集合
    k : int
        元集合から選択する数
    mod : int
        あまり
    fac : list
        階乗のリスト
    finv : list
        逆元のリスト

    Returns
    c : int
        nCkの組み合わせの数
    '''
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


answer = comb(r2 + c2 + 2, r2 + 1) - comb(r1 + c2 + 1, r1) - \
    comb(c1 + r2 + 1, c1) + comb(r1 + c1, r1)
answer %= mod
print(answer)

Measured memory_bytes: 161324
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	N, R := getInt(), getInt()

	if N >= 10 {
		out(R)
	} else {
		out(R + 100*(10-N))
	}

}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
int a,b,c,ans=0,t=0;
while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
if(a*a+b*b==c*c)ans++;
if(a==b)t++;
}
printf("%d\n%d\n",ans,t);
}

Measured memory_bytes: 2752
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    cin >> a >> b;
    int la = a.size();
    int lb = b.size();
    if(la>lb){
        cout << "GREATER" << endl;
        return 0; 
    }else if(lb > la){
        cout << "LESS" << endl;
        return 0;
    }
    for(int i = 0;i<la;++i){
        if(a[i]>b[i]){
            cout << "GREATER"   << endl;
            return 0; 
        }else if(a[i] < b[i]){
            cout << "LESS" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Aman
 */


#include<bits/stdc++.h>

using namespace std;

#include <iostream>

void __print(int x) { cout << x; }

void __print(long x) { cout << x; }

void __print(long long x) { cout << x; }

void __print(unsigned x) { cout << x; }

void __print(unsigned long x) { cout << x; }

void __print(unsigned long long x) { cout << x; }

void __print(float x) { cout << x; }

void __print(double x) { cout << x; }

void __print(long double x) { cout << x; }

void __print(char x) { cout << '\'' << x << '\''; }

void __print(const char *x) { cout << '\"' << x << '\"'; }

void __print(const string &x) { cout << '\"' << x << '\"'; }

void __print(bool x) { cout << (x ? "true" : "false"); }

template<typename T, typename V>
void __print(const pair<T, V> &x) {
    cout << '{';
    __print(x.first);
    cout << ',';
    __print(x.second);
    cout << '}';
}

template<typename T>
void __print(const T &x) {
    int f = 0;
    cout << '{';
    for (auto &i: x) cout << (f++ ? "," : ""), __print(i);
    cout << "}";
}


#define ll   long long
#ifdef LOCAL
#else
#define dbg(x...)
#endif


class

ANot {
public:


    void solve(std::istream &cin, std::ostream &cout) {
        ll n;
        cin >> n;
        cout << (!n);
    }

};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ANot solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;

int main(){
  int N,M;
  ll ans;
  scanf("%d%d",&N,&M);

  if(abs(N - M) >= 2) {
    ans = 0;
  }else{
    ans = 1;
    REP(i,2,N + 1){
      ans *= i;
      ans %= MOD;
    }

    REP(i,2,M + 1){
      ans *= i;
      ans %= MOD;
    }

    if(N == M){
      ans *= 2;
      ans %= MOD;
    }
  }
  

  printf("%lld",ans);

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

S = raw_input()
cnt1 = cnt2 = 0
for c in S:
    if c == '0':
        cnt1 += 1
    else:
        cnt2 += 1

print min(cnt1, cnt2) * 2

exit()

A, B, K = map(int, raw_input().split())

cnt = 0

for i in range(1, 200):
    if A % i == 0 and B % i == 0:
        cnt += 1
    if cnt == K:
        print i
        exit()

Measured memory_bytes: 2936
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){
  string S, T;
  cin >> S;
  cin >> T;
  int t = 0;
  int flag = -1;
  for(int i = S.length()-T.length(); i >= 0; i--){
    if(S[i] == T[0] || S[i] == '?'){
      int ii = i+1;
      if(T.length() == 1){
        flag = 1;
      }
      for(t = 1; t < T.length(); t++, ii++){
        if(! (S[ii] == T[t] || S[ii] == '?')){
          break;
        }else if(t == T.length()-1){
          flag = 1;
        }
      }

      if(flag == 1){
        for(int j = 0; j < T.length(); j++){
          S[i+j] = T[j];
        }
        break;
      }

    }
  } // End of for

  if(flag == 1){
    for(int i = 0; i < S.length(); i++){
      if(S[i] == '?'){
        S[i] = 'a';
      }
    }
    cout << S << endl;
  }else{
    cout << "UNRESTORABLE" << endl;
  }

  char c = S[2];
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> ab(N), cd(M);
  for (int i=0; i<N; i++) cin >> ab.at(i).first >> ab.at(i).second;
  for (int i=0; i<M; i++) cin >> cd.at(i).first >> cd.at(i).second;
  for (int i=0; i<N; i++) {
    int dist = abs(ab.at(i).first-cd.at(0).first)+abs(ab.at(i).second-cd.at(0).second);
    for (int j=1; j<M; j++) {
      int num = abs(ab.at(i).first-cd.at(j).first)+abs(ab.at(i).second-cd.at(j).second);
      dist = min(dist, num);
    }
    for (int j=0; j<M; j++) {
      if (dist==abs(ab.at(i).first-cd.at(j).first)+abs(ab.at(i).second-cd.at(j).second)) {
        cout << j+1 << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair

using namespace std;

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

const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1000000000000000000L;

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

    int infox[100];
    int infoy[100];
    int infoh[100];
    rep(i, n) {
        cin >> infox[i];
        cin >> infoy[i];
        cin >> infoh[i];
    }

    rep(i, 101) {
        rep(j, 101) {
            int h = -1;
            rep(k, n) {
                if(infoh[k] == 0) continue;
                h = infoh[k] + abs(infox[k] - i) + abs(infoy[k] - j);
                break;
            }
            if(h <= 0) continue;

            bool flag = true;
            rep(k, n) {
                if(max(0, h - abs(infox[k] - i) - abs(infoy[k] - j)) != infoh[k]) {
                    flag = false;
                    break;
                }
            }

            if(flag) {
                cout << i << " " << j << " " << h << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {
    long mod = 1000000000 + 7;

    long binpow(long a, long n) {
        if (n == 0)
            return 1;
        if (n % 2 == 1)
            return (binpow(a, n - 1) * a) % mod;
        else {
            long b = binpow(a, n / 2);
            return (b * b) % mod;
        }
    }

    public void solve() throws IOException {
        int n = nextInt(), k = nextInt();
        int a[] = new int[n];
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
            if (a[i] == 1) cnt = i;
        }
        int res = (n - 1 + k - 2) / (k - 1);
        out.print(res);
    }

    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    public void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    public String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}


Measured memory_bytes: 33896
//package AtCoder;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;


public class Main {
	static int INF = (int) 1e9;
	static ArrayList<Integer>[] adjList;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int res = 0 ;
		int n = sc.nextInt();
		int[] arr = new int[60001];
		for(int i = 1 ; i <= 100 ; i++ ) {
			for(int j = 1 ; j <= 100 ; j++) {
				for(int k = 1 ; k <= 100 ; k++) {
					int sum = i*i + j*j + k*k + i*j + j*k + k*i;
					arr[sum] += 1;
				}
			}
		}
		for(int i = 1 ; i <= n ; i++)
			System.out.println(arr[i]);
	}
	
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}

	public static int gcd(int a, int b) {
		if (a == 0)
			return b;

		return gcd(b % a, a);
	}

	public static void shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}

	public static long square(long l) {
		return l * l;
	}
}


Measured memory_bytes: 35776
import java.util.Scanner;
import java.lang.Math;

public class Main {
    
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    
    //変数radius(半径)を宣言と入力
    double radius = sc.nextDouble();
    
    //計算結果：円周の長さと円の面積の表示
    
    System.out.printf("%.5f %.5f",  (radius*radius*Math.PI), (2*Math.PI*radius));
        
    }
}


/*覚えよう！！
  
〇数学の式を使用：　まずクラス外に「 import java.lang.Math; 」を宣言

　　　　　　　　　　次に使いたい式の命令を書く ⇒  Math.命令名 の順番で書く
　　　　　　　　　　
　　　　　　　　　　命令はたくさんあるから調べてみよう

*/
   
   
/*前回の内容！！
 
〇import java.util.Arrays;は重要↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
 
・Arrays：ソート（並べ変え）や検索など、配列を操作するための機能
 
・並べ変えするとき
　import java.util.Arrays;を上に書く
　class Main内に Arrays.sort(a); と書く　←　このとき()内は配列の変数名
　
〇配列とは、同じ変数名に複数の値を入力できる箱
 
　※イメージ
    前回まで、a = 1, b = 2, c = 3など各変数名は1箱に値を代入できない
    今回の配列はa[0] = 1, a[1] = 2, a[2] = 3 のように変数名aは3つの箱に値を代入できる。
    注意：配列の箱は｢ 0 ｣から開始する
 
 
・複数のif(条件)：かつ｢ && ｣とまたは｢ || ｣の２つを使用する
　※かつ｢ && ｣：「真 && 真 = 真」, 「真 && 偽 = 偽」, 「偽 && 真 = 偽」 ,「偽 && 偽 = 偽」の4つの条件
　　または｢ || ｣：「真 && 真 = 真」, 「真 && 偽 = 真」, 「偽 && 真 = 真」 ,「偽 && 偽 = 偽」の4つの条件
 
 
・関係を比較する：if(条件式)
　例：if(2 < 3) この条件は｢真（成立）｣　→　何か命令があれば実行する
　　　if(5 < 3) この条件は｢偽（不成立）｣　→　何か命令があれば実行しない
　　　
・比較の条件式：等しいか比較｢==｣、等しくないか比較｢!=｣ 
　　　　　　　　大きいか比較｢<｣、小さいか比較｢>｣
　　　　　　　　以上の比較｢<=｣、以下の比較｢>=｣
  
  
・else；ifの条件以外の場合に使用する。
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else System.out.println("傘を持って行かない");
　
  
・else if：詳細な場合分けしたいときに使用
　例：if(雨 == 降っている) System.out.println("傘を持って行く");
　　　else if(雨 == 午後から降るかも) System.out.println("念のため傘を持って行く");
　　　else System.out.println("傘を持って行かない");
  
 
  
・変数に計算結果を代入する：面積　＝　縦　×　横
　※計算は変数名でも数値でもいける
   
・四則演算：足し算｢＋｣、引き算｢－｣、掛け算｢＊｣、割り算｢／｣
　1 + 2 = 3;
　4 - 3 = 1;
　2 * 5 = 10;
　8 / 2 = 4;
   
・余りの計算：割り算の余り｢％｣
  5 % 3 = 2;
     
     
・printlnの複数表示：｢＋｣を使用
　例：println("Kobe" + "Kagikou"); = KobeKajikou
　　　println("明治 + 20 + "年"); = 明治20年　数値が入ってもOK！
   
   
   
・変数の宣言は｢型｣と｢変数名｣の２つ必要
　例：型＿変数名　→　int x;
　
・キーボードから入力するときは・・・｢ import java.util.Scanner; ｣ と ｢  Scanner sc = new Scanner(System.in) ; ｣が必要
   
・入力するとき・・・変数名 = sc.nextInt(); nextの後は型を書く、頭文字は大文字　
　※  scは変更しても大丈夫しかし全て変更後の文字に統一　例：nyuryoku
   
・println・・・画面に出力するときに使用
   
・文字列の表示・・・"〇〇〇の間に入力"ことが約束
   
*/


Measured memory_bytes: 28360
#include <stdio.h>

bool isPrimeNumber(const int num)
{
    if (num <= 3) {
         return num >1;
    } else if (num % 2 == 0 || num % 3 == 0) {
        return false;
    } else {
        for (int i = 5; i * i <= num; i+= 6) {
            if (num % i == 0 || num % (i + 2) == 0) {
                return false;
            }
        }
        return true;
    }
}

int main() 
{
    int n;
    int cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int num;
        scanf("%d", &num);
        if (isPrimeNumber(num)) ++cnt;
    }
    printf("%d\n", cnt);
}



Measured memory_bytes: 2756
#include <stdio.h>

int N, K, Q;
int A[114514];

int genten_kaihi[114514];

int main(void) {
	int i;
	if (scanf("%d%d%d", &N, &K, &Q) != 3) return 1;
	for (i = 0; i < Q; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}

	for (i = 0; i < Q; i++) {
		genten_kaihi[A[i]]++;
	}

	for (i = 1; i <= N; i++) {
		puts(K - Q + genten_kaihi[i] > 0 ? "Yes" : "No");
	}

	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    ll k;
    cin >> k;
    ll n = SZ(s);
    char mc = 'z';
    rep(i, n){
        chmin(mc, s[i]);
    }
    set<string> ss;
    for(char c = mc; c <= 'z'; c++){
        rep(i, n){
            if(s[i] == c){
                rep(j, k){
                    ss.emplace(s.substr(i, j+1));
                }
            }
        }
        if(ss.size() >= 5) break;
    }
    ll c = 0;
    dump(ss);
    for(auto&& e:ss){
        if(c == k-1){
            cout << e << endl;
            return 0;
        }
        c++;
    }
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#define Maxn 100010

char s[Maxn];

int mymin(int x,int y) {return x<y?x:y;}

int main()
{
	int n,k,sm=1,ans=0;
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	for(int i=2;i<=n;i++)
	{
		if(s[i]!=s[i-1]&&s[i]==s[1]) sm++;
		else if(s[i]==s[i-1]) ans++;
	}
	if(s[1]==s[n])
	{
		int kk=sm-1;
		printf("%d\n",ans+mymin(kk,k)*2);
	}
	else
	{
		if(k>sm-1) printf("%d\n",ans+(sm-1)*2+1);
		else printf("%d\n",ans+mymin(k,sm-1)*2); 
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int ae[5];
	int k;
	int ans = 0;
	scanf("%d %d %d %d %d %d", &ae[0],&ae[1],&ae[2],&ae[3],&ae[4],&k);
	for (int i = 0; i < 5; ++i) {
		for (int j = i + 1; j < 5; ++j) {
			if (ae[j] - ae[i] > k) {
				++ans;
			}
		}
	}
	printf(ans == 0 ? "Yay!" : ":(");


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int a;
    char b[10];
    while (cin >> a)
    {
        cin >> b;
        if (a >= 3200)
        {
            cout << b << endl;
        }
        else
        {
            cout << "red" << endl;
        }
    }
    return 0;
}

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

int n,y;

int main() {
  scanf("%d%d",&n,&y);
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(i*10000+j*5000+(n-i-j)*1000==y){
        printf("%d %d %d",i,j,n-i-j);
        return 0;
      }
    }
  }
  printf("-1 -1 -1");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
int nxt[N], cnt[N], val[N], wal[N];
vector <int> bi[N];
queue <int> Q;
int n, rt;
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i)
    {
        cin >> nxt[i], cnt[nxt[i]] ++;
        bi[nxt[i]].push_back(i);
    }
    for (int i = 1; i <= n; ++ i) if (!cnt[i]) Q.push(i);
    while (!Q.empty())
    {
        int t = Q.front(); Q.pop();
        set <int> S;
        for (int i = 0; i < bi[t].size(); ++ i) S.insert(val[bi[t][i]]);
        for (int i = 0; ; ++ i) if (!S.count(i)) {val[t] = i; break;}
        cnt[nxt[t]] --; if (!cnt[nxt[t]]) Q.push(nxt[t]);
    }
    for (int i = 1; i <= n; ++ i) if (cnt[i])
    {
        set <int> S;
        for (int j = 0; j < bi[i].size(); ++ j) if (!cnt[bi[i][j]]) S.insert(val[bi[i][j]]);
        for (int j = 0; ; ++ j) if (!S.count(j)) {val[i] = j; break;}
        for (int j = val[i] + 1; ; ++ j) if (!S.count(j)) {wal[i] = j; break;}
        if (!rt) rt = i;
    }
    {
        int p = val[rt];
        for (int i = nxt[rt]; i != rt; i = nxt[i])
            if (p == val[i]) p = wal[i];
            else p = val[i];
        if (p != val[rt]) {cout << "POSSIBLE" << endl; return 0;}
    }
    {
        int p = wal[rt];
        for (int i = nxt[rt]; i != rt; i = nxt[i])
            if (p == val[i]) p = wal[i];
            else p = val[i];
        if (p == val[rt]) {cout << "POSSIBLE" << endl; return 0;}
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 16640
import java.io.*;
import java.util.*;

public class Main{
    
    public static void main(String args[]) throws IOException{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	String s[]=br.readLine().split(" ");

        int x=Integer.parseInt(s[0]);
	int y=Integer.parseInt(s[1]);
	int z=Integer.parseInt(s[2]);

	int sum=z;
	int count=0;

	while(true){
	    sum+=y+z;
	    	count++;
	    if(sum==x){
		break;
	    }else if(sum>x){
		count--;
		break;
	    }
	}

	System.out.println(count);
	
    }
    public static void permutation(String q, String ans){
        // Base Case
        if(q.length() <= 1) {
	    //   comb.add(ans + q);
        }
        // General Case
        else {
            for (int i = 0; i < q.length(); i++) {
                permutation(q.substring(0, i) + q.substring(i + 1),
                        ans + q.charAt(i));
            }
        }
    }
}


Measured memory_bytes: 22612
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math

sets = [
    set([1,3,5,7,8,10,12]),
    set([4,6,9,11]),
    set([2])
]

def find_group(i):
    for index, group in enumerate(sets):
        if i in group:
            return index


H,W = map(int, sys.stdin.readline().rstrip().split())
print("#"*(W+2))
for _ in range(H):
    print("#"+sys.stdin.readline().rstrip()+"#")
print("#"*(W+2))

exit(0)


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

int main(){
	int n, sum, result;
	while(cin >> n){
		if(n == 0) break;
		vector<int> array;
		for(int i=0; i<n; i++){
			int t;
			cin >> t;
			array.push_back(t);
		}
		result = array[0];
		for(int i=0; i<n; i++){
			sum = 0;
			for(int j=i; j<n; j++){
				sum += array[j];
				result = max(result, sum);
			}
		}
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
int main()
{
    int x;
    cin >> x;
    cout << x*x*x << endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int x=r*100+g*10+b;
  if(x%4==0) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#include <map>
#define ll long long 
#define PI 3.14159265358979323846
#define INF 10000000000
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;

int main() {
	ll N;
	cin >> N;
	map<string, ll> S;
	rep(i, N) {
		string s;
		cin >> s;
		S[s]++;
	}
	ll ma = 0;

	for (auto p : S) ma = max(ma, p.second);
	for (auto p : S) {
		if (p.second == ma) cout << p.first << endl;
	}

	return 0;
}

Measured memory_bytes: 19092
#include<bits/stdc++.h>
#define int long long
#define INF 1e18
using namespace std;
const int Maxn=1e2+10,Maxv=1e6+100;
int N,W;
int w[Maxn],v[Maxn];
int Dp[Maxn][Maxv];
int Ans=0;
signed main()
{
	cin>>N>>W;
	for(int i=1;i<=N;i++) cin>>w[i]>>v[i];
	for(int i=1;i<Maxv;i++) Dp[0][i]=INF;
	Dp[0][0]=0;
	for(int i=1;i<=N;i++) for(int j=1;j<Maxv;j++)
	{
		Dp[i][j]=Dp[i-1][j];
		if(v[i]<=j) Dp[i][j]=min(Dp[i][j],Dp[i-1][j-v[i]]+w[i]);
	}
	for(int j=0;j<Maxv;j++) if(Dp[N][j]<=W) Ans=j;
	cout<<Ans<<endl; 
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, i, j;
	cin >> n;
	vii a(2, vi(n));
	for (i = 0; i < n; i++) {
		cin >> a[0][i];
	}
	for (i = 0; i < n; i++) {
		cin >> a[1][i];
	}

	vii dp(2, vi(n, -1));
	dp[0][0] = a[0][0];
	for (i = 1; i < n; i++) {
		dp[0][i] = dp[0][i - 1] + a[0][i];
	}
	dp[1][0] = dp[0][0] + a[1][0];
	for (i = 1; i < n; i++) {
		dp[1][i] = max(dp[0][i], dp[1][i - 1]) + a[1][i];
	}
	cout << dp[1][n - 1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

string s;
ll q, a, f;
char c;
double A, B;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A >> B;
  for (int i = 1; i < 100000; ++i) {
    int s = (int)i * 0.08;
    int t = (int)i * 0.1;
    if (A == s && B ==  t) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1;
  return 0;
}



Measured memory_bytes: 256
def solve():
  R, C, K = map(int, input().split())
  item = [[0]*C for _ in range(R)]
  for i in range(K):
    r,c,v = map(int, input().split())
    item[r-1][c-1] = v
  last_dp = [[0]*5 for _ in range(C+1)]
  for i in range(1,R+1):
    dp = [[0]*5 for _ in range(C+1)]
    for j in range(1,C+1):
      for k in range(4): #横から取らない
        dp[j][k] = dp[j-1][k]
      #上から取らない
      dp[j][0] = max(dp[j][0],last_dp[j][-1])
      if item[i-1][j-1]>0:
        #上からとる
        dp[j][1] = max(dp[j][1],last_dp[j][-1]+item[i-1][j-1])
        for k in range(1,4): #横から取る
          dp[j][k] = max(dp[j][k],dp[j-1][k-1]+item[i-1][j-1])
      dp[j][4] = max(dp[j][:4])
    last_dp = dp
  ans = max(last_dp[-1])
  return ans
print(solve())

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c;
    Scd3(a,b,c);

    YESNO( 2*b == a+c );

    return 0;
}



Measured memory_bytes: 256
<?php
$fline = trim(fgets(STDIN));
$fnum = trim(fgets(STDIN));
$farray = explode(' ',$fnum);
$sline = trim(fgets(STDIN));
$snum = trim(fgets(STDIN));
$sarray = explode(' ',$snum);
$scount = 0;

foreach ($sarray as $skey => $svalue) {
    foreach ($farray as $fkey => $fvalue) {
        if ($svalue == $fvalue) {
            $scount++;
            break;
        }
    }
}
echo $scount, PHP_EOL;

Measured memory_bytes: 16740
#include<cstdio>

#define ull long long

ull sea(ull a,ull x){
  if(a == -1) return 0;
  
  return a/x +1;
}

int main(void){
  ull a,b,x,ans=0;

  scanf("%lld %lld %lld",&a,&b,&x);

  ans = sea(b,x) - sea(a-1,x);


  printf("%lld\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


ll gcm(ll a,ll b);
ll lcm(ll a,ll b);
ll fac(ll a);

int main(){
  ll n,k;
  cin >> n >> k;
  map<ll,ll> count;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    count[a] += b;
  }
  ll ans = 0;
  ll sum = 0;
  for(auto p:count){
    auto key = p.first;
    auto value = p.second;
    sum += value;
    if(k <= sum){
      ans = key;
      break;
    }
  }
  cout << ans << endl;
}

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

using namespace std;
inline void FAST_IO(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

class  SegTree{
    vector<int> st;
    vector<int> lazy;
    vector<bool> has;
    int size;

    int el_neutro = 0;

    int f(int a, int b){
        return __gcd(a,b);
    }

     void propagate(int sti, int stl, int str){
        if(has[sti]){
            st[sti] = lazy[sti];
            if(stl != str){
                lazy[sti*2 + 1] = lazy[sti];
                lazy[sti*2 + 2] = lazy[sti];

                has[sti*2 + 1] = true;
                has[sti*2 + 2] = true;
            }
            has[sti] = false;
        }
    }

    int query(int sti, int stl, int str, int l, int r){
        propagate(sti, stl, str);

        if(str < l || r < stl)
            return el_neutro;

        if(stl >= l and str <= r)
            return st[sti];

        int mid = (str+stl)/2;

        return f(query(sti*2+1,stl,mid,l,r),query(sti*2+2,mid+1,str,l,r));
    }

    void update_range(int sti, int stl, int str, int l,int r, int amm){
		propagate(sti, stl, str);
		
		if(stl >= l and str <= r){
            lazy[sti] = amm;
            has[sti] = true;
            propagate(sti, stl, str);
            return;
        }

        if(stl > r  or str < l)
            return;
        
		int mid = (stl + str)/2;
        
		update_range(sti*2+1,stl,mid,l,r,amm);
        update_range(sti*2+2,mid+1,str,l,r,amm);
        
		st[sti] = f(st[sti*2+1],st[sti*2+2]);
    }

    public:
        SegTree(int n):  st(4*n,0), lazy(4*n,0),has(4*n,false),size(n){}
		
        int query(int l, int  r){
			return query(0,0,size-1,l,r);
		}
        
		void update_range(int l, int r, int amm){
			update_range(0,0,size-1,l,r,amm);
		}
};

int main() {
	FAST_IO();
	int n;
	cin >> n;
	SegTree st(n);
	
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		st.update_range(i,i, x);
	}
	
	int max = 1;
	for(int i = 0; i < n; ++i){
		int l = (i == 0 ? 0 : st.query(0,i-1));
		int r = (i == n-1 ? 0 : st.query(i+1,n-1));
		max = std::max(max, __gcd(l,r));
	}
	
	cout << max << endl;
	
    return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>
#include<string.h>

int main(){
  int n;
  int d[1000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
  	scanf("%d",&d[i]);
  }
 int sum=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      sum+=d[i]*d[j];
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<algorithm>

using namespace std;

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

    cout << min(a * n, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#16:38
n,m = map(int,input().split())
raw = [[] for _ in range(n)]
precnt = [0 for _ in range(n)]
root = [1 for _ in range(n)]
for _ in range(n-1+m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  raw[a].append(b)
  precnt[b] += 1
  root[b] = 0
for i in range(n):
  if root[i] == 1:
    r = i
    break
pre = [-1 for _ in range(n)]
now = [r]
#print(precnt)
while now:
  last = now
  now = []
  for x in last:
    for y in raw[x]:
      precnt[y] -= 1
      if precnt[y] == 0:
        now.append(y)
      pre[y] = x
#print(pre)
#print(precnt)
for x in pre:
  print(x+1)

Measured memory_bytes: 64816
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<bitset>
#include<stack>
#include<set>
#include<vector>
#include <time.h>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 4e5+5;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e=exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl
pll que[maxn];
ll h[maxn];
ll dp[maxn];
int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);
    int n;ll c;
    scanf("%d%lld",&n,&c);
    for(int i=1;i<=n;i++) scanf("%lld",&h[i]);
    dp[1]=0;
    int tail=-1,head=0;
    que[++tail]=pll(h[1],1LL*h[1]*h[1]);
    for(int i=2;i<=n;i++)
    {
        while(head<tail&&(que[head+1].Se-que[head].Se)<2LL*h[i]*(que[head+1].Fi-que[head].Fi)) head++;
        dp[i]=que[head].Se-que[head].Fi*que[head].Fi+1LL*(h[i]-que[head].Fi)*(h[i]-que[head].Fi)+c;
        while(head<tail&&1.0*(que[tail].Se-que[tail-1].Se)*(h[i]-que[tail].Fi)>1.0*(dp[i]+h[i]*h[i]-que[tail].Se)*(que[tail].Fi-que[tail-1].Fi)) tail--;
        que[++tail]=pll(h[i],dp[i]+h[i]*h[i]);
       // dbg2(i,dp[i]);
       // dbg2(head,tail);
    }
    printf("%lld\n",dp[n]);
    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}



Measured memory_bytes: 9984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    int[] tree;

    private void insert(int index, int num, int a, int b, int node) {
        if (a == b) {
            tree[node] = num;
            return;
        }

        int mid = (a + b) / 2;
        if (index <= mid) insert(index, num, a, mid, node * 2);
        else insert(index, num, mid + 1, b, node * 2 + 1);

        tree[node] = Math.max(tree[node * 2], tree[node * 2 + 1]);
    }

    private int getMax(int from, int to, int a, int b, int node) {
        if (from <= a && b <= to) return tree[node];

        int mid = (a + b) / 2;
        int max = 0;
        if (from <= mid) max = Math.max(max, getMax(from, to, a, mid, node * 2));
        if (to > mid) max = Math.max(max, getMax(from, to, mid + 1, b, node * 2 + 1));

        return max;
    }

    public static void main(String[] args) throws IOException {
        new Main().solve();
    }

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(tokenizer.nextToken());
        int k = Integer.parseInt(tokenizer.nextToken());

        int maxNum = 300000;
        tree = new int[4 * (maxNum + 1)];
        for (int i = 0;i  <n; i++) {
            int num = Integer.parseInt(f.readLine());
            int left = Math.max(0, num - k);
            int right = Math.min(num + k, maxNum);
            insert(num, getMax(left, right, 0, maxNum, 1) + 1, 0, maxNum, 1);
        }

        out.println(getMax(0, maxNum, 0, maxNum, 1));
        out.close();
    }
}

Measured memory_bytes: 57228
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

const ll inf = 1e18;
ll cache[102][102][500];
bool ready[102][102][500];
int n;
ll W, fw;

ll a[102], b[102];


bool ok(int cnt, int extra) {
    ll total = cnt * 1LL * fw + extra;
    return (total <= W);
}


ll dp(int k, int cnt, int extra) {
    if (k == n) {
        return 0;
    }
    if (ready[k][cnt][extra]) return cache[k][cnt][extra];
    ready[k][cnt][extra] = true;

    ll &rv = cache[k][cnt][extra];
    rv = 0;
    if (ok(cnt + 1, extra + a[k] - fw)) {
        rv = b[k] + dp(k + 1, cnt + 1, extra + a[k] - fw);
    }
    rv = max(rv, dp(k + 1, cnt, extra));
    return rv;
}

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


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

    fw = a[0];

    ll res = dp(0, 0, 0);
    cout << res << endl;

}

Measured memory_bytes: 43776
import sys
input = sys.stdin.readline
n = int(input())
s = input()

ans = 0
for i in range(1000):
    i = str(i)
    i = (3-len(i)) * '0' + i
    r = 0
    for j in range(n):
        if s[j] == i[r]:
            r += 1
        if r == 3:
            break
    if r == 3:
        ans +=1

print(ans)

Measured memory_bytes: 42968
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    while(1){
        int h, w; cin>>h>>w;
        if(h == 0) break;

        int dist = h * h + w * w;

        int mindist = inf;

        int ansh = inf;
        int answ = inf;

        // h
        for(int i=1; i<=150; i++){
            // w
            for(int j=i+1; j<=150; j++){
                int cdist = i * i + j * j;

                if(dist < cdist){
                    if(mindist == cdist){
                        if(i < ansh){
                            ansh = i, answ = j;
                        }
                    }
                    else if(cdist < mindist){
                        mindist = cdist;
                        ansh = i, answ = j;
                    }
                }
                else if(dist == cdist){
                    if(h < i){
                        ansh = i, answ = j;
                        goto END;
                    }
                }
            }
        }

        END:;
        cout << ansh << " " << answ << endl;
    }

    return 0;
}


Measured memory_bytes: 3188
def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    P = [x - 1 for x in P]
    C = list(map(int, input().split()))
    ans = -(10 ** 18)
    for i in range(N):
        j = i
        S = 0
        L = 0
        for _ in range(K):
            j = P[j]
            S += C[j]
            L += 1
            ans = max(ans, S)
            if j == i:
                break
        if j == i:
            M = max(0, K // L - 1)
            T = S * M
            for _ in range(M * L, K):
                j = P[j]
                T += C[j]
                ans = max(ans, T)
    print(ans)


if __name__ == "__main__":
  main()


Measured memory_bytes: 74212