akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC159
{
    class D
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(long.Parse).ToArray();

            //出てきた数字の数
            var count = new long[n + 1];
            for (long i = 0; i < n; i++)
            {
                count[A[i]]++;
            }

            //nCkしたやつ
            var res = new long[n + 1];
            for (long i = 0; i < n; i++)
            {
                res[A[i]] = count[A[i]] * (count[A[i]] - 1) / 2;
            }

            long sum = res.Sum();

            for (long i = 0; i < n; i++)
            {
                long tmpSum = sum - res[A[i]] + (count[A[i]] - 1) * (count[A[i]] - 1 - 1) / 2;

                Console.WriteLine(tmpSum);
            }
        }
    }
}


Measured memory_bytes: 40532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } 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 (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(long long N, long long M, std::vector<long long> L, std::vector<long long> R){
	ll res = 0;
	ll low = 0, high = 1e9;
	REP(i, M) {
		chmax(low, L[i]);
		chmin(high, R[i]);
	}
	res = high - low + 1;
	if (res<0) res = 0;
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> L(M);
    std::vector<long long> R(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&L[i]);
        scanf("%lld",&R[i]);
    }
    solve(N, M, std::move(L), std::move(R));
    return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by khrom on 2017/06/12.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<String> numList = new ArrayList<>();
        while (true) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            if (x == 0 && y == 0) {
                break;
            } else {
                numList.add(x <= y ? x + " " + y : y + " " + x);
            }
        }
        numList.forEach(s -> System.out.println(s));
    }
}

Measured memory_bytes: 38836
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin>>n>>s;
    int x=0;
  	int ans=0;
    rep(i,n){
        if(s[i]=='I')x++;
        else x--;
      	chmax(ans,x);
    }
    cout<<ans<<"\n";
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double time = h * 60 + m;
	double ax = a * sin(time/(12*60)*2*PI);
	double ay = a * cos(time/(12*60)*2*PI);
	double bx = b * sin(m/60*2*PI);
	double by = b * cos(m/60*2*PI);
	double ans = sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by));
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
//??????URL http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2311&lang=jp

using namespace std;
typedef pair<int,int> pii;

char board[8][8];

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

char memo[2]={'o','x'};
//player 0:mami 1:magi
int dfs(int x,int y,int cnt,int idx,int player){
    int nx=x+dx[idx],ny=y+dy[idx];
    if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]==memo[1-player]){
      cnt++;
      return dfs(nx,ny,cnt,idx,player);
    }
    else if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]==memo[player]){
      return cnt;
    }
    else if(0<=nx && nx<=7 && 0<=ny &&ny<=7 && board[nx][ny]=='.'){
      return 0;
    }
    return 0;
}

int count(int x,int y,int player){
    int res=0;
    for(int i=0;i<8;i++) res+=dfs(x,y,0,i,player);
    return res;
}

int solve(int player){
    int ma=-1,x,y;
    if(player==1){
        for(int i=7;i>=0;i--)for(int j=7;j>=0;j--){
          if(board[i][j]=='.'&&count(i,j,player)>ma){
            ma=count(i,j,player);
            x=i;y=j;
          }
        }
    }
    if(player==0){
        for(int i=0;i<8;i++)for(int j=0;j<8;j++){
            if(board[i][j]=='.' && count(i,j,player)>ma){
                ma=count(i,j,player);
                x=i;y=j;
            }
        }//?????§?????????????????´???
    }
    if(ma<1) return 0;
    board[x][y]=memo[player];
    for(int i=0;i<8;i++){
      int tmp=dfs(x,y,0,i,player);
      for(int j=1;j<=tmp;j++){
        board[x+dx[i]*j][y+dy[i]*j]=memo[player];
      }
    }
    return 1;
}

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

  for(int i=0;i<8;i++)for(int j=0;j<8;j++) cin>> board[i][j];
  bool mami_flag=true,magi_flag=true;
  while(mami_flag || magi_flag){
    mami_flag=solve(0);
    magi_flag=solve(1);
  }
  for(int i=0;i<8;i++){
    for(int j=0;j<8;j++){
      cout<< board[i][j];
    }
    cout<<endl;
  }
}

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

