akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Splay_Tree{
	private:
	int n;
	vi L,R,par,val,date,sub;
	inline void Fix(int k){
		sub[k]=sub[L[k]]+sub[R[k]]+1;
		date[k]=((val[k]+date[L[k]])%mod+date[R[k]])%mod;
	}
	inline void Set(int k,int l,int r,int p,bool B=0){
		if(B) swap(l,r);
		L[k]=l;R[k]=r;par[k]=p;
		if(l!=n) par[l]=k;
		if(r!=n) par[r]=k;
		Fix(k);
	}
	inline int Ch(int v,bool B){return (B?R[v]:L[v]);}
	void Rotate(int v,bool B){
		int p=par[v],u=Ch(v,B);
		Set(v,Ch(u,!B),Ch(v,!B),u,B);
		Set(u,Ch(u,B),v,p,B);
		if(p!=n) (L[p]==v?L[p]:R[p])=u;
	}
	int Splay(int u){
		while(par[u]!=n){
			int v=par[u],w=par[v];
			bool A=(R[v]==u),B=(R[w]==v);
			if(w==n){
				Rotate(v,A);
				continue;
			}
			if(A==B){swap(v,w);swap(A,B);}
			Rotate(v,A);Rotate(w,B);
		}
	}
	public:
	void Init(int N){
		n=N;
		L=R=par=vi(n+1,n);
		val=date=vi(n+1);
		sub=vi(n+1,1);
		sub[n]=0;
	}
	int Find(int v,int k){
		Splay(v);
		while(1){
			int t=sub[L[v]];
			if(t==k) break;
			if(k<t) v=L[v];
			else k-=t+1,v=R[v];
		}
		Splay(v);
		return v;
	}
	void Update(int k,int x){
		k=Find(0,k);
		val[k]=x;Fix(k);
	}
	int Sub(int v){Splay(v);return sub[v];}
	void Merge(int l,int r){
		r=Find(r,0);
		Splay(l);
		Set(r,l,R[r],n);
	}
	int Split(int v,int k){
		if(!k||k==Sub(v)) return n;
		v=Find(v,k);
		par[L[v]]=n;
		Set(v,n,R[v],n);
		return v;
	}
	int Split_id(int v){
		Splay(v);
		return Split(v,sub[L[v]]+1);
	}
	void Open(){
		for(int i=0;i<=n;i++) cout<<i<<':'<<L[i]<<' '<<R[i]<<' '<<par[i]<<endl;
	}
};

class LinkCut_Tree{
	private:
	int n;
	Splay_Tree sp;
	vi par;
	public:
	LinkCut_Tree(int N){
		n=N;
		sp.Init(n);
		par=vi(n+1,n);
	}
	int Expose(int v){
		int u=sp.Split_id(v);
		if(u!=n) par[u]=v;
		while(1){
			u=sp.Find(v,0);
			if(par[u]==n) break;
			int w=sp.Split_id(par[u]);
			if(w!=u) par[w]=par[u];
			sp.Merge(par[u],u);
		}
		return u;
	}
	void Link(int v,int p){
		Expose(p);
		par[v]=n;
		sp.Merge(p,v);
	}
	void Cut(int v){
		Expose(v);
		sp.Split_id(par[v]);
		par[v]=n;
	}
	int LCA(int u,int v){
		int ru=Expose(u),rv=Expose(v);
		if(ru!=rv) return -1;
		int w=par[sp.Find(u,0)];
		if(w==n) return u;
		return  w;
	}
	void Open(){
		sp.Open();
		for(auto i:par) cout<<i<<' ';
		cout<<endl;
	}
};

int n,q;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	LinkCut_Tree lct(n);
	for(int i=0;i<n;i++){
		int m;
		cin>>m;
		for(int j=0;j<m;j++){
			int v;
			cin>>v;
			lct.Link(v,i);
		}
	}
	cin>>q;
	for(int i=0;i<q;i++){
		int u,v;
		cin>>u>>v;
		cout<<lct.LCA(u,v)<<endl;
	}
}


Measured memory_bytes: 5532
import fractions


class AntiDivision:
    def __init__(self):
        self.A, self.B, self.C, self.D = map(int, input().split())

    def cal(self):
        a_b_count = self.B - self.A + 1
        lcm = (self.C * self.D) // fractions.gcd(self.C, self.D)
        c_count = self.B // self.C - (self.A - 1) // self.C
        d_count = self.B // self.D - (self.A - 1) // self.D
        lcm_count = self.B // lcm - (self.A - 1) // lcm

        print(a_b_count - c_count - d_count + lcm_count)


