akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <bitset>

using ll = long long int;
using ul = unsigned long long int;

namespace lamlib
{
	// Absolute
	template<class T> inline T abs(const T &a){ return (a>0) ? a : -a; }
	// GCD: a > b
	ul gcd(ul a,ul b) { return (!b) ? a : gcd(b,a%b); }
}

int main(int argc,char *argv[])
{
	std::string a,b;
	std::cin >> a >> b;

	double num = std::sqrt(std::stoi(a+b));

	if(num == static_cast<int>(num)) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[100001],a[100001]={1};
int main()
{
	int i,j,n,z=1;
	memset(f,1,sizeof(f));
	f[0]=0;
	scanf("%d",&n);
	for(i=1;;i++)
	{
		if(pow(6,i)>n)
			break;
		else
			a[z++]=pow(6,i);
	}
	for(i=1;;i++)
	{
		if(pow(9,i)>n)
			break;
		else
			a[z++]=pow(9,i);
	}
	sort(a,a+z);
	for(i=1;i<=n;i++)
	{
		for(j=0;j<z&&i>=a[j];j++)
			f[i]=min(f[i],f[i-a[j]]+1);
	}
	printf("%d",f[n]);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
    ll x, k, d; cin >> x >> k >> d;
    x = abs(x);
    ll nd = x / d;
    if(nd > k) {
        x -= k * d;
    } else {
        k -= nd, x -= nd * d;
        if(k & 1) x -= d;
    }
    cout << abs(x) << endl;
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std; 
#define ll unsigned long long int
void readtxt()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
}

int main() 
{ 
    //readtxt();
    ll n, k;
    cin >> n >> k;
    int a[n+1],b[n+1]={0};

    for(int i = 1; i<=n; i++)
    {
      cin >> a[i];
    }
    int i = 1;
    ll cycle = 0;
    int c[2000001];
    while(b[i]==0)
    {
      b[i] = 1;
      c[cycle] = i;
      i = a[i];
      ++cycle;

    }
    int j = 1;
    ll neww = 0;
    while(j != i)
    {
      j = a[j];
      ++neww;
    }
    if(k>neww)
    {
      k = k-neww;
      k = k%(cycle-neww);
      // int w = neww+k;
      cout << c[neww+k] << endl;
    }
    else
    {
      // int w = k;
      cout << c[k] << endl;
    }
    //cout << cycle << neww << endl;
   // k = k%cycle;
   // cout << c[k] << endl;


    
} 

Measured memory_bytes: 5908
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  vector<bool> dp(k+1);
  REP(i, k) {
    if(dp[i] == true) continue;
    REP(j, n) {
      if(i+a[j] <= k) dp[i+a[j]] = true;
    }
  }

  if(dp[k]) cout << "First" << endl;
  else cout << "Second" << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
S=sys.stdin.readline().strip()
R=[]
G=[]
B=[]
for x in S:
    if x=="R":
        R.append(1)
        G.append(0)
        B.append(0)
    elif x=="G":
        R.append(0)
        G.append(1)
        B.append(0)
    elif x=="B":
        R.append(0)
        G.append(0)
        B.append(1)

#累積和
RR=[0]
GG=[0]
BB=[0]
for r in R: RR.append(RR[-1]+r)
for g in G: GG.append(GG[-1]+g)
for b in B: BB.append(BB[-1]+b)

ans=0

for i in range(N):
    for j in range(i+1,N):
        if S[i]=="R" and S[j]=="G":
            ans+=BB[-1]-BB[j+1]
            try:
                if S[j+j-i]=="B":
                    ans-=1
            except:
                pass
        elif S[i]=="R" and S[j]=="B":
            ans+=GG[-1]-GG[j+1]
            try:
                if S[j+j-i]=="G":
                    ans-=1
            except:
                pass
        elif S[i]=="G" and S[j]=="B":
            ans+=RR[-1]-RR[j+1]
            try:
                if S[j+j-i]=="R":
                    ans-=1
            except:
                pass
        elif S[i]=="G" and S[j]=="R":
            ans+=BB[-1]-BB[j+1]
            try:
                if S[j+j-i]=="B":
                    ans-=1
            except:
                pass
        elif S[i]=="B" and S[j]=="G":
            ans+=RR[-1]-RR[j+1]
            try:
                if S[j+j-i]=="R":
                    ans-=1
            except:
                pass
        elif S[i]=="B" and S[j]=="R":
            ans+=GG[-1]-GG[j+1]
            try:
                if S[j+j-i]=="G":
                    ans-=1
            except:
                pass
print ans

Measured memory_bytes: 74016
package main

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

func main() {
	N := nextInt()
	A := nextInt()
	B := nextInt()
	if A*N < B {
		fmt.Printf("%d", A*N)
	} else {
		fmt.Printf("%d", B)
	}
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextString() string {
	return nextReader()
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

func MinA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Min(s, v)
	}
	return s
}

func MaxA(arg ...int) int {
	var s = arg[0]
	for _, v := range arg {
		s = Max(s, v)
	}
	return s
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i,k,n) for(int i = (k); i < (n); ++i)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100005
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
typedef long long  ll;
typedef pair<int, int> P;
 
int pow(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n>0)
    {
        if (n & 1)res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}
 
int main()
{
    int m, n; 
    cin >> m >> n;
    cout << pow(m, n, 1000000007) << endl;
    return 0;
}

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

int main(int argc, const char * argv[]) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    if(a<=c && c<=b && b<=d){
        cout << b-c;
    }else if(c<=a && a<=d && d<=b){
        cout << d-a;
    }else if(c<=a && b<=d){
        cout << b-a;
    }else if(a<=c && d<=b){
        cout << d-c;
    }else{
        cout << 0;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
l = len(S)
flg = 0
if l%2 == 1:
	flg = 1
	print("No")
else:
	for i in range(int(l/2)):
		if S[i] != S[i+int(l/2)]:	
			print("No")
			flg = 1
			break
if flg == 0:
	print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <queue>
#include <complex>

using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))
#define F first
#define S second
#define mkp make_pair
#define PB push_back
#define ALL(v) v.begin(),v.end()
#define maxs(a,b) (a=max(a,b))
#define mins(a,b) (a=min(a,b))
const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef pair<int, int> pii;
// typedef pair<,pii> P;

