akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")
//#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)

//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
const ld pi=3.14159265359;
ll inf = 1e18,mod1=1e9+7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll R=1e4;
const ll tx[4]={0,0,-1,1};
const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const int N=1e5+1;
const int M=1e9+7;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> st;
int n,m,k;
int a[N],b[N];
int f[N],cnt[26],dp[N];
signed main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    int ans=0;
    for(auto &z : a) cin>>z;
    for(int i=0;i<n;i++){
        if((i+1)%2 && a[i]%2) ans++;
    }
    cout<<ans;
    return 0;
}
/*
    4 4
    1 2 a
    3 2 a
    1 4 a
    3 4 b




*/


Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt(), w = sc.nextInt();
		String a[] = new String[h];
		String cw = "";
		String rw = "";
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < w; ++i)
			cw += '.';
		for (int i = 0; i < h; ++i) {
			a[i] = sc.next();
			if(!a[i].equals(cw)) {
				list.add(a[i]);
			}
		}
		for(int i = 0; i < list.size(); ++i)
			rw += '.';
		sc.close();
		List<String>list2 = new ArrayList<String>();
		for(int i = 0; i < w; ++i) {
			String tmp2 = "";
			for(int j = 0; j < list.size(); ++j) {
				tmp2 += list.get(j).charAt(i);
			}
			if(!tmp2.equals(rw))list2.add(tmp2);
		}
		String ans[] = new String[list.size()];
		for(int i = 0; i < list.size(); ++i) {
			String tmp2 = "";
			for(int j = 0; j < list2.size(); ++j) {
				tmp2 += list2.get(j).charAt(i);
			}
			ans[i] = tmp2;
		}
		for(String i : ans)
			System.out.println(i);
	}

}


