akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
constexpr long long MAX = 1e15;

vector<long long> dijkstra(const vector<vector<pair<int, long long>>> &G, int s){
    struct RadixHeap {
        inline int bsr(long long x){ return (x == 0) ? -1 : 63-__builtin_clz(x); }
        vector<pair<long long, int>> v[65];
        long long last, sz;
        RadixHeap() : last(0), sz(0) { }
        bool empty () { return (sz == 0); }
        void push(long long x, int u) { sz++; v[bsr(x^last)+1].emplace_back(x, u); }
        inline pair<long long, int> pop () {
            if (!v[0].size()) {
                int i = 1;
                while (!v[i].size()) { i++; }
                last = min_element(v[i].begin(), v[i].end())->first;
                for (auto x : v[i]) { v[bsr(x.first^last)+1].emplace_back(x); }
                v[i].clear();
            }
            pair<long long, int> res = v[0].back();
            sz--;
            v[0].pop_back();
            return res;
        }
    };
    constexpr long long inf = INT64_MAX;
    vector<long long> ret(G.size(), inf); ret[s] = 0;
    RadixHeap rh; rh.push(ret[s], s);
    while (!rh.empty()) {
        long long dist; int node;
        tie(dist, node) = rh.pop();
        if (ret[node] < dist) continue;
        for (auto &e : G[node]) {
            int next_node; long long next_dist;
            tie(next_node, next_dist) = e;
            if (ret[next_node] > ret[node] + next_dist){
                ret[next_node] = ret[node] + next_dist;
                rh.push(ret[next_node], next_node);
            }
        }
    }
    return ret;
}

int main() {
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<vector<pair<int, long long>>> g1(n), g2(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        long long c1, c2;
        cin >> a >> b >> c1 >> c2;
        a--; b--;
        g1[a].emplace_back(b, c1);
        g1[b].emplace_back(a, c1);
        g2[a].emplace_back(b, c2);
        g2[b].emplace_back(a, c2);
    }
    
    vector<long long> d1 = dijkstra(g1, s); // yen
    vector<long long> d2 = dijkstra(g2, t); // snuuk
    vector<long long> d(n);
    for (int i = 0; i < n; i++) d[i] = d1[i] + d2[i];
    for (int i = n-1; i > 0; i--) d[i-1] = min(d[i-1], d[i]);
    
    for (auto& ans : d) cout << MAX - ans << '\n';
    return 0;
}

Measured memory_bytes: 19108
using System;
using System.Linq;

namespace キーエンスPC2019_D___Double_Landscape
{
    class Program
    {
        static long combMax;
        static long combMOD;

        static long[] factorial;
        static long[] inverse;
        static long[] factInv;
        static void Main(string[] args)
        {
            Console.WriteLine(solve());
        }
        static long solve()
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0]; var M = NM[1];
            var max = N * M;
            var Row = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var Column = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            long MOD = 1000000007;
            if (Row.Length != Row.Distinct().Count() || Column.Length != Column.Distinct().Count()) return 0;

            combInit(max, MOD);

            var isFixed = new bool[max + 1];
            var maxCount = new int[max + 1];
            for (int a = 0; a < N; a++)
            {
                for (int b = 0; b < M; b++)
                {
                    maxCount[Math.Min(Row[a], Column[b])]++;
                    if (Row[a] == Column[b]) isFixed[Row[a]] = true;
                }
            }

            var usedCount = 0;
            long result = 1;
            for (int i = 1; i < max + 1; i++)
            {
                if (maxCount[i] == 0) continue;
                if (i - usedCount < maxCount[i]) return 0;

                result *= combination(i - usedCount - 1, maxCount[i] - 1);
                result %= MOD;
                if (isFixed[i])
                {
                    result *= factorial[maxCount[i] - 1];
                    result %= MOD;
                }
                else
                {
                    result *= factorial[maxCount[i]];
                    result %= MOD;
                }
                usedCount += maxCount[i];
            }
            return result;
        }
        public static void combInit(long _max, long _mod)
        {
            combMax = _max;
            combMOD = _mod;
            factorial = new long[combMax];
            inverse = new long[combMax];
            factInv = new long[combMax];

            factorial[0] = factorial[1] = 1;
            factInv[0] = factInv[1] = 1;
            inverse[1] = 1;

            for (int i = 2; i < combMax; i++)
            {
                factorial[i] = factorial[i - 1] * i % combMOD;
                inverse[i] = combMOD - inverse[combMOD % i] * (combMOD / i) % combMOD;
                factInv[i] = factInv[i - 1] * inverse[i] % combMOD;
            }
        }

        public static long combination(int n, int k)
        {
            if (n < k) return 0;
            if (n < 0 || k < 0) return 0;
            return factorial[n] * (factInv[k] * factInv[n - k] % combMOD) % combMOD;
        }
    }
}


Measured memory_bytes: 39488
/*

	f(i, W):- max( f( i - 1, W - e[i].w ) + e[i].v, f( i, W - e[i].w ) + e[i].v, f( i - 1, W));


*/
#include <bits/stdc++.h>

using namespace std;

const int INF = int(1e9);
const int maxo = 10001;
struct info{
	int v;
	int w;
}e[101];

