akhauriyash/Code-Regression huggingface dataset:
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

import itertools

a = [i+1 for i in range(n)]

C = list(itertools.permutations(a))

idxs = []

for i, c in enumerate(C):
    l = list(c)
    if l == p:
        idxs.append(i)
    if l == q:
        idxs.append(i)

ans = idxs[1]-idxs[0]

print(ans)

Measured memory_bytes: 8052
#include <iostream>

using namespace std;

int main()
{
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	for (int i = 0; i < H - B; ++i) {
		for (int j = 0; j < A; ++j) {
			cout << 1;
		}
		for (int j = A; j < W; ++j) {
			cout << 0;
		}
		cout << endl;
	}
	for (int i = H - B; i < H; ++i) {
		for (int j = 0; j < A; ++j) {
			cout << 0;
		}
		for (int j = A; j < W; ++j) {
			cout << 1;
		}
		cout << endl;
	}
}


Measured memory_bytes: 1280
S = input()
S_list = list(S)
n = len(S) 
a = []

list_0or1 = [0] * (n-1)
check = []

def f(i):
    if i == n-1 :
        check.append(list_0or1.copy())
    if i != n-1:
        list_0or1[i] = 0
        f(i+1)
    if i != n-1:
        list_0or1[i] = 1
        f(i+1)
f(0)

sum_list = []
for i in range(len(check)):
    S_list_copy = S_list.copy()
    for j in range(n-1) :
        if check[i][j] == 1 :
            S_list_copy[j+1] = '+' + S_list_copy[j+1]
    S_list_copy = ''.join(S_list_copy)
    S_list_copy = list(map(int,S_list_copy.split('+')))
    s = sum(S_list_copy)
    sum_list.append(s)
print(sum(sum_list))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
int a[100005];
int main()
{
	int n,k;
	long long ans=0;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		if(a[i]+a[i-1]>k)
		{
			ans+=a[i]+a[i-1]-k;
			a[i]=k-a[i-1];
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 640
def z_algo(s):
    N = len(s)
    A = [0]*N
    i = 1; j = 0
    l = len(s)
    A[0] = l
    while i < l:
        while i+j < l and s[j] == s[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k

    # 自身は含まない
    for i in range(N):
        A[i] = min(A[i],i)
    #
    return A

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

N = I()
S = str(input())
cur = int(0)
ans = int(0)
lenC = []

for i in range(N):
#    print(z_algo(S[i:]))
    lenC.append(max(z_algo(S[i:])))

#print(lenC)
ans = max(lenC)
print(ans)

Measured memory_bytes: 48092
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
template<typename T>
inline void read(T& s)
{
    s=0;int f=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){s=s*10+c-'0';c=getchar();}
    s*=f;
}
typedef pair<int,int> pi;
pi mp(int a,int b)
{
	return make_pair(a,b);
}
int n;
int s[200005];
//int hs[200005];
int dell[200005];
int tot;
bool gg=0;
pi q[200005];
int top=0;
int kkk;
void add(int pos)
{
	if(pos<=0)
	{
		gg=1;
		return;
	}
	if(top==0 || q[top-1].first<pos)
	{
		q[top++]=mp(pos,1);
		return;
	}
	int sb=q[top-1].second+1;
	if(sb<kkk)
	{
		q[top-1].second++;
		return;
	}
	top--;
	add(pos-1);
}
bool check(int x)
{
	gg=0;
	kkk=x;
	top=0;
	for(int i=1;i<n;i++)
	{
		if(s[i]>s[i-1])	continue;
		while(top && q[top-1].first>s[i])	top--;
		add(s[i]);
		if(gg==1)	return 0;
	}
	return 1;
}
int main()
{
	read(n);
	bool fg=0;
	for(int i=0;i<n;i++)
		read(s[i]);
	for(int i=1;i<n;i++)
		if(s[i-1]>=s[i])
		{
			fg=1;
			break;
		}
	if(fg==0)
	{
		cout<<1<<endl;
		return 0;
	}
	int l=2,r=n;
	while(l!=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))	r=mid;
		else	l=mid+1;
	}
	cout<<l<<endl;
    return 0;
}

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