typedef complex<double> P;

#define EPS (1e-8)
double dot(P a, P b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double cross(P a, P b) {
	return a.real() * b.imag() - a.imag() * b.real();
}

double distance_l_p(P a, P b, P c) {
	return abs(cross(b - a, c - a)) / abs(b - a);
}

template<class T>
T sq(T a){
	return a*a;
}

double dd[]={1,-1};

bool check(P a,P b,P p,double r,double c){
	double d = distance_l_p(a,b,p);
	if(r-d>EPS){
		return false;
	}
	if(c-(d-r)>-EPS) return true;
	return false;
}

int main() {
	int n;
	while(cin >> n, n) {
		vector<pair<P, P>> v(n);
		vector<pair<P, P>> w;
		rep(i, n) {
			double a, b, c, d;
			cin >> a >> b >> c >> d;
			v[i] = mkp(P(a, b), P(c, d));
			w.PB(mkp(P(a,b),P(c+d,d)));
			w.PB(v[i]);
		}
		vector<pair<P,P>> line;
		rep(i,w.size()){
			rep(j,i){
				double xp=w[j].F.real()-w[i].F.real();
				double yp=w[j].F.imag()-w[i].F.imag();
				double r = w[i].S.real();
				double R = w[j].S.real();
				// cout<<xp<<" "<<yp<<" "<<endl;
				if(sq(xp)+sq(yp)-sq(r+R)>=0){
					rep(k,2){
						double xq,yq,xx,yy;
						P p;
						xq = r*(xp*(r+R)+dd[k]*yp*sqrt(sq(xp)+sq(yp)-sq(r+R)))/(sq(xp)+sq(yp));
						yq = r*(yp*(r+R)-dd[k]*xp*sqrt(sq(xp)+sq(yp)-sq(r+R)))/(sq(xp)+sq(yp));
						// cout<<"xq yq "<<xq<<" "<<yq<<endl;
						p = P(xq,yq) * P(0,1) + P(xq,yq) + w[i].F;
						line.PB(mkp(P(xq,yq)+w[i].F,p));
						// cout<<i<<" "<<j<<endl;
					}
				}
				R=-R;
				if(sq(xp)+sq(yp)-sq(r+R)>=0){
					rep(k,2){
						double xq,yq,xx,yy;
						P p;
						xq = r*(xp*(r+R)+dd[k]*yp*sqrt(sq(xp)+sq(yp)-sq(r+R)))/(sq(xp)+sq(yp));
						yq = r*(yp*(r+R)-dd[k]*xp*sqrt(sq(xp)+sq(yp)-sq(r+R)))/(sq(xp)+sq(yp));
						// cout<<"xq yq "<<xq<<" "<<yq<<endl;
						p = P(xq,yq) * P(0,1) + P(xq,yq) + w[i].F;
						line.PB(mkp(P(xq,yq)+w[i].F,p));
					}
				}
			}
		}
		int ans = 1;
		for(auto z:line){
			// cout<<z.F<<" "<<z.S<<endl;
			int tmp = 0;
			rep(i,n){
				if(check(z.F,z.S,v[i].F,v[i].S.real(),v[i].S.imag())){
					tmp++;
				}
			}
			maxs(ans,tmp);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 4648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define size(x) int(x.size())
typedef long long ll;
using namespace std;
int main(){
    int N,M; cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    REP(i,M){
        int l,r; cin >> l >> r;
        L[i] = l; R[i] = r;
    }

    int l_max,r_min;
    int ans;
    sort(ALL(L));
    sort(ALL(R));
    l_max = L[M-1];
    r_min = R[0];
    ans = max(0,(r_min - l_max + 1));
    cout << ans <<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<climits>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX


int map[150][150]={};
int gone[150][150]={};

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

bool dfs(int nx,int ny){
	if(gone[nx][ny])return false;
	gone[nx][ny]=1;
	if(nx == gx && ny == gy)return true;
	bool res = false;
	rep(i,4){
		int tx = nx+dx[i],ty=ny+dy[i];
		if(map[tx][ty]!=map[nx][ny])continue;
		res |= dfs(tx,ty);
	}
	return res;
}

int main(void){
	while(1){
		int w,h;
		scanf("%d%d",&w,&h);
		if(w==0 && h==0)break;
		int sx,sy,n;
		scanf("%d%d%d%d%d",&sx,&sy,&gx,&gy,&n);
		memset(map,0,sizeof(map));
		memset(gone,0,sizeof(gone));
		rep(i,n){
			int c,d,nx,ny;
			scanf("%d%d%d%d",&c,&d,&nx,&ny);
			int fx=2,fy=4;
			if(d==0)swap(fx,fy);
			rep(x,fx)rep(y,fy){
				map[x+nx][y+ny]=c;
			}
		}
		/*
		rep(y,20)rep(x,20){
			printf("%d%c",map[x][y],x==19?'\n':' ');
		}*/
		if(map[sx][sy]!=0 && dfs(sx,sy))printf("OK\n");
		else printf("NG\n");
	}
		
	return 0;
}

Measured memory_bytes: 1196
def f(v, x, d, k):
  return x + d * (2 * v - k)


def swap(x, y):
  r = x
  x = y
  y = r


lt = input().split(' ')
x = int(lt[0])
k = int(lt[1])
d = int(lt[2])

lf = 1
r = k

# for i in range(k + 1):
#   print(f(i, x, d, k))

ans = abs(f(0, x, d, k))
# ans = min(ans, abs(x))

while (lf <= r):
  mid = (lf + r) // 2
  nt = f(mid, x, d, k)
  cur = f(mid - 1, x, d, k)
  # print('mid = ', mid)
  # cur = abs(cur)
  # nt = abs(nt)
  # swap(nt, cur)
  # print('cur = ', cur)
  # print('nt = ', nt)
  # print('')
  nt = abs(nt)
  cur = abs(cur)
  if (nt > cur):
    ans = min(ans, abs(cur))
    r = mid - 1
  else:
    lf = mid + 1
    ans = min(ans, abs(nt))

print(abs(ans))

Measured memory_bytes: 9096
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>

using namespace std;

int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i) {
    if (i % 3 == 0) {
      cout << " " << i;
    } else {
      int x = i;
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }
  cout << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;

// Greatest Common Divisor
ll gcd(ll a, ll b){ return b ? gcd(b,a%b) : a; }
// Least Common Multiple
ll lcm(ll a, ll b){ return a/gcd(a,b)*b; }



void solve(long long N, std::vector<long long> d){
    int n = (int)N/2;
    sort(d.begin(), d.end());
    cout << d[n] - d[n-1] << endl;
}


int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> d(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&d[i]);
    }
    solve(N, std::move(d));
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()

l = ""
r = ""
cnt = 0
for i in S :
	if i == '(' :
		cnt += 1
	else :
		cnt -= 1
	
	if cnt < 0 :
		cnt += 1
		l += '('

r = ')' * cnt

print(l + S + r)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;
     
    vl dp; 
    vector<vl> adj;
    
    ll dfs(int v){
        if(adj[v].size()==0){
            return dp[v]=0;
        }
        if(dp[v] != -1){
              return dp[v];
        }
        
       for(int i=0;i<adj[v].size();i++){
             if(dp[adj[v][i]]==-1){
                 dp[adj[v][i]] = dfs(adj[v][i]);
             }
        }
        for(int i=0;i<adj[v].size();i++){
           dp[v] = max( dp[v] ,  1 +   dp[adj[v][i]] );
        }
        
        return dp[v];
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        int n,m,u,v;
        cin>>n>>m;
        dp.resize(n);adj.resize(n);
        for(int i=0;i<n;i++) dp[i]=-1;
        for(int i=0;i<m;i++){
            cin>>u>>v;
            u--;v--;
            adj[u].push_back(v);
        }
        for(int i=0;i<n;i++){
            if(dp[i]==-1)
           dp[i] = dfs(i);
        }
        ll  ans=0;
        for(int i=0;i<n;i++){
            ans = max(ans,dp[i]);
        }
        cout<<ans;
        return 0;
    } 

Measured memory_bytes: 8576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
#include <fstream>
#include <complex>

using namespace std;
typedef long long LL;


int main() {
	string s;
	cin >> s;

	map<string,int> a;
	a["SUN"] = 7;
	a["MON"] = 6;
	a["TUE"] = 5;
	a["WED"] = 4;
	a["THU"] = 3;
	a["FRI"] = 2;
	a["SAT"] = 1;
	cout << a[s] << endl;
	return 0;
}

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

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n),b(n),c(n),dpb(n+1,0),dpc(n+1,0);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];
    rep(i,n) cin>>c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));
    ll ans=0,cnta=0,cntb=0;
    for(ll i=1;i<=n;i++){
        while(cnta<n&&a[cnta]<b[i-1]) cnta++;
        dpb[i]=dpb[i-1]+cnta;
    }
    for(ll i=1;i<=n;i++){
        while(cntb<n&&b[cntb]<c[i-1]) cntb++;
        dpc[i]=dpc[i-1]+dpb[cntb];
    }
    cout<<dpc[n]<<endl;
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define int long long
#define maxn 2005
#define maxm 200000
#define mod 1000000007
using namespace std;
int ans,fac[maxn*4+100],inv[maxn*4+100],duliu[maxn*2+100][maxn*2+100],n,a[maxm+5],b[maxm+5];
inline int c(int n,int m){
	return 1ll*fac[n]%mod*inv[m]%mod*inv[n-m]%mod;
}
inline void prepare(){
	fac[0]=1;
	inv[0]=1;
	inv[1]=1;
	for(int i=1;i<=maxn*4;i++)
		fac[i]=fac[i]=1ll*fac[i-1]%mod*i%mod;
	for(int i=2;i<=maxn*4;i++)
		inv[i]=1ll*(mod-mod/i)%mod*inv[mod%i]%mod;
	for(int i=1;i<=maxn*4;i++)
		inv[i]=1ll*inv[i-1]%mod*inv[i]%mod;
}
signed main(){
	//freopen("math.in","r",stdin);
	//freopen("math.out","w",stdout);
	prepare();
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		duliu[maxn-a[i]][maxn-b[i]]++;
	}
	for(int i=-maxn+1;i<=maxn;i++){
		for(int j=-maxn+1;j<=maxn;j++){
			duliu[maxn+i][maxn+j]+=duliu[maxn+i-1][maxn+j]+duliu[maxn+i][maxn+j-1];//duliudp
			duliu[maxn+i][maxn+j]%=mod;
		}
	}
	for(int i=1;i<=n;i++){
		ans+=duliu[maxn+a[i]][maxn+b[i]];
		ans%=mod;
		ans-=c(a[i]*2+b[i]*2,a[i]*2);
        ans=(ans+mod)%mod;
	}
	ans*=500000004;
	ans%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 135552