int N, W, n, w, b[101][maxo];


int f( int vt, int wt ){

	if( wt < 0 )
		return -INF;

	if( wt == 0 )
		return 0;
	
	if( vt == 0 )
		return 0;

	if(b[vt][wt])
		return b[vt][wt];

	b[vt][wt] = max( f( vt - 1, wt - e[vt].w ) + e[vt].v, max( f( vt, wt - e[vt].w ) + e[vt].v , f( vt - 1, wt ) ) );
	return b[vt][wt];
}


int main( void ){

   //freopen("input.in", "r", stdin);
	scanf("%d%d", &N, &W);

	for( int i = 1; i <= N; ++i )
		scanf("%d%d", &e[i].v, &e[i].w);


	printf("%d\n", f( N, W ));

	return 0;
}

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

void excep_max(int *p, int n, int e){
  	int max = -1;
	for(int i=0; i<n; i++){
    	if(i != e){
	      	if(p[i] > max){
    	    	max = p[i];
        	}
        }
    }
  	cout << max << endl;
}

int main(){
	int n;
  	int *a = NULL;
  	cin >> n;
  	a = (int *)malloc(sizeof(int)*n);
  
  	int max = 0;
  	int sub_max = -1;
  	for(int i=0; i<n; i++){
    	cin >> a[i];
        if(a[i] >= max){
          sub_max = max;
          max = a[i];
        }else if(a[i] > sub_max){
        	sub_max = a[i];
        }
    }
  
  	for(int i=0; i<n; i++){
    	if(a[i] == max){
        	cout << sub_max << endl;
        }else{
        	cout << max << endl;
        }
    }
  	return 0;
}

Measured memory_bytes: 2432
n = int(input())
bot = [int(input()) for i in range(n)]
bot = [-1] + bot
flag = [False]*(n+1)
count = 0
i = 1
while True:
  count += 1
  if flag[i]:
    print(-1)
    break
  flag[i] = True
  if bot[i] == 2:
    print(count)
    break
  i = bot[i]

Measured memory_bytes: 7852
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::*,
    std::{cmp::*, collections::*, convert::*, iter::*, marker::*, mem::*, ops::*},
};
fn main() {
    input! {//
        n:usize,
        mut d:[(usize,usize);n],
    }
    let mut ok = false;
    for i in 2..n {
        if d[i - 2].0 == d[i - 2].1 && d[i - 1].0 == d[i - 1].1 && d[i].0 == d[i].1 {
            ok = true;
        }
    }
    yn(ok);
}

pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string query(ll n)
{
	string answer="";
	while(n>0)
	{
		n-=1;
		answer+=string(1,'a'+n%26);
		n/=26;
	}
	reverse(answer.begin(),answer.end());
	return answer;
}
int main()
{
	ll n;
	cin>>n;
	cout<<query(n)<<endl;
	return 0;
}

Measured memory_bytes: 3628
n=int(input())
s=[input() for _ in range(n)]
ans={}
for i in range(len(s)):
    if(s[i] not in ans):
        ans[s[i]] = 1
    else:
        ans[s[i]] += 1
ans=sorted(ans.items(), key = lambda x:x[1], reverse = True)
anss=[]
anss.append(ans[0][0])
for j in range(1,len(ans)):
    if(ans[j][1] == ans[0][1]):
        anss.append(ans[j][0])
    else:
        break
for t in sorted(anss):
    print(t)

Measured memory_bytes: 44800
import Data.Array
import Data.List

main = do
  getLine
  li <- getLine
  let ls = map read $ words li
  let ans =compute ls
  print ans

compute :: [Int] -> Int
compute ls = ans
  where
    ls1@(l0:l1:ls2) = sort ls
    ar0 = accumArray (+) 0 (2,2000) [(l0+l1,1)]
    (_,_,ans) = foldl' step (ar0,2,0) ls2

    step (ar,i,acc) c = (ar1, succ i, acc+cnt)
      where
        cnt = sum [ ar ! j | j <- [succ c..2000]]
        ar1 = accum (+) ar $ [ (c + j, 1) | j <- take i ls1 ]


Measured memory_bytes: 3452
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        
        if(n%2 == 0){
            ans = n;
        }else{
            ans = n*2;
        }
        System.out.println(ans);
    }
}

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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <math.h>

int main() {

    long long int n;
    cin >> n;

    vector< long long int > a( n );
    vector< long long int > b( n );

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

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

    if ( ( n % 2 ) == 0 ) {
        cout << b[ n / 2 - 1 ] + b[ n / 2 ] - a[ n / 2 - 1 ] - a[ n / 2 ] + 1 << endl;
    } else {
        cout << b[ n / 2 ] - a[ n / 2 ] + 1 << endl;
    }

    return 0;

}


Measured memory_bytes: 6428
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,mx=0,x=0;
  string s;
  cin>>n;
  cin>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='I'){
      x++;
      mx=max(x,mx);
    }else{
      x--;
    }
  }
  cout<<mx<<endl;
}

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

#define       sf                 scanf
#define       pf                 printf
#define       pb                 push_back
#define       sz                 200005
#define       inf                0x3f3f3f3f
#define       MOD                1000000007
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);