int N,K;
vector<int>A,B;
int main(){
  cin>>N>>K;
  B.push_back(0);
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    if(x<0)A.push_back(-x);
    else B.push_back(x);
  }
  while(B.size()<=K)B.push_back(1e9);
  int ans = B[K], cnt=0;
  for(auto it=A.rbegin();it!=A.rend();it++){
    cnt++;
    ans = min(ans, B[K-cnt]+2*(*it));
    ans = min(ans, 2*B[K-cnt]+(*it));
  }
  cout<<ans<<'\n';
}

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

int main() {
    string S;
    int N, ans=0;
    cin >> S;
    if(S[2]==S[3] && S[4]==S[5])
	cout << "Yes" << endl;
    else
	cout << "No" << endl;
} 




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.E
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs();
            var all = 0L;
            for (int i = 0; i < N; i++)
            {
                all ^= a[i];
            }

            return string.Join(" ", a.Select(x => (all ^ x).ToString()).ToArray());
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

using namespace std;

#define MAX 100005

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

vector<pll> adj[MAX];
vector<int> col(MAX);

void dfs(ll n, ll p, ll ds){
    if(ds&1)
        col[n] = 1;
    else
        col[n] = 0;
    for(auto e : adj[n])
        if( e.first != p )
            dfs(e.first, n, ds+e.second);
}

int main(){

    int n;
    cin >> n;
    ll a, b, c;
    for(int i = 0; i < n-1; i++){
        cin >> a >> b >> c;
        a--, b--;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }
    dfs(0, -1, 0);
    for(int i = 0; i < n; i++)
        cout << col[i] << endl;
    return 0;
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define mx 100005
#define PLL pair<ll,ll>

ll dp[2003];

ll F(ll sum)
{
    if(sum==0) return 1;
    if(sum<0) return 0;
    if(dp[sum]!=-1) return dp[sum];

    ll ret = 0;

    for(ll i = 3;i<=sum;i++)
    {
        ret = ret + F(sum-i);
        ret%=mod;
    }

    return dp[sum] = ret;
}

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

    ll s;
    cin>>s;

    memset(dp,-1,sizeof dp);
    cout<<F(s)<<endl;





    return 0;
}