antiDivision = AntiDivision()
antiDivision.cal()


Measured memory_bytes: 5048
#!/usr/bin/env python3
#ABC134 C

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
a = [int(input()) for _ in range(n)]
b = sorted(a)
for i in a:
    if i == b[-1]:
        print(b[-2])
    else:
        print(b[-1])


Measured memory_bytes: 70488
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

#define mp make_pair
#define f first
#define s second

using namespace std;

typedef pair<int,int> P;

const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int h,w;
string grid[1000];
int d[1000][1000];
P v[1001];

int bfs(P S,int n){

  queue<P>que;
  que.push(S);
  d[S.f][S.s]=0;

  while(!que.empty()){
    P now=que.front();
    que.pop();

    for(int i=0;i<4;i++){
      if(0<=now.f+dx[i] && 0<=now.s+dy[i] &&
	 now.f+dx[i]<h && now.s+dy[i]<w
	 && grid[now.f+dx[i]][now.s+dy[i]]!='X'){

	if(d[now.f][now.s]+1<d[now.f+dx[i]][now.s+dy[i]]){
	  d[now.f+dx[i]][now.s+dy[i]]=d[now.f][now.s]+1;
	  que.push(P(now.f+dx[i],now.s+dy[i]));
	}
      }
    }
  }
  return d[v[n+1].f][v[n+1].s];
}

int main(void){
  int n;

  cin >> h >> w >> n;

  for(int i=0;i<h;i++)cin >> grid[i];

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(grid[i][j]=='S')v[0]=mp(i,j);
      if(grid[i][j]!='X'&&grid[i][j]!='.')
	v[grid[i][j]-'0']=mp(i,j);
    }
  }

  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<h;j++)
      for(int k=0;k<w;k++)d[j][k]=100000000;
    ans+=bfs(v[i],i);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6184
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

int r[100050];
int root(int x) {
	return (x == r[x]) ? x : (r[x] = root(r[x]));
}

int main() {
	int N, M, i, j;
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) r[i] = i;
	while (M--) {
		int t1, t2, t3;
		scanf("%d %d %d", &t1, &t2, &t3);
		r[root(t1)] = root(t2);
	}

	int ans = 0;
	for (i = 1; i <= N; i++) if (r[i] == i) ans++;
	return !printf("%d\n", ans);
}

Measured memory_bytes: 640
#!/usr/bin/perl

while (<>) {
    ($a, $b) = split /\s+/, $_;
}

if ($a % 3 == 0) {
    print "Possible\n";
} elsif ($b % 3 == 0) {
    print "Possible\n";
} elsif (($a + $b) % 3 == 0) {
    print "Possible\n";
} else {
    print "Impossible\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n;
vector <int> vec[10005];
int c[10005];
int k;
int res[10005];
bool visit[10005];

void dfs(int x,int p)
{
	visit[x]=true;
	res[x]=c[k++];
	for(auto u:vec[x])
	{
		if(visit[u]) continue;
		if(u==p) continue;
		dfs(u,x);
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	int x,y;
	for(int i=0;i<n-1;i++)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	for(int i=0;i<n;i++)
	{
		scanf("%d",c+i);
	}
	sort(c,c+n);
	reverse(c,c+n);
	dfs(0,-1);
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		ans+=c[i];
	}
	cout<<ans<<endl;
	for(int i=0;i<n;i++)
	{
		printf("%d ",res[i]);
	}
	cout<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using edge = struct { int to; ll cost; };

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)

long long combination[10001][10001];

//initC(int n);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    int q;
    cin >> q;
    vector<ll> a(q), b(q);
    REP(i, q) cin >> a[i] >> b[i];
    REP(i, q) {
        ll ans = 0ll;
        ll score = a[i]*b[i];
        if(a[i] > b[i]) swap(a[i], b[i]);

        if(a[i] == b[i] || a[i] + 1ll == b[i]) cout << 2ll*a[i] - 2ll << "\n";
        else {
            ll c = (ll)sqrt(score);
            if(c*c == score) c--;
            if(c*(c+1ll) >= score) cout << 2ll*c - 2ll << "\n";
            else cout << 2ll*c - 1ll << "\n";
        }
    }
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
x,y = map(int, input().split())

mod = 10**9+7
def inv(x):
        return pow(x, mod-2, mod)
def fact(x):
        f = 1 
        for i in range(1, x + 1): 
                f *= i
                f %= mod    
        return f
def comb(n, r): 
        return (fact(n) * inv(fact(n-r)) * inv(fact(r))) % mod 

if (x + y) % 3 != 0 or y / x < 1/2 or y/x > 2:
    print(0)
else:
    n = (2*y-x)//3
    m = (2*x-y)//3
    res = comb(n+m, m)
    print(res)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, C; cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    vector<vector<int>> G(N, vector<int>(N));
    
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            cin >> D[i][j];
        }
    }
    
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            cin >> G[i][j];
            G[i][j]--;
        }
    }
    
    
    vector<vector<int>> Sum(3, vector<int>(C));
    for(int i=0; i<C; i++){
        for(int x=0; x<N; x++){
            for(int y=0; y<N; y++){
                Sum[(x+y)%3][i] += D[G[x][y]][i];
            }
        }
    }
    
    
    int ret = INF;
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            for(int k=0; k<C; k++){
                
                if(i==j || j==k || k==i) continue;
                ret = min(ret, Sum[0][i]+Sum[1][j]+Sum[2][k]);
                
            }
        }
    }
    
    cout << ret << endl;
    
    return 0;
}





Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,X;
    cin >> N >> X;
    ll n;
    map<ll,bool> ma;
    rep(i,X){
        cin >> n;
        ma[n] = true;
    }
    ll left = 0;
    for(ll i = N;i >= 0;i--){
        if(!(ma[i])){
            left = i;
            break;
        }
    }
    ll now = N;
    ll right = 0;
    while(true){
        if(!(ma[now])){
            right = now;
            break;
        }
            now++;
    }
    if(N - left > right - N)cout << right << endl;
    else cout << left << endl;
}

