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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N;
    cin >> N;

    ll mat[N][N];
    FOR(i, 0, N){
        FOR(j, 0, N){
            mat[i][j] = 0;
        }
    }

    FOR(i, 0, N){
        ll u; cin >> u; u--;
        ll k; cin >> k;
        FOR(j, 0, k){
            ll to; cin >> to; to--;
            mat[i][to] = 1;
            // mat[to][i] = 1;
        }
    }
    
    FOR(y, 0, N){
        FOR(x, 0, N){
            if(x) cout << ' ';
            cout << mat[y][x];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
ll solve(vector<vector<ll>> &graph, vector<ll>&dp, ll node){

    if(dp[node]!=-1)
        return dp[node];

    //db(node);

    ll ans = 0;
    for(auto child : graph[node]){
        ll temp = solve(graph,dp,child);
        ans=max(ans,1+temp);
    }
    return dp[node]=ans;
}


void solve(){

    ll n,m;
    cin>>n>>m;

    vector<vector<ll>> graph(n+1);
    vector<ll>dp(n+1,-1);
    rep(i,m){
        ll x,y;
        cin>>x>>y;
        graph[x].push_back(y);
    }
    
   
    ll ans = 0;

    repA(i,1,n){
        if(dp[i]==-1){
            ans = max(ans,solve(graph,dp,i));
        }
        //db1(" ");
    }
    // repA(i,1,n)
    // db(dp[i]);
    // db1(" ");
    db1(ans);
}
int main(){ 

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





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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << a;
	}
	else {
		cout << a - 1;
	}
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int k = 1, m = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == k) {
            ans += m;
            m = 0;
            k++;
        }
        else m++;
    }
    ans += m;
    if (k > 1) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 1024
use std::io;

fn main() {
    let mut input = String::new();
    match io::stdin().read_line(&mut input) {
        Ok(_) => match input.trim_end().parse::<i32>() {
            Ok(x) => println!("{}", if x >= 30 { "Yes" } else { "No" }),
            Err(_) => eprintln!("not a number")
        } // ここにカンマが要らないのはなぜ……？
        Err(_) => eprintln!("can't read anything")
    }
}


Measured memory_bytes: 2112
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;