using namespace std;

typedef       long long int      ll;

int r, c, m;

char a[10][10];

bool func(int x, int y)
{
	// cout << x << " " << y << endl;

	set <int> rs, cs;

	int cn = 0;

	for(int i = 0; i < r; i++) if((x&(1<<i))) rs.insert(i);
	for(int i = 0; i < c; i++) if((y&(1<<i))) cs.insert(i);

	for(int i = 0; i < r; i++)
	{
		for(int j = 0; j < c; j++)
		{
			if(!rs.count(i) and !cs.count(j) and a[i][j]=='#') cn++;
		}
	}

	if(cn==m) return true;
	else return false;
}

int main()
{
    // READ
    optimize

    int ans = 0;

    cin >> r >> c >> m;

    for(int i = 0; i < r; i++)
    	for(int j = 0; j < c; j++)
    		cin >> a[i][j];

    for(int i = 0; i <= pow(2, r)-1; i++)
    {
    	for(int j = 0; j <= pow(2, c)-1; j++)
    	{
    		if(func(i, j)) ans++;
    	}
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= x; i++) {
    if (2 * i + 4 * (x-i) == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

int main () {
    int N, K, tmp, cnt = 0;
    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        if (tmp >= K) {cnt++;}
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
///#include<bits/stdc++.h>
#include <iterator>
#include<algorithm>
#include<vector>
#include<complex>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<math.h>
#include<map>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include <iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<math.h>
#include<map>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include<map>
#include<sstream>
using namespace std;



/// Info.
///****************************************************************************************************************************************///
/// Coder               : BAHAA El_DEEN OSAMA SAYED.
/// Problem name        : C-AtCoder Crackers
/// Method              : IM
/// Date                : 1/3/2020
///****************************************************************************************************************************************///


#define rep0(i,x)         for(int i=0; i<x ;++i)
#define all(v)           ((v.begin()),((v.end())
#define mm(v,d)          memset(v,d,sizeof(v))
#define lp(i,v)          for(int i=0;i<sizeof(v);++i)
#define lpi(i,j,n)       for(int i=(j);i>=(int)n;++i)
#define lpd(i,j,n)       for(int i=(j);i>=(int)n;--i)
#define MP               make_pair
#define SZ(v)            ((int) ( (v).size() ) )
#define ull              unsigned long long
#define ll               long long
#define pi               3.1415926536
#define oo               1e9
#define OO               1e18
#define Fx(n)            fixed<<setprecision(n)
#define FasterIO           std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define RE0              return 0
#define RE1              return 1
#define mp(a,b)          make_pair(a,b)
#define X                first
#define Y                second
#define pii              pair(int a, int b)
#define rep1(i,x)        for(int i=1;i<x;++i)
#define rep2(i,x)        for(int i=2;i<x;++i)
#define RE               return
//#define LD               long double
#define all(v) ((v).begin()),((v).end())


const  int  N   = (int) 1e5+100;
const  int  M   = (int) 1e4+4;
const  int  INF = (int) 0x3f3f3f3f;
///const double ESP = 1e-7;
///const ll MOD=1e8+9;


int a=0,b=0;


void GalhO0O0O0O0O0M()
{
cin>>a>>b;
(a%b==0)? cout << a%b : cout<< 1   ;
}




int main()
{
FasterIO;
GalhO0O0O0O0O0M();
RE0;}


Measured memory_bytes: 256
import math as m

def has_odd_digits(i):
  if i > 10**5:
    raise Exception("?")
  if 0 <= i and i <= 9:
    return True
  elif 100 <= i and i <= 999:
    return True
  elif 10000 <= i and i <= 99999:
    return True
  return False

n = int(raw_input())
# 1 digit = 10
# 3 digit = 9*10*10 = 900
# 5 digit = 9*10*10*10*10 = 90000
x = m.log(n, 10)

p = 0
for i in xrange(n):
  if has_odd_digits(i+1):
    p += 1
print p


Measured memory_bytes: 2568
s = input()
n = len(s)
MOD = 10**9 + 7
dp = [[0]*13 for _ in range(n+1)]
# dp[i][j]は先頭からi文字目を見た時の13でわったあまりがjのものの数

dp[0][0] = 1
#print(dp[0])
for i in range(n):
    if s[i] != "?":
        for j in range(13):
            dp[i+1][(10*j+int(s[i])) % 13] = dp[i+1][(10*j+int(s[i])) % 13] + dp[i][j] % MOD
    else:
        for k in range(10):
            for j in range(13):
                dp[i+1][(10*j+k) % 13] = dp[i+1][(10*j+k) % 13] + dp[i][j] % MOD
print(dp[n][5]%MOD)


Measured memory_bytes: 63892
from collections import deque
n, m = map(int, input().split())
p = [tuple(map(int, input().split())) for _ in range(m)]

d = dict()
for a, b in p:
    if a not in d.keys():
        d[a] = [b]
    else:
        d[a].append(b)
    if b not in d.keys():
        d[b] = []

node = deque()
node.append((1, 0))
visit = set()
while node:
    (s, count) = node.popleft()
    if s in visit:
        continue
    if s == n:
        if count == 2:
            print('POSSIBLE')
            exit()
        else:
            break
    for i in d[s]:
        node.append((i, count+1))
    visit.add(s)
print('IMPOSSIBLE')


Measured memory_bytes: 67784
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#define ll long long
using namespace std;
int main()
{
    int n,i,j;
    char a[100010],b[100010];
    scanf("%s",&a);
    n=strlen(a);
    for(i=0;i<=n;i++)
    {
        if(i%2==0)
            b[i/2]=a[i];
    }
    printf("%s",b);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int,int>
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int i=n/100,j=n%100;
    if(j<=i*5)cout<<1<<endl;
    else cout<<0<<endl;
}


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

int main(){
	string a;
	cin>>a;
	for(int i=0; i<a.length(); i++){
		if(a[i]=='0'){
			if(a[i+1]=='U'){
				cout<<"nn";
				i++;
				continue;
			}
			cout<<'w';
		}
		if(a[i]=='2')cout<<'k';
		if(a[i]=='3')cout<<'s';
		if(a[i]=='4')cout<<'t';
		if(a[i]=='5')cout<<'n';
		if(a[i]=='6')cout<<'h';
		if(a[i]=='7')cout<<'m';
		if(a[i]=='8')cout<<'y';
		if(a[i]=='9')cout<<'r';
		if(a[i]=='T')cout<<'a';
		if(a[i]=='L')cout<<'i';
		if(a[i]=='U')cout<<'u';
		if(a[i]=='R')cout<<'e';
		if(a[i]=='D')cout<<'o';
	}
	cout<<endl;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
const double pi=acos(-1.0);
int n,X1,X2,Y1,Y2,fx,fy,s[maxn],top;
struct point{
	int x,y;
}p[maxn];
bool cmp(point a,point b){return a.x==b.x?a.y<b.y:a.x<b.x;}
double ans;
int main()
{
	X1=read();Y1=read();X2=read();Y2=read();
	fx=X1>X2?-1:1;fy=Y1>Y2?-1:1;X1*=fx;X2*=fx;Y1*=fy;Y2*=fy;
	n=read();
	for(int i=1;i<=n;i++)
	{
		p[i].x=read()*fx,p[i].y=read()*fy;
		if(p[i].x<X1 || p[i].x>X2 || p[i].y<Y1 || p[i].y>Y2) n--,i--;
	}
	X1=X2-X1;Y1=Y2-Y1;
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=n;i++)
	if(top==0 || s[top]<p[i].y)s[++top]=p[i].y;
	else s[(lower_bound(s+1,s+1+top,p[i].y)-s)]=p[i].y;
	ans=X1*100.0+Y1*100.0+(double)top*(pi*5.0-20.0);
	if(top==min(X1+1,Y1+1)) ans+=pi*5;
	printf("%.11lf\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
vector<int>g[110000];
int dfs(int a,int b){
	int ret=0;
	int z=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		int tmp=dfs(g[a][i],a);
		if(tmp==0)z++;
		ret+=tmp;
	}
	if(z>1)ret+=z-1;
	return ret;
}
vector<int>V;
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);
		g[p].push_back(q);g[q].push_back(p);
	}
	for(int i=0;i<a;i++)if(g[i].size()==1)V.push_back(i);
	int ret=mod;
for(int i=0;i<10;i++){
	ret=min(ret,dfs(V[rand()%V.size()],-1));
}
	ret++;
	printf("%d\n",ret);
}

Measured memory_bytes: 13696
import java.util.Scanner;

public class Main {

	
	/**２つのn次元ベクトルが与えられるので、それぞれの
	 * ミンコフスキー距離を求めるプログラム
	 * 
	 * @param args inputベクトルの次元、ｘ座標、ｙ座標 output: 1、2、3、∞ それぞれの距離
	 */
	
	static Scanner scan = new Scanner(System.in);
	public static void main(String[] args){

		int vec_num = scan.nextInt();
		//int vec_num = Integer.parseInt(args[0]);
		//p = 1
		double D_1 =0;
		double D_2 = 0;
		double D_3 = 0;
		double D_inf = 0;
		
		//一時的に入力されたｘとｙの座標を別々に格納する
		double[] tmp_x = new double[vec_num];
		double[] tmp_y = new double[vec_num];
		for(int i = 0; i< vec_num;i++){
			tmp_x[i] = scan.nextDouble();
			}
		for(int i = 0; i < vec_num;i++){
			tmp_y[i] = scan.nextDouble();
		}

		//ミンコフスキー距離を求める
		for(int i = 0; i<vec_num;i++){
			double x = tmp_x[i];
			double y = tmp_y[i];

			D_1 = D_1 + Math.abs(x - y );
			D_2 = D_2 + Math.pow(Math.abs(x - y), 2);

			D_3 = D_3 + Math.pow(Math.abs(x - y), 3);
			if(D_inf < Math.abs(x-y)){
				D_inf = Math.abs(x-y);
			}
		}


		D_2 = Math.sqrt(D_2);
		D_3 = pow_1_3(D_3);
		System.out.println(D_1);
		System.out.println(D_2);
		System.out.println(D_3);
		System.out.println(D_inf);
		//p = 2

		//p = 3

		//p = ∞
	}
	//3乗根を求める
	//powの近似値→Newton法の漸化式
	static double pow_1_3(double a){
		double x = Math.pow(a, 1./3);
		if(x != 0){
			return (2 * x + a / x / x ) /3;
		}else{//0では割り切れないので別途対応
			return 0;
		}

	}
}


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

int main() {
    int a;
    cin >> a;
    if(a) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;

int R[260], I[260], O[260];

int s, a, c, n, m = 256;
int ans[3];
double H, min_H;

int main(void){
	int i, j;
	while(cin >> n, n){
		for(i = 1; i <= n; i++) cin >> I[i];
		min_H = 100;
		for(s = 0; s <= 15; s++){
			for(a = 0; a <= 15; a++){
				for(c = 0; c <= 15; c++){
					H = 0;
					memset(R, 0, sizeof(R));
					memset(O, 0, sizeof(O));
					R[0] = s;
					for(i = 1; i <=  n; i++){
						R[i] = (a * R[i-1] + c) % m;
						O[i] = (I[i] + R[i]) % m;
					}
					int cnt[256] = {0};
					for(i = 1; i <= n; i++) cnt[O[i]]++;
					for(i = 0; i < 256; i++){
					       	if(!cnt[i]) continue;
						H -= cnt[i] * log(cnt[i]);
					}
					if(min_H > H){
						ans[0] = s; ans[1] = a; ans[2] = c;
						min_H = H;
					}
				}
			}
		}
		cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int n;
    cin >> n;

    int ten_sum = 0;
    int one_sum = 0;
    vector<int> nums(n);
    rep(i, n){
        int num;
        cin >> num;
        ten_sum += num / 10;
        one_sum += num % 10;
        nums[i] = num;
    }

    sort(all(nums));
    for(int idx = 0; idx < nums.size() && one_sum % 10 == 0; idx++){
        if(nums[idx] % 10 != 0){
            ten_sum -= nums[idx] / 10;
            one_sum -= nums[idx] % 10;
        }
    }

    int out = ten_sum * 10 + one_sum;
    if(out % 10 == 0) out = 0;
    cout << out << endl;
}

Measured memory_bytes: 256
n,q = gets.split.map(&:to_i)
s = gets.chomp.chars
qs = []
q.times do
  qs << gets.split.map(&:to_i)
end

h = {}
n.times do |i|
  h[i+1] = 0
  next if i == 0
  if (s[i - 1] + s[i]) == "AC"
    h[i+1] = h[i] + 1
  else
    h[i+1] = h[i]
  end
end

qs.each do |q|
  puts h[q[1]] - h[q[0]]
end


Measured memory_bytes: 32764
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> arr(N);
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    tmp--;
    arr[tmp] = i;
  }
  int ans = 0;
  tmp = 1;
  for(int i=1;i<N;++i) {
    if(arr[i-1]<arr[i]) {
      tmp++;
    }
    else {
      ans = max(ans, tmp);
      tmp = 1;
    }
  }
  ans = max(ans, tmp);
  cout<<N-ans<<endl;
}



Measured memory_bytes: 4044
#!/usr/bin/env python3
import sys


def solve(N: int, P: "List[int]"):
    P.sort(reverse=True)
    print(int(P[0]/2 + sum(P[1:])))

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, p)

if __name__ == '__main__':
    main()


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

int a[100005];

int main()
{
	int n, k;
	cin>>n >>k;
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
	}
	sort(a, a+n);
	int minn=a[n-1]-a[0];
	for(int i=0; i<=n-k; i++)
	{
		int f=i, b=k+i-1;
		minn=min(minn, a[b]-a[f]);
	}
	cout<<minn;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
  int i, x, n;
  scanf(" %d", &n);
  i = 1;
  do {
    x = i;
    if (x % 3 == 0) {
      printf(" %d", i);
      continue;
    }
    do {
      if (x % 10 == 3) {
	printf(" %d", i);
	break;
      }
      x /= 10;
    } while (x);
  } while (++i <= n);
  printf("\n");
  return 0;
}