Measured memory_bytes: 3652
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class WeightedUnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes
        self.parents = [-1] * n_nodes

        # 親への重みを管理
        self.weights = [0] * n_nodes

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            parent = self.find(self.parents[x])
            # 親への重みを追加しながら根まで走査
            self.weights[x] += self.weights[self.parents[x]]
            self.parents[x] = parent
            return parent

    # xからyへの重みがw
    def unite(self, x, y, w):
        w += self.weights[x]
        w -= self.weights[y]
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x
            w *= -1

        self.parents[x] += self.parents[y]
        self.parents[y] = x
        self.weights[y] = w
        return

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへの重みの取得
    def get_weight(self, x, y):
        return self.weights[y] - self.weights[x]

    def get_size(self, x):
        return -self.parents[self.find(x)]

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

    def get_parent_list(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def get_n_groups(self):
        return len(self.get_parent_list())

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M = map(int, input().split())
    tree = WeightedUnionFind(N)
    flag = True
    for _ in range(M):
        l, r, d = map(int, input().split())
        l -= 1
        r -= 1
        if not tree.is_same(l, r):
            tree.unite(l, r, d)
        else:
            if tree.get_weight(l, r) == d:
                continue
            else:
                flag = False

    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 8932
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string S, T;
    cin >> S >> T;
    if (S == T.substr(0, S.length()) && (S.length() + 1) == T.length()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    

    vector<int> colors{r,g,b};
    sort(colors.begin(), colors.end());
    vector<vector<int>> cs(3, vector<int> (3001));
    for (int j =0; j < colors.size(); ++j) {
        cs[j][colors[j]]++;
    }

    for (int i = 1; i <= n; ++i) {
        for (int j =0; j < colors.size(); ++j) {
            cs[0][i] += cs[j][max(i-colors[0],0)];
        }
        cs[1][i] += cs[1][max(i-colors[1],0)];
        cs[1][i] += cs[2][max(i-colors[1],0)];
        cs[2][i] += cs[2][max(i-colors[2],0)];
    }
    cout << cs[0][n] + cs[1][n] + cs[2][n] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = s; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    string n; 
    cin >> n;
    string ans = "No";
    REP(i, 3) if (n[i] == '7') ans = "Yes";
    cout << ans << endl; 
    return 0;
}

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

int main()
{
    string s;
    cin>>s;
    int a = 2019;
    int p = 1, n = 0;
    long long cnt[2019] = {0}, ans = 0;
    cnt[0]=1;
    for (int i = s.length() - 1; i >= 0; i--)
    {
        int d = s[i] - '0';
        d = (d * p) % a;
        p = (p * 10) % a;
        n = (d + n) % a;
        // cout<<n<<"\n";
        ans += cnt[n];
        cnt[n]++;
    }
    cout<<ans;
}

Measured memory_bytes: 3772
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

// I'm trying to ~~~
int main(){
    string A; cin >> A;
    int res = 0;
    rep(i,4){
        if(A[i]=='+') res++;
        else res--;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll M = 1000000000;
ll gcd(ll a, ll b){
  if(a==0) return b;
  else return gcd(b%a, a);
}
int main(){
    ll N, K;
    cin >> N >> K;

    ll Max = 0;
    ll A;
    ll GCD;

    for(ll i=0;i<N;i++){
      cin >> A;
      Max = max(A, Max);
      GCD = gcd(A, GCD);
    }

    if(K<=Max && K%GCD==0){
      cout << "POSSIBLE" <<endl;
      return 0;
    }
    cout << "IMPOSSIBLE" <<endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		String ans = "";

		if (X == 25) {
			ans = "Christmas";
		} else if ( X == 24 ) {
			ans = "Christmas Eve";
		} else if ( X == 23 ) {
			ans = "Christmas Eve Eve";
		}else if ( X == 22 ) {
				ans = "Christmas Eve Eve Eve";
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 23764
## abc070c: Multiple Clocks

def gcm(q,r): ## 最大公約数
    if q<r: q, r = r, q
    while(r>0):
        q, r = r, q%r,
    return q

def lcm(a,b): ## 最小公倍数
    if a==b: return a
    return a*b//gcm(a,b)

n = int(input())
t = [int(input()) for _ in range(n)]
for i in range(n-1):
    l = lcm(t[i],t[i+1])
    t[i+1] = l
print(t[n-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int k;
  string s;
  cin>>k>>s;
  int size=s.size();
  if(size<=k){
    cout<<s<<endl;
  }else{
    string output=s.substr(0,k);
    cout<<output;
    cout<<"..."<<endl;
  }
  return 0;
}

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


int main(){
  ll a[5],memo = 0;
  ll cnt = LINF;
  rep(i,0,5){
    cin >> a[i];
  }

  do{
    memo = 0;
    rep(i,0,5){
      memo += a[i];
      if(i != 4 && a[i] % 10)memo += 10 - a[i] % 10;
    }

    cnt = min(cnt,memo);
  }while(next_permutation(a,a+5));
  

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

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,-1,-1):
  x=0
  s=2**i
  for j in range(l):
    if b[j]&(ans+s)==ans+s:x+=1
  if x>=k:ans+=s
print(ans)

Measured memory_bytes: 65916
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
#define pi 3.141592653589
using namespace std;
ll n, ans = 0; ll a[114514]; pair<ll, ll>memo[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n)memo[i].first = a[i];
	rep(i, n)memo[i].second = i;
	sort(memo, memo + n);
	rep(i, n) {
		if (abs(memo[i].second - i) % 2 == 1)ans++;
	}
	cout << ans / 2 << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
using P = pair<int,int>;
using ivec = vector<int>;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const int MOD=1000000007;
int INF=100100100100100;
int add(int a,int b){
  return (a+b)%MOD;
}
int prod(int a,int b){
  return (a*b)%MOD;
}

int beki(int a,int b)
{
	if(b==0)return 1;
	int x=beki(a,b/2);
	if(b%2==0)return (x*x)%MOD;
	else return (((a*x)%MOD)*x)%MOD;
}

int inv(int a)
{
	return beki(a,MOD-2);
}

int kaijou(int a)
{
	int ans=1;
	for(int i=1;i<=a;i++)
	{
		ans=(ans*i)%MOD;
	}			
	return ans;
}

/*int combi(int a,int b)
{
	int ret=1;
	for(int i=1;i<=b;i++)
	{
		ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
	}
	return ret;
}*/
/*
const int MAX_a=200010;
int cb[MAX_a+1]
void combi(int a,int b)
{
    int ret=1;
    cb[0]=1;
    for(int i=1;i<=b;i++)
    {
	ret=(((ret*(a+1-i))%MOD)*inv(i))%MOD;
        cb[i]=ret;
    }
	
}*/

vector<P> prime_factorize(int N)
{
	vector<P> res;
	for(int a=2;a*a<=N;a++)
	{
		if(N%a!=0)continue;
		int ex=0;
		while(N%a==0)
		{
			ex++;N/=a;
		}
		res.push_back(P(a,ex));
	}
	if(N!=1)res.push_back(P(N,1));
	return res;
}

//ここから書く
signed main(){
  double t,x;cin>>t>>x;
  cout<<fixed<<setprecision(10)<<t/x<<endl;
  return 0;
}

Measured memory_bytes: 3796
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>


const int MAXN = 3e3 + 1;
const std::pair<int, int> END = { MAXN, MAXN };

std::string s, t;
int dp[MAXN][MAXN];
std::pair<int, int> next[MAXN][MAXN];


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

    std::fill_n((std::pair<int, int> *)next, MAXN * MAXN, END);

    std::cin >> s >> t;
    for (int iLetter = s.length() - 1; iLetter > -1; iLetter--)
        for (int jLetter = t.length() - 1; jLetter > -1; jLetter--)
        {
            int iNext = (iLetter - 1 + MAXN) % MAXN;
            int jNext = (jLetter - 1 + MAXN) % MAXN;

            if (s[iLetter] == t[jLetter])
            {
                if (iLetter == 0 || jLetter == 0)
                {
                    iNext = MAXN - 1;
                    jNext = MAXN - 1;
                }
                
                dp[iLetter][jLetter]++;
                if (dp[iLetter][jLetter] > dp[iNext][jNext])
                {
                    dp[iNext][jNext] = dp[iLetter][jLetter];
                    next[iNext][jNext] = { iLetter, jLetter };
                }
            }
            else
            { 
                if (dp[iLetter][jLetter] > dp[iNext][jLetter])
                {
                    dp[iNext][jLetter] = dp[iLetter][jLetter];
                    next[iNext][jLetter] = next[iLetter][jLetter];
                }
                if (dp[iLetter][jLetter] > dp[iLetter][jNext])
                {
                    dp[iLetter][jNext] = dp[iLetter][jLetter];
                    next[iLetter][jNext] = next[iLetter][jLetter];
                }
                if (dp[iLetter][jLetter] > dp[iNext][jNext])
                {
                    dp[iNext][jNext] = dp[iLetter][jLetter];
                    next[iNext][jNext] = next[iLetter][jLetter];
                }
            }
        }

    std::pair<int, int> pos(MAXN - 1, MAXN - 1);
    while (pos != END)
    {
        pos = next[pos.first][pos.second];
        if (pos != END)
            std::cout << s[pos.first];
    }

    std::cout << '\n';

    return 0;
}


Measured memory_bytes: 105856
#include<iostream>
using namespace std;
static const int INF=10e5;
int main(void)
{
	int N,Time;
		cin >> N >> Time;
	int res=INF;
	for(int i=0;i<N;i++){
		int a,b;
			cin >> a >> b;
		if(b<=Time)
			res=min(a,res);
	}
	if(res==INF)
		cout << "TLE" << endl;
	else 
		cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n;
    cin>>n;
    string s[n];
    map<string,ll>m;
    ll c=0;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
        sort(s[i].begin(),s[i].end());
        c+=m[s[i]];
        m[s[i]]++;
    }
    cout<<c<<endl;



}
//Alhamdulillah









Measured memory_bytes: 14540
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
#include <set>
using namespace std;




void solve()
{
	int r;
	cin >> r;
	cout << r * r;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long n = sc.nextLong();
		long m = sc.nextLong();
		long ans = 0;
		long N = Math.max(n,m);
		long M = Math.min(n,m);
		long Mod = 1000000007L;
		long a = 1;
		long b = 1;
		for( int i=1; i<=N; i++ ){
			a = (a*i)%Mod;
		}
		for( int i=1; i<=M; i++ ){
			b = (b*i)%Mod;
		}
		if( N-M>1 ){
			ans = 0;
		}
		if( N-M==1 ){
			ans = (a*b)%Mod;		
		}
		if( N==M ){
			ans = (a*b)%Mod;
			ans = (2*ans)%Mod;
		}
		System.out.println(ans);
	}
}


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


int main() {
  int N, K;
  cin >> N >> K;

  priority_queue<int, vector<int>, greater<int>> q;

  int p;
  while (N--) {
    cin >> p;
    q.push(p);
  }

  int ans = 0;
  while (K--) {
    ans += q.top();
    q.pop();
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

ll n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n >> m;
  ll s = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s += a[i];
  }
  if (s == m)
    cout << n;
  else {
    sort(a, a + n);
    ll ans = 0;
    for (int i = 0; i < n; ++i)
      if (a[i] <= m) ++ans, m -= a[i];

    if (ans != n)
      cout << ans;
    else
      cout << n - 1;
  }
  return 0;
}


Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;

	if(k%2)	// se o k for maior que 0
		cout<<((k/2)*((k/2)+1))<<endl;
	else
		cout<<((k/2)*(k/2))<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

struct Ret { ll sum, num; };

int main() {
  ll n,m; cin >> n >> m;
  vector<ll> A(n);
  loop(i,0,n) cin >> A[i];
  sort(A.begin(), A.end());
  vector<ll> acc(n+1, 0);
  loop(i,0,n) acc[i+1] = acc[i] + A[i];

  auto f = [&](ll x) {
    Ret ret = {0LL, 0LL};
    loop(i,0,n) {
      ll xx = x - A[i];
      int j = lower_bound(A.begin(), A.end(), xx) - A.begin();
      ll num = n-j;
      ret.num += num;
      ret.sum += A[i]*num;
      ret.sum += acc[n]-acc[j];
    }
    return ret;
  };

  ll ok = -1, ng = 10000000;
  while (ok + 1 < ng) {
    ll mid = (ok+ng)>>1;
    // 足りないからXの基準を緩める(X--)
    if (f(mid).num < m) ng = mid;
    // Mに余裕があるからXの基準を厳しくする(X++)
    else ok = mid;
  }

  // okには和がx以上のペアの個数がM個以上の最大のxが入っている
  auto ret = f(ok);
  ret.sum -= (ret.num-m)*ok;
  cout << ret.sum << endl;
  return 0;
}


Measured memory_bytes: 4852
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n, k;
    cin >> n >> k;
    int freq = 1;
    for (int i = 0; i < k - 1; i++) {
        freq *= 2;
        freq = min(freq, 10000);
        if (freq == 10000) break;
    }

    string s;
    cin >> s;
    char mi = 'z';
    for (char c: s) mi = min(mi, c);
    dbg(mi);
    {
        string t = s;
        reverse(t.begin(), t.end());
        s += t;
    }

    string ans = "~";
    for (int r = n; r <= 2 * n; r++) {
        // use s[r - n .. r]
        string t = s.substr(r - n, n);
        if (t.back() != mi) continue;        
        int le = 1;
        while (le < n && t[n - 1 - le] == mi) le++;
        int u = min(n, le * freq);
        string pred = string(u, mi);
        string t2 = t.substr(n - le - (n - u), n - u);
        reverse(t2.begin(), t2.end());
        dbg(t, le, freq, u, pred, t2);
        pred += t2;
        ans = min(ans, pred);
    }
    dbg(ans);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let c: char = sc.cin();
    put!(if c.is_ascii_uppercase() { 'A' } else { 'a' });
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ReadInt();
            if (x == 1)
            {
                WriteLine("Hello World");
                return;
            }
            var a = ReadInt();
            var b = ReadInt();
            
            
                WriteLine(a + b);
            
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  string ans="None";
  for(int i=0;i<26;i++){
    bool b=true;
    for(int j=0;j<s.size();j++){
      if((char)('a'+i)==s.at(j)){b=false;}
    }
    if(b){ans=(char)('a'+i); break;}
  }
  cout<<ans;
}


Measured memory_bytes: 512
n = int(input())


def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)


resu = digitSum(n) % 9
if resu == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 79840
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            int ar[n+1];
            for(i=1;i<=n;++i)
            {
                cin>>ar[i];
            }
            map<int,int> mp;
            ll ans=0;
            for(i=n;i>=1;--i)
            {
                ans=ans+mp[ar[i]+i];
                mp[i-ar[i]]++;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 21496
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)
const double pi=3.14159265358979323846;

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  dset(10);
  ind a,b,h,m;
  cin >> a >> b >> h >> m;
  in6 time = 60*h + m;
  ind hour = 0.5*time;
  ind minute = 6*time%360;
  ind A = abs(hour - minute);
  if(a > 180) A = 360-A;
  A = A/360*2*pi;
  ind ans = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(A));
  cout << ans;
}