class Program
{
    static void Main(string[] Args) {
        ReadLine(); //N
        var T = new List<string>(Console.ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();
        int M = Int32.Parse(ReadLine());
        List<KeyValuePair<int, int>> DrinkData = new List<KeyValuePair<int, int>>(); //Pi,Xi
        for(int Count = 0;Count < M; Count++) {
            var v = new List<string>(ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToArray();
            DrinkData.Add(new KeyValuePair<int, int>(v[0], v[1]));
        }

        List<int> Result = new List<int>();
        foreach(var ele in DrinkData) {
            int Result_Tmp = 0;
            for(int Count = 0;Count < T.Count(); Count++) {
                int Plus = 0;
                if (ele.Key - 1 == Count) Plus = ele.Value;
                else Plus = T[Count];
                Result_Tmp += Plus;
            }
            Result.Add(Result_Tmp);
        }

        foreach(var ele in Result) {
            WriteLine(ele);
        }

        ReadLine();
    }
}

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

vector<ll>adj[100005];
ll visited[100005];

pair<ll,ll> dfs(ll pa)
{
	visited[pa]=1;
	ll i,w,b;
	w=1;
	b=1;
	for(i=0;i<adj[pa].size();i++)
	{
		if(!visited[adj[pa][i]])
		{
			pair<ll,ll>p=dfs(adj[pa][i]);
			w=(w*((p.first+p.second)%1000000007))%1000000007;
			b=(b*p.first)%1000000007;
		}
	}
	return make_pair(w,b);
}

int main()
{
   
    ll n,i,x,y;
    cin>>n;
    for(i=0;i<n-1;i++)
    {
    	cin>>x>>y;
    	adj[x].push_back(y);
    	adj[y].push_back(x);
    }
    pair<ll,ll>p=dfs(1);
    cout<<(p.first+p.second)%1000000007<<endl;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const int n_max=1e3+10;
vector<int> g[n_max];
const int x_max=5010;
vector<int> x;
bool ok=true;
pair<int, int> dfs(int p,int v){
  vector<bool> dp(x_max,false);
  vector<bool> ndp(x_max,false);
  int sum=0;
  dp[0]=true;
  for(auto i:g[v]){
    if(i==p) continue;
    auto tp=dfs(v,i);
    int a=tp.first;
    int b=tp.second;
    sum+=a+b;
    rep(i,x_max) ndp[i]=false;
    rep(i,x_max){
      if(i+a<x_max) ndp[i+a] = (ndp[i+a] || dp[i]);
      if(i+b<x_max) ndp[i+b] = (ndp[i+b] || dp[i]);
    }
    rep(i,x_max){
      dp[i]=ndp[i];
    }
  }
  pair<int,int> ret;
  bool ng=true;
  for(int i=x[v];i>=0;i--){
    if(dp[i]){
      ret={x[v],sum-i};
      ng=false;
      break;
    }
  }
  if(ng) ok=false;
  //  cout << "v a b " << v << " " << ret.first << " " << ret.second << endl;
  return ret;

}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  rep(i,n-1){
    int p;
    cin >> p;
    --p;
    g[i+1].pb(p);
    g[p].pb(i+1);
  }
  rep(i,n){
    int tx;
    cin >>tx;
    x.pb(tx);
  }
  dfs(-1,0);
  if(ok) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;

  return 0;
    

}


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

int main() {
    int n;
    cin >>n ;
     vector<int> B(n);
for (int i = 0; i < n-1; i++) {
  cin >> B[i];
}
  vector<int> A(n)  ;
  for( int i=0 ; i< n-2 ; i++){
    A[i]= min(B[i],B[i+1]);
    
  }
  
  int ans=0 ;
  for (int i=0 ;i<n-2 ;i++){
      ans += A[i] ;
  }


  cout <<  ans + B[n-2] +B[0]<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc059_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

void solve(int a, int b) {
  if (a > b) {
    cout << "GREATER" << endl;
  } else if (b > a) {
    cout << "LESS" << endl;
  }
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string A, B;
  cin >> A >> B;
  
  if (A.size() != B.size()) {
    solve(A.size(), B.size());
    return 0;
  } else {
    rep(i, A.size()) {
      if (A[i] != B[i]) {
        solve(A[i], B[i]);
        return 0;
      }
    }
  }
  cout << "EQUAL" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

int main(){
    int a,b,c;
    cin >>a >> b >> c;
    if (a+b+c>=22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 764
N, M = gets.chomp.split(" ").map(&:to_i)

foods = Array.new(M+1, 0)
N.times do
  k, *a = gets.chomp.split(" ").map(&:to_i)
  a.each do |x|
    foods[x] += 1
  end
end
ans = 0
foods.each do |x|
  if x == N
    ans += 1
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int Q;
int A,B;

bool check(int x) {
  int n = x-A;
  return (A+n/2)*(x-n/2) < A*B;
}

void solve() {
  int ans = 2*(A-1);
  if (A+1 < B && A*(A+1) < A*B) {
    int ok = A+1, ng = B;
    while (ng - ok > 1) {
      int mid = (ok + ng) / 2;
      if (check(mid)) ok = mid;
      else ng = mid;
    }
    ans += ok-A;
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> Q;
  REP(i,Q) {
    cin >> A >> B;
    if (A > B) swap(A,B);
    solve();
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n;
	int a,b,c,d;
	int counter;
	while(1){
		counter = 0;
		if(scanf("%d",&n) == EOF){break;}
		for(a = 0; a <= 9; a++){
			if(a >= n){
				if(a == n){counter++;}
				break;
			}
			for(b = 0; b <= 9; b++){
				if(a + b >= n){
					if(a + b == n){counter++;}
					break;
				}
				for(c = 0; c <= 9; c++){
					if(a + b + c >= n){
						if(a + b + c == n){counter++;}
						break;
					}
					for(d = 0; d <= 9; d++){
						if(a + b + c + d >= n){
							if(a + b + c + d == n){
								counter++;
							}
							break;
						}
					}
				}
			}
		}
		printf("%d\n",counter);
	}
	return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int[] a = ir.nextIntArray(3);
		out.println(a[1] + a[2] > a[0] ? a[2] - a[0] + a[1] : 0);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    map<char, int> cnt;
    set<char> se;
    for (int i = 0; i < H; i++) cin >> S[i];
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        if (cnt.count(S[i][j])) cnt[S[i][j]]++;
        else cnt[S[i][j]] = 1;
        se.insert(S[i][j]);
    }
    
    int s = 0, t = 0;
    for (auto c : se) {
        int m = cnt[c] % 4;
        if (m == 1) s++;
        if (m == 2) t++;
        if (m == 3) { s++; t++; }
    }
    
    int f, g;
    if (H % 2 == 1 && W % 2 == 1) {
        f = 1; g = (H/2) + (W/2);
    } else if (H % 2 == 0 && W % 2 == 0) {
        f = 0, g = 0;
    } else {
        f = 0;
        if (H % 2 == 0) g = H/2;
        else g = W/2;
    }
    
    if (f == s && g >= t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A_list = list(map(int, input().split()))
import math
#部分列の和を考えるなら累積和を
ruiseki_A_list = [0 for _ in range(N)]

for i in range(N):
    if i == 0:
        ruiseki_A_list[i] = A_list[i]
    else:
        ruiseki_A_list[i] = A_list[i] + ruiseki_A_list[i-1]

#元のある区間の総和が知りたい

ruiseki_A_list.insert(0,0)
ans = 0
'''
for left_num in range(N+1):
    for right_num in range(N+1):
        if left_num < right_num:
            if ruiseki_A_list[right_num] - ruiseki_A_list[left_num]==0: #要素が等しい物の数数えたらええんか...
                ans += 1
'''
#やってることの中身というか本質を見逃してた
ruiseki_A_list.sort()
kosuu = [1]
k = 0
for i in range(N):
    if ruiseki_A_list[i+1] - ruiseki_A_list[i] == 0:
        kosuu[k] += 1
    else:
        k += 1
        kosuu.append(1)
        
for num in kosuu:
    if num <= 1:
        ans += 0
    else:
        ans += math.factorial(num)/(math.factorial(2) * math.factorial(num-2))
print(int(ans))

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

internal static class CR
{
    public static string GetText() { return Console.ReadLine(); }
    public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
    public static long GetLong() { return long.Parse(Console.ReadLine()); }
    public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
}

namespace AtCoder.C
{
    public class Program
    {
        public static long A { get; private set; }
        public static long B { get; private set; }

        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = CR.GetLongs();
            A = inputs[0];
            B = inputs[1];

            for (int i = 1; i <= 1000; i++)
            {
                if (Math.Floor(i * 0.08) == A && Math.Floor(i * 0.10) == B)
                {
                    return i;
                }
            }

            return "-1";
        }
    }
}


Measured memory_bytes: 13268
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL C[51][51];

void comb_table(int N) {
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i) {
				C[i][j] = 1LL;
			}
			else {
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);
			}
		}
	}
}

int main() {

	int n, a, b; cin >> n >> a >> b;

	vector<LL> v(n);

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

	sort(v.begin(), v.end(),greater<LL>());

	double max_average = 0.0;

	for (int i = 0; i < a; i++) {
		max_average += v[i];
	}

	max_average /= a;

	int a_th_val_num = 0;
	int a_th_va_pos = 0;

	for (int i = 0; i < n; i++) {
		if (v[i] == v[a - 1]) {
			a_th_val_num++;

			if (i < a) {
				a_th_va_pos++;
			}
		}
	}

	comb_table(n);

	LL cnt = 0LL;

	if(a_th_va_pos == a) {
		for (a_th_va_pos = a; a_th_va_pos <= b; a_th_va_pos++) {
			cnt += C[a_th_val_num][a_th_va_pos];
		}
	}
	else {
		cnt += C[a_th_val_num][a_th_va_pos];
	}

	//小数点以下何桁までか設定。
	cout.precision(20);
	//設定どおりに出力するためにfixedオプションつける。
	cout << fixed << max_average << endl;
	//組合せの総数は整数で出力。
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import os

il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, Q = il()
    A = il()
    Q = il()

    for q in Q:
        # 合計, 範囲, 左端の初期化
        sm, ret, l = 0, 0, 0
        for r in range(N):
            # 右端を0から、
            # 合計がq以下の位置まで進める
            sm += A[r]
            while sm > q:
                # 合計がqを上回る場合、
                # 左端をインクリメント
                sm -= A[l]
                l += 1

            # 合計がq以下となる範囲
            ret += r - l + 1

        print(ret)


if __name__ == '__main__':
    main()



Measured memory_bytes: 14920
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;


int main() {
	
	int A, B, C;
	int X;
	cin >> A >> B >> C;
	cin >> X;

	int ans = 0;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				if ((500 * i + 100 * j + 50 * k) == X) {
					ans++;
				}
			}
		}
	}

	cout << ans;
	return 0;

}

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

using namespace std;


int a,b,c;

typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<double> vdb;
typedef vector<bool> vbol;
typedef vector<string> vstr;

#define vvll(a,b,c) vector<vector<long long>> c(a,vector<long long>(b,0))
#define vvit(a,b,c) vector<vector<int>> c(a,vector<int>(b,0))
#define vvstr(a,b,c) vector<vector<string>> c(a,vector<string>(b,0))
#define vvbol(a,b,c) vector<vector<bool>> c(a,vector<bool>(b,0))
#define vvdb(a,b,c) vector<vector<double>> c(a,vector<double>(b,0))
#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=0;i<=b;i++)
#define f_j(a,b) for(int j=0;j<=b;j++)


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

    int n;
    cin >> n;
    long long count=0;
    fi(0,n)
    {
        int a,b;
        cin >> a >> b;
        if(a==b)
        {
            count++;
        }
        else
        {
            count=0;
        }
        if(count>=3)
        {
            cout << "Yes" << endl;
            return(0);
        }
        
    }
    cout << "No" << endl;

    return(0);

}

Measured memory_bytes: 3640
size = int(input())
arr = list(map(int, input().split()))
dp = [0]*(size)
dp[0] = 0
dp[1] = abs(arr[1] - arr[0])
for i in range(2,size):
    dp[i] = min(dp[i-1] + abs(arr[i-1]-arr[i]), dp[i-2] + abs(arr[i-2]- arr[i]))

print(dp[size-1])


Measured memory_bytes: 20376
#include <stdio.h>

int main() {
    int N;
    int W;
    scanf("%d", &N);
    scanf("%d", &W);
    int w[N];
    int v[N];
    long DP[N][W]; // [i番目の荷物][重さj以下で最大の価値の最大値]
    for (int i = 0; i < N; i++) {
        scanf("%d", &w[i]);
        scanf("%d", &v[i]);
    }

//    printf("N: %d\n", N);
//    printf("W: %d\n", W);
//
//    for (int i = 0; i < N; i++) {
//        printf("w[%d]: %d\n", i, w[i]);
//        printf("v[%d]: %d\n", i, v[i]);
//    }
//
    // 初期値
    for (int j = 0; j < W + 1; j++) {
        if (j < w[0])
            DP[0][j] = 0;
        else
            DP[0][j] = v[0];
    }

    int max = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < W + 1; j++) {
            // w[i]がjより大きければ、iは持って帰れない。
            if (j < w[i]) {
                DP[i][j] = DP[i-1][j];
            } else {
            // 持って帰る場合
                DP[i][j] = ((DP[i-1][j - w[i]] + v[i]) > DP[i-1][j]) ? (DP[i-1][j - w[i]] + v[i]) : DP[i-1][j];
            }
            if (j > 1 && DP[i][j - 1] > DP[i][j])
                DP[i][j] = DP[i][j - 1];
//            printf("DP[%d][%d]: %ld\n", i, j, DP[i][j]);
        }
    }

    long ans = DP[N-1][W];

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

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> l(N,0);
  for(int i=0;i<N;i++){
    cin >> l.at(i);
  }
  
  sort(l.begin(),l.end());
  /*
  for(int i=0;i<N;i++){
    cout << l.at(i);
  }*/
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum += l.at(i);
  }
  int mxl = l.at(N-1);
  
  if(mxl < sum){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, D, X;
    cin >> N >> D >> X;
    int A;
    rep(i,N) {
        cin >> A;
        X += 1 + (D - 1) / A;
    }

    cout << X << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String strA = reader.next();
		int[] A = new int[5];
		String strB = reader.next();
		int[] B = new int[5];
		for (int i = 0; i < 5; i++) {
			A[i] = Character.getNumericValue(strA.charAt(i));
			B[i] = Character.getNumericValue(strB.charAt(i));
		}
		int ans = 0;
		int[] C = new int[5];
		C[0] = B[0] - A[0];
		if (C[0] == 0) {
			C[1] = B[1] - A[1]  - 1;
		} else {
			C[1] = 10;
		}
		if (C[1] == 0) {
			C[2] = B[2] - A[2]  - 1;
		} else {
			C[2] = 10;
		}
		ans = C[0] * C[1] * C[2];
		int intA = Integer.parseInt(strA);

		int below = 0;
		for (int i = A[0]*10000; i < intA; i++) {
			int n1 = i/10000;
			int n2 = i%10000/1000;
			int n4 = i%100/10;
			int n5 = i%10;
			if (n1 == n5 && n2 == n4) {
				below++;
			}
		}

		int intB = Integer.parseInt(strB);
		int above = 0;
		for (int i = B[0]*10000; i <= intB; i++) {
			int n1 = i/10000;
			int n2 = i%10000/1000;
			int n4 = i%100/10;
			int n5 = i%10;
			if (n1 == n5 && n2 == n4) {
				above++;
			}
		}

		System.out.println(ans - below + above);
		reader.close();
	}
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