Measured memory_bytes: 1828
#include <iostream>

int main()
{
    std::ios_base::sync_with_stdio(0);
    int n;
    std::cin >> n;
    for (int i=1;i<10;++i)
    {
        if (n%i == 0 && n/i < 10)
        {
            std::cout << "Yes";
            return 0;
        }
    }
    std::cout << "No";
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);
#define nl printf("\n");
#define _FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull; 

int main() {
  int n, t =0, x =0, y =0;
  bool bisa = true;
  cin>>n;
  for (int i = 0; i < n; ++i)
  {
  	int tempT, tempX, tempY;
  	cin>> tempT >> tempX >> tempY;
  	if (bisa)
  	{
  		int banyakJalanMungkin = tempT-t;
  		int banyakJalan = abs(x- tempX) + abs(y- tempY);

  		if (banyakJalanMungkin == banyakJalan)
  		{
  			x = tempX;
  			y = tempY;
  			t = tempT;
  		} else if (banyakJalanMungkin > banyakJalan) {
  			int testHitung = banyakJalanMungkin - banyakJalan;
  			if (testHitung%2 == 0)
  			{
  				x = tempX;
  				y = tempY;
  				t = tempT;
  			} else {
  				bisa = false;
  			}
  		} else {
  			bisa = false;
  		}
  	}
  }

  if (bisa)
  {
  	printf("Yes\n");
  } else {
  	printf("No\n");
  }

  return 0;
}




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