Measured memory_bytes: 4252
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>

using namespace std;

#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define Str(x) to_string(x)
#define len(s) (int)s.size()

typedef long long ll;
typedef long double lld;
typedef string str;
typedef unsigned long long ull;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int h, n;
    cin >> h >> n;
    while (n--) {
        int x;
        cin >> x;
        h -= x;
    }
    if (h <= 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}


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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int a,b,c;

int main(){
    cin >> a >> b >> c;
    if(a+b-c >= 0) cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;


signed main(){
	int N,M,X;
	cin >> N >> M >> X;
	vector<int>c(N);
	vector<vector<int>>a(N,vector<int>(M));
	REP(i,N){
		cin >> c[i];
		REP(j,M){
			cin >> a[i][j];
		}
	}
	int ans = INF;
	REP(i,1ll << N){
		vector<int>cnt(M);
		int cost = 0;
		REP(j,N){
			if(!(i & (1ll << j)))continue;
			cost += c[j];
			REP(k,M){
				cnt[k] += a[j][k];
			}
		}
		int flg = 1;
		REP(j,M)if(cnt[j] < X)flg = 0;
		if(flg)CHMIN(ans,cost);
	}
	if(ans == INF)out(-1);
	else out(ans);
}

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

using namespace std;
int N;


int bit_jud(int *A,vector<vector<int>> x,vector<vector<int>> y){
  int max=0;
  for(int bit=0;bit<(1<<N);bit++){
  vector <bool> S;
    for(int i=0;i<N;i++){
      if(bit&(1<<i))
	S.push_back(true);
      else
	S.push_back(false);
      
      int count=0;
      for(int j=0;j<N;j++){
	if(S[j]){
	  for(int k=0;k<A[j];k++){
	    if(y[j][k]==0){
	      if(S[x[j][k]-1]){
		goto OUT;
	      }
	    }else{
	      if(!S[x[j][k]-1])
		goto OUT;
	    }
	  }
	
	}
      }
      for(int l=0;l<N;l++){
	if(S[l])
	  count++;
      }
      
    OUT:
      if(max<count){
	max=count;
      
      }
    }
 }
  return max;
}
int main(){
  cin>>N;
  int A[N];
  vector<vector<int>> x(N),y(N);
  for(int i=0;i<N;i++){
    cin>>A[i];

    for(int j=0;j<A[i];j++){
      int X,Y;
      cin>>X>>Y;
      x[i].push_back(X);
      y[i].push_back(Y);
    }
  }
  
  cout<< bit_jud(A,x,y)<<endl;
 
  return 0;
}


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

#define int long long int
#define mp make_pair
using namespace std;

int32_t main() {
    int n,m;
    scanf("%lld", &n);
    scanf("%lld", &m);
    int a,b;
    int ans = 1000000000000000000;
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &a);
        scanf("%lld", &b);
        if(b <= m){
            if(a < ans){
                ans = a;
            }
        }
    }
    if(ans == 1000000000000000000){
        printf("TLE");
        return 0;
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define ff first
#define sc second
#define INF 3000000000
#define SINF 2*(1e18)
#define inf -10000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mpk make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
#define D(x) cout << #x " = " << (x) << endl
#define mem(a,val) memset(a,val,sizeof a)
#define cc continue
#define bb break
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
//priority_queue<ll> pq;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
bool pal(string s){
  ll j=s.size()-1;
  ll sw=0;
  for(ll i=0;i<s.size()/2;i++){
    if(s[i]!=s[j]){sw=1;break;}j--;}
  if(sw)return false;
  else return true;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
    ll a,b,c,d,n,t,m,k;
    while(cin>>n){
      ll ans=0;
      forr(i,1,n+1){
	forr(j,1,n+1){
	  forr(k,1,n+1){
	    ll h=gcd(i,gcd(j,k));
	    ans+=h;
	  }
	}
      }
      cout<<ans<<endl;
    }
}


Measured memory_bytes: 3640
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new UndirectedGraph(N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        G.add_edge(s[0], s[1]);
    }

    G.detect_articulation_points.each!writeln;
}