ll a,b;


int main(){
  ll ans,ans2,n,t,m;
  cin >> a >> b;
  
  n=a;
  REP(i,40){
    if (i==0){
      t=4;
      m=n%t;
      if (m==2)ans++;
      if (m==3)ans++;
    }else{
      m=n%t;
      if (m>=(t/2)){
        m-=t/2;
        ans+=(m%2)*(1LL<<i);
      }
      t*=2;
    }
  }

  ans2=ans;
  ans=0LL;
  
  n=b+1;
  REP(i,40){
    if (i==0){
      t=4;
      m=n%t;
      if (m==2)ans++;
      if (m==3)ans++;
    }else{
      m=n%t;
      if (m>=(t/2)){
        m-=t/2;
        ans+=(m%2)*(1LL<<i);
      }
      t*=2;
    }
  }
  
  ans^=ans2;
  
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n;
  cin >> n;
  vector<int> a(n+1), b(n);
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll ans = 0;
  for (int i = n-1; i >= 0; i--){
    if (b[i] <= a[i+1]){
      ans += b[i];
      a[i+1] -= b[i];
    } else {
      ans += a[i+1];
      b[i] -= a[i+1];
      a[i+1] = 0;
      if (b[i] <= a[i]){
        ans += b[i];
        a[i] -= b[i];
      } else {
        ans += a[i];
        a[i] = 0;
      }
    }
  }
  cout << (ll)ans << "\n";
}