Measured memory_bytes: 35128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N,D,X;
	cin>>N>>D>>X;
	int A[100];
	rep(i,N)cin>>A[i];
	int ans=X;
	
	//各人に対して食べるチョコの個数を求め、答えに足す
	rep(i,N){
		int choco=(D-1)/A[i]+1;
		ans+=choco;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int number_a, number_b, number_c, i;
  scanf("%d %d %d", &number_a, &number_b, &number_c);
  int remainder[number_b];
  for(i = 1; i <= number_b; i++) {
    remainder[i] = (number_a * i) % number_b;
  }
  for(i = 0; i < number_b; i++) {
    if(remainder[i] == number_c) {
      printf("YES\n");
      i--;
      break;
    }
  }
  if(i == number_b) {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X;
	cin >> X;
	eFOR(i, 1,1000000000) {
		if (i*(i + 1) >= 2 * X) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string aaa = "abcdefghijklmnopqrstuvwxyz";
		string str = Console.ReadLine();
		string str2 = Console.ReadLine();
		long[] A = new long[26];
		long[] B = new long[26];
		for(var i=0;i<str.Length;i++){
			A[aaa.IndexOf(str.Substring(i,1))] += 1;
		}
		for(var i=0;i<str2.Length;i++){
			B[aaa.IndexOf(str2.Substring(i,1))] += 1;
		}
		Array.Sort(A);
		Array.Sort(B);
		string ans = "Yes";
		for(var i=0;i<26;i++){
			if(A[i] != B[i]){
				ans = "No";
				break;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 19160
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int main()
{
    string str;
    cin >> str;
    int cnt = 0, max = 0;
    for (int i = 0; i < str.length(); i++)
    {
        if (str[i] == 'R')
            cnt++;
        else
        {
            if (cnt > max)
                max = cnt;
            cnt = 0;
        }
    }
    if (cnt > max)
        max = cnt;
    cout << max;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
 
#define int long long 
#define pb push_back
#define all(s) s.begin(),s.end()
#define pii pair<int,int>
#define fr first
#define sc second
#define bst ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;

using namespace std;

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e18 + 7, logn = 23;
const double pi = acos(-1);

int dp[N], w[N], c[N], n, W;


void solve() {
	//soln
	cin >> n >> W;
	for(int i = 1; i <= 100000; i++) {
		dp[i] = inf;
	}
	
	for(int i = 1; i <= n; i++) {
		cin >> w[i] >> c[i];
		for(int j = 100000; j >= 1; j--) {	
			if(j >= c[i]) {
				dp[j] = min(dp[j], dp[j - c[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	for(int i = 0; i <= 100000; i++) {
		if(dp[i] <= W) {
			ans = i;
		}
	}
	cout << ans << endl;
}
main() {
	bst;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
}


Measured memory_bytes: 6400
N,M = map(int,input().split())
lis = ["0"]*N
sl = []
cl = []
lis[0] = "1"
jud = True
ex = True
for i in range(M):
    s,c = map(int,input().split())
    if s == 1 and c == 0:
        jud = False
    if c != 0:
        ex = False 
    sl.append(s)
    cl.append(c)
    if s in sl:
        if cl[sl.index(s)] != c:
            jud = False
    lis[s-1] = str(c)
if N == 1 and ex:
    print("0")
else:
    if jud:
        print(int("".join(lis)))
    else:
        print("-1")

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

int N;
int digit2=0;
bool digitJudge(long long te){
  
  long long save = te;
  
 // for (int i=1;;i++){
    
 //   if(test !=0)
//    test = test / 10 ;
    
//    if (test == 0) {digit = i;break;}
    
 //   if (test == 10) digit = i + 1;
    
//  }
 // cout<<digit<<endl;
  
  bool flag3=false,flag5=false,flag7=false;
  for (int j=0;j<=10;j++){
    if( save %10 == 3 ) flag3 = true;
    if (save %10 == 5) flag5 = true;
    if (save % 10 == 7) flag7 = true;
    save= save / 10;
    
    
  }
  return flag3 && flag5 && flag7 ;
}

int preans(long long test,long long next){
  test *= 10;
  //digit2++;
  test += next;
  
  if(N < test) return 0;
  
  else{
    if(digitJudge(test)){
      
      return preans(test,3) + preans(test,5)+ preans(test,7)+1;
    }
    
    
  }
  
  
  
 
  return preans (test,3) + preans(test,5) + preans(test,7);
}


int main(){
  //cout<<123<<endl;
  cin>>N;
  
  long long ans = preans(0,3) + preans(0,5) + preans(0,7);
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 256
A = ["* = ****",
     "* =* ***",
     "* =** **",
     "* =*** *",
     "* =**** ",
     " *= ****",
     " *=* ***",
     " *=** **",
     " *=*** *",
     " *=**** "]

n = map(int,list("0000"+raw_input())[-5:])
while True:
    print "\n".join("".join(s) for s in zip(*[A[i] for i in n]))
    try:
        n = map(int,list("0000"+raw_input())[-5:])
    except EOFError:
        break
    print

Measured memory_bytes: 4212
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;
 





import static java.util.Comparator.*;
 
public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
//        solver.test();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    //================================================================================
    // エラトステネスの篩(ふるい）　→　素数の表を作る（大体　O(N) らしい）									
    boolean[] arr = new boolean[110100];					// 初期値 false(素数なら false　[2] = false  2は素数)				
    void eratosthenes(long n){									
        	arr[0] = arr[1] = true;				// １　は素数でない				
        	for(int i = 2; i * i <= n; i++){								
       		 if( !arr[i] ) {							
        			for(int j = i + i; j <= n; j += i){			// j は i の倍数となる			
       				 arr[j] = true;		// i の倍数は素数でない			
        			}						
        		}							
        	}								
    }									

    public void solve() {
    	long X = Long.parseLong(sc.next());
    	eratosthenes(110000);
    	for (int i = (int)X; i < 110000; i++) {
			if(!arr[i]) {
				out.println(i);
				return;
			}
		}
    }
}

Measured memory_bytes: 23892
import numpy as np
input()
A = np.array(input().split(), dtype=np.int64)
S = np.sign(A)
A = np.sort(np.abs(A))
a = A[0]
print(A.sum() if 0 in S or not ((S == -1).sum() & 1) else A.sum() - a * 2)

Measured memory_bytes: 24820
#define LOCAL

#undef _GLIBCXX_DEBUG

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

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int n, k;
vector<int> a;
vector<int> dp;

bool dfs(int left) {
	int& ret = dp[left];
	if (ret != INF) return ret == 1 ? true : false;
	bool ret2 = false;
	for (int i = 0; i < n; i++) {
		if (left - a[i] < 0) break;
		bool res = dfs(left - a[i]);
		ret2 |= !res;
	}
	ret = ret2 ? 1 : -1;
	return ret2;
}

int main() {
	IOS;
	cin >> n >> k;
	a = vector<int>(n);
	dp = vector<int>(k + 1, INF);
	for (int i = 0; i < n; i++) cin >> a[i];
	if (dfs(k)) cout << "First";
	else cout << "Second";
	return 0;
}

Measured memory_bytes: 8260
#include<iostream>

using namespace std;

int main()
{
	int a;
	int total = 0;
	int h = 0;
	
	for(int i = 0; i < 4; i++){
		cin >> a;
		total += a;
	}
	
	for(int i = 0;; i++){
		if(total < 60){
			break;
		}
		total -= 60;
		h++;
	}
	
	
	cout << h << "\n" << total << endl;
}

Measured memory_bytes: 0
////////////////////////////////////////////////////////////////////
// This source code is for Visual Studio
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>

#define	numberof(a)	(sizeof(a) / sizeof(a[0]))
#define	INF		UINT32_MAX
#define Rep(i,n) for(int i = 0; i < (n); ++i )

using namespace std;

typedef vector< vector<int> > MAT;
typedef pair<int, int> PINT;
typedef long long ll;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t s32;
typedef int64_t s64;

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main()
{
	ll N = 0;
	ll M = 0;
	ll a = 0;
	ll b = 0;
	map<ll, ll> ret;

	cin >> N >> M;

	Rep(i, N) {
		ret[i + 1] = 0;
	}

	Rep(i, M) {
		cin >> a >> b;
		ret[a]++;
		ret[b]++;
	}

	map<ll, ll>::iterator itr = ret.begin();
	Rep(i, N) {
		cout << itr->second << endl;
		itr++;
	}

	return 0;
}





Measured memory_bytes: 256
ans = [2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, 322, 521, 843, 1364, 2207, 3571, 5778, 9349,\
       15127, 24476, 39603, 64079, 103682, 167761, 271443, 439204, 710647, 1149851, 1860498, 3010349, \
       4870847, 7881196, 12752043, 20633239, 33385282, 54018521, 87403803, 141422324, 228826127, \
       370248451, 599074578, 969323029, 1568397607, 2537720636, 4106118243, 6643838879, 10749957122, \
       17393796001, 28143753123, 45537549124, 73681302247, 119218851371, 192900153618, 312119004989, \
       505019158607, 817138163596, 1322157322203, 2139295485799, 3461452808002, 5600748293801, \
       9062201101803, 14662949395604, 23725150497407, 38388099893011, 62113250390418, 100501350283429, \
       162614600673847, 263115950957276, 425730551631123, 688846502588399, 1114577054219522, \
       1803423556807921, 2918000611027443, 4721424167835364, 7639424778862807, 12360848946698171, \
       20000273725560978, 32361122672259149, 52361396397820127, 84722519070079276, 137083915467899403, \
       221806434537978679, 358890350005878082, 580696784543856761, 939587134549734843, 1520283919093591604]

N = int(input())
print(ans[N])

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

int main()
{
 char w[100];
 int j,s=0,i,flag=0;
 gets(w);
 for(i=0;i<strlen(w);i++)
 {
     for(j=0;j<strlen(w);j++)
     {
         if(w[i]==w[j])
            s++;
     }
     if(s%2!=0)
     {
         flag=1;
         break;
     }
 }
 if(flag==1)
    printf("No\n");
 else
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int p[65000], q[65000];
int main() {
	long long n;
	while (1) {
		scanf("%lld", &n);
		if (n == 0) break;
		long long sum_p = 0;
		for (long long i = 0; i < n; i++) {
			cin >> p[i];
			sum_p += p[i];
		}
		for (long long i = 0; i < n - 1; i++)
			cin >> q[i];
		sort(q, q + n - 1);
		unsigned long long max = sum_p * n;
		for (long long i = 0; i < n; i++) {
			sum_p += q[n - 2 - i];
			if (sum_p * (n - 1 - i) > max) max = sum_p * (n - 1 - i);
		}
		cout << max << endl;
	}
}


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

int main()
{
  int arr[3];
  cin>>arr[0]>>arr[1]>>arr[2];
  sort(arr,arr+3);
  int ans=0;
  for(int i=1 ; i>=0 ; --i)
  {
  	ans+=abs(arr[i]-arr[i+1]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for(int i{};i<N;i++)
using namespace std;
int M = 1e9+7;
int p[100001][13];
string S;
int d(int n){
  return (13 + n%13)%13;
}
void f(int &i, int j, int &l){
  int k{};
  k = l + d(j*pow(10, i%3)) * pow(-1, i/3);
  (p[i+1][d(k)] += p[i][l]) %= M;
}
int main(){
  cin >> S;
  reverse(S.begin(), S.end());
  p[0][0] = 1;
  rep(i, S.size()) rep(l, 13){
    if(S[i] == '?') rep(j, 10) f(i, j, l);
    else f(i, S[i] - '0', l);
  }
  cout<<p[S.size()][5]<<"\n";
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
//テストケース7だけ通らない
int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    int n;
    vector<int> p;
    vector<int> q;
    cin >> n;
    for(int i=0;i<n;i++){
        int t; 
        cin >> t;
        p.push_back(t);
    }
    for(int i=0;i<n;i++){
         int t; 
        cin >> t;
        q.push_back(t);
    }
    vector<int> base;
    for(int i=1;i<=n;i++){
        base.push_back(i);
    }
    int pi=0;//piでpの順列の順番
    int qi=0;//qiでqの(ry
    for(int i=1;i<=facctorialMethod(n);i++){
        if(base == p){
            pi = i;
        }
        if(base == q){
            qi = i;
        }
        if(pi > 0 && qi > 0)break;
        next_permutation(base.begin(),base.end());
    }
    cout << abs(pi-qi) << endl;    
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int N, M;
vector<pair<int, int>> city[100010];
int ans1[100010], ans2[100010];

int main() {
    scanf("%d %d", &N, &M);
    for(int i = 1; i <= M; ++i){
        int P, Y;
        scanf("%d %d", &P, &Y);
        city[P].emplace_back(Y, i);
    }
    for(int i = 1; i <= N; ++i){
        sort(city[i].begin(), city[i].end());
        for(int j = 0; j < city[i].size(); ++j){
            ans1[city[i][j].second] = i;
            ans2[city[i][j].second] = j+1;
        }
    }
    for(int i = 1; i <= M; ++i){
        printf("%06d%06d\n", ans1[i], ans2[i]);
    }
}


Measured memory_bytes: 7808
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int N, X, T;
	cin >> N >> X >> T;

	int result = N / X;
	if (N % X > 0) result++;

	cout << result * T;

	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	int n; bool ans = true;
	cin >> n;
	vector<vector<ll>> x(n+1, vector<ll>(3));
	x[0][0] = (0, 0, 0);
	rep(i, n)
		cin >> x[i+1][0] >> x[i+1][1] >> x[i+1][2];
	rep(i, n)
	{
		ll z = abs(x[i + 1][1] - x[i][1]) + abs(x[i + 1][2] - x[i][2]);
		if (((x[i + 1][0] - x[i][0])-z) % 2==1|| z > x[i + 1][0] - x[i][0])
			ans = false;
	}
	Cout(Yes(ans));

	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

bool ok[50][50][50][50];

int sx, sy, tx, ty;
int dis[50][50];
pii pre[50][50];
int w,h,n;

int bfs(bool f) {
  queue<pii> Q;
  memset(dis,-1,sizeof(dis));
  Q.push(pii(sy,sx));
  dis[sy][sx] = 0;
  pre[sy][sx] = pii(-1,-1);
  const int dy[] = {-1,0,1,0};
  const int dx[] = {0,1,0,-1};

  int res = -1;
  while(!Q.empty()) {
    pii p = Q.front(); Q.pop();
    if (p==pii(ty,tx)) {
      res = dis[ty][tx];
      break;
    }
    
    int y = p.first;
    int x = p.second;
    
    REP(i,4) {
      int yy = y+dy[i];
      int xx = x+dx[i];
      if (yy<0||yy>=h||xx<0||xx>=w) continue;
      if (!ok[y][x][yy][xx]) continue;
      if (dis[yy][xx]<0) {
        dis[yy][xx] = dis[y][x] + 1;
        if (f) pre[yy][xx] = pii(y,x);
        Q.push(pii(yy,xx));
      }
    }
  }
  
  return res;
}
int main() {
  cin >> w >> h >> n;
  REP(i,h)REP(j,w)REP(k,h)REP(l,w)ok[i][j][k][l]=1;
  REP(i,n) {
    int ay,ax,by,bx;
    cin>>ax>>ay>>bx>>by;
    if (ay==by) {               // 横
      if (ay<=0||ay>=h) continue;
      if (ax>bx) swap(ax,bx);
      for (int i=max(0,ax); i<min(w,bx); ++i) {
        ok[ay-1][i][ay][i]=0;
        ok[ay][i][ay-1][i]=0;
      }
    } else {
      if (ax<=0||ax>=w) continue;
      if (ay>by) swap(ay,by);
      for (int i=max(0,ay); i<min(h,by); ++i) {
        ok[i][ax-1][i][ax]=0;
        ok[i][ax][i][ax-1]=0;
      }
    }
  }
  // REP(i,h)REP(j,w)REP(k,h)REP(l,w) {
  //   if (ok[i][j][k][l]==0) {
  //     printf("%d,%d %d,%d\n",j,i,l,k);
  //   }
  // }
  cin>>sx>>sy;
  cin>>tx>>ty;
  int d = bfs(1);
  int ans = 0;

  for(pii p=pii(ty,tx);;) {
    pii pp = pre[p.first][p.second];
    // cout << pp.first << "," << pp.second << " " << p.first << "," << p.second << endl;
    // cout << bfs(0) << endl;
    if (pp.first == -1) break;
    ok[pp.first][pp.second][p.first][p.second]=0;
    ok[p.first][p.second][pp.first][pp.second]=0;
    ans = max(ans, bfs(0)-d);
    ok[pp.first][pp.second][p.first][p.second]=1;
    ok[p.first][p.second][pp.first][pp.second]=1;
    p = pp;
  }
  cout << ans << endl;
}

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

int keta(int x){
  int sum=0;
  while(x>0){
    x/=10;
    sum++;
  }
  return sum;
}

int main() {
  int n;
  cin >> n;
  
  int ans=0;
  for(int i=1;i<=n;i++){
    if(keta(i)%2==1){
      ans++;
    }
  }
  cout << ans;
  
}


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

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

int main() {
  int n = 0, h, w;
  char c;
  cin >> h >> w;
  vector<vector<int>> s(h, vector<int>(w));
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      cin >> c;
      if(c == '.') {
        s.at(i).at(j) = INT_MAX / 2;
        n++;
      } else
        s.at(i).at(j) = -10;
    }
  }
  s.at(0).at(0) = 1;
  queue<pair<int, int>> que;
  pair<int, int> p = {0, 0};
  que.push(p);
  while(que.size()) {
    p = que.front();
    que.pop();
    if(p.first == w - 1 && p.second == h - 1)
      break;
    for(int i = 0; i < 4; i++) {
      if(0 <= p.first + dx[i] && p.first + dx[i] < w && 0 <= p.second + dy[i] &&
         p.second + dy[i] < h) {
        if(s.at(p.second + dy[i]).at(p.first + dx[i]) != -10) {
          if(s.at(p.second + dy[i]).at(p.first + dx[i]) == INT_MAX / 2) {
            s.at(p.second + dy[i]).at(p.first + dx[i]) =
                s.at(p.second).at(p.first) + 1;
            que.push({p.first + dx[i], p.second + dy[i]});
          }
        }
      }
    }
  }
  if(s.at(h - 1).at(w - 1) == INT_MAX / 2)
    cout << -1 << endl;
  else
    cout << n - s.at(h - 1).at(w - 1) << endl;
}

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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define mk make_pair

typedef long long LL;
typedef pair<int,int> pi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){
    os << v.first <<" "<<v.second<<endl;
    return os;
}

const int maxn = 3e4+5;

int can[maxn];
set<int> si;

int main()
{
    int cnt = 0;
    LL temp;
    _rep(i,1,30000){
        if(!(i%2)||!(i%3)){
            can[i] = 1;
        }
    }

    int N;
    cin >> N;

    if(N == 3){
        printf("2 5 63\n");
        return 0;
    }

    vector<int> even = {2,10,3,9,4,8,6,12};
    vector<int> odd =  {6,2,10,3,9,4,8,12};

    vector<int> us;
    vector<int> ans;
    if(N%2) us = odd;
    else us = even;

    cnt = 0;
    int ok = 0;
    _for(k,0,(30000/12)){
        _for(j,0,8){
            ans.push_back(k*12 + us[j]);
            cnt++;
            if(cnt == N) {ok = 1;break;}
        }
        if(ok) break;
    }

    _for(i,0,ans.size()){
        if(i) printf(" ");
        printf("%d",ans[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 640
// ------------------
// author: MatsuTaku
// date  : 22/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N; cin>>N;
  vector<int> X(N); for (auto& x : X) cin>>x;
  ll ans = numeric_limits<ll>::max();
  for (int p = 1; p <= 100; p++) {
    ll sum = 0;
    for (auto x : X) {
      auto r = x-p;
      sum += r*r;
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


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

#define fio                            \
     ios_base::sync_with_stdio(false); \
     cin.tie(NULL);                    \
     cout.tie(NULL);
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
ll M = 1e9 + 7;
const ll N = 300000 + 5;

ll mod(ll a, ll m)
{
     return (a % m + m) % m;
}

int main()
{
     fio;
     ll n, k;
     cin >> n >> k;
     if(n>k)cout<<"safe";
     else
          cout << "unsafe";
     return 0;
}

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

int n, c[510], s[510], f[510];

int main() {
  cin >> n;
  rep(i, 0, n - 1) cin >> c[i] >> s[i] >> f[i];
  rep(i, 0, n) {
    int now = 0;
    rep(j, i, n - 1) {
      if (now <= s[j]) {
        now = s[j];
      } else {
        now = (now + f[j] - 1) / f[j] * f[j];
      }
      now += c[j];
    }
    cout << now << endl;
  }
}


Measured memory_bytes: 256
fn read() -> (i32, i32) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let vec: Vec<i32> = s
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = read();
    let n = a + b;
    if n < 24 {
        println!("{}", n);
    } else {
        println!("{}", n - 24);
    }
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
// const int mod = 1e9 + 7;
// const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool bad[15];
void solve(){
	int n, k;
	cin >> n >> k;
	fr(i, 1, k){
		int x;
		cin >> x;
		bad[x] = 1;
	}
	for(int i = n;; i++){
		int val = i;
		bool pos = 1;
		while(val){
			if(bad[val % 10]) { pos = 0; break; }
			val /= 10;
		}
		if(pos){
			cout << i << endl;
			return;
		}
	}
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
using namespace std;

vector<int> xdir,ydir;
int X, Y;
int N;

void decode(string S) {
	int n = 0;
	for (; n < N; n++) {
		if (S[n] == 'T')break;
		else X--;
	}
	int dir = 1;   //y->1 x->0
	int counter = 0;
	n++;
	for (; n < N; n++) {
		if (S[n] == 'F')counter++;
		else {
			if (counter != 0) {
				if (dir == 0) xdir.push_back(counter);
				else ydir.push_back(counter);
			}
			counter = 0;
			dir = 1 - dir;
		}
	}
	if (counter != 0) {
		if (dir == 0) xdir.push_back(counter);
		else ydir.push_back(counter);
	}
}

//vector内で和差がxになるか判定
bool judge(vector<int>& vec, int x) {
	int M = vec.size();
	vector<vector<bool>> dp;
	dp.resize(M + 1,vector<bool>(8001,false));
	dp[0][0] = true;
	for (int m = 1; m <= M; m++) {
		for (int d = 0; d <= 8000; d++) {
			if (d + vec[m-1] <= 8000) {
				dp[m][d] = dp[m][d] | dp[m - 1][d + vec[m-1]];
			}
			if (abs(d - vec[m-1]) <= 8000) {
				dp[m][d] = dp[m][d] | dp[m - 1][abs(d - vec[m-1])];
			}
		}
	}
	return dp[M][abs(x)];
}

int main() {
	string S;
	cin >> S >> X >> Y;
	N = S.size();
	decode(S);
	bool xres = judge(xdir, X);
	bool yres = judge(ydir, Y);
	if (xres && yres)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[2000];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin>>n;
    ll sum=0;
    ll ans=0;
    for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum+=a[i];
        }
    ll pingjun=sum/double(n)+0.5;
    for(int i=1;i<=n;i++)
    {
        ans+=(a[i]-pingjun)*(a[i]-pingjun);
    }
    cout<<ans<<'\n';











}


Measured memory_bytes: 256
/*
author : nit1n
created : 31.08.2020 16:40:58
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;

const double pi = acos(-1) ; 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int a , b , h ,m ; 
	cin >> a >> b >> h >> m ; 
	if(h == 12) h = 0 ; 
	double l  = 0.5*(h*60 + m) ; 
	double r = 6*m ; 
	double d = abs ( l - r) ; 
	double k = min(d  , 360 - d) ; 
	double  ans = pow(a ,2) + pow(b , 2)  - 2*a*b*(cos(k*pi/180)) ;
//	cout << pow(a ,2) + pow(b , 2) << " " << cos(k); 
	cout << fixed << setprecision(18) <<sqrt( ans) ; 

}


Measured memory_bytes: 4140
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::min;

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<char>>();

    let mut c = vec![0; s.len()+1];
    let mut d = vec![0; s.len()+1];
    for i in 0..n {
        if s[i] == 'W' {
            c[i+1] = c[i] + 1;
        } else {
            c[i+1] = c[i];
        }
    }
    for i in 0..n {
        if s[s.len()-i-1] == 'E' {
            d[s.len()-i-1] = d[s.len()-i] + 1;
        } else {
            d[s.len()-i-1] = d[s.len()-i];
        }
    }

    let mut ans = 1 << 20;
    for i in 0..n {
        ans = min(ans, c[i+1] + d[i] - 1);
    }

    println!("{}", ans);
}

Measured memory_bytes: 10492
import numpy as np

n = int(input())
x = np.array(list(map(int, input().split())))

small = x.min()
big = x.max()

min_cost = 1e10

for i in range(small, big+1):
    cost = ((x - i)**2).sum()
    min_cost = np.minimum(cost, min_cost)

print(int(min_cost))

Measured memory_bytes: 12508
import java.util.Scanner
fun main(args: Array<String>) {
    val (N,M) = readLine()!!.split(" ").map { it.toInt() }
    val ans = IntArray(N)
    repeat(M) { 
        val (a,b) = readLine()!!.split(" ").map { it.toInt() }.map { it.dec() }
        ans[a]++
        ans[b]++
    }
    ans.forEach { println(it) }
}

Measured memory_bytes: 37688
n = int(input())
nums = [int(x) for x in input().split()]
multinums = [0]
total = 0

for i in range(0,n):  #累積和配列を作成する
    multinums.append(multinums[i]+nums[i])

#print(multinums)

for i in range(0,n):
    #print(nums[i],multinums[n]-multinums[i+1],nums[i] * (multinums[n]-multinums[i+1]))
    total += nums[i] * (multinums[n]-multinums[i+1])

print(total%(10**9+7))

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

int main(void){
	ll n, p;
	cin >> n >> p;
	ll ans = 1;
	if(n == 1){
		cout << p << endl;
		return 0;
	}
	for(ll i = pow(p, 1/(double)n)+1; i >= 2; i--){
		ll tmp = pow(i,n);
		if(p % tmp == 0){
			ans *= i;
			p /= tmp;
			i--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def calc():
  import numpy as np
  h,n = map(int,input().split())
  a = np.zeros(n,np.int)
  b = a.copy()
  for i in range(n):
      a[i],b[i] = map(int,input().split())


  attack_max = np.max(a)
  majik_min = min(b)
  dp = np.zeros(h+attack_max,np.int)

  for i in range(1,len(dp)):
      c = dp[i-a[i-a>=0]]
      e = i-a[i-a>=0]
      d = c[(c!=0)+(e==0)]+b[i-a>=0][(c!=0)+(e==0)]
      if len(d)>0:
          dp[i] = np.min(d)

  print(np.min(dp[h:][dp[h:]>0]))
  
calc()

Measured memory_bytes: 12616
import sys
sys.setrecursionlimit(10**8)
input = lambda: sys.stdin.readline()[:-1]
n,q=map(int,input().split())
ab=[tuple(map(int,input().split())) for i in range(n-1)]
px=[tuple(map(int,input().split())) for i in range(q)]
# ab.sort(key=lambda tup:(tup[0],tup[1]))
visited=[0]*(n+1)
cnt=[0]*(n+1)
data=[[] for i in range(n+1)]

for i in ab:
	data[i[0]].append(i[1])
	data[i[1]].append(i[0])
for j in px:
	cnt[j[0]]+=j[1]
	# print(cnt)
# count=0
def plus(now,value,parent):
	for i in data[now]:
		# global count
		# count+=1
		if i==parent:continue
			
		cnt[i]+=value
		visited[i]=1
		# print(cnt)	
		
		plus(i,cnt[i],now)
		
		
visited[1]=1
plus(1,cnt[1],0)
print(*cnt[1:])
# print(count)

# ans=sorted(cnt.items())
# print(*[i[1] for i in ans])



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

int n,m;
vector<vector<int>> g;
vector<bool> seen;
void dfs(int v){
    if(!seen[v]) return;
    seen[v]=false;
    for(auto nv:g[v]){
        if(!seen[nv]) continue;
        dfs(nv);
    }
}

int main(){
    cin>>n>>m;
    g.resize(n);
    seen.assign(n,true);
    for(int i=0;i<m;++i){
        int a,b,c;
        cin>>a>>b>>c;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int res=0;
    for(int i=0;i<n;++i){
        if(!seen[i]) continue;
        dfs(i);
        ++res;
    }

    cout<<res<<endl;
}

Measured memory_bytes: 11736
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
      .map(|e| e.parse().ok().unwrap()).collect()
}

fn format_output(xs: &Vec<i32>) -> String {
    xs.iter()
        .map(|&x| x.to_string())
        .collect::<Vec<String>>()
        .join(" ")
}

fn main() {
    let n: usize = read();
    let mut xs: Vec<i32> = read_vec();
    let mut has_unsort = true;
    let mut count = 0;

    while has_unsort {
        has_unsort = false;

        for i in (1..n).rev() {
            if xs[i] < xs[i - 1] {
                let tmp = xs[i];
                xs[i] = xs[i - 1];
                xs[i - 1] = tmp;
                has_unsort = true;
                count += 1;
            };
        };
    };

    println!("{}", format_output(&xs));
    println!("{}", count);
}



Measured memory_bytes: 5036
#include<stdio.h>
#include<string.h>
long long IN(void)
{
  long long x=0;short f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
signed main(void)
{
  char c,S[1000000];
  int a=0x7f7f7f7f,cusum[1000001]={0},len=1,max=0,min,temp,RT=2,rv[1000001]={0};
  if(scanf("%s",S)!=0)len=strlen(S);
  for(int i=0;i<len;i++)
  {
    temp=cusum[i]+((S[i]=='1')?1:-1);
    cusum[i+1]=temp;rv[i+1]=temp;
    max=(cusum[i+1]<max)?max:cusum[i+1];
  }
  for(int i=len-1;i>=0;i--){rv[i]=(rv[i]<rv[i+1])?rv[i+1]:rv[i];}
  while(RT--)
  {
    temp=0,min=0;
    for(int i=0;i<len;i++)
    {
      if(S[i]=='?'){if(temp+rv[i+1]-cusum[i]+2<=max){temp++;}else temp--;}
      else if(S[i]=='0'){temp--;}
      else{temp++;}
      min=(min<temp)?min:temp;
    }
    temp=(a<max-min)?a:max-min;
    a=temp;max++;
  }
  return printf("%d\n",a),0;
}

Measured memory_bytes: 10500
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = Console.ReadLine().Split(' ');
            var r = int.Parse((K[0]));
            var D = int.Parse((K[1]));
            var x0 = int.Parse((K[2]));

            List<int> result = new List<int>();
            result.Add(r * x0 - D);
            Console.WriteLine(r * x0 - D);
            for (int i = 0; i < 9; i++)
            {
                result.Add(r *result[i] - D);
                Console.WriteLine(r * result[i] - D);
            }
            
            

        }

    }

    //var N = int.Parse(Console.ReadLine());
    //var S = Console.ReadLine();
    //var K = Console.ReadLine().Split(' ');
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll maxn = 1e5 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 123456789;
const int maxx = 1005;
ll q, t, n, m, T, k, ans, a[maxn], b[maxn], f[maxx][maxx];
priority_queue<ll> pr;
string s, str;
char ss[maxx][maxx];
map<ll, ll> mp;
void sol()
{
    cin >> n;
    ll mx = 1e16;
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i];
    }
    for(int i = n - 1; i >= 0; i--)
    {
        for(int j = i; j >= 0; j --)
        {
            if(i == n - 1)f[i][j] = (j == 0 ? a[i] : 0);
            else
                f[i][j] = min(a[i] + f[i+1][a[i] > 100 ? j + 1 : j], j > 0 ? f[i+1][j-1] : mx);
        }
    }
    cout << f[0][0];
}
deque<char>st;
char ch;
void test()
{
    //ll c[maxn], d[maxn];
    cin >> n >> m >> k;
    if(k < m-1)
    {
        cout << n * k / m;
    }
    else
    {
        t = m - 1;
        cout << t * n / m;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    test();
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
typedef vector<int> vi;
typedef vector<vi> vvi;
inline int in() { int x; cin >> x; return x; }

void solve() {
  int n = in(), k = in();
  vi p(n+1, 0); FOR(i,0,n) p[i+1] = in();
  int e = 0, maxe = 0;
  FOR(i,0,k) e += p[i]+1;
  FOR(i,k,n+1) {
    e += p[i]-p[i-k];
    if (maxe<e) maxe = e;
  }
  cout << fixed << setprecision(1) << (double)maxe/2 << endl;
}
#undef int
int main() {
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    string s;
    cin >> s;
    cout << count(All(s), '1') << "\n";
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef	    long long       ll;
typedef	    vector<ll>      vll;
#define     pb              push_back
#define	    PB              pop_back
#define	    nn              "\n"
#define	    all(p)          p.begin(),p.end()
#define	    zz(v)           (ll)v.size()
#define	    mms(ar,a)       memset(ar,a,sizeof(ar))
#define	    ss              ' '
#define     S(a)            scanf("%lld",&a)
#define     SS(a,b)         scanf("%lld %lld",&a,&b)
#define     SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define     P(a)            printf("%lld\n",a)
#define     PP(a,b)         printf("%lld %lld\n",a,b)
#define	    gcd(a,b)        __gcd(a,b)
#define	    lcm(a,b)        (a*b)/gcd(a,b)
#define	    pi              acos(-1.0)
#define	    OO              1000000007

int main(){
//    freopen("input.txt","r",stdin);
    ll a,b,c=0,i,j,t,k,lie,m,n,o,x=0,y,z,ar[200010];
    SS(k,n);
    for(i=0;i<n;i++) S(ar[i]);
    sort(ar,ar+n);
    ar[n]=ar[0]+k;
    ll mn=-OO;
    for(i=0;i<n;i++){
        mn=max(mn,ar[i+1]-ar[i]);
    }
    P(k-mn);

    return 0;
}


Measured memory_bytes: 1792