int main(){
  int W,A,B;
  cin >> W >> A >> B;
  if((A + W) < B) cout << B - (A + W) << endl;
  else if((B + W) < A) cout << A - (B + W) << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 384
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);
	cini(k)
	cinai(p, n);
	ll masum = 0;
	ll sum = 0;
	queue<int> q;

	for (int i = 0; i < n; i++) {
		sum += (p[i] + 1);
		q.push(p[i] + 1);
		if (q.size() == k) {
			masum = max(masum, sum);
			int nval = q.front();
			q.pop();
			sum -= nval;
		}
	}
	double d = masum;
	cout << setprecision(15)<< d / 2.0 << endl;
}

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



Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(ll i = 0; i < (ll) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    ll n; cin >> n;
    vector<ll> A(n + 1);
    for(ll i = 1; i <= n; i++) cin >> A[i];
    map<ll, pair<ll, ll>> mp;
    set<pair<ll, ll>> st;
    for(ll i = 1; i <= n; i++)
    {
        ll tmp = i + A[i];
        st.insert(make_pair(i, tmp));
        mp[tmp].first++;
    }
    ll ans = 0;
    for(ll i = 1; i <= n; i++)
    {
        ll tmp = i - A[i];
        if(st.count(make_pair(i, tmp)));
        mp[tmp].second++;
    }
    for(auto& x : mp)
    {
        ll cnt = x.second.first * x.second.second;
        ans += cnt;
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 40128
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt(scanner)
	y := getNextInt(scanner)
	if (x+y)%3 != 0 || x > 2*y || y > x*2 {
		fmt.Println(0)
		return
	}

	c := (x + y) / 3
	cm := CombinationMod{}
	cm.init(c)

	fmt.Fprintln(writer, cm.calc(c, x-c))
	writer.Flush()
}

// CombinationMod ...
type CombinationMod struct {
	n, mod   int64
	fac, inv []int64
}

func (cm *CombinationMod) init(n int) {
	cm.n = int64(n)
	cm.fac = make([]int64, n+1)
	cm.inv = make([]int64, n+1)
	cm.fac[0] = 1
	cm.mod = int64(1e9 + 7)
	var i int64
	for i = 1; i < cm.n+1; i++ {
		cm.fac[i] = (cm.fac[i-1] * i) % cm.mod
	}
	cm.inv[n] = cm.calcInv(cm.fac[n])
	for i = cm.n; i > 0; i-- {
		cm.inv[i-1] = (cm.inv[i] * i) % cm.mod
	}
}
func (cm *CombinationMod) calcInv(n int64) int64 {
	if n == 1 {
		return 1
	}
	var a, b, x, y int64
	a = cm.mod
	b = n
	x = 1
	y = -a / b

	stack := [][]int64{
		[]int64{
			x, y,
		},
	}
	for a%b > 0 {
		a, b = b, a%b
		x = 1
		y = -a / b
		stack = append(stack, []int64{
			x, y,
		})
	}

	for i := len(stack) - 2; i > 0; i-- {
		stack[i-1][0] *= stack[i][1]
		stack[i-1][1] *= stack[i][1]
		stack[i-1][1] += stack[i][0]
	}

	ans := stack[0][1] % cm.mod
	if ans < 0 {
		ans += cm.mod
	}

	return ans
}

func (cm *CombinationMod) calc(n, m int) int64 {
	ans := (cm.fac[n] * ((cm.inv[m] * cm.inv[n-m]) % cm.mod)) % cm.mod
	return ans
}


Measured memory_bytes: 11392
#include <stdio.h>
#define _CRT_SECURE_NO_WARNINGS

int main() {
	int a1, b1, c1;
	int x, ans = 0;
	scanf("%d%d%d%d", &a1, &b1, &c1, &x);
	int sum = x;

	for (int i = 0; i <= a1; i++) {
		for (int j = 0; j <= b1; j++) {
			for (int k = 0; k <= c1; k++) {
				int sum = 500 * i + 100 * j + 50 * k;
				if (sum == x) {
					ans++;
				}
			}
		}
	}
	printf("%d", ans);
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n, t; cin >> n >> t;
    vector<ll> time(n);
    rep(i, n) cin >> time[i];
    
    ll ans = t;
    ll now = 0;
    rep(i, n) {
        if(time[i] - now > t) ans += t;
        else ans += time[i] - now;
        now = time[i];
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define nl '\n'
#define ll long long int
#define loop(i,a,b)           for(int i=a;i<b;++i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define clr(x)                x.clear()
#define MOD                   1000000007
#define itoc(c)               ((char)(((int)'0')+c))
#define vi                    vector<int>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define max(x,y)              (x>y)?x:y
#define min(x,y)              (x<y)?x:y
#define mid(s,e)              (s+(e-s)/2)
#define tcase()                ll t,n; scanf("%lld",&t);n=t; while(t--)
#define iscn(num)             scanf("%d",&num);
using namespace std;
void FAST_IO();
long long  table[1010][100000];
long long  val[110];
long long  wt[110];
int main()
{
    FAST_IO();
    long long  n,w;
    cin>>n;
    cin>>w;
    for(long long  i=1;i<=n;i++)
    {
        cin>>wt[i];
        cin>>val[i];
    }
    for(long long  i=1;i<=n;i++)
    {
        for(long long  j=1;j<=w;j++)
        {
            if(wt[i]<=w && j-wt[i]>=0)
            {

                table[i][j]=max(table[i-1][j],val[i]+table[i-1][j-wt[i]]);
            }

            else
                table[i][j]=table[i-1][j];
        }
    }

    cout<<table[n][w]<<endl;
    return 0;
}
void FAST_IO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.setf(ios::fixed);
    //cout.precision(20);
#ifndef _offline
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}


Measured memory_bytes: 79360
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;


int main(){
    char C;
    cin >> C;
    if(C >= 'A' && C <= 'Z'){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }

    return 0;
}


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

int main()
{
    long long int n,ww,i,j,k;
    cin>>n>>ww;
    vector<long long int> w(n),v(n);
    vector<vector<long long int>> dp(n+1,vector<long long int>(ww+1));

    for(i=0;i<n;i++)
        cin>>w[i]>>v[i];

    for(i=0;i<=n;i++)
        dp[i][0]=0;
    for(i=0;i<=ww;i++)
        dp[0][i]=0;

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=ww;j++)
        {
            if(w[i-1]>j)
                dp[i][j]=dp[i-1][j];
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            }
        }
    }
    cout<<dp[n][ww]<<endl;
    return 0;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
    string S;cin>>S;
    for(int i=0;i<S.length();i+=2) cout<<S[i];
    cout<<"\n";
}