h,w,k = map(int, input().split())

hs = [i for i in range(h)]
ws = [i for i in range(w)]
m = []
total = 0
for _ in range(h):
   l = input()
   total += l.count('#')
   m.append(l)

ans = 0
from itertools import combinations
# removing
for i in range(h+1):
   for hcomb in combinations(hs, i):
      total_ = total - sum(m[h_].count('#') for h_ in hcomb)
      for j in range(w+1):
         for wcomb in combinations(ws, j):
            total__ = total_
            for i_ in range(h):
               if i_ in hcomb:
                  continue
               total__ -= len([w_ for w_ in wcomb if m[i_][w_] == '#'])
            if total__ == k:
               ans += 1
print(ans)

Measured memory_bytes: 9248
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

void fin(){
	freopen("test.txt", "r", stdin);
}

int main(){
	while(1){
		int n, y;
		cin >> n;
		if(!n) break;
		cin >> y;

		double maxrate = 0;
		int maxb = -1;

		rep(i, n){
			double b, r, t;
			cin >> b >> r >> t;
			double rate = 1;
			t--;
			if(!t){
				rate = (1+y*r/100);
			} else{
				rep(j, y){
					rate *= (1+r/100);
				}
			}
			if(rate > maxrate){
				maxrate = rate;
				maxb = b;
			}
		}

		cout << maxb << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
int digitcount(int num)
{
    int cnt = 0;
    while(num != 0)
    {
        num = num / 10;
        cnt++;
    }
    return cnt;
}
int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        int i, a, cont = 0;
        for(i = 1; i <= n; i++)
        {
            a = digitcount(i);
            if(a % 2 == 1)
            {
                cont++;
            }
        }
        cout<<cont<<endl;
    }
}



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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() const { return m_val; }
    constexpr modint operator+(const modint &rhs) const { return modint(*this) += rhs; }
    constexpr modint operator-(const modint &rhs) const { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint &rhs) const { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint &rhs) const { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint &rhs) {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint &rhs) {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint &rhs) {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(const modint &rhs) {
      *this *= rhs.pow(m_mod - 2);
      return *this;
    }
    constexpr modint pow(ll n) const {
      if (n == 0) return 1;
      modint o = pow(n >> 1);
      o *= o;
      if (n & 1) o *= *this;
      return o;
    }
    friend ostream& operator<<(ostream& os, const modint &a) { os << a.val(); return os; }
};