int[] detect_articulation_points(const ref UndirectedGraph g) {
    int root = 0;
    int root_children = 0;
    int cnt = 1;
    auto ord = new int[](g.n);
    auto low = new int[](g.n);
    auto is_articulation_point = new bool[](g.n);

    void dfs(int u) {
        ord[u] = cnt++;
        low[u] = ord[u];
        foreach (v; g.adj[u]) {
            if (ord[v] == 0) {
                dfs(v);
                low[u] = min(low[u], low[v]);
                if (u == root) {
                    root_children += 1;
                    if (root_children == 2) {
                        is_articulation_point[u] = true;
                    }
                } else if (ord[u] <= low[v]) {
                    is_articulation_point[u] = true;
                }
            } else {
                low[u] = min(low[u], ord[v]);
            }
        }
    }

    dfs(root);
    return g.n.iota.filter!(u => is_articulation_point[u]).array;
}

class UndirectedGraph {
    int n;
    int[][] adj;

    this (int n) {
        this.n = n;
        adj = new int[][](n);
    }

    void add_edge(int u, int v) {
        adj[u] ~= v;
        adj[v] ~= u;
    }
}



Measured memory_bytes: 10288
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

d = [0] * N
s = [0] * N
    
for i in range(N):
  d[i] = x[i] - y[i]
  s[i] = x[i] + y[i]