Measured memory_bytes: 3596
def main():
	import sys

	w = []

	for line in sys.stdin:
		w = list(map(float, line.split()))
		solve(w)

def solve(w):
	x = (w[2]*w[4]-w[1]*w[5]) / (w[0]*w[4]-w[1]*w[3])
	y = (w[2]*w[3]-w[0]*w[5]) / (w[1]*w[3]-w[0]*w[4])
	x = round(x, 3)
	y = round(y, 3)
	if x == -0.0:
		x = 0.0
	if y == -0.0:
		y = 0.0
	print('{0:.3f} {1:.3f}'.format(x, y))

if __name__ == '__main__':
	main()

Measured memory_bytes: 7492
#include <cstdio>           // printf(), getchar(), scanf()
#include <stack>

using namespace std;
static const int MAX_M = 1400;

struct Rectangle
{
	int height;
	int pos;
};

int G[MAX_M][MAX_M];
int dp[MAX_M][MAX_M + 1];
int H, W;

int
getLargestRectangle(int size, int H[])
{
	Rectangle rect;
	stack<Rectangle> S;

	int maxv = 0;
	H[size] = 0;

	for (int i = 0; i <= size; ++i)
	{
		rect.height = H[i];
		rect.pos = i;
		if (S.empty())
			S.push(rect);
		else
		{
			if (S.top().height < rect.height)
				S.push(rect);
			else if (S.top().height > rect.height)
			{
				int target = i;
				while (!S.empty() && S.top().height >= rect.height)
				{
					Rectangle pre = S.top(); S.pop();
					int area = pre.height * (i - pre.pos);
					if (area > maxv)
						maxv = area;

					target = pre.pos;
				}

				rect.pos = target;
				S.push(rect);
			}
		}
	}

	return maxv;
}

int
getLargestRectangle()
{
	for (int j = 0; j < W; ++j)
	{
		for (int i = 0; i < H; ++i)
		{
			if (G[i][j])
				dp[i][j] = 0;
			else
				dp[i][j] = (i > 0) ? dp[i - 1][j] + 1 : 1;
		}
	}

	int maxv = 0;
	for (int i = 0; i < H; ++i)
	{
		int t = getLargestRectangle(W, dp[i]);
		if (t > maxv)
			maxv = t;
	}

	return maxv;
}

int
main(int argc, char** argv)
{
	int c;

	scanf("%d %d", &H, &W);
	c = getchar();
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			while (c == ' ' || c == '\n')
				c = getchar();

			G[i][j] = (c != '0') ? 1 : 0;
			c = getchar();
		}
	}

	printf("%d\n", getLargestRectangle());
	return 0;
}

Measured memory_bytes: 18072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeSet;

import javax.swing.*;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;


    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        Boolean[] vis = new Boolean[n];
        Arrays.fill(vis, true);
        int[] vals = new int[n];
        for (int i = 0; i < n; i++) vals[i] = in.nextInt();
        for (int i = 0; i < m; i++) {
            int a = in.nextInt() - 1;
            int b = in.nextInt() - 1;
            if (vals[b] >= vals[a]) {
                vis[a] = false;
            }
            if (vals[a] >= vals[b]) {
                vis[b] = false;
            }
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) if (vis[i]) cnt++;
        out.println(cnt);

    }



}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

}