int main() {
  ll n;
  cin >> n;

  string s;
  cin >> s;

  map<char, ll> m;
  each (ch, s) {
    m[ch]++;
  }

  modint ans = 1;
  each (i, m) {
    ans *= (i.second+1);
  }
  ans -= 1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define FOR(i, n) for (int(i) = 0; (i) < n; (i)++)
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define MOD 1000000007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who cannot acknowledge themselves, will invariably fail
    int n, k;
    cin >> n >> k;
    int arr[n];
    string s;
    cin >> s;
    for (int i = 0; i < n; i++)
    {
        arr[i] = s[i] - '0';
    }
    vector<pair<int, int>> a;
    if (arr[0] == 0)
    {
        a.push_back({0, 1});
    }
    else
    {
        a.push_back({1, 1});
    }
    for (int i = 1; i < n; i++)
    {
        if (arr[i] == arr[i - 1])
        {
            a[a.size() - 1].second++;
        }
        else
        {
            a.push_back({arr[i], 1});
        }
    }
    int count = 0;
    for (int i = 0; i < a.size(); i++)
    {
        if (a[i].first == 0)
            count++;
    }
    if (count <= k)
    {
        cout << n;
        return 0;
    }
    int l, r;
    if (a[0].first == 0)
        l = 0;
    else
    {
        l = 1;
    }
    r = -1;
    count = k;
    while (count)
    {
        r++;
        if (a[r].first == 0)
            count--;
    }
    vector<int> prefix;
    int curr = 0;
    for (int i = 0; i < a.size(); i++)
    {
        curr += a[i].second;
        prefix.push_back(curr);
    }
    int sol = 0;
    curr = 0;
    while (r < a.size())
    {
        int curr = prefix[r];
        if (r + 1 < a.size())
            curr += a[r + 1].second;
        if (l - 1 > 0)
            curr -= prefix[l - 2];
        else if (l > 0)
        {
            curr -= prefix[l - 1];
        }
        sol = max(sol, curr);
        r += 2;
        l += 2;
    }
    cout << sol;
    return 0;
}

