akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=a;i>=b;i--)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair
#define mod 1000000007b
#define pi 3.14159265358979323
#define sz(a) (int)((a).size())
#define len(a) (int)(a.length())
#define FOR(i,j,k,l) for(ll i=j;i<k;i+=l)

void Fast_IO() {
   ios::sync_with_stdio(0);
   cin.tie(0);
   #ifndef ONLINE_JUDGE
   freopen("input.in","r",stdin);
   freopen("output.out","w",stdout); 
   #endif
} 
vector<vector<ll> >vii;

int main(){
   //Fast_IO();
   ll n,ans=0;
   cin>>n;
   ll f[10000005];
   f(i,0,10000004) f[i]=1;
   f(i,1,n+1){
     for(int j = i; j <= n; j += i){
        if(j!=i) f[j]+=1;
     }
   }
   f[1]=1;
   f(i,1,n+1){
       //cout<<f[i]<<spc;
       ans += f[i]*i;
   }
   cout<<ans<<endl;
   
      
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	int n;
	int a[100010];
	scanf("%d",&n);
	rep1(i,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	
	int s = n , t = 1;
	while(s >= 2 && a[s-1] >= t+1){
		s --;
		t ++;
	}
	
	int cnt[2] = {};
	cnt[0] = a[s]-t;
	while(s >= 2 && a[s-1] == t){
		cnt[1] ++;
		s --;
	}
	if(((cnt[0]%2)+(cnt[1]%2)) == 0)puts("Second");
	else puts("First");
}



Measured memory_bytes: 640
//#############################################################################
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define INF 1000000000000009
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define vec vector
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
#define sum(v) accumulate(all(v),0LL)
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
#ifdef LOCAL_TESTING
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
template <typename T>
void print_matrix(vector<vector<T>> mat){
    for(auto row: mat){
        for(auto e : row){
            auto fst = e[0]==INF?"INF":to_string(e[0]);
            auto scd = e[1]==INF?"INF":to_string(e[1]);
            cout <<"["<<fst<<","<<scd<< "]"<<" ";
        }
        cout << endl;
    }
}
template <typename T>
void print_vector(vector<T> v){
    for(auto e : v){cout<< e <<" ";}
    cout<<endl;
}
template <typename T>
map<T,T> get_count(vector<T> v){
    map<T,T> count;
    for(auto e: v){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
void add_self(ll &a, ll b){
    a = a+b; if (a>=MOD){a -= MOD;}
}
ll sub_mod(ll a, ll b){
    a = (a-b+MOD)%MOD;
    return a;
}
//#############################################################################
//Solution
void solve(){
    ll n; cin>>n;
    vec<vec<vec<ll>>> dp(n,vec<vec<ll>>(n,{INF,INF}));
    for(ll i = 0LL; i<n; i++){
        ll x; cin>>x;
        dp[i][i] = {x,0LL};
    }
    for(ll ln = 2LL; ln<n+1; ln++){
        for(ll l = 0LL; l<n-ln+1; l++){
            ll r = l+ln-1;
            for(ll k = l; k<r; k++){
                ll curr_val = dp[l][k][0]+dp[k+1][r][0];
                ll curr_cost = curr_val+dp[l][k][1]+dp[k+1][r][1];
                if(curr_cost<dp[l][r][1]){
                    dp[l][r][0] = curr_val;
                    dp[l][r][1] = curr_cost;
                }
            }
        }
    }
    cout<<dp[0][n-1][1]<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
#ifdef LOCAL_TESTING
    cout << "⏰ Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
//#############################################################################

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(void){
    
    int N;
    string s, t;
    cin >> N;
    cin >> s >> t;
    
    for(int i = 0; i < N; i++){
        cout << s[i] << t[i] << (i != N-1 ? "" : "\n");
    }
    
    return 0;
    
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_8_A
    {
        static void Main(string[] args)
        {
            char[] inputLine;
            string outputLine = "";

            inputLine = Console.ReadLine().ToCharArray();

            foreach (var c in inputLine)
            {
                if (char.IsLower(c))
                {
                    outputLine += char.ToUpper(c);
                }
                else
                {
                    outputLine += char.ToLower(c);
                }
            }
            Console.WriteLine(outputLine);
            Console.ReadLine();
        }
    }
}



Measured memory_bytes: 15864
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b)for(int i=a;i<b;i++)
#define repre(i,a,b)for(int i=a;i<=b;i++)
#define clr1(arr) memset(arr,-1,sizeof(arr));
#define clr0(arr) memset(arr,0,sizeof(arr));
#define pi pair<int,int>
#define pii pair<int,pi>
#define aint(v) v.begin(),v.end()
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> orderedSet;
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> orderedMSet;
//*p.find_by_order(index) return value at index
//p.order_of_key(key) return index
/*
2d pointer array
int **dp;
in main function
int row,col;
dp=new int*[n];
rep(i,n)dp[i]=new int[m]
*/
int dp[1009][1009];
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

int32_t main()
{
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  fastio
  int n,m,a,b;
  cin>>n>>m>>a>>b;
  int temp=b;
  int id=0;
  while(temp--)
  {
    int zeros=a;
    int ones=m-a;
    rep(i,m)
    {
      if(zeros)
      {
        dp[id][i]=0;
        zeros--;
      }
      else if(zeros==0 && ones)
      {
        dp[id][i]=1;
        ones--;
      }
    }
    id++;
  }
  temp=n-b;
  while(temp--)
  {
    int zeros=m-a;
    int ones=a;
    rep(i,m)
    {
      if(ones)
      {
        dp[id][i]=1;
        ones--;
      }
      else if(ones==0 && zeros)
      {
        dp[id][i]=0;
        zeros--;
      }
    }
    id++;
  }
  rep(i,n)
  {
    rep(j,m)cout<<dp[i][j];
    cout<<endl;
  }
  return 0;
}

int modInv(int a, int m){
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}

int gcdExtended(int a, int b, int *x, int *y){
if (a == 0){
    *x = 0, *y = 1;
    return b;
}
int x1, y1;
int gcd = gcdExtended(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd;
}

int mpower(int x, int y, int p){
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
}
return res;
}

int power(int x, int y){
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
    y = y>>1;
    x = x*x;
}
return res;
}

bool isPrime(int n){
if (n <= 1)  return false;
if (n <= 3)  return true;
if (n%2 == 0 || n%3 == 0) return false;
int p=sqrt(n);
for(int i=5;i<=p;i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
        return false;
return true;
}


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


int main(void){
    ll n, k;
    cin >> n >> k;
    vector<int> a(n), s, done(n+1, -1);
    int c = 1, l = 0;

    loop(i,n){
        cin>>a[i];
    }

    int v = 1;
    while (done[v] == -1){
        done[v] = s.size();
        s.emplace_back(v);
        v = a[v-1];
    }
    c = s.size() - done[v];
    l = done[v];

    if (k < l) cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5884
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	_ = iScan()
	s := Scan()
	q := iScan()
	k := iSScan(q)
	for _, v := range k {
		d, m, dm, dmc := 0, 0, 0, 0
		for i, r := range s {
			if string(r) == "D" {
				d++
			} else if string(r) == "M" {
				m++
				dm += d
			}
			if i-v >= 0 {
				if string(s[i-v]) == "D" {
					d--
					dm -= m
				} else if string(s[i-v]) == "M" {
					m--
				}
			}
			if string(r) == "C" {
				dmc += dm
			}
		}
		fmt.Println(dmc)
	}
}


Measured memory_bytes: 4868
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, count=1;

    cin >> N;

    vector<int> P(N), Q(N);
    vector<int> nums(N);
    vector<int> a(2, -1);
    iota(nums.begin(), nums.end(), 1);

    rep(i, N) {
        cin >> P[i];
    }
    rep(i, N) {
        cin >> Q[i];
    }

    do{
        count++;
        if(nums==P) {
            a[0] = count;
        }
        if(nums==Q) {
            a[1] = count;
        }
        if(a[0]!=-1&&a[1]!=-1) break;
    } while (next_permutation(nums.begin(), nums.end()));

    cout << abs(a[0]-a[1]) << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PII;
typedef long double DB;
mt19937 mrand(random_device{}()); 
const LL mod=1000000007;
int rnd(int x) { return (int)mrand() % x;}
LL powmod(LL a,LL b) { LL res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
LL gcd(LL a,LL b) { return b?gcd(b,a%b):a;}
// head

const int N=1001010;
VI num[N];
int a[N],vis[N],bad[N];
int n;
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%d",a+i);
		num[a[i]].pb(i);
		vis[a[i]]=1;
	}
	rep(i,1,N) if (vis[i]) {
		// printf("i=%d\n",i);
		if (SZ(num[i])>1) bad[i]=1;
		for (int j=2*i;j<N;j+=i) if (vis[j]) {
			// printf("%d\n",j);
			bad[j]=1;
		}
	} 
	int cnt=0;
	rep(i,1,N) if (vis[i]) {
		// printf("%d %d\n",i,bad[i]);
		if (!bad[i]) cnt+=SZ(num[i]);
 	}
 	printf("%d",cnt);
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll ans = 0;
    ll A[N+1]; rep(i, N+1) cin >> A[i];
    ll B[N]; rep(i, N) cin >> B[i];
    for(int i = N-1; i >= 0; i--){
        if(B[i] >= A[i+1]){
            ans += A[i+1];
            B[i] -= A[i+1];
            A[i+1] = 0;
            if(B[i] >= A[i]){
                ans += A[i];
                B[i] -= A[i];
                A[i] = 0;
            }
            else{
                ans += B[i];
                A[i] -= B[i];
                B[i] = 0;
            }
        }
        else{
            ans += B[i];
            A[i+1]-=B[i];
            B[i] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

int main()
{
    using namespace std;
    string w;
    cin >> w;
    
    vector<char> count(26);
    bool flag = true;
    
    for (auto iter = w.begin(); iter != w.end(); ++iter) {
        auto idx = *iter - 'a';
        count[idx] += 1;
    }
    
    for (auto iter = count.begin(); iter != count.end(); ++iter) {
        if (*iter % 2 != 0) {
            flag = false;
            break;
        }
    }
    
    if (flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

long long gcd(long long a,long long b) {
  if (a > b) {
    swap(a,b);
  }
  if (b%a == 0) return a;
  return gcd(a,b%a);
}

long long lcm(long long a,long long b) {
  long long x;
  x = a / gcd(a,b);
  x *= b;
  return x;
}

int main() {
  long long N,M;
  cin >> N >> M;
  vector<long long> a(N);
  
  for (int i=0; i<N; i++) {
    cin >> a[i];
    a[i] /= 2;
  }
  
  long long BLCM = a[0];
  for (int i=1; i<N; i++) {
    BLCM = lcm(BLCM,a[i]);
    if (BLCM > M) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  long long val;
  for (int i=0; i<N; i++) {
    val = BLCM / a[i];
    if (val % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  
  long long ans = M / BLCM;
  ans = (ans + 1) / 2;
    
  
  cout << ans << endl;
} 

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

int main() {
  int A, B;
  cin >> A >> B;
  vector<int> results = {A+B, A-B, A*B};
  int MaxValue = results.at(0);
  for (auto a : results) {
    if (MaxValue < a) MaxValue = a;
  }
  cout << MaxValue << endl;
}

Measured memory_bytes: 256
//package code;
import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
    public static int t,Dx ,Dy ,J,ans,n,len=0,answer,q ,k,x ,m, a[],tin[],tout[],discover[],time, b[],count,degree[],parent[] ,parent_count[], size[] ,mat[][] , depth[],pre[],blockSize;
    static long  mod=(long)(1e9) + 7 , dp[],sum ,mod1=(long)(998244353);
    static int[] dx={-1, 1,0,0} , dy={0 ,0 , -1 ,1};
    static boolean visited[],isPandatic[];
    public static TreeSet<Integer> ts[];
    public static LinkedList<Integer> lst ,adj[];
    public static PrintWriter pw;
    public static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    public static int max1=2000005;
    public static void main(String[] args){
        new Thread(null,null,"Prabhat Kumar Prajapati",1<<28)
        {
           public void run() 
           {
               try
               {
                   solve();
               }
               catch(Exception e)
               {   
                   e.printStackTrace();
                   System.exit(1);
               }
           }
        }.start();
    }
public static void solve()throws IOException
{
    pw = new PrintWriter(System.out);
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    long k=sc.nextLong();
    a=new int[n];
    for(int i=0;i<n;i++)a[i]=sc.nextInt()-1;

    int cycleLength=0;
    int move=0;
    int[] moveTillIndex=new int[n];
    Arrays.fill(moveTillIndex,-1);
    moveTillIndex[0]=0;
    int pos=0;
    boolean cycle=false;
    while(k>0){
        pos=a[pos];
        move++;
        k--;
        if(cycle){

        }
        else if(moveTillIndex[pos]>=0){
            k%=(move-moveTillIndex[pos]);
            cycle=true;
        }
        else moveTillIndex[pos]=move;
    }
   
    pw.println(pos+1);
    pw.close();
}

// here ans will store number of nodes on longest path
static int dfs(int cur){
    int d1=0;
    int d2=0;
    visited[cur]=true;
    for(int ver:adj[cur]){
        if(visited[ver])continue;
        int x=dfs(ver);
        if(x>d1){
            d2=d1;
            d1=x;
        }
        else if(x>d2){
            d2=x;
        }
        ans=Math.max(ans , d1+d2+1);
    }
    //pw.println((cur+1)  +" "+d1+" "+d2);
    return d1+1;
}
public static long pow(long n,long p,long m)
{
    long  result = 1;
      if(p==0)
        return 1;
    
    while(p!=0)
    {
        if(p%2==1)
            result *= n;
        if(result>=m)
        result%=m;
        p >>=1;
        n*=n;
        if(n>=m)
        n%=m;
    }
    return result;
}

}

Measured memory_bytes: 60448
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long 
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define N ((ll)(2e6+100))
#define MAX ((ll)(1e16+100))
#define ARRS ((ll)(3e5+100))
#define MOD ((ll)(1e9+7))
#define M1 ((ll)(1001783))
#define M2 ((ll)(1001941))
#define M3 ((ll)(1002073))
#define pb push_back

ll dp[ARRS];
ll f[ARRS];
ll c[ARRS];


ll go(ll x){
	if(x&1)x^=1;
	if(!x)return 0;
	if(dp[x])return dp[x];
	ll a[18];
	ll b[18];
	for(int i=0; i<16; i++)a[i]=(x>>i)&1;
	dp[x]=MAX;
	for(int i=1; i<16; i++){
		for(int j=i+1; j<16; j++){
			if(a[i]&&a[j]){
				for(int t=1; t<16; t++){
					for(int i=0; i<16; i++)b[i]=a[i];
					b[i]--;
					b[j]--;
					b[i^t]++;
					b[j^t]++;
					ll k=0;
					ll r=0;
					for(int i=0; i<16; i++){
						k+=b[i]/2;
						b[i]&=1;
						r=r|(b[i]<<i);
					}
					//cout<<bitset<16>(x)<<endl;
					//cout<<i<<" "<<j<<" "<<t<<" "<<k<<endl;
					//cout<<bitset<16>(r)<<endl;
					//cout<<endl;
					if(x==r)continue;
					dp[x]=min(dp[x],go(r)+k+1);
				}
			}
		}
	}
	return dp[x];
}


int main(){

	ll n;
	cin>>n;
	for(int i=0; i<n-1; i++){
		ll k,p,c;
		cin>>k>>p>>c;
		f[k]^=c;
		f[p]^=c;
	}
	for(int i=0; i<n; i++)
		c[f[i]]++;

	ll t=0;
	ll pas=0;
	for(int i=0; i<16; i++){
		if(i)
		pas+=c[i]/2;
		c[i]&=1;
		t=t|(c[i]<<(i));
	}

	pas+=go(t);

	cout<<pas;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
#define db double
#define vi vector<int>
#define pb push_back
#define mod 998244353
#define fi first
#define se second
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
// head
map<ll, ll> r;
#define iter map<ll, ll>::iterator
ll st[maxn];
ll ans[maxn];
int main() {
	int top = 0;
	int n, q;
	cin >> n >> q;
	st[top++] = n;
	for (int i = 0; i < q; i++) {
		ll u;
		scanf("%lld", &u);
		while (top && st[top - 1] >= u) top--;
		st[top++] = u;
	}
	r[st[top - 1]]++;
	for (int i = top - 2; i >= 0; i--) {
		ll ns = st[i];
		while (1) {
			iter g = r.end();
			g--;
			if (g->fi <= ns) break;
			ll dv = g->fi, nm = g->se;
			if (dv % ns) r[dv % ns] += nm;
			r[ns] += dv / ns * nm;
			r.erase(g->fi);
		}
	}
	for (int i = n; i >= 1; i--)
		ans[i] = ans[i + 1] + r[i];
	for (int i = 1; i <= n; i++)
		printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 9472
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let N = read!(i64);
	println!("{}", (N - 1) / 2);
}


Measured memory_bytes: 8572
#include<iostream>
#include<stdio.h>
using namespace std;

#define N 100

int n;

void print(int A[]){
  int i;
  for(i=0; i<n-1; i++) printf("%d ",A[i]);
  cout<<A[i]<<endl;
}

int main(){
  int i,key,A[N],j;

  cin >> n;
  for(i=0; i<n; i++){
    cin >> A[i];
  }
  print(A);
  for(i=1; i<n; i++){
    key = A[i];
    j = i-1;
    while(j>=0 && A[j]>key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    print(A);
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,j,n) for(int i = (int)(j); i < (int)(n); i++)
#define mrep(i,n) for (int i = (int)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20)
#define fi first
#define se second
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int n,m; ll k; cin >> n >> m >> k;
	ll a[n],b[m];
	ll A[n+1],B[m+1];
	A[0]=0; B[0]=0;
	rep(i,n) {
		cin >> a[i];
		A[i+1]=A[i]+a[i];
	}
	rep(i,m) {
		cin >> b[i];
		B[i+1]=B[i]+b[i];
	}
	int ans=0;
	for(int i=0;i<=n;i++) {
		ll tim=A[i];
		if(tim>k) continue;
		ll limit=k-tim;
		if(limit>=B[m]) {
			ans=max(ans,i+m);
			continue;
		}
		int ok=0; int ng=m;
		rep(i,40) {
			int c=(ok+ng)/2;
			if(limit>=B[c]) ok = c;
			else ng = c;
		}
		ans=max(ans,i+ok);
	}
	cout << ans << endl;
}

Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main() {
    cin>>n>>a>>b;
    if(a>b||(n==1&&a!=b)) puts("0");
    else printf("%lld\n",1ll*b*(n-1)+a-1ll*a*(n-1)-b+1);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  int cand[10]={111,222,333,444,555,666,777,888,999,1111};
  for(int i=0;i<10;i++){
    if(N<=cand[i]){
      cout<<cand[i]<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
v,e,r = map(int,input().split())
std = [ list(map(int,input().split())) for _ in range(e) ]

def BellmanFord(edges,num_v,source):
    #グラフの初期化
    inf = float("inf")
    dist = [ inf for i in range(num_v)]
    dist[source] = 0
    
    #辺の緩和
    for i in range(num_v):
        for edge in edges:
            if edge[0] != inf and dist[edge[1]]>(dist[edge[0]]+edge[2]):
                dist[edge[1]] = dist[edge[0]] + edge[2]
                if i==(num_v-1):
                    return False,[]
    return True,dist

flag,distance = BellmanFord(std,v,r)
# print(flag)
if flag:
    for i in range(v):
        if distance[i]!=float("inf"):
            print(distance[i])
        else:
            print("INF")
else:
    print("NEGATIVE CYCLE")


Measured memory_bytes: 6128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>

using namespace std;

using ll = long long;
using ld = long double;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    int result = 0;
    int pa = N + 1, a, b, c;
    vector<int> is;
    REP(i, 0, N)
    {
        cin >> a;
        if (pa == a - 1) is.emplace_back(a - 2);
        pa = a;
    }

    REP(i, 0, N)
    {
        cin >> b;
        result += b;
    }

    REP(i, 0, N - 1)
    {
        cin >> c;
        if (find(is.begin(), is.end(), i) != is.end())
        {
            result += c;
        }
    }

    cout << result << endl;
}


Measured memory_bytes: 256
N = int(input())
e = [0] * (N+1)
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m): # e の要素のうち m-1 以上のものの個数
    return len(list(filter(lambda x: x >= m-1, e)))


print(num(75) + num(25) * (num(3) - 1) + num(15) * (num(5) - 1) + num(5) * (num(5) - 1) * (num(3) - 2) // 2)

Measured memory_bytes: 3064
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int N=sc.nextInt();
        int n=N%10;
        if(n==3){
            System.out.println("bon");
        }
        else if(n==0 || n==1 || n==6 || n==8){
            System.out.println("pon");
        }
        else{
            System.out.println("hon");
        }
        
        
    }
}

Measured memory_bytes: 35752
H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]
ans = [[0]*W for _ in range(H)]
empty_index = [False]*H
first_flg = False
cnt = 0
for i in range(H):
    if '#' not in grid[i]:
        empty_index[i] = True
for i in range(H):
    if not empty_index[i] and not first_flg:
        first_flg = True
        first_index = i
    if not first_flg:
        continue
    if empty_index[i]:
        for k in range(W):
            ans[i][k] = ans[i-1][k]
    else:
        cnt += 1
        flg = False
        for k in range(W):
            if grid[i][k] == '#':
                if not flg:
                    flg = True
                else:
                    cnt += 1
            ans[i][k] = cnt
for i in range(H):
    if not empty_index[i]:
        break
    for k in range(W):
        ans[i][k] = ans[first_index][k]
for i in ans:
    print(*i)

Measured memory_bytes: 79768
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll) (1e15)
#define mod (ll) (1e9 + 7)
#define endl "\n"
#define tt ll testcase; cin>>testcase; while(testcase--)

const int mxn = 1*(1e5) + 5;
ll n;

int solve(){
	ll x,y;
	cin>>x>>y;
	if((4*x-y >= 0) && ((4*x-y)%2 == 0)){
		if(y%2 == 0){
		if((y-2*x >= 0) && ((y - 2*x)%2 == 0)) {
			cout<<"Yes";
			return 0;
		}
		}
	}		
	cout<<"No";
  return 0;
}
 
int main(){
	fast;
	// tt
		solve();
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {
	int s,w;
	cin >> s >> w;
	if(s>w){
		println("safe");

	}else{
		println("unsafe");
	}
	return 0;
}


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

int t[100000];

int main() {
	int n;
	int s = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> t[i];
		s += t[i];
	}
	int m;
	cin >> m;
	for (int i = 0;i < m;i++) {
		int p, x;
		cin >> p >> x;
		int y = t[p - 1] - x;
		y = s - y;
		cout << y << endl;
	}
	return 0;
}

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

int main(){
    int r, D, x2000, now, next;
    cin >> r >> D >> x2000;
    now = x2000;
    for (int i = 0; i < 10; i++)
    {
        next = r * now - D;
        cout << next << endl;
        now = next;
    }
    
}

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

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  
  int ans;
  if (a <= b) {
    if (a + W <= b) ans = b - (a + W);
    else ans = 0;
  }
  else {
    if (b + W <= a) ans = a - (b + W);
    else ans = 0;
  }
  
  cout << ans << endl;
  return 0;
}

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

string s;
int n, p;
map<int,int> freq;
long long delta = 1;

#define f(i,a,b) for (int i = a; i < b; i++)

long long modpow(long long a, long long b) {
  	long long res = 1;
  	while (b) {
    	if (b&1) res = res*a%p;
      	a = a*a%p;
      	b /= 2;
    }
	return res;
}

int main() {
  	ios_base::sync_with_stdio(0);
  	cin.tie(0);
	cin>>n>>p>>s;
  
  	if (p == 2 || p == 5) {
      	long long ans = 0;
    	f(i,0,n) {
          	if ((s[i]-'0')%p == 0) {
          		ans += i+1;
        	}
        }
      	cout << ans << endl;
    } else {
      	long long rho = 0, ans = 0;
      	freq[0]++;
		f(i,0,n) {
    		rho = (rho*10%p + (s[i]-'0')) % p;
          	long long rhodelta = rho * modpow(delta, p-2) % p;
          	ans += freq[rhodelta]++;
    		delta = delta * 10 % p;
  	  	}
      	cout << ans << endl;
    }
  	
	return 0;
}

Measured memory_bytes: 916
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	taxa := 8
	taxb := 10

	for i := 1; i < 10000; i++ {
		vala := i * taxa / 100
		valb := i * taxb / 100
		if vala == a && valb == b {
			fmt.Println(i)
			return
		}
		if i == 10000-1 {
			fmt.Println(-1)
		}
	}
}

Measured memory_bytes: 512
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  cout << t << s << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int A = scanner.nextInt();
		int B = scanner.nextInt();

		String feel = "dangerous";

		if (B - A <= 0) {
			feel = "delicious";
		} else if (B - A <= X) {
			feel = "safe";
		}
		System.out.println(feel);
	}

}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n, q; cin >> m >> n >> q;
	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];

	vvl root(m+1,vl(n+1)), comp(m,vl(n,-1)), h(m,vl(n));
	ll C = 0;

	FOR(i,0,m) FOR(j,0,n) if (a[i][j] == '1' && comp[i][j] == -1) {
		root[i+1][j+1] = 1;
		queue<ll> q;
		comp[i][j] = C++;
		q.push(i), q.push(j);
		while (sz(q)) {
			ll x = q.front(); q.pop();
			ll y = q.front(); q.pop();
			FOR(dir,0,4) {
				ll nx = x+dx[dir], ny = y+dy[dir];
				if (nx < 0 || nx >= m || ny < 0 || ny >= n) continue;
				if (a[nx][ny] == '0') continue;
				if (comp[nx][ny] != -1) continue;
				comp[nx][ny] = comp[x][y];
				h[nx][ny] = h[x][y] + 1;
				q.push(nx), q.push(ny);
			}
		}
	}
	
	FOR(i,0,m) FOR(j,0,n) root[i+1][j+1] += root[i+1][j] + root[i][j+1] - root[i][j];
	
	vvl up(m+1,vl(n+1)), dn(m+1,vl(n+1));
	vvl le(m+1,vl(n+1)), ri(m+1,vl(n+1));
	
	FOR(i,1,m) FOR(j,0,n)
		up[i][j+1] = up[i][j] + (a[i-1][j] == '1' && a[i][j] == '1' && h[i][j] > h[i-1][j]);
	FOR(i,0,m-1) FOR(j,0,n)
		dn[i][j+1] = dn[i][j] + (a[i+1][j] == '1' && a[i][j] == '1' && h[i][j] > h[i+1][j]);
	FOR(i,0,m) FOR(j,1,n)
		le[i+1][j] = le[i][j] + (a[i][j-1] == '1' && a[i][j] == '1' && h[i][j] > h[i][j-1]);
	FOR(i,0,m) FOR(j,0,n-1)
		ri[i+1][j] = ri[i][j] + (a[i][j+1] == '1' && a[i][j] == '1' && h[i][j] > h[i][j+1]);

	while (q--) {
		ll x1, y1, x2, y2;
		cin >> x1 >> y1 >> x2 >> y2;
		x1--, y1--;

		ll res = root[x2][y2] - root[x1][y2] - root[x2][y1] + root[x1][y1];
		res += up[x1][y2] - up[x1][y1];
		res += dn[x2-1][y2] - dn[x2-1][y1];
		res += le[x2][y1] - le[x1][y1];
		res += ri[x2][y2-1] - ri[x1][y2-1];
		cout << res << "\n";
	}
}



Measured memory_bytes: 225536
N, K = input().split()
d = []
x2 = []
count = 0
for i in range(0, int(N)):
  x2.append(0)
for i in range(0, int(K)):
  d = int(input())
  x = input().split()
  for j in x:
    if x2[int(j)-1] == 0:
      x2[int(j)-1] = 1
      count += 1
print(int(N)-count)

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

int main()
{
    char s[2][51],pass[102];
    int num[2];

    scanf("%s %s",s[0],s[1]);

    num[0] = strlen(s[0]);
    num[1] = strlen(s[1]);

    for (int i = 0; i < num[0]; i++)
    {
        pass[i * 2] = s[0][i];
    }
    for (int i = 0; i < num[1]; i++)
    {
        pass[i * 2 + 1] = s[1][i];
    }
    pass[num[0] + num[1]] = NULL;
    printf("%s",pass);
}

Measured memory_bytes: 128
// 未解決

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

#define EACH(i, a) for (auto &&i : a)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RFOR(i, a, b) for (int i = (int)b - 1; i >= (int)a; --i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREPS(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(x) (x).begin(), (x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define debug(x) cout << #x << ": " << x << endl

#define pb push_back
#define mp make_pair
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define INF (1L << 30)
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
template <class T>
void pvp(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << "(" << i->first << ", " << i->second << ") ";
  cout << endl;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

using ll = long long;
#define int ll

//**********

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

  int n;
  cin >> n;

  double x[8];
  double y[8];  // 0-7

  REP(i, n) {
    int a, b;
    cin >> a >> b;
    x[i] = a;
    y[i] = b;
  }

  double sum = 0.0;
  REP(i, n) {
    FOR(j, i + 1, n) {
      sum += sqrt(pow(x[j] - x[i], 2) + pow(y[j] - y[i], 2));
      // cout << i << j << endl;
    }
  }

  // debug(sum);

  int n_kaijo = 1;
  REPS(i, n) { n_kaijo *= i; }
  // debug(n_kaijo);
  double ans = sum * 2.0 / n;

  cout << setprecision(10) << ans << endl;
  return 0;
};


Measured memory_bytes: 256
# W, Hは上限
# x, hは下限
# W, w, H, hをN回更新

W, H, N = map(int, input().split())
w, h = 0, 0

for i in range(N):
    x, y, a = map(int, input().split())

    if a == 1 and w < x:
        w = x
    elif a == 2 and W > x:
        W = x
    elif a == 3 and h < y:
        h = y
    elif a == 4 and H > y:
        H = y
if W-w <= 0 or H-h <= 0:
    print(0)
else:
    S = (W - w) * (H -h)
    print(S)

Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
from collections import deque
que=deque()
for i in range(n):
    if i%2==0:
        que.append(a[i])
    else:
        que.appendleft(a[i])
if n%2==0:
    print(*list(que))
else:
    print(*list(que)[::-1])


Measured memory_bytes: 92956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N;
    cin >> N;
    double x[10], y[10];
    rep(i, 0, N) cin >> x[i] >> y[i];
    int array[10];
    rep(i, 0, N) array[i] = i;
    double cnt = 0, ans = 0;
    do{
        double l = 0;
        for(int i=0; i<N-1; i++){
            int ind = array[i];
            int ind2 = array[i+1];
            double dx = x[ind2] - x[ind];
            double dy = y[ind2] - y[ind];
            l += sqrt(dx * dx + dy * dy);
        }
        ans += l;
        cnt += 1;
    }while(next_permutation(array,array+N));
    
    printf("%.12lf\n", ans/cnt);
    return 0;
}

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

int main(){
  int N; cin>>N;
  vector<int> cards(N);
  
  for(int i=0; i<N; i++){
    cin>>cards.at(i);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int asum=0, bsum=0;
  for(int i=0; i<N; i++){
    if(i % 2 == 0)
      asum += cards.at(i);
    else
      bsum += cards.at(i);
  }
  
  cout<<asum - bsum;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, s: "List[int]"):
    v = [A, B, C]
    ans = []
    if sum(v) == 0:
        return None
    if sum(v) == 1:
        for l, r in s:
            if v[l] + v[r] == 0:
                return None
            if v[l] == 0:
                ans.append(l)
            else:
                ans.append(r)
            v[l], v[r] = v[r], v[l]
        return ans
    if sum(v) > 1:
        for i in range(N):
            l, r = s[i]
            if v[l] + v[r] == 0:
                return None
            if v[r] == 1 and v[l] == 1 and i != N - 1:
                ln, rn = s[i + 1]
                if r == ln or r == rn:
                    ans.append(r)
                    v[l] -= 1
                    v[r] += 1
                else:
                    ans.append(l)
                    v[l] += 1
                    v[r] -= 1
            elif v[r] == 0 or v[l] > v[r]:
                ans.append(r)
                v[l] -= 1
                v[r] += 1
            else:
                ans.append(l)
                v[l] += 1
                v[r] -= 1
        return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    def s2i(s: str):
        return ord(s[0])-ord('A'), ord(s[1])-ord('A')

    def i2s(i: int):
        return chr(i + ord('A'))

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    s = [s2i(next(tokens)) for _ in range(N)]  # type: "List[int]"
    ans = solve(N, A, B, C, s)
    if ans == None:
        print(NO)
    else:
        print(YES)
        print("\n".join(list(map(i2s, ans))))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    vector<P> a;
    int x,y;
    for(int i=0;i<n;i++){
        cin>>x>>y;
        a.push_back(P(x,y));
    }
    sort(a.begin(),a.end(),greater<P>());
    vector<P> Q;
    int x1,y1;
    for(int i=0;i<n;i++){
       x1=a.at(i).first;
       y1=a.at(i).second;
        for(int j=i+1;j<n;j++){
            int dx1=x1-a.at(j).first;
            int dy1=y1-a.at(j).second;
           Q.push_back(P(dx1,dy1));
        }
    }
    sort(Q.begin(),Q.end());
    int j=1,count=1,ans=0;
    P fal=make_pair(0,0);
for(int i=0;i<Q.size();i++){
    if(Q.at(i)==fal)continue;
    j=i+1;
while(j<Q.size()&&Q.at(i)==Q.at(j)){
    count++;
    j++;
}
i+=j-i-1;
chmax(ans,count);
count=1;
}

cout<<n-ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int N,M;
const double EPS = 1e-10;
vector<vector<int>> G;
double dp[600];
int ab[600];

double dfs1(int v) {
    if (v==N-1) return 0.0;
    if (dp[v] > EPS) return dp[v];
    double MAX = 0.0;
    for (auto nv : G[v]) {
        double val = dfs1(nv);
        dp[v] += val+1.0;
        if (chmax(MAX,val)) ab[v] = nv;
    }
    if (G[v].size()==1) ab[v] = -1;
    dp[v] /= G[v].size();
    return dp[v];
}

double dfs2(int v, int u) {
    if (v==N-1) return 0.0;
    if (dp[v] > EPS) return dp[v];
    int cnt = 0;
    for (auto nv : G[v]) {
        if (v==u&&nv==ab[v]) continue;
        dp[v] += dfs2(nv,u) + 1.0;
        cnt++;
    }
    dp[v] /= cnt;
    return dp[v];
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> M;
    G.resize(N);
    rep(i,M) {
        int s,t; cin >> s >> t;
        --s; --t;
        G[s].emplace_back(t);
    }

    rep(i,N) ab[i] = -1;
    double ans = dfs1(0);
    rep(i,N) {
        rep(j,N) dp[j] = 0;
        chmin(ans,dfs2(0,i));
    }

    cout << fixed << setprecision(10) << ans << ln;
}


Measured memory_bytes: 1408
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()

	// make([]int, length, capacity)
	exp := make([]bool, 1001, 1001)
	exp[1] = true
	for i := 2; i <= n; i++ {
		for j := i * i; j <= n; j *= i {
			exp[j] = true
		}
	}
	for i := n; i > 0; i-- {
		if exp[i] {
			fmt.Printf("%+v\n", i) // output for debug
			break
		}
	}

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640