Measured memory_bytes: 1024
import numpy as np
import sys

N = int(input())
A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

# print(A >= B)
# print(np.sort(A - B))
C = np.sort(A - B)
negative = C[C < 0]
positive = C[C >= 0]
positive = positive[::-1]
# print(negative, positive)
sum_neg = np.sum(negative)
cnt = 0
if len(negative) == 0:
    print(0)
    sys.exit()

for i in range(len(positive)):
    sum_neg += positive[i]
    cnt += 1
    if sum_neg >= 0:
        break

if sum_neg < 0:
    print(-1)
    sys.exit()
else:
    print(cnt + len(negative))


Measured memory_bytes: 25884
#include<bits/stdc++.h>
using namespace std;
int main() {
	vector<int> vec = { 0,1,3,1,2,1,2,1,1,2,1,2,1 };
	int x, y;
	cin >> x >> y;
	if (vec.at(x) == vec.at(y)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
from sys import stdin
def input():
    return stdin.readline().strip()

n, m = map(int, input().split())
a, b, c, d = [], [], [], []
for _ in range(n):
    i, j = map(int, input().split())
    a.append(i)
    b.append(j)
for _ in range(m):
    i, j = map(int, input().split())
    c.append(i)
    d.append(j)

l = []
for i in range(n):
    ans = (float('inf'), 0)
    for j in range(m):
        distance = (abs(a[i] - c[j]) + abs(b[i] - d[j]), j)
        if distance < ans:
            ans = distance
    l.append(ans[1] + 1)

for i in l:
    print(i)

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  string s;
  cin >> s;
  int k;
  cin >> k;
  REP(i, s.size()) {
    if (i == s.size() - 1) {
      k %= 26;
      s[i] = (s[i] - 'a' + k) % 26 + 'a';
    } else if('z' - s[i] + 1 <= k && s[i] != 'a') {
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
    if (k == 0) break;
  }
  cout << s << endl;
}

Measured memory_bytes: 512
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val Array(a,b,c,d) = s.next().toCharArray.map(_.asDigit)
    val ops = Seq(1, -1)
    val o = for {
      op1 <- ops
      op2 <- ops
      op3 <- ops if a + b * op1 + c * op2 + d * op3 == 7
    } yield Seq(op1, op2, op3).map(o => if (o == 1) "+" else "-")
    val oh = o.head
    s"$a${oh(0)}$b${oh(1)}$c${oh(2)}$d=7"
  }

  val tests = List(
    """1222""".stripMargin -> """1+2+2+2=7""",
    """0290""".stripMargin -> """0-2+9+0=7""",
    """3242""".stripMargin -> """3+2+4-2=7"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 27448
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int min = 200000;
        
        for(int i=1; i<N/2+1; i++){
            int j = N-i;
            int sum = 0;
            String s1 = String.valueOf(i);
            String s2 = String.valueOf(j);
            for(int k=0; k<s1.length(); k++){
                sum += Character.getNumericValue(s1.charAt(k));
                //System.out.println(s1.charAt(k));
                //System.out.println(sum);
            }
            for(int k=0; k<s2.length(); k++){
                sum += Character.getNumericValue(s2.charAt(k));
                //System.out.println(s2.charAt(k));
                //System.out.println(sum);
            }
            if(sum < min){
                min = sum;
            }
            //System.out.println(sum);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 42900
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<int> vi;
const int MOD=1000000007;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a[10];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[3]*10+a[2]+a[1]<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<list>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<cctype>
#include<string>
#include<vector>
#include<climits>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<algorithm>
#define endl '\n'
#define rtl rt<<1
#define rtr rt<<1|1
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define maxx(a, b) (a > b ? a : b)
#define minn(a, b) (a < b ? a : b)
#define zero(a) memset(a, 0, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define NIL(a) memset(a, -1, sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define _test printf("============\n")
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> P2;
const double pi = acos(-1.0);
const double eps = 1e-7;
const ll MOD =  1000000007LL;
const int INF = 0x3f3f3f3f;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
const int maxn = 4e3+10;
vector<int> p[3];
int main() {
    char str[maxn]; int n;
    scanf("%d%s", &n, str);
    for (int i = 0; i<n; ++i) {
        if (str[i]=='R') p[0].push_back(i);
        else if (str[i]=='G') p[1].push_back(i);
        else p[2].push_back(i);
    }
    int cnt = 0;
    for (int i = 0; i<n; ++i)
        for (int j = i+1; j<n; ++j) {
            int k = 2*j-i;
            if (k<n && str[i]!=str[j] && str[j]!=str[k] && str[i]!=str[k]) ++cnt;
        }
    printf("%lld\n", p[0].size()*p[1].size()*p[2].size()-cnt);
    return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<vector<int>>
#define vpi vector<pair<int,int>>
#define w(t) int t;cin>>t;while(t--)
#define pi pair<int,int>
#define mii map<int,int>
#define pb push_back
#define ff first
#define ss second
#define FOR(i,t,n) for(int i=t;i<n;i++)
#define SCI(x)  scanf("%d",&x)
#define SCL(x) scanf("%lld",&x)

int main()
{
	int n;
	cin>>n;
	int d = n%10;
	if(d ==2 || d==4 || d == 5 || d == 7 || d == 9){
		cout<<"hon"<<endl;
	}
	else if(d == 0|| d == 1 || d == 6 || d == 8){
		cout<<"pon"<<endl;
	}

	else if(d == 3){
		cout<<"bon"<<endl;
	}
	
}

Measured memory_bytes: 3616
// E - Crested Ibis vs Monster
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int a, b, dp[10000+1], INF = INT_MAX>>2;
int H,N;

int main(){
	cin>>H>>N;
	rp(i,1,H+1) dp[i] = INF;
	dp[0] = 0;
	rp(i,0,N){
		cin>>a>>b;
		rp(j,1,H+1)
			dp[j] = min(dp[j], (j-a<0? 0:dp[j-a]) + b);
	}
	cout<< dp[H] <<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll A;
    string B;
    cin >> A >> B;
    ll ans = 0;
    ll mul = 100;
    rep(i, 4) {
        if (i == 1) continue;
        ans += (mul * (B[i] - '0') * A);
        mul /= 10;
    }
    cout << ans / 100 << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define zero(x) (fabs(x)<eps)
#define pi acos(-1.0)
#define f1 first
#define f2 second
#define CLR(x,y) memset(x,y,sizeof(x))
using namespace std;
typedef long long LL;
typedef pair <int, int> PII;
template<typename X> inline bool minimize(X&p,X q){if(p<=q)return 0;p=q;return 1;}
template<typename X> inline bool maximize(X&p,X q){if(p>=q)return 0;p=q;return 1;}
#define fr(i,x,y) for(int i=x;i<=y;i++)
#define ms(x,y) memset(x,y,sizeof(x))
int n;
void doit()
{
    scanf("%d",&n);
    int x=sqrt(2*n+0.5);
    if (x*(x+1)>=2*n)
        printf("%d\n",x);
    else printf("%d\n",x+1);


}
int main() {

   // while (1)
    {
        doit();
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int maxn=1e5+7;
const int mod=1e9+7;

//ll a[maxn];
int main()
{
	ll x;
	vc<ll> a;
	int n;
	cin>>n;
	for(int i=0;i<n;++i) cin>>x,a.push_back(x);
	ll ans=0;
	/*while(true)
	{
		vc<ll> res;
		sort(a.begin(),a.end());
		reverse(a.begin(),a.end());
		dbg(a);
		if(a[0]<n) break;
		++ans;
		res.push_back(a[0]-n);
		for(int i=1;i<(int)a.size();++i)
		{
			res.push_back(a[i]+1);
		}
		a.clear();
		a=res;
	}*/
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	if(a[0]<n) ans=0;
	else
	{
		while(true)
		{
			ll cnt[52],now[52],sum=0;
			bool fl=1;
			for(int i=0;i<n;++i)
			{
				cnt[i]=a[i]/n;
				now[i]=a[i]%n;
				sum+=cnt[i];
				ans+=cnt[i];
			}
			a.clear();
			for(int i=0;i<n;++i)
			{
				a.push_back(now[i]+sum-cnt[i]);
				if(now[i]+sum-cnt[i]>=n) fl=0;
			}
			if(fl) break;
		}
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3552
#import<cstdio>
#import<algorithm>
using namespace std;
int main(){
	for(int n,m,f,i;scanf("%d%d",&n,&m),n|m;printf("%d\n",f)){
		int a[200010]={0};
		for(i=1;i<=n+m;i++)
			scanf("%d",a+i);
		std::sort(a,a+n+m+1);
		f=0;
		for(i=1;i<=m+n;i++)
			f=std::max(f,a[i]-a[i-1]);
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<int> ls;
  for (int i = 0; i < 2 * n; i++) {
    int l;
    std::cin >> l;
    ls.push_back(l);
  }
  std::sort(ls.begin(), ls.end());
  int sum =0;
  for (int i = 0; i < n; i++) {
    sum += ls[2 * i];
  }
  std::cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

using namespace std;

void d()
{
	int h, w;
	cin >> h >> w;
	vector<vector<bool> > s(h, vector<bool>(w));
	for (int i = 0; i < h; i++) {
		string t;
		cin >> t;
		for (int j = 0; j < w; j++) {
			s[i][j] = t[j] == '#';
		}
	}

	// R
	vector<vector<int> > R(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j]) {
				R[i][j] = 0;
			}
			else if (j == 0) {
				R[i][j] = 1;
			}
			else {
				R[i][j] = R[i][j - 1] + 1;
			}
		}
	}

	// L
	vector<vector<int> > L(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = w - 1; j >= 0; j--) {
			if (s[i][j]) {
				L[i][j] = 0;
			}
			else if (j == w - 1) {
				L[i][j] = 1;
			}
			else {
				L[i][j] = L[i][j + 1] + 1;
			}
		}
	}

	// D
	vector<vector<int> > D(h, vector<int>(w));
	for (int j = 0; j < w; j++) {
		for (int i = 0; i < h; i++) {
			if (s[i][j]) {
				D[i][j] = 0;
			}
			else if (i == 0) {
				D[i][j] = 1;
			}
			else {
				D[i][j] = D[i - 1][j] + 1;
			}
		}
	}

	// U
	vector<vector<int> > U(h, vector<int>(w));
	for (int j = 0; j < w; j++) {
		for (int i = h - 1; i >= 0; i--) {
			if (s[i][j]) {
				U[i][j] = 0;
			}
			else if (i == h - 1) {
				U[i][j] = 1;
			}
			else {
				U[i][j] = U[i + 1][j] + 1;
			}
		}
	}

	int max = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int t = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3;
			if (max < t) {
				max = t;
			}
		}
	}
	cout << max << endl;
}

int main()
{
	d();
}


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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, k, x, y, imo[3333][3333], r;
char c;

int sum(int a, int b, int aa, int bb) {
	return imo[aa][bb] - imo[aa][b-1] - imo[a-1][bb] + imo[a-1][b-1];
}

signed main() {
	cin >> n >> k;
	// (x,y)が白である というのは (x+k,y)が黒である と置き換えられる
	// また (x+2ak,y+2bk)が黒である というのは (x,y)が黒である と置き換えられる
	rep(i,n) {
		cin >> x >> y >> c;
		if (c == 'W') x += k;
		x %= 2 * k, y %= 2 * k;
		imo[x+1][y+1]++;
	}
	// 累積和
	repst(i,1,2222) rept(j,2222) imo[i][j] += imo[i-1][j];
	repst(i,1,2222) rept(j,2222) imo[j][i] += imo[j][i-1];
	// 2k*2kのボードの中には最大で5個黒い四角形が入る(はみ出るやつも含めて)
	// その真ん中の正方形の左上の座標を(1,1)から(k,k)までk*k通り全部試せばいい
	repst(i,1,k) repst(j,1,k) {
		int tmp = 0;
		tmp += sum(i, j, i+k-1, j+k-1);
		tmp += sum(i+k, j+k, 2*k, 2*k);
		tmp += sum(1, 1, i-1, j-1);
		tmp += sum(i+k, 1, 2*k, j-1);
		tmp += sum(1, j+k, i-1, 2*k);
		// tmp個の条件を満たせるってことは白黒反転すればn-tmp個の条件を満たせることにもなる
		chmax(r, max(tmp, n-tmp));
	}
	cout << r << ln;
}

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}

int a[100005];

int main(void){
    int n;
    int i;
    int tmp;
    int cnt = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    int button = 1;
    while (button != 2 && button != 0){
        tmp = button;
        button = a[button-1];
        a[tmp-1] = 0;
        cnt++;
    }

    if (button == 0){
        printf("-1\n");
    }else if (button == 2){
        printf("%d\n", cnt);
    }

    return 0;


}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#define LEN 1000005

using namespace std;

typedef struct pp{
  string name;
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  ++tail;
  Q[tail].name = x.name;
  Q[tail].t = x.t;
}

P dequeue(){
  ++head;
  return Q[head - 1];
}


int main(){
  int e = 0, c;
  int i, q;
  P u;
  cin >> n >> q;
  
  for ( i = 1; i <= n; i++){
    cin >> Q[i].name >> Q[i].t;
  }
  head = 1;
  tail = n;

  while(head <= tail ){
    if(Q[head].t <= q){
      e += Q[head].t ;
      cout << Q[head].name << " " << e << endl;
      dequeue();
    }else{
      e += q;
      Q[head].t -= q;
      enqueue(dequeue());
    }

  }

  
  return 0;
}



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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int x, y; read(x, y);
	rep(i, 0, x + 1) {
		int g = i * 2 + (x - i) * 4;
		if (g == y) die("Yes");
	} die("No");
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
const int INF = 1000000000;

int main()
{
	int a=INF,i;
	string s;
	cin >> s;
	for (i = 0; i <= s.size() - 3; i++)
	{
		int n = (s[i]-'0') * 100 + (s[i + 1]- '0') * 10 + (s[i + 2]- '0');
		a = min(abs(753 - n), a);
		//printf("a%d,n%d\n", a,n);
	}
	printf("%d\n", a);
}


Measured memory_bytes: 256
import math

start, kai, step = map(int, input().split(" "))

if 0 <= abs(start) - (kai * step):
    print(abs(start) - (kai * step))
    exit()

ans1 = start % step
ans2 = abs(ans1 - step)
if (kai - abs(start // step)) % 2 == 0:
    print(abs(ans1))
else:
    print(abs(ans2))


Measured memory_bytes: 9100