Measured memory_bytes: 2500
#define _USE_MATH_DEFINES

#include <iostream>
#include <iterator>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <climits>
#include <ctime>

using namespace std;
using ll = long long;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;

void solve() {
	string s;
	getline(cin, s);
	for (int i = 1; i < s.size(); ++i) {
		if (s[i - 1] == 'A' && s[i] == 'C') {
			cout << "Yes";
			return;
		}
	}
	cout << "No";
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << double(clock()) / CLOCKS_PER_SEC << " sec" << endl;
#endif
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    if (0L in a) return println(0)
    var answer = 1L
    for (i in 0 until n) {
        val j = answer
        answer *= a[i]
        if (answer > 1_000_000_000_000_000_000 || answer / a[i] != j) return println(-1)
    }
    println(answer)
}



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

int main(){
  int N;
  cin >> N;
  vector<tuple<string, int, int>> R(N);
  
  for(int i = 0; i < N; i++){
    int n;
    cin >> get<0>(R[i]) >> n;
    get<1>(R[i]) = -n;
    get<2>(R[i]) = i+1;
  }
  
  sort(R.begin(), R.end());
  
  for(int i = 0; i < N; i++){
    cout << get<2>(R[i]) << endl;
  }
  
  return 0;
  
}

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

li = []
flag = True