int main(void){


int len;
char s[200000];

scanf("%s",s);

len = strlen(s);

for(int i = 0;i<len;i++){

        if(s[i] == '?'){
                s[i] = 'D';
        }   

}

printf("%s\n",s);

return 0;
}

Measured memory_bytes: 1840
#include<bits/stdc++.h>
using namespace std;
int jdz(int t)
{
	if(t>=0) return t;
	return -t;
}
int bj1(int m,int n)
{
	if(m>=n) return m;
	return n;
}
int bj2(int m,int n)
{
	if(m<=n) return m;
	return n;
}
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(jdz(a-c)<=d) cout<<"Yes";
	else if(bj1(a,c)<=b||bj2(a,c)>=b) cout<<"No";
	else if(jdz(a-b)<=d&&jdz(b-c)<=d) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int res=0;
    for(int i=0; i < 2; i++){
        if(a<b){
            res += b;
            b --;
        }else{
            res += a;
            a --;
        }

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


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

int main(int argc, const char * argv[]) {
    int input, n = 1;
    cin >> input;
    while (input != 0){
        printf("Case %d: %d\n",n,input);
        n++;
        cin >> input;
    }
    return 0;
}



Measured memory_bytes: 3120
package main

import (
	"fmt"
)

func main() {
	var x int
	fmt.Scan(&x)

	ans := 1
	for b := 2; b*b <= x; b++ {
		v := b
		var e int
		for v <= x {
			e = v
			v *= b
		}
		ans = max(ans, e)
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


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

int main() {
  int N, A;
  cin >> N >> A;
  if (N % 500 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 500 < A) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s==u)
    a -= 1;
  else if(t==u)
    b -= 1;

  cout << a << " " << b << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
#include <iomanip>
int main(int argc, char const *argv[]) {
  int N;
  std::cin >> N;
  std::vector<long double> V(N);
  for(int i=0;i<N;i++) std::cin >> V[i];
  sort(V.begin(), V.end());
  long double ans = 0;
  ans = (V[0] + V[1])/2;
  for(int i=2;i<N;i++){
    ans = (ans + V[i])/2;
  }
  std::cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
L=[];
P=[];

def dfs(n,x):
    if(x==0):
        return 0;
    if(n==0):
        return 1;
    if(x==1):
        return 0;
    if(x>=L[n]-1):
        return P[n];
    nx=x-1;
    if(nx<=L[n-1]):
        return dfs(n-1,nx);
    if(nx==L[n-1]+1):
        return P[n-1]+1;
    if(nx>L[n-1]+1):
        return P[n-1]+1+dfs(n-1,nx-(L[n-1]+1));
    
def main():
    N,X = input().split();
    n=int(N);
    x=int(X);
    for i in range(0,51):
        L.append(0);
        P.append(0);
    L[0]=1;
    P[0]=1;
    for i in range(1,n+1):
        L[i]=L[i-1]*2+3;
        P[i]=P[i-1]*2+1;
    print(dfs(n,x));
    
main();


Measured memory_bytes: 3064
public class Main{
  static int top;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int w, h, i, j, res;
    int[][] c;
    int[] nowx, nowy;

    for(;;){
      w = sc.nextInt(); h = sc.nextInt();
      if(w == 0 && h == 0)break;
      c = new int[h][w];
      nowx = new int[h * w]; nowy = new int[h * w];
      for(i = 0;i < h;i++)for(j = 0;j < w;j++)c[i][j] = sc.nextInt();
      res = 0;

      for(i = 0;i < h;i++)for(j = 0;j < w;j++){
        if(c[i][j] == 1){
          res++; top = 0; c[i][j] = 0;
          pushxy(nowx, nowy, i, j);
          for(;top != 0;){
            i = popx(nowx); j = popy(nowy);
            if(i != 0 && c[i - 1][j] == 1){
              c[i - 1][j] = 0; pushxy(nowx, nowy, i - 1, j);
            }
            if(i != 0 && j != 0 && c[i - 1][j - 1] == 1){
              c[i - 1][j - 1] = 0; pushxy(nowx, nowy, i - 1, j - 1);
            }
            if(i != 0 && j != w - 1 && c[i - 1][j + 1] == 1){
              c[i - 1][j + 1] = 0; pushxy(nowx, nowy, i - 1, j + 1);
            }
            if(j != 0 && c[i][j - 1] == 1){
              c[i][j - 1] = 0; pushxy(nowx, nowy, i, j - 1);
            }
            if(j != w - 1 && c[i][j + 1] == 1){
              c[i][j + 1] = 0; pushxy(nowx, nowy, i, j + 1);
            }
            if(i != h - 1 && c[i + 1][j] == 1){
              c[i + 1][j] = 0; pushxy(nowx, nowy, i + 1, j);
            }
            if(i != h - 1 && j != 0 && c[i + 1][j - 1] == 1){
              c[i + 1][j - 1] = 0; pushxy(nowx, nowy, i + 1, j - 1);
            }
            if(i != h - 1 && j != w - 1 && c[i + 1][j + 1] == 1){
              c[i + 1][j + 1] = 0; pushxy(nowx, nowy, i + 1, j + 1);
            }
          }
          i = 0;j = 0;
        }
      }
      out.println(res);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }

  private static int popx(int[] stack){
    return stack[--top];
  }
  private static int popy(int[] stack){
    return stack[top];
  }
  private static void pushxy(int[] stack1, int[] stack2, int x, int y){
    stack1[top] = x;
    stack2[top++] = y;
    return;
  }
}

Measured memory_bytes: 42852
#include <bits/stdc++.h>
using namespace std;
long long bin[30], ps;
int main()
{
    long long s;
    bin[0] = 1;
    for (int i = 1; i < 30; i++) bin[i] = bin[i - 1] * 26;
    bin[0] = 1;
    scanf("%lld", &s);
    ps = s;
    int len;
    for (int i = 1; i < 30; i++) {
        if (s <= bin[i]) {
            len = i;
            break;
        } else
            s -= bin[i];
    }
    long long ys = 0;
    for (int i = len; i >= 1; i--) {
        if (i > 1) {
            printf("%c", (s % bin[i - 1] == 0 ? s / bin[i - 1] - 1 : s / bin[i - 1]) + 'a');
        } else {
            printf("%c", s + 'a' - 1), ys += s * bin[i - 1];
        }
        s -= (s % bin[i - 1] == 0 ? s / bin[i - 1] - 1 : s / bin[i - 1]) * bin[i - 1];
    }
    // printf("\n%d", ys == ps);
    return 0;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s=="RRR")cout<<3<<endl;
    else if(s=="RRS"||s=="SRR")cout<<2<<endl;
    else if(s=="SSS")cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	ll h, w; cin >> h >> w;
	vector<vector<ll>> v1(h, vector<ll>(w));
	vector<ll> v2(w);
	rep(i, h)
		rep(j, w)
		cin >> v1[i][j];
	rep(i, w) {
		cin >> v2[i];
	}
	rep(i, h) {
		ll ans = 0;
		rep(j, w) ans += v1[i][j] * v2[j];
		cout << ans << endl;
	}
}


Measured memory_bytes: 3184
import sys
# from heapq import heappop, heappush
from collections import deque
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline

N, M = map(int, input().split())
check_lst = [0] * N
lst = [[] for _ in range(N)]
for _ in range(N + M - 1):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    lst[A].append(B)
    check_lst[B] += 1

n = check_lst.index(0)
ans = [0] * N
que = deque()
que.append(n)
while que:
    v = que.popleft()
    for v2 in lst[v]:
        check_lst[v2] -= 1
        if check_lst[v2] == 0:
            que.append(v2)
            ans[v2] = v + 1
print (*ans, sep = '\n')


Measured memory_bytes: 25480
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <queue>
#define ll long long int
#define maxn 300005
#define M 1000000007
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
using namespace std;

int n, m, s, t;

struct edge{
    int next, to, len;
    edge(int next, int to, int len) : next(next), to(to), len(len){}
    edge(){}
}e[maxn << 1];

int cnt = 1, h[maxn];
void Add_Edge(int x, int y, int z){
    e[++cnt] = edge(h[x], y, z);
    h[x] = cnt;
    e[++cnt] = edge(h[y], x, z);
    h[y] = cnt;
}

ll d[maxn];
queue<int> spfa;
int tim[maxn];
int ti = 0;
bool vis[maxn];
void SPFA(){
    tim[s] = ++ti;
    d[s] = 0;
    vis[s] = 1;
    spfa.push(s);
    while (!spfa.empty()){
        int x = spfa.front(); spfa.pop();
        erep(i, x){
            int op = e[i].to;
            if (tim[op] != ti || d[op] > d[x] + e[i].len){
                tim[op] = ti;
                d[op] = d[x] + e[i].len;
                if (!vis[op]){
                    vis[op] = 1;
                    spfa.push(op);
                }
            }
        }
        vis[x] = 0;
    }
}

int pre[maxn];
int suf[maxn];
int line[maxn];
bool cmp(int x, int y){
    return d[x] < d[y];
}
bool cmp2(int x, int y){
    return d[y] < d[x];
}

int main(){
    int x, y, z;
    scanf("%d%d%d%d", &n, &m, &s, &t);
    rep(i, 1, m){
        scanf("%d%d%d", &x, &y, &z);
        Add_Edge(x, y, z);
    }
    SPFA();
    rep(i, 1, n) line[i] = i;
    sort(line + 1, line + 1 + n, cmp);
    pre[s] = 1;
    rep(i, 1, n) {
        int x = line[i];
        erep(j, x){
            int op = e[j].to;
            if (d[op] == d[x] - e[j].len) pre[x] = (pre[x] + pre[op]) % M;
        }
    }
    rep(i, 1, n) line[i] = i;
    sort(line + 1, line + 1 + n, cmp2);
    suf[t] = 1;
    rep(i, 1, n){
        int x = line[i];
        erep(j, x){
            int op = e[j].to;
            if (d[op] == d[x] + e[j].len) suf[x] = (suf[x] + suf[op]) % M;
        }
    }
    int ans = 0;
    rep(i, 1, n){
        int x = line[i];
        if (d[x] << 1 == d[t]){
            ll tem = (ll)pre[x] * suf[x] % M;
            ans = (ans + tem * tem % M) % M;
        }
        else {
            erep(j, x){
                int op = e[j].to;
                if (d[op] == d[x] + e[j].len) {
                    if ((d[x] << 1) < d[t] && d[t] < (d[op] << 1)) {
                        ll tem = (ll)pre[x] * suf[op] % M;
                        ans = (ans + tem * tem % M) % M;
                    }
                }
            }
        }
    }
    printf("%lld", (M + (ll)pre[t] * pre[t] % M - ans) % M);
    return 0;
}

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


int main()
{
  int N;
  cin >> N;
  vector<int> num1(N);
  for (int &i : num1)
    cin >>i;
  
  vector<int> num(N);
  for (int i=0; i<N; i++)
    num.at(i) = num1.at(i);
  
  sort(num1.begin(),num1.end());
  int max1 = num1.at(N-1);
  int max2 = num1.at(N-2);
  
  if (max1 == max2){
    for (int i=0; i<N; i++)
      cout << max1 << endl;
      
  }
  else {
    for (int i=0; i<N; i++){
      if (num.at(i) != max1)
        cout << max1 << endl;
      
      else
        cout << max2 << endl;
    }
  }
  
  return 0;
}

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

int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n, greater<int>());
    int i = 0;
    while (i < n && i < a[i]) i++;
    i--;
    bool up = a[i] > i + 1, right = (i < n - 1 && a[i + 1] == i + 1);
    if (up && (a[i] - i) % 2 == 0) { cout << "First\n"; return 0; }
    if (right) {
        int j = i;
        while (j < n-1 && a[j+1] == i+1) j++;
        if ((j - i) % 2 == 1) { cout << "First\n"; return 0; }
    }
    cout << "Second\n";
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
/*
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma") 
*/
using namespace std;
#define pb push_back
#define ll long long
#define fi first
#define se second
#define vi vector< int > 
#define pii pair<int,int>


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
ios_base::sync_with_stdio(false);  
cin.tie(NULL);
cout.tie(NULL);
	int x; cin >> x;
	int y = __gcd(x,360);
	cout << 360/y <<'\n';


}

Measured memory_bytes: 3608
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    print(N<4||N==5||N==6||N==9||N==10||N==13||N==17?"No":"Yes");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100010

struct CARD {
	int num;
	char sym;
};

struct CARD card[MAX];
struct CARD buf[MAX];

int Partition(struct CARD card[], int sp, int ep) {
	struct CARD x = card[ep];
	int i = sp - 1;
	struct CARD buff;
	for (int j = sp; j < ep; j++) {
		if (card[j].num <= x.num) {
			i++;
			buff = card[i];
			card[i] = card[j];
			card[j] = buff;
		}
	}
	card[ep] = card[i + 1];
	card[i + 1] = x;
	return i + 1;
}

void QuickSort(struct CARD card[], int sp, int ep) {
	int q;
	if (sp < ep) {
		q = Partition(card, sp, ep);
		QuickSort(card, sp, q - 1);
		QuickSort(card, q + 1, ep);
	}
}

void ShellSort(struct CARD card[], int size) {
	int i;
	int zone;
	struct CARD buff;
	int step = 1;
	while (step <= size) {
		step = 3 * step + 1;
	}
	step = step / 3;
	while (step >0) {
		for (zone = step; zone < size; zone++) {
			buff = card[zone];
			for (i = zone - step; (i >= 0) && (card[i].num > buff.num); i = i - step) {
				card[i + step] = card[i];
			}
			card[i + step] = buff;
		}
		step = step / 3;
	}
}

int main() {
	int N;
	char bufS;
	scanf("%d\n", &N);
	for (int i = 0; i < N; i++) {
		scanf("%c %d%c", &card[i].sym, &card[i].num,&bufS);
		buf[i].num = card[i].num;
		buf[i].sym = card[i].sym;
	}
	QuickSort(card, 0, N - 1);
	ShellSort(buf, N);
	for (int i = 0; i < N; i++) {
		if (card[i].sym == buf[i].sym) {
			if (i == N - 1) {
				printf("Stable\n");
				break;
			}
			else continue;
		}
		else {
			printf("Not stable\n");
			break;
		}
	}

	for (int i = 0; i < N; i++) {
		printf("%c %d\n", card[i].sym, card[i].num);
	}
	return 0;
}



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

using namespace std;


typedef long long ll;


int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = 0;
  for(ll i = 1; i <= n; i++) {
    ans += i*(n/i)*((n/i)+1)/2;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n,c,k;
  cin>>n>>c>>k;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  sort(all(vec));

  int ans=0;
  int s = vec[0]+k, d=0;
  rep(i,n){
    if(vec[i]>s || d==c){
      ans++;
      d=0;
      s = vec[i]+k;
    }
    d++;
  }
  ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int p,q,r;
	cin >> p >> q >> r;
	cout << p+q+r-max({p,q,r}) << endl;
}


Measured memory_bytes: 256