print(max(max(s)-min(s), max(d)-min(d)))

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

int main() {
	multiset<int, greater<int>> ms; int temp;
	for (int i = 0; i < 10; i++) { cin >> temp; ms.insert(temp); }
	auto itr_e = ms.begin();
	for (int i = 0; i < 3; ++i) ++itr_e;
	for (auto itr_s = ms.begin(); itr_s != itr_e; ++itr_s) {
		cout << *itr_s << endl;
	}
	return 0;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */

signed main() 
{
  int n = in();
  string s[110];
  rep(i,n) cin >> s[i];
  int m = in();
  string t[110];
  rep(i,m) cin >> t[i];

  int ans=0;

  rep(i,n)
  {
    int score=0;
    rep(j,n) if(s[j]==s[i]) score++;
    rep(j,m) if(t[j]==s[i]) score--;
    ans=max(ans,score);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
]
N = int(input())
print(l[N-1])

Measured memory_bytes: 3060
#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++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

const int INF = ((ll)1 << 31) - 1;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    Rep(i, N) cin >> h[i];
    vector<int> dp(N, INF);
    dp[0] = 0;
    Rep(i, N) {
        for (int j = max(0, i - K); j <= i; j++) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

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

int n,ans;
char s[1000001],t[1000001];
deque<int>q;//记录当前折线的拐点 
int offset;//偏移量 

int main()
{
//	freopen("copy.in","r",stdin);
//	freopen("copy.out","w",stdout);
	scanf("%d%s%s",&n,s+1,t+1);
	int j=n+1;
	q.push_back(n+1);
//	cout<<n<<endl;
	for(int i=n;i>=1;i--)
	{
		int mem=j;
		while(j>0&&(s[j]!=t[i]||i<j))j--;
		if(!j)
		{
			cout<<"-1\n";
			return 0;
		}
		if(mem==j)
		{
			while(!q.empty()&&q.back()-offset>=i)q.pop_back();
			q.push_back(i+offset);
		}
		else
		{
			offset++;
			if(i!=j)
			{
				ans=max(ans,(int)q.size());
//				cout<<"qwq"<<endl;
				q.push_front(j+offset);
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const double PI = 3.1415926535897923;
double a, b, x, v, t;

int main() {
    cin >> a >> b >> x;
    v = a * a * b;
    if (x >= v / 2) {
        t = 2 * (v - x) / (a * a);
        printf("%.7lf\n", atan(t / a) * 180 / PI);
    } else {
        t = 2 * x / a / b;
        printf("%.7lf\n", 90 - atan(t / b) * 180 / PI);
    }
    return 0;
}
// 斜率是 1 的直线的夹角：atan(1.0) * 180 / PI

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    if (C < D) {
        if (S.substr(A, D - A).find(string("##")) == string::npos)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    if (C > D) {
        if (S.substr(A, C - A).find(string("##")) == string::npos && S.substr(B - 2, D - B + 3).find(string("...")) != string::npos)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }

    return 0;
}


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

int main() {

  long long X, K, D;
  cin >> X >> K >> D;

  long long ans;

  if(llabs(X) / D <= K){
    if((K - llabs(X) / D) % 2 == 0){
      ans = llabs(X) % D;
    }else{
      ans = llabs(llabs(X) % D - D);
    }
  }else{
      ans = llabs(X) - K * D;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3572