for i in range(n):
  word = input()
  li.append(word)
  if i != 0:
    if li[i-1][-1] != li[i][0]:
      flag = False

for i in li:
  if li.count(i) >= 2:
    flag = False

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

Measured memory_bytes: 3060
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int k, n;
	cin >> k >> n;
	vector<int> as(n);
	for(auto &a : as) cin >> a;
	int answer = as[0] + k - as[n - 1];
	for(int i = 0; i < n - 1; ++i) answer = max(answer, as[i + 1] - as[i]);
	cout << k - answer << '\n';
}

Measured memory_bytes: 3944
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{    

    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        string input = Console.ReadLine();
        string[] str = input.Split(' ');

        int[] data = new int[n];

        for(int i = 0; i < n; i++)
        {
            data[i] = int.Parse(str[i]);
        }
      
        int count = 0;
        bool flag = true;

        while (flag)
        {
            flag = false;
            int i = 0;
            for(int j = n - 1; j > i; j--)
            {
                if(data[j] < data[j - 1])
                {
                    int temp = data[j];
                    data[j] = data[j - 1];
                    data[j - 1] = temp;
                    flag = true;
                    count++;
                }
            }
            i++;
        }

        Console.WriteLine(String.Join(" ", data));
        Console.WriteLine(count);
       
    }
}


Measured memory_bytes: 17956
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int cnt = 0;
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        for (int i = 0; i < N; i++) {
            int minj = i;
            for (int j = i; j < N; j++) {
                if (A[j] < A[minj]) {
                    minj = j;
                }
            }
            if (i != minj) {
                int tmp = A[i];
                A[i] = A[minj];
                A[minj] = tmp;
                cnt++;
            }
        }

        System.out.print(A[0]);
        for(int i = 1; i < N; i++) {
            System.out.print(" " + A[i]);
        }
        System.out.println();
        System.out.println(cnt);
    }
}


Measured memory_bytes: 26356
'use strict'

const main = (input) => {
    let tasks = input.split('\n')[0].split(' ').map(i => parseInt(i))
    tasks = tasks.sort((a, b) => a - b)
    let total = 0
    for(let i = 1; i < tasks.length; i++) {
        total += tasks[i] - tasks[i - 1]
    }
    console.log(total)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 9420
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    std::vector<int> p(N);
    for (int i = 0; i < N;i++){
        cin >> p[i];
    }

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

    int sum = 0;
    for (int i = 0; i < K;i++){
        sum += p[i];
    }
    cout << sum;
    return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    bool ans = false;
    for (int i = 1; i < b; i++) {
        if (i * a % b == c % b) {
            ans = true;
            break ;
        }
    }

    if (ans) cout << "YES" << '\n';
    else cout << "NO" << '\n';
    return 0;
}

Measured memory_bytes: 256
"use strict"