Measured memory_bytes: 27148
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
    cin >> N;
    string ans = "No";
    int L = N / 4;
    for (int i = 0; i <= L; i++) {
        for (int j = 0; j <= N/7; j++) {
            if (i * 4 + j * 7 == N) ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
const ll INF=1LL<<60;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;cin >> a >> b >> c >> d;
    cout << min({abs(a+b-(c+d)),abs(a+c-(b+d)),abs(a+d-(c+b))}) << endl;
}


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

int main()
{
    int n[3], steps = 0, x;
    cin >> n[0] >> n[1] >> n[2];
    sort(n, n + 3);

    while (!(n[0] == n[2] && n[1] == n[2] && n[0] == n[1]))
    {
        sort(n, n + 3);

        if (n[0] + 2 <= n[2])
        {
            n[0] += 2;
            steps++;
        }
        else
        {
            n[0]++;
            n[1]++;
            steps++;
        }
    }

    cout << steps;
    return 0;
}

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

int main(){
  vector<int>ti(5);
  for(int i=0;i<5;i++)
    cin >> ti.at(i);
  for(int i=0;i<5;i++){
    for(int j=0;j<4;j++){
      if((ti.at(j)%10!=0&&ti.at(j)%10<ti.at(j+1)%10)||ti.at(j+1)%10==0)
        swap(ti.at(j),ti.at(j+1));
    }
  }
  int ans=0;
  for(int i=0;i<5;i++){
    //cout << ti.at(i) << "#";
    if(ans%10!=0)
      ans=(ans/10+1)*10;
    ans+=ti.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>

#include <map>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

const ll MOD { 1000000007 };

ll Ep(ll n, ll p)
{
    ll res = 0;

    while (n / p)
    {
        res += n / p;
        n /= p;
    }

    return res;
}

bool is_prime(ll n)
{
    for (ll p = 3; p * p <= n; p += 2)
    {
        if (n % p == 0)
            return false;
    }

    return true;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ll> ds;

    ll res = Ep(N, 2);

    if (res)
        ds.push_back(res);

    for (ll p = 3; p <= N; p += 2)
    {
        if (not is_prime(p))
            continue;

        res = Ep(N, p);

        if (res)
            ds.push_back(res);
    }

    res = 1;

    for (const auto& d : ds)
    {
        res *= (d + 1);
        res %= MOD;
    }

    cout << res << endl;

    return 0;
}


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

//--------------some #defines-------------------------
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define get1(x) int x; cin>>x
#define get2(x,y) int x,y; cin>>x>>y
#define min2(x,y) (x<y?x:y)
#define max2(x,y) (x>y?x:y)

#define loop(i,a,b) for(int i=(a);i<(b);i++)
#define rev(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define all(x) (x).begin(), (x).end()
#define sz(x) (x).size()
#define endl '\n'

#define vi vector<int>

#define matrix(x,n,m) vector<vector<int> > x(n,vi (m))
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define ff first
#define ss second
#define vpii vector<pair<int,int> >
#define ll long long


//#define gcd(x,y) __gcd(x,y)
//#define lcm(x,y) (x)*(y)/__gcd(x,y)

//-------------------------------------------------------------

int main()
{
    boost;
    get2(l,r);
    get1(d);

    int cont=0;
    int i=1,n=d;
    while(d<r+1)
    {
        if(d>=l)
        {
            cont++;
        }
        i++;
        d=n*i;
    }
    cout<<cont;


    return 0;
}



Measured memory_bytes: 3576
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <stdlib.h>
#include <cmath>
#include <set>

using namespace std;
#define mk make_pair
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100100;
const int mod=1000000007;
const ll INF=1000000000;

int a[maxn];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int flag=1;
    for(int i=0;i<n;i++){
        if(i==0){
            if(a[i]>1)
                a[i]--;
        }
        else if(i==n-1){
            if(a[i]<a[i-1])
            {
                flag=0;
                break;
            }
        }
        else{
            if(a[i]<a[i-1]){
                flag=0;
                break;
            }
            if(a[i]>a[i-1]){
                a[i]--;
            }
        }
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

/*
 2598708396863
*/


Measured memory_bytes: 640
# ビット全探索
N, M, X = map(int, input().split())

C = []
A = []
for i in range(N):
    t = list(map(int, input().split()))
    C.append(t[0])
    A.append(t[1:])

result = -1
for i in range(1 << N):
    t = [0] * M
    c = 0
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        c += C[j]
        for k in range(M):
            t[k] += A[j][k]
    if all(x >= X for x in t):
        if result == -1:
            result = c
        else:
            result = min(result, c)
print(result)

Measured memory_bytes: 9204
#include <bits/stdc++.h>  
using namespace std;  
const int N = 3e5+5;  
typedef long long ll;  
char s[N];  
int a[N];  
int flag[N];  
int main()  
{  
    int n;  
    string s;  
    cin>>n>>s;  
    int l=0,r=0;  
    for(int i=1;i<n;i++){  
        if(s[i]=='W') r++;  
    }  
    int ans=n-r-1;  
    for(int i=1;i<n;i++){  
        if(s[i-1]=='E')  l++;  
        if(s[i]=='W') r--;  
        ans=min(ans,n-l-r-1);  
    }  
    cout<<ans<<endl;  
}  

Measured memory_bytes: 900
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;


int main(){
  int N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  rep(i, N) cin >> w[i] >> v[i];

  vector<vector<ll> > dp(101, vector<ll>(100001, 0));
  ll ans = 0;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j <= 100000; ++j){
      if(j < w[i]){
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
      }
      if(ans < dp[i + 1][j]){
        ans = dp[i + 1][j];
      }
    }
  }

  cout << dp[N][W] << endl;
}


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

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

  int t[n + 1][n + 1] = {};

  for (int i = n - 1; i >= 0; i--) {
    for (int j = n - 1; j > i; j--) {
      if (s[i] == s[j]) {
        t[i][j] = t[i + 1][j + 1] + 1;
      }
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (t[i][j] <= j - i) {
        ans = max(ans, t[i][j]);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 97920
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

template <class T> void max_swap(T& a, const T b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T b) { a = min(a, b); }

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int h, w, n;
	while (scanf("%d%d%d", &h, &w, &n), h | w | n)
	{
		static bool east[1024][1024];
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				int t;
				scanf("%d", &t);
				east[i][j] = t == 1;
			}
		}

		static int visit[1024][1024];
		for (int i = 0; i < h; ++i)
			for (int j = 0; j < w; ++j)
				visit[i][j] = 0;

		visit[0][0] = --n;
		for (int i = 0; i < h; ++i)
		{
			for (int j = 0; j < w; ++j)
			{
				int a = visit[i][j] / 2, b = (visit[i][j] + 1) / 2;
				if (east[i][j])
					swap(a, b);
				visit[i][j + 1] += a;
				visit[i + 1][j] += b;

				east[i][j] ^= visit[i][j] & 1;
			}
		}

		int x, y;
		x = y = 0;
		while (x < w && y < h)
		{
			if (east[y][x])
				++x;
			else
				++y;
		}
		printf("%d %d\n", ++y, ++x);
	}
}

Measured memory_bytes: 0
#!/usr/bin/env python3


def main():
    n, m, d = (int(x) for x in input().split())
    a_at_d0 = (m - 1) / n
    if d == 0:
        res = a_at_d0
    else:
        unit = a_at_d0 * 2
        res = (n - d) / n * unit
    print("{:.10f}".format(res))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
'use strict'
function main(input) {
    let prevNum = input[0];
    for (let digit = 1; digit < 4; digit++) {
        if (input[digit] === prevNum) {
            console.log("Bad");
            break;
        }
        if (digit === 3) {
            console.log("Good");
        }
        prevNum = input[digit];
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(' ').map { it.toInt() }
    val queries = (1..q).map {
        readLine()!!.split(' ').map { it.toInt() }
            .let { Query(if (it[0] == 0) QueryType.UPDATE else QueryType.FIND, it[1], it[2]) }
    }

    val infinity = (1L shl 31) - 1
    val segmentTree = SegmentTree(LongArray(n) { infinity }, infinity, Math::min)
    val answer = StringBuilder()

    for (query in queries) {
        val (type, x, y) = query
        when (type) {
            QueryType.UPDATE -> segmentTree[x] = y.toLong()
            QueryType.FIND -> answer.appendln(segmentTree[x..y])
        }
    }

    print(answer)
}

private data class Query(val type: QueryType, val x: Int, val y: Int)
private enum class QueryType { UPDATE, FIND }

private class SegmentTree(init: LongArray, val initValue: Long, val monad: (Long, Long) -> Long) {
    val indices: Int
    val nodes: LongArray

    init {
        var indices = 1
        while (indices < init.size) indices = indices shl 1
        val nodes = LongArray(2 * indices - 1) { initValue }
        for (i in init.indices) nodes[i + indices - 1] = init[i]
        for (i in indices - 2 downTo 0) nodes[i] = monad(nodes[2 * i + 1], nodes[2 * i + 2])
        this.indices = indices
        this.nodes = nodes
    }

    operator fun set(x: Int, value: Long) {
        var index = x + indices - 1
        nodes[index] = value
        while (index > 0) {
            index = (index - 1) / 2
            nodes[index] = monad(nodes[2 * index + 1], nodes[2 * index + 2])
        }
    }

    operator fun get(range: IntRange) = get(range.first, range.last + 1)

    fun get(a: Int, b: Int, k: Int = 0, l: Int = 0, r: Int = indices): Long {
        if (r <= a || b <= l) return initValue
        if (a <= l && r <= b) return nodes[k]
        return monad(
            get(a, b, 2 * k + 1, l, (l + r) / 2),
            get(a, b, 2 * k + 2, (l + r) / 2, r)
        )
    }
}



Measured memory_bytes: 126388
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int top = 0, c[20000], area[20000][2] = {};

void push(int x){
  top++;
  c[top] = x;
}

int pop(){
  top--;
  return c[top + 1];
}

int main(){

  int sum = 0, cnt = 0;
  char ch;

  for(int i = 0;cin >> ch;i++){
    if(ch == '\\'){
      push(i);
    }else if(ch == '/' && top > 0){
      int j = pop(), tmp;
      sum += i - j;
      tmp = i - j;
      while(cnt > 0 && area[cnt][1] > j){
        tmp += area[cnt][0];
        cnt--;
      }
      cnt++;
      area[cnt][0] = tmp;
      area[cnt][1] = j;
    }
  }

  cout << sum << endl;
  cout << cnt;
  for(int i = 1;i <= cnt;i++) cout << " " << area[i][0];
  cout << endl;

  return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;cin>>k;
  int ans=0;
  for(int i=0;i<k;i++){
    for(int j=0;j<k;j++){
      if(i%2 == 0 && j%2 != 0)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int R[200010];
  for (int i = 0; i < n; i++) {
    cin >> R[i];
  }

  int max_v = -1000000000;
  int min_R = R[0];
  for (int i = 1 ; i < n; i++) {
    int v = R[i] - min_R;
    if (v > max_v) {
      max_v = v;
      //cout << "i:" << i << ", R:" << R[i] << ", min_R:" << min_R << ", max_v:" << max_v << endl;
    }
    if (R[i] < min_R) {
      min_R = R[i];
    }
  }
  cout << max_v << endl;
}



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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 0; i < 1e6; ++i) {
        if (a % 2 || b % 2 || c % 2) {
            cout << i;
            return 0;
        }
        int d = (b + c) / 2;
        int e = (a + c) / 2;
        int f = (a + b) / 2;
        a = d;
        b = e;
        c = f;
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
//---------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                        NEVER  GIVE  UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug cout<<"Hello\n";
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//------------------------------------------------------------------------------------------------------------------------------

int main()
{
	
	#ifndef ONLINE_JUDGE
	freopen("C:/Users/DELL/Desktop/input.txt", "r", stdin);
	#endif

	fast;
	int n;
	cin>>n;
	string str;
	map<string,int> mp;
	for(int i=0;i<n;i++)
	{
		cin>>str;
		mp[str]++;
	}
	cout<<"AC x "<<mp["AC"]<<"\n";
	cout<<"WA x "<<mp["WA"]<<"\n";
	cout<<"TLE x "<<mp["TLE"]<<"\n";
	cout<<"RE x "<<mp["RE"]<<"\n";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pq priority_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
using namespace std;
typedef long long ll; typedef long double ld;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<10> fact;
constexpr Prime<10> prime;
constexpr int comb(int a, int b){long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b];return pos * pot % MOD * por % MOD;}
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr int sqrtN = 512, logN = 32;
constexpr ld PI = abs(acos(-1));
constexpr ll LINF=1e18;

int main(){
	int n, m; cin >> n >> m;
	vector<int> g[25];
	int h[25] = {};
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		g[a - 1].push_back(b - 1);
		h[b - 1]++;
	}
	
	queue<int> qu;
	vector<int> vec;
	for(int i = 0; i < n; i++) if(!h[i]) qu.push(i);
	while(!qu.empty()){
		auto p = qu.front(); qu.pop();
		
		vec.push_back(p);
		for(auto e:g[p]){
			h[e]--;
			if(!h[e]) qu.push(e);
		}
	}
	
	for(auto s:vec) cout << s + 1 << endl;
	return 0;
}



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

int main() {
  int n;
  cin >> n;
  
  vector<long long> a(n+1);
  for (int i=0; i<n; i++) cin >> a[i+1];
  
  vector<long long> ans(n);
  
  if (n%2 == 0) {
    for(int i=0; i<n/2; i++){
      ans[i] = a[n-2*i]; 
      ans[n-1-i] = a[n-1-2*i];
    }
  }else{
    for(int i=0; i<n/2; i++){
      ans[i] = a[n-2*i];
      ans[n-1-i] = a[n-1-2*i];
    }
    ans[n/2] = a[1];
  }
  
  for(int i=0; i<n-1; i++){
    cout << ans[i] << " ";
  }
  cout << ans[n-1] << endl;
}

Measured memory_bytes: 5248
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        double x=Math.PI;
        double r = sc.nextDouble();
        System.out.println(String.format("%.6f",r*r*x));
        System.out.println(String.format("%.6f",2*r*x));
   }
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	int alice = 0;
	int bob = 0;
	rep(i, n){
		if(i%2 == 0) alice += a.at(i);
		else bob += a.at(i);
	}
	cout << alice - bob << endl;
}

Measured memory_bytes: 256
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s,t = SL()
ss,tt = IL()
n = S()

if s == n:
  ss -= 1
if t == n:
  tt -= 1
print(ss,tt)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

Int Gcd(Int a, Int b) {
    return b ? Gcd(b, a%b) : a;
}

Int Lcm(Int a, Int b) {
    return a / Gcd(a, b) * b;
}

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

    Int A, B, C, D; cin >> A >> B >> C >> D;

    Int minDivisorC = A - A%C;
    if (minDivisorC < A) minDivisorC += C;
    Int maxDivisorC = B - B%C;

    Int minDivisorD = A - A%D;
    if (minDivisorD < A) minDivisorD += D;
    Int maxDivisorD = B - B%D;

    Int LCM = Lcm(C, D);
    Int minDivisorLCM = A - A%LCM;
    if (minDivisorLCM < A) minDivisorLCM += LCM;
    Int maxDivisorLCM = B - B%LCM;

    Int res = B-A+1 - ((maxDivisorC-minDivisorC)/C+1) - ((maxDivisorD-minDivisorD)/D+1) + ((maxDivisorLCM-minDivisorLCM)/LCM+1);
    cout << res << endl;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,k;
  scanf("%d%d",&n,&k);
  printf("%d\n",n%k==0?0:1);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define mod 1000000007LL
#define all(x) x.begin() , x.end()
#define ld long double
void solve();
vector<vector<ll>>adj;
vector<bool>used;
vector<ll>comp;
void dfs(ll v)
{
	used[v] = 1;
	comp.push_back(v);
	for (auto u : adj[v])
	{
		if (!used[u]) dfs(u);
	}
}
int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int t = 1; //cin >> t;
	while (t--)
		solve();
	return 0;
}
void solve()
{
	ll N = 1299827; // first 100008 primes;
	vector<ll>lp(N + 1, 0);
	vector<ll>pr;
	for (ll i = 2; i <= N; ++i)
	{
		if (lp[i] == 0)
		{
			lp[i] = i;
			pr.push_back(i);
		}
		for (ll j = 0; j < pr.size() and i * pr[j] <= N ; ++j)
		{
			lp[i * pr[j]] = pr[j];
		}
	}
	ll n; cin >> n;
	ll g;
	bool ok = 1;
	set<ll>s;
	for (int i = 0; i < n; i++)
	{
		ll tp; cin >> tp;
		if (i == 0) g = tp;
		else g = __gcd(tp , g);
		while (tp != 1)
		{
			ll x = lp[tp];
			if (s.count(x))
			{
				ok = 0; break;
			}
			else
			{
				while (tp % x == 0) tp /= x;
				s.insert(x);
			}
		}
	}
	if (ok) cout << "pairwise coprime";
	else if (g == 1) cout << "setwise coprime";
	else cout << "not coprime";
	cout << "\n";
	return ;
}

Measured memory_bytes: 17828
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int V;
int cost[120][120];
int d[120];
bool visit[120];
void dijkstra(int s){
	d[s]=0;
	while(true){
		int v =-1;
		for(int u = 0;u < V;u++){
			if(!visit[u]&&(v==-1||d[u] < d[v])){
				v = u;
			}
		}
		if(v==-1)break;
		visit[v]=true;
		for(int u = 0;u < V;u++){
			d[u] =min(d[u],d[v]+cost[v][u]);
		}
	}
}

int main(){
	cin>>V;
	for(int i =0;i <120;i++){
		d[i]=INF;
		visit[i]=false;
		for(int j =0;j <120;j++){
			cost[i][j]=INF;

		}
	}
	for(int i =0;i < V;i++){
		int u,k;
		cin>>u>>k;
		for(int j =0;j <k;j++){
			int v,c;
			cin>>v>>c;
			cost[u][v]=c;
		}
	}
	dijkstra(0);
	for(int i =0;i <V;i++){
		cout <<i<<" "<<d[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1216
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_num(LL n) { int ret = 0; while (n > 0) { ret ++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, c;
int d[30][30];
int a[500][500];
int cnt[3][30];
int iwakan[3][30];

int main() {
	cin >> n >> c;
	REP(i, c) REP(j, c) cin >> d[i][j];
	REP(i, n) REP(j, n) {
		cin >> a[i][j]; 
		a[i][j]--;
	}

	REP(i, n) {
		REP(j, n) {
			int type = (i + j) % 3;
			cnt[type][a[i][j]]++;
		}
	}

	REP(i, 3) {
		REP(j, c) {	//色jで合わせる
			REP(k, c) {
				iwakan[i][j] += cnt[i][k] * d[k][j];
			}
		}
	}

	int ans = INF;
	REP(i, c) {
		REP(j, c) {
			REP(k, c) {
				if (i == j) continue;
				if (j == k) continue;
				if (k == i) continue;
				int ssum = iwakan[0][i] + iwakan[1][j] + iwakan[2][k];
				ans = min(ans, ssum);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
def resolve():
    n = int(input())
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        divisors.sort()
        return divisors

    divisors = make_divisors(n)
    min_pair = 10**19
    for i in divisors:
        pair_i = n//i
        min_pair = min(min_pair, ((i-1)+(pair_i-1)))
    print(min_pair)
resolve()

Measured memory_bytes: 9572
#include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    int main(void)
    {
        int n, i, count = 0;
        scanf("%d", &n);
        char *s1 = (char *)malloc(sizeof(char) * n+1);
        char *s2 = (char *)malloc(sizeof(char) * n+1);
        char *c = (char *)malloc(sizeof(char) * 2 * n+2);
        scanf("%s", s1);
        scanf("%s", s2);
        for (i = 0; i < n; i++)
        {
            c[2 * i] = s1[i];
            c[2 * i + 1] = s2[i];
        }
        printf("%s\n", c);
        return 0;
    }

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int n = s.size();
	vector<int> v(n); {
		rep(i, n) v[i] = s[i] - '0';
	}

	bool f = true;
	if (v[0] == 0) f = false;
	if (v[n - 1] == 1) f = false;
	rep(i, n) {
		if (i > n - i - 1) break;
		if (v[i] != v[n - i - 2]) f = false;
	}
	if (!f) {
		printf("-1\n");
		return 0;
	}

	v[n - 1] = 1;
	queue<int> que; {
		rep(i, n) {
			if (v[i] == 1) que.push(i);
		}
	}

	rep(i, n - 1) {
		if (i == que.front()) que.pop();
		printf("%d %d\n", i + 1, que.front() + 1);
	}
	
	return 0;

}

Measured memory_bytes: 2304
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    long[] ans = new long[n+1];
    ans[0] = 2;
    ans[1] = 1;
    for(int i=2; i<=n; i++) {
      ans[i] = ans[i-2] + ans[i-1];
    }
    System.out.println(ans[n]);
  }
}


Measured memory_bytes: 32600
#include<queue>
#include<cstdio>

#define	mp	make_pair

using namespace std;

typedef	pair<int,int>	pii;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int w,h;
unsigned char board[50][50],memo[50][50][50][50];

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		int tx,ty,kx,ky;	scanf("%d%d%d%d",&tx,&ty,&kx,&ky);
		tx--,ty--,kx--,ky--;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)	scanf("%d",board[i]+j);
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<h;k++)for(int l=0;l<w;l++)	memo[i][j][k][l]=255;

		int ans=-1;
		memo[ty][tx][ky][kx]=0;
		queue< pair<pii,pii> > qu;	qu.push(mp(mp(ty,tx),mp(ky,kx)));
		while(!qu.empty()){
			pair<pii,pii> a=qu.front();	qu.pop();
			int tx=a.first.second, ty=a.first.first;
			int kx=a.second.second,ky=a.second.first;
			int cost=memo[ty][tx][ky][kx];
			if(cost>=100)	break;
			if(ty==ky && tx==kx){
				ans=cost;
				break;
			}
			for(int i=0;i<4;i++){
				int txx=tx+dx[i],tyy=ty+dy[i];
				int kxx=kx-dx[i],kyy=ky-dy[i];
				if(!(0<=txx && txx<w && 0<=tyy && tyy<h && !board[tyy][txx]))	txx=tx,tyy=ty;
				if(!(0<=kxx && kxx<w && 0<=kyy && kyy<h && !board[kyy][kxx]))	kxx=kx,kyy=ky;
				if(cost+1<memo[tyy][txx][kyy][kxx]){
					memo[tyy][txx][kyy][kxx]=cost+1;
					qu.push(mp(mp(tyy,txx),mp(kyy,kxx)));
				}
			}
		}

		printf(~ans?"%d\n":"NA\n",ans);
	}

	return 0;
}

Measured memory_bytes: 7056