Measured memory_bytes: 47640
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    cout << fixed << setprecision(15);
    
    int n;
    cin >> n;
    int arr[n];
    int tot=1;
    for(int i=0;i<n;i++) {
        arr[i]=i+1;
        tot*=(i+1);
    }
   
    pair<double,double> p[n];
    
    for(int i=0;i<n;i++) {
        cin >> p[i].ff >> p[i].ss;
    }
    double x=0;
    do {
        for(int i=1;i<n;i++) {
            double a = pow(abs(p[arr[i]-1].ff-p[arr[i-1]-1].ff),2.0);
            double b = pow(abs(p[arr[i]-1].ss-p[arr[i-1]-1].ss),2.0);
            a*=1.0,b*=1.0;
            //cout << sqrt(a+b) << " ";
            x += sqrt(a+b);
        }
    }while(next_permutation(arr,arr+n));
    //cout << endl;
    cout << (x*1.0)/tot << endl;

	return 0;
    
}

Measured memory_bytes: 8832
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

LLONG times[50][2501];

int main()
{
    int N, M, S; cin >> N >> M >> S;
    vector<vector<int>> adList(N);
    int as[50][50];
    LLONG bs[50][50];
    for (int i = 0; i < M; ++i)
    {
        int ui, vi, ai;
        LLONG bi;
        cin >> ui >> vi >> ai >> bi;
        --ui; --vi;
        adList[ui].push_back(vi);
        adList[vi].push_back(ui);
        as[ui][vi] = as[vi][ui] = ai;
        bs[ui][vi] = bs[vi][ui] = bi;
    }
    // 換金は自己リンクとして表現
    for (int v = 0; v < N; ++v)
    {
        adList[v].push_back(v);
        cin >> as[v][v] >> bs[v][v];
        as[v][v] *= -1; // 換金は銀貨が増えるので逆符号
    }
    // max(A)*(N-1) < 50 * 50 = 2500枚銀貨があれば必ず移動できる
    // -> 2500枚以上銀貨を持った状態は考える必要がない
    S = min(S, 2500);
    // times[v][s]:頂点v・銀貨s枚の状態に至るまでの最短時間
    for (int v = 0; v < 50; ++v)
    {
        for (int s = 0; s <= 2500; ++s)
        {
            times[v][s] = 1e15;
        }
    }
    times[0][S] = 0;
    // 状態 { v, s } のグラフ上で状態 { 0, S } からの移動時間をDFSで計算
    // G(V,E)のDFS計算量はO(V+E)なので高々O(2500+2500)で十分間に合う
    deque<pair<int, int>> Q{ { 0, S } };
    while (!Q.empty())
    {
        auto id = Q.front(); Q.pop_front();
        int v = id.first, s = id.second;
        for (int n : adList[v])
        {
            int coin = as[v][n], nCoin = s - coin;
            LLONG time = bs[v][n], nTime = times[v][s] + time;
            if (nCoin < 0) continue;
            else if (nCoin > 2500) nCoin = 2500;
            if (times[n][nCoin] > nTime)
            {
                times[n][nCoin] = nTime;
                Q.push_back({ n, nCoin });
            }
        }
    }
    for (int v = 1; v < N; ++v)
    {
        LLONG minTime = 1e15;
        for (int s = 0; s <= 2500; ++s)
        {
            minTime = min(minTime, times[v][s]);
        }
        cout << minTime << endl;
    }
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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


int modpower(int x,int n,int m){
    long long result=x;
    long long ans=1;
    int ans_int;

    while (n!=0){
        if(n%2==0){

            result = ((result%m)*(result%m))%m;
            n >>= 1;

        }else{
            ans = ((ans%m) * (result%m))%m;
            --n;

        }
    }
    ans_int=ans%m;
    return ans_int;
}

int modmul(int p,int q,int m){
    long long ans,pp=p,qq=q;
    int ans_int;
    ans=((pp%m)*(qq%m))%m;
    ans_int=ans%m;
    return ans_int;
}

int moddiv(int p,int q,int m){
    return modmul(p,modpower(q,m-2,m),m);
}

vector<int> modfact(int x,int m){
    vector<int> fact(x+1);
    fact[0]=1;
    
    for(int i = 0; i < x; i++){
        fact[i+1] = modmul(fact[i],i+1,m);
    }

    return fact;
}

int modcomb(int n,int r,int m,vector<int> fact){  //aaaaa
    long long ans;
    int ans_int;

    int a = fact[n];
    int div = modmul(fact[r],fact[n-r],m);

    ans_int = moddiv(a,div,m);

    return ans_int;
}



int main(){

    bool flag=false;
    ll ans=1,sum=0;

    int n;
    cin >>n;


    vector<int> fact;
    fact = modfact(n+5,MOD2);
    map<int,int> dm;

    for (int i = 0; i < n; i++){
        int d;
        cin >>d;

        if(i==0 && d!=0){
            puts("0");
            return 0;
        }

        dm[d]++;
    }


    if(dm[0] != 1){
        puts("0");
        return 0;
    }


    int pastn;
    int restv = n;

    int must = 1;
    for(auto num : dm){
        int nown = num.second;

        if(num.first==0){
            pastn = num.second;
            restv -= num.second;
            continue;
        }

        if(restv < nown){
            puts("0");
            return 0;
        }else if( num.first != must){
            puts("0");
            //cout <<num.first<<"!="<<must<<endl;
            return 0;
        }

        
        //int mul1 =  modpower(nown+1,pastn-1,MOD2);
        //int mul2 = modcomb(restv,nown,MOD2,fact);
        int mul3 = modpower(pastn,nown,MOD2);
        //int div1 = fact[pastn-1];
        
        /*
        mul2=1;
        div1=1;
        */

        ans = modmul(ans, mul3 ,MOD2);

        //ans = modmul(ans, mul2 ,MOD2);
        //ans = moddiv(ans,div1,MOD2);

        //cout << mul1 << " and " <<mul2<<" and "<<div1<<endl;
        //cout << " n=" << restv <<" r="<< nown <<endl;

        pastn = nown;
        restv -= nown;

        must++;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //cout <<fact[1]<<fact[5]<<fact[6]<<fact[n];

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int a[100005],b[100005];
//vector<pair<int,int>> v;
int main()
{
    int n,m;cin>>n>>m;
    int t1=(m+1)/2,t2=m/2;
    for(int i=1;i<=t1;i++)
    {
        cout<<i<<" "<<t1*2-i+1<<endl;
    }
    for(int i=1;i<=t2;i++)
    {
        cout<<i+2*t1<<" "<<2*(t1+t2)-i+2<<endl;
    }

//    int n=9;
//    for(int i=0; i<n; i++)
//    {
//        for(int j=0; j<n; j++)
//            cout<<char('A'+(i+j)%n);
//        cout<<endl;
//    }

}


Measured memory_bytes: 3592
using System;

namespace ABC138
{
    class A
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (3200 <= a)
            {
                Console.WriteLine(s);
            }
            else
            {
                Console.WriteLine("red");
            }
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
t = 0
x = 0
y = 0
for _ in range(N):
    nt, nx, ny = map(int, input().split())
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if dt >= dx + dy and dt % 2 == (dx+dy) % 2:
        continue
    else:
        print('No')
        break
else:
    print('Yes')


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int MOD=pow(10,9)+7;
    string s;
    cin>>s;
    int l=s.size();
    long dp[l+1][13];
    int table10[7];
    table10[1]=1;
    rep(i,5){
        table10[i+2]=(10*table10[i+1])%13;
    }
    table10[0]=4;
  
    if (s.at(l-1)=='?'){
        rep(i,10){
            dp[1][i]=1;
        }
        rep(i,3){
          dp[1][i+10]=0;
        }
    }
    else{
        int num=s.at(l-1)-'0';
        rep(i,13){
            dp[1][i]=0;
        }
        dp[1][num]=1;       
    }
    for (int i=2;i<l+1;i++){
        if (s.at(l-i)=='?'){
            for (int j=0;j<13;j++){
                dp[i][j]=0;
                for (int k=0;k<10;k++){
                    int mod1=(table10[i%6]*k)%13;
                    dp[i][j]+=dp[i-1][(13+j-mod1)%13];
                    dp[i][j]=dp[i][j]%MOD;
                }
                
                //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
            }

        }
        else{
            int num=s.at(l-i)-'0';
            int mod1=(table10[i%6]*num)%13;
            for (int j=0;j<13;j++){
                 dp[i][j]=dp[i-1][(13+j-mod1)%13];
                 //cout<<i-1<<" "<<(13+j-mod1)%13<<endl;
                 //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
                }
            
        }
    }
    cout<<dp[l][5]<<endl;

    return 0;
}

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


int K;

int main(){
	cin>>K;
	int x=0;
	for(int i=1;i<=10000000;++i){
		x=(x*10+7)%K;
		if(x==0){
			printf("%d\n",i);return 0;
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
int n,k;
int a[100000];
int ans;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=k;i++){
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3640
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const string MINUSINF = "-";
int N , M;
long long match[10] = {2,5,5,4,5,6,3,7,6};
string dp[11000];

void chmax(string &a, string b) {
    if (a == MINUSINF) a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}
int main()
{
    scanf("%d %d " ,&N , &M);
    vector<int> A(M);
    for(int i = 0; i < M ; i ++)
    {
        cin >> A[i];
    }
    dp[0] = "";
    for (int i = 1; i < 11000; ++i)
        dp[i] = MINUSINF;
    for (int i = 0; i <= N; ++i) {
        if (dp[i] == MINUSINF) continue;
        for (auto a : A)  chmax(dp[i+match[a-1]], dp[i] + (char)('0' + a));
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 43776
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>

typedef long long ll;
typedef unsigned short int unsi;
typedef unsigned int uni;
typedef unsigned long int unli;

using namespace std;

int main(){
	int N;
	int inputA;
	vector<pair<int,int>> A;
	
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> inputA;
		A.push_back(make_pair(inputA, i));
	}

	sort(A.begin(), A.end());

	/*debug
	for (int i = 0; i < N; i++) {
		cout << A[i].first << "," << A[i].second << endl;
	}
	*/

	for (int i = 0; i < N; i++) {
		if (A[N - 1].second == i) {
			cout << A[N - 2].first << endl;
		}else{
			cout << A[N - 1].first << endl;
		}
	}

}






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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述
	int K;
	cin >> K;

	// BFSを用いて探索できる
	// --> Queueを使用
	queue<ll> Q;

	// 1~9はすべてルンルン数
	FOR(i,1,10){
		Q.push(i);
	}

	// K回以下の操作を繰り返す
	int ans = 0;
	REP(i,K){
		ans = Q.front();
		Q.pop();
		// ans % 10 != 0 (つまり最下位の桁が1~9) なら
		if(ans % 10 != 0){
			// ケツに-1した桁をくっつけてもルンルン数
			Q.push(10 * ans + (ans % 10 - 1));
		}
		// ケツに同じ桁をくっつけてもルンルン数
		Q.push(ans * 10 + ans % 10);
		// ans % 10 != 9 (つまり最下位の桁が0~8) なら
		if(ans % 10 != 9){
			// ケツに+1した桁をくっつけてもルンルン数
			Q.push(10 * ans + (ans % 10 + 1));
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int dp[100001],h[100001];
int abs(int x);
int main(void)
{
  int i,j,n,a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  for(i=0;i<n;i++) dp[i]=1000000000; 
  dp[0]=0;
  for(i=0;i<n-1;i++){
    if(abs(h[i]-h[i+1])+dp[i]<=dp[i+1]){
      dp[i+1]=abs(h[i]-h[i+1])+dp[i];
    }
    if(i<n-1){
      if(abs(h[i]-h[i+2])+dp[i]<=dp[i+2]){
        dp[i+2]=abs(h[i]-h[i+2])+dp[i];
       // printf("%d.",dp[i+2]);
      }
    }
  }
 // for(i=0;i<n;i++) printf(".%d.",dp[i]);
  printf("%d\n",dp[n-1]);
}

int abs(int x){
  if(x < 0) x = -x;
  return x;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define maxn 300005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int type[205] , y[205] ;

int main()
{
    int n ;

    scanf("%d",&n) ;

    for(int i=1 ; i<=n ; i++)
    {
        int x , Y ;
        scanf("%d %d",&x,&Y) ;
        type[x] = 1 ;
        y[x] = Y ;
    }

    for(int i=1 ; i<=n ; i++)
    {
        int x , Y ;
        scanf("%d %d",&x,&Y) ;
        type[x] = 2 ;
        y[x] = Y ;
    }

    int ans = 0 ;

    for(int i=2*n ; i>=0 ; i--)
    {
        if(type[i]==2) continue ;
        int mnY = 205 , idx = -1 ;
        for(int j=i+1 ; j<2*n ; j++)
        {
            if( type[j]==2 && y[j] > y[i] )
            {
                if( y[j] < mnY )
                {
                    mnY = y[j] ;
                    idx = j ;
                }
            }
        }
        if( idx != -1 )
        {
            ans++ ;
            type[idx] = -1 ;
        }
    }

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

    return 0 ;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
if k%2 == 1:
  ans = (n//k)**3
  print(ans)

else:
  ans = (n//k)**3
  if n%k >= k//2:
    ans += (n//k+1)**3
  else:
    ans += (n//k)**3
  print(ans)

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

const int MAXN = 550;
struct node
{
    int c,s,f;
}ns[MAXN];
int N;
int res[MAXN];

int main()
{
    memset(res,0,sizeof(res));
    scanf("%d",&N);
    for(int i = 1; i < N; ++i)
        scanf("%d %d %d",&ns[i].c,&ns[i].s,&ns[i].f);

    for(int i = 1; i < N; ++i)
    {
        int& ans = res[i];
        ans += ns[i].s+ns[i].c;//从站台i到达了i+1
        for(int j = i+1; j < N; ++j)
        {
            if(ans < ns[j].s)
                ans = ns[j].s+ns[j].c;
            else if((ans-ns[j].s)%ns[j].f == 0)
                ans += ns[j].c;
            else
                ans = ns[j].s + ((ans-ns[j].s)/ns[j].f+1)*ns[j].f+ns[j].c;
        }
    }
    for(int i = 1; i <= N; ++i)
        printf("%d\n",res[i]);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second
typedef pair<ll, ll> pll;   // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> A, vector<long long> B) {
  ll ans = 0;
  std::vector<pll> v;
  REP(i, N) { v.push_back(pll(A[i], B[i])); }

  sort(ALL(v));
  ans = v.back().first - v.front().first + 1;

  // front
  ans += v.front().first - 1;

  // back
  ans += v.back().second;

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N - 1 + 1);
  vector<long long> B(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> A[i];
    cin >> B[i];
  }
  solve(N, A, B);
  return 0;
}


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

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

	u64 mod = 998244353;
	vector<pair<u64, u64>> S(K);
	u64 maxR = 0;

	for(u64 i=0; i<K; i++) {
		u64 L, R;
		cin >> L >> R;
		S[i] = make_pair(L, R);
		maxR = max(maxR, R);
	}
	
	maxR++;
	vector<u64> sum(maxR);
	sum[0] = 1;
	u64 dp = 0;

	for(s64 i=1; i<N; i++) {
		dp = 0;

		for(const auto& lr : S) {
			s64 R = i - lr.first;
			if(R >= 0) {
				dp = (dp + sum[R%maxR]) % mod;
				s64 L = i - lr.second - 1;
				if(L >= 0) {
					dp = (dp >= sum[L%maxR]) ? dp - sum[L%maxR] : dp + mod - sum[L%maxR];
				}
			}
		}
		
		sum[i%maxR] = (sum[(i-1)%maxR] + dp) % mod;
	}

	cout << dp << endl;
    return 0;
}


Measured memory_bytes: 4732
package main

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

var sc = bufio.NewScanner(os.Stdin)

// var rdr = bufio.NewReaderSize(os.Stdin, 100000)
var rdr *bufio.Reader

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	// ABC051B
	k, s := nextInt(), nextInt()

	cnt := 0
	for x := 0; x <= k; x++ {
		for y := 0; y <= k; y++ {
			xy := x + y
			if xy > s {
				break
			}
			z := s - xy
			if 0 <= z && z <= k {
				cnt++
			}
		}
	}

	ans := cnt
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func readLine() string {
	buf := make([]byte, 0, 100000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextI64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func maxi64(a int64, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func updateMax(a *int, b int) {
	if *a < b {
		*a = b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func mini64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func updateMin(a *int, b int) {
	if *a > b {
		*a = b
	}
}

func absi64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func anser(b bool, y string, n string) string {
	if b {
		return y
	}
	return n
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    vector<string> v(3);
    v[0]="Sunny";
    v[1]="Cloudy";
    v[2]="Rainy";
    string s;
    cin>>s;
    cout<<(s==v[0]?v[1]:s==v[1]?v[2]:v[0])<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll la;
    ll lb;
    ll ra;
    ll rb;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int n;
//int dat[2*10000000];
//int dat2[2*10000000];
int dat[2*100];
int dat2[2*100];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        dat2[i]=0;
    }
}

void initset(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
}

//[a,b)の間を[l,r]区間で比較しアップデート
//引数のindexに注意
//nは固定。initで計算すみ
//update2(L[i],R[i]+1,0,0,n,D[i]);
void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
    if(r<=a || b<=l)return;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=v*(r-l);
        return;
    }else{
        update2(a,b,k*2+1,l,(l+r)/2,v);
        update2(a,b,k*2+2,(l+r)/2,r,v);
        return;
    }
}

int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=0;
        return dat[k];
    }
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}



int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs("1_06.txt");//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    ifstream ifs("test4.txt");
    
    string s;
    cin >> s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(s.substr(i,1)=="+"){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e6+5;

int n,m;
int main()
{
    int h,w,n;
    cin>>n>>h>>w;
    int ok[3]={0};
    for(int i=0;i<n;i++)
    {
        scanf("%d",&m);
        if(m<=h)ok[0]++;
        else if(m<=w)ok[1]++;
        else ok[2]++;
    }
    sort(ok,ok+3);
    cout<<ok[0]<<endl;
    //main();
}


Measured memory_bytes: 256
#141

s = input()

res = "Yes"
for i in range(0,len(s)):
    if (i+1) % 2 == 1 and s[i] == "L":
        res = "No"
        break
    elif (i+1) % 2 == 0 and s[i] == "R":
        res = "No"
        break
print(res)

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

int main(void){
    ll h,w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
    } else {
        cout << (h*w+1)/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import os


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

    N = int(sys.stdin.buffer.readline())
    S = sys.stdin.buffer.readline().decode().rstrip()


    ret = []
    for s in S:
        n = (ord(s) + N - 65 ) % 26
        ret.append(chr(n+65))

    print("".join(ret), end="")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream>

#define _USE_MATH_DEFINES

#include <cmath>

using namespace std;

class triangle{
private:
	double a, b, C;
	double S, L, h;
public:
	int set();
	int show();
	int cal();
};

int triangle::set(){
	cin >> a >> b >> C;
	return 0;
}

int triangle::show(){
	cout << fixed << S << endl << L << endl << h << endl;
	return 0;
}

int triangle::cal(){
	S = a * b * sin(C*M_PI / 180) / 2;
	L = a + b + sqrt(a*a + b*b - 2*a*b*cos(C*M_PI / 180));
	h = S * 2 / a;
	return 0;
}

int main()
{
	triangle tri;

	tri.set();
	tri.cal();
	tri.show();

	return 0;
}

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

int main(){
	int T;
	cin >> T;
	for(int t=0 ; t < T ; t++ ){
		int n;
		cin >> n;
		int a[101] = {0};
		for(int i=0 ; i < n ; i++ ){
			cin >> a[i];
		}
		int mx=0, mi=1e+8;
		for(int i=1 ; i < n ; i++ ){
			mx = max( mx , a[i] - a[i-1] );
			mi = min( mi , a[i] - a[i-1] );
		}
		if( mi == 1e+8 ) mi = 0;
		if( mx < 0 ) mx = 0;
		if( mi > 0 ) mi = 0;
		cout << mx << " " << abs(mi) << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int n;
int main(){
	cin>>n;
	if(n<10)cout<<n;
	else if(n<100)cout<<9;
	else if(n<1000)cout<<9+n-99;
	else if(n<10000)cout<<9+900;
	else if(n<100000)cout<<9+900+n-9999;
	else cout<<9+900+90000;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			final int W = sc.nextInt();
			final int Q = sc.nextInt();
			
			if(W == 0 && Q == 0){
				break;
			}
			
			int[] is_used = new int[W];
			
			for(int i = 0; i < W; i++){
				is_used[i] = -1;
			}
			
			for(int i = 0; i < Q; i++){
				final String type = sc.next();
				
				if("s".equals(type)){
					final int id = sc.nextInt();
					final int w = sc.nextInt();
					
					int count = 0;
					int pos = -1;
					for(int j = 0; j < W; j++){
						if(is_used[j] == -1){
							count++;
							if(count >= w){
								pos = j;
								break;
							}
						}else{
							count = 0;
						}
					}
					
					if(pos == -1){
						System.out.println("impossible");
					}else{
						for(int j = pos - w + 1; j <= pos; j++){
							is_used[j] = id;
						}
						System.out.println(pos - w + 1);
					}
					
					
				}else if("w".equals(type)){
					final int id = sc.nextInt();
					
					for(int j = 0; j < W; j++){
						if(is_used[j] == id){
							is_used[j] = -1;
						}
					}
				}
			}
			
			System.out.println("END");
			
		}
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	int k,a,b;
	cin>>k>>a>>b; 
	rep(i,1001){
		if(k*i>=a&&k*i<=b){
			cout<<"OK";
			re 0;
		}
	}
	cout<<"NG";
	re 0;
}

Measured memory_bytes: 3632
def solve(n, a):
    odd = 0
    even = 0
    for x in a:
        if x % 2 == 0:
            even += 1
        else:
            odd += 1
    res = int(odd % 2) + int((even + (odd // 2)) > 0)
    return "YES" if (res == 1) else "NO"

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Measured memory_bytes: 14108