function main(input) {
  //一部の正解がjsで扱う最大値を越えるため、文字列として扱う。
  //計算は配列を使った筆算（上の配列と下の配列を計算、桁上がりも対応）にて行う

  input = Number(input)

  let numbers = ["2", "1"]

  for (let i = 2; i <= input; i++) {
    const cal = (a, b) => {
      //   console.log("a,b", a, b)

      //左詰の配列だと計算しづらいのでreverse
      let aa = a
        .split("")
        .map(v => ~~v)
        .reverse()
      let bb = b
        .split("")
        .map(v => ~~v)
        .reverse()

      let cc = []
      let digit = 0
      //   const maxlength = bb.length//Math.max(aa.length, bb.length)
      //
      //各配列の値についてaa[i] + bb[i]する=筆算 桁数の大きい方の回数
      for (let i = 0; i < bb.length; i++) {
        let tmp = Number(aa[i])
          ? Number(aa[i]) + Number(bb[i]) + digit
          : Number(bb[i]) + digit //
        // console.log("tmp", tmp, aa[i], bb[i], digit)
        digit = 0

        if (tmp >= 10) {
          //   if (bb[i + 1] < maxlength) {
          digit = Math.floor(tmp / 10)
          //   console.log(digit)
          //   } else {
          //     bb.push(Math.floor(tmp / 10))
          //   }
          tmp = tmp % 10
        } else {
          digit = 0
        }
        cc.push(tmp)
        // console.log("tmp", tmp, aa[i], bb[i], digit)

        //桁が上がった場合を考慮
      }
      //   console.log(digit)
      if (digit > 0) cc.push(digit)

      //   if(bb.pop)

      //    let tmp = numbers[i - 2] + numbers[i - 1]
      //
      //   console.log(cc)

      return cc.reverse().join("") //array - string
    }
    let tmp = cal(numbers[i - 2], numbers[i - 1])
    // console.log(tmp)
    numbers.push(tmp)
  }
  //ans
  console.log(numbers.pop()) //string

  //   let nummax = Number.MAX_SAFE_INTEGER

  //   let xxx = 1
  //   let numbers = [2, 1]
  //   for (let i = 2; i <= input; i++) {
  //     let tmp = numbers[i - 2] + numbers[i - 1]
  //     // console.log(i, tmp)
  //     if (tmp <= nummax || xxx < 1) {
  //       numbers.push(tmp)
  //     } else {
  //       console.log("------")

  //       xxx = 1000000 // 10 ** 6
  //       numbers.push(numbers[i - 2] / xxx + numbers[i - 1] / xxx)
  //     }
  //     console.log(numbers[numbers.length - 1])
  //   }
  //   // console.log(Number.MAX_SAFE_INTEGER)

  //   console.log(numbers.pop() * xxx)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7612
// --------------
// Tejas Pandey  |
// 19 - 06 - 20  |
// Atcoder BC 171|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  char a;
  cin >> a;
  if(a < 'a') cout << 'A';
  else cout << 'a';
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main(void)
{
    int L, R, d;
    cin >> L >> R >> d;
    
    int count = 0;

    for(int i=L;i<=R;++i){
        if(i % d == 0 ) ++count;
    }
 
    cout << count << endl;
}

Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main () {
    int n, m;
    cin >> n >> m;

    int a[n][m], b[m], t;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> t;
            a[i][j] = t;
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> t;
        b[i] = t;
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            sum += a[i][j] * b[j];
        }
        cout << sum << endl;
        sum = 0;
    }
}


Measured memory_bytes: 3108
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

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

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());





#ifdef LOCAL
void signalHandler(int) {
  throw "Abort detected";
}
#endif

void doReplace() {
}

template <typename T, typename U, typename...Vs>
void doReplace(T &t, const U &u, Vs &&...vs) {
  t = u;
  doReplace(vs...);
}

template <typename T, typename...Us>
T minim(T &was, const T &cand, Us &&...us) {
  if (was > cand) {
    was = cand;
    doReplace(us...);
  }
  return was;
}

template <typename T, typename...Us>
T maxim(T &was, const T &cand, Us &&...us) {
  if (was < cand) {
    was = cand;
    doReplace(us...);
  }
  return was;
}

struct DSU {
  int n;
  std::vector<int> par;
  std::vector<int> rank;
  
  explicit DSU(int _n) : n(_n) {
    par.resize(n);
    rank.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 1;
    }
  }
  
  int root(int x) {
    return par[x] = (x == par[x]) ? x : root(par[x]);
  }
  
  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return true;
    if (rank[x] < rank[y]) swap(x, y);
    par[y] = x;
//    if (rank[x] == rank[y]) rank[x]++; // Rank
    rank[x] += rank[y]; // Size use any one.
    return false;
  }
};

class DFriends {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    DSU dsu(n);
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      u--, v--;
      dsu.unite(u, v);
    }
    int mx = -1;
    for (int i = 0; i < n; ++i) {
      maxi(mx, dsu.rank[i]);
    }
    cout << mx << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DFriends solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    double x[n],y[n];
    double s1,s2,s3,si=0;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        cin>>y[i];
        double gap=fabs(x[i]-y[i]);
        s1+=gap;
        s2+=pow(gap,2);
        s3+=pow(gap,3);
        si=max(si,gap);
    }
    s2=sqrt(s2);
    s3=cbrt(s3);
    printf("%.5f\n%.5f\n%.5f\n%.5f\n",s1,s2,s3,si);
    return 0;
}


Measured memory_bytes: 3404
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int H[1010];
signed main() {
    int N, T, A; cin >> N >> T >> A;
    for(int i=0; i<N; i++) cin >> H[i];
    
    double diff = INF;
    int ans = -1;

    for(int i=0; i<N; i++) {
        double tmp = T - H[i] * 0.006;
        double d = abs(A - tmp);

        if(d < diff) {
            diff = d;
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int x = Integer.parseInt(chr[2]);
			System.out.println(x>=a&&a+b>=x?"YES":"NO");

		}
	}
}

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

int main(){
    int n;
    cin>> n;

    vector<int> d(n);
    for(int& a : d){
        cin>>a;
    }

    sort(d.begin(), d.end(), greater<int>());
    
    int ans=0;
    int now=1e9;
    for(int i=0; i<n; i++){
        if(now>d[i]){
            now = d[i];
            ans++;
        }
    }

    cout<< ans <<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int sum = 0, num = 0, mi = 10;
	vector<int> a(5);

	for(int i=0;i<5;i++){
		cin >> a.at(i);
		if(a.at(i)%10!=0 && mi>a.at(i)%10){
			mi = a.at(i)%10;
			num = i;
		}
	}
	for(int i=0;i<5;i++){
		if(i==num)
			sum += a.at(i);
		else
			sum += (a.at(i) + 9) / 10 * 10;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin>>n>>m;
    ll a[m];
    rep(i,0,m)
    cin>>a[i];
    sort(a,a+m);
    ll p=a[0];
    rep(i,0,m)
    a[i]-=p;
    rep(i,0,m)
    if(n>=m)
    {
        cout<<0<<"\n";
        return 0;
    }
    vl v;
    rep(i,0,m-1)
        v.pb(a[i]-a[i+1]);
    sort(all(v));
    ll ans=a[m-1];
    rep(i,0,n-1)
    ans+=v[i];
    cout<<ans;

}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}

Measured memory_bytes: 3496
fun main(args: Array<String>) {
  print(readLine()!!.toInt().let { n ->
    (0..n).map {
      var six = it * 6
      var nine = (n - it) * 9
      (1..7).map { six /= 6; nine /= 9; six % 6 + nine % 9 }.sum()
    }.min()
  })
}


Measured memory_bytes: 39776
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=0

for i in range(n):
    x+=b[a[i]-1]
    if i>0:
        if a[i]==a[i-1]+1:
            x+=c[a[i-1]-1]
print(x)

Measured memory_bytes: 3060
n, m = map(int, input().split())
G = [[] for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    a-=1; b-=1
    G[a].append(b)
    G[b].append(a)

flag = (1<<n)-1

def dfs(v=0, visited=1):
    if visited == flag:
        return 1

    cnt = 0
    for to in G[v]:
        if visited & (1<<to):
            continue
        cnt += dfs(to, visited^(1<<to))
    return cnt

print(dfs())

Measured memory_bytes: 3064
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    data class Cuisine(val a: Long, val b: Long, val t: Long)

    val n = readLine()?.toInt() ?: return
    val cuisines = mutableListOf<Cuisine>()
    repeat(n) {
        val (a, b) = longList()
        cuisines.add(Cuisine(a, b, a + b))
    }
    cuisines.sortByDescending { it.t }
    var at = 0L
    var bt = 0L
    cuisines.forEachIndexed { i, (a, b, _) ->
        if (i % 2 == 0) {
            at += a
        } else {
            bt += b
        }
    }
    println((at - bt).toString())
}

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

int main()
{
    double n;
    cin >> n;
    vector<vector<double>> xy(n, vector<double>(2));
    rep(i, n) {
        cin >> xy.at(i).at(0);
        cin >> xy.at(i).at(1);
    }

    vector<double> order(n);
    rep(i, n) order.at(i) = i;
    double cnt = 0;
    double tmp = 0;
    do {
            rep(i, n-1) {
                tmp += sqrt( pow(( xy.at(order.at(i)).at(0) - xy.at(order.at(i+1)).at(0) ), 2) +pow(( xy.at(order.at(i)).at(1) - xy.at(order.at(i+1)).at(1) ), 2) );
            }
        cnt++;
    } while(next_permutation(order.begin(), order.end()));

    cout << fixed << setprecision(10) << tmp/cnt << endl;
}

Measured memory_bytes: 256