akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    init();

	int N, M; cin >> N >> M;
	if (abs(N - M) > 1)cout << 0 << "\n";
	else {
        mint ans = 1;
        rep(i, 1, N + 1)ans *= i;
        rep(i, 1, M + 1)ans *= i;
        if (N == M)ans *= 2;
        cout << ans.x << "\n";
	}

    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
*A, = map(int, input().split())
s = 0
l = 0
n = 0
h = [0]*N
while True:
    h[s] = l
    s = A[s]-1
    l += 1
    if h[s]:
        n = l-h[s]
        break

if K < h[s]:
    s = 0
else:
    K -= h[s]
    K = K % n

while K > 0:
    s = A[s]-1
    K = K-1
print(s+1)


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

using namespace std;

bool inField(int x,int y){
    return (0 <= x && x < 3 && 0 <= y && y < 3);
}

int main(){
    int n;
    while(cin >> n, n){
        char s,t,b;
        double dp[20][20] = {{0}};
        int dx[] = {-1,0,1,0};
        int dy[] = {0,-1,0,1};
        cin >> s >> t >> b;
        int S = s-'A',T = t-'A',B = b-'A';
        dp[n][S] = 1;
        for(int i = n ; i > 0 ; i--){
            for(int j = 0 ; j < 9 ; j++){
                int x = j%3, y = j/3;
                for(int k = 0 ; k < 4 ; k++){
                    int nx = x + dx[k],ny = y + dy[k];
                    int nj = ny*3+nx;
                    if(!inField(nx,ny) || nj == B){
                        dp[i-1][j] += dp[i][j]/4;
                    }else{
                        dp[i-1][nj] += dp[i][j]/4;
                    }
                }
            }
        }
        printf("%.12f\n",dp[0][T]);
    }
    return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

void leap(int a,int b)
{
    int i; int flg=0;
    for(i=a;i<=b;i++){
        if(i%4!=0){ continue; }
        if(i%100==0 && i%400!=0){ continue; }
        printf("%d\n",i); flg=1;
    }
    if(!flg){ printf("NA\n"); }
}

//#define DEBUG
int main(void)
{
	FILE *fpin;
#ifdef DEBUG
	fpin=fopen("input.txt","r");
#else
	fpin=stdin;
#endif
	int first_line=1;
    while(1){
        int a,b;
        fscanf(fpin,"%d %d\n",&a,&b);
        if(a==0 && b==0){ break; }
    	if(first_line){ first_line=0; }
    	else{ printf("\n"); }
        leap(a,b);
    }
    return 0;
}

Measured memory_bytes: 0
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


class DisjointSetUnion:
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == -1:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            x, y = y, x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        return


if __name__ == '__main__':
    n, q = map(int, readline().split())
    dsu = DisjointSetUnion(n)

    for i in range(q):
        t, u, v = map(int, readline().split())

        if t:
            print(int(dsu.same(u, v)))
        else:
            dsu.unite(u, v)


Measured memory_bytes: 78900
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n, k; cin >> n >> k;
    int ans=1;
    for (int i=0;i<n;i++){
        if (ans<k) ans *= 2;
        else ans += k;
    }
    cout << ans << endl; 
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int, input().split()))
ans=0
for i in range(60):
  g = [0,0]
  for j in a:
    g[(j>>i)%2]+=1
  ans+=2**i*g[0]*g[1]
  ans%=10**9+7
print(ans)

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

#define GETA 256
#define INF 1e18

int err(int a, int b){ return (a - b) * (a - b); }

int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    int input;
    vector<bool> c(256 + GETA, false);
    for(int i = 0; i < m; i++){
      cin >> input;
      c[input + GETA] = true;
    }

    vector<bool> lower_c(256 + GETA, false);
    vector<bool> upper_c(256 + GETA, false);
    for(int i = 1; i < 256 + GETA; i++){ lower_c[i] = c[i - 1] | lower_c[i - 1]; }
    for(int i = 256 + GETA - 2; i >= 0; i--){ upper_c[i] = c[i + 1] | upper_c[i + 1]; }

    vector<int> x(n + 1);
    for(int i = 1; i <= n; i++){ cin >> x[i]; }
    
    vector<vector<long long int> > dp(n + 1, vector<long long int>(255 + 1, INF));
    dp[0][128] = 0;
    for(int i = 1; i <= n; i++){
      for(int j = 0; j <= 255; j++){
        for(int k = 0; k <= 255; k++){
          int diff = j - k + GETA;
          if(c[diff] || (j == 255 && upper_c[diff]) || (j == 0 && lower_c[diff])){
            dp[i][j] = min(dp[i][j], dp[i - 1][k] + err(j, x[i]));
          }
        }
      }
    }

    long long int ans = INF;
    for(int i = 0; i <= 255; i++){ ans = min(ans, dp[n][i]); }
    cout << ans << endl;
  }
    
  return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  vector<map<string,ll>>m1(n+1),m2(n+1);
  bitset<18>a;
  rep(i,0,1<<n){
    a=i;
    string l,r;
    ll cnt=0;
    rep(j,0,n){
      if(a[j]){
        cnt++;
        l+=s[j];
      }
      else r+=s[j];
    }
    reverse(ALL(r));
    l+=r;
    emp(m1[cnt],l);
  }

  rep(i,0,1<<n){
    a=i;
    string l,r;
    ll cnt=0;
    rep(j,n,2*n){
      if(a[j-n]){
        cnt++;
        l+=s[j];
      }
      else r+=s[j];
    }
    reverse(ALL(r));
    r+=l;
    emp(m2[cnt],r);
  }
  rep(i,0,n+1){
    for(auto z:m1[i]){
      if(m2[n-i].find(z.fi)!=m2[n-i].end()){
        res+=z.se*m2[n-i][z.fi];
        //cout<<i spa z.fi spa z.se spa m2[n-i][z.fi]<<endl;
      }
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class D { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long H = GetLong();
		long W = GetLong();
		long D = GetLong();
		var xy = new (long, long)[H * W];
		for(long i = 0; i < H; i++)
		{
			for(long j = 0; j < W; j++)
				xy[GetLong() - 1] = (i, j);
		}

		var dp = new long[H * W];
		for(long i = 0; i < D; i++)
		{
			for(long j = 0; (j + 1) * D + i < H * W; j++)
			{
				long c = j * D + i;
				long n = (j + 1) * D + i;
				var (cx, cy) = xy[c];
				var (nx, ny) = xy[n];
				dp[n] = dp[c] + Abs(nx - cx) + Abs(ny - cy);
			}
		}

		long Q = GetLong();
		var ans = new long[Q];
		for(long i = 0; i < Q; i++)
		{
			long L = GetLong() - 1;
			long R = GetLong() - 1;
			ans[i] = dp[R] - dp[L];
		}
		WriteLine(string.Join("\n", ans));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


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

vector<int> g[100000];
int dp[2][100000];
void dfs(int cur, int prev, int dist, int idx) {
  dp[idx][cur] = dist;
  for (int to: g[cur]) {
    if (to == prev) {
      continue;
    }
    dfs(to, cur, dist + 1, idx);
  }
}
int main() {
  int n, u, v;
  cin>>n>>u>>v;
  --u;
  --v;
  for (int i=0; i<n-1; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(u, -1, 0, 0);
  dfs(v, -1, 0, 1);
  int ans = 0;
  for (int i=0; i<n; i++) {
    if (dp[0][i] < dp[1][i]) {
      ans = max(dp[1][i] - 1, ans);
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	cout << (n+1)*n/2 << endl;

	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc113/tasks/abc113_c

N, M = map(int, input().split())
c_l = [[int(i) for i in input().split()] + [j] for j in range(M)]

# print(c_l)
c_l.sort(key=lambda x: x[1])

counter = [0] * (N+1)
for c in c_l:
    p = c[0]
    counter[p] += 1
    c.append("{:06}{:06}".format(c[0], counter[p]))

c_l.sort(key=lambda x: x[2])

for c in c_l:
    print(c[3])



Measured memory_bytes: 35008
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var SW = ReadInts();
            var S = SW[0];
            var W = SW[1];
            if (S <= W)
            {
                WriteLine("unsafe");
            }
            else
            {
                WriteLine("safe");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27436
#include "bits/stdc++.h"

using ll = long long;
using namespace std;
int main(){
int n,l;
cin>>n>>l;
int sum=0;
for(int i=0;i<n;i++){
sum+=i+l;
}

if(l>0)
sum-=l;

if(l<(((-1)*n)+1))
sum+=(-1)*(l+n-1);

cout<<sum<<endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

template<typename T> using maximum_heap = std::priority_queue<T, std::vector<T>, std::less<T>>;
template<typename T> using minimum_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;

  vector<uint64_t> A(N), B(N);
  N_TIMES(n, N) { cin >> A[n]; }
  N_TIMES(n, N) { cin >> B[n]; }

  uint64_t S = accumulate(A.begin(), A.end(), static_cast<uint64_t>(0));
  uint64_t T = accumulate(B.begin(), B.end(), static_cast<uint64_t>(0));
  if (S < T) {
    cout << -1 << endl;
    return 0;
  }

  maximum_heap<uint64_t> xs;
  minimum_heap<uint64_t> ys;
  N_TIMES(n, N) {
    if (A[n] >= B[n]) {
      xs.push(A[n] - B[n]);
    } else {
      ys.push(B[n] - A[n]);
    }
  }

  uint64_t r = 0;
  while (!xs.empty()) {
    uint64_t x = xs.top(); xs.pop();
    r += x;

    uint64_t c = 0;
    while (!ys.empty()) {
      uint64_t y = ys.top(); ys.pop();

      if (r < y) {
        ys.push(y);
        break;
      }

      r -= y;
      ++c;
    }

    if (ys.empty()) {
      if (c == 0) { xs.push(x); }
      break;
    }
  }

  cout << (N - xs.size()) << endl;

  return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* class */
class Info {
public:
    ll value,
       weight;
    string type;
    ll date;
    string name;
    Info() {};
    Info(ll v, ll w, string t, ll d, string n)
        : value(v), weight(w), type(t), date(d), name(n) {};

    bool operator<(const Info &I) const{
        if (value != I.value) return value < I.value;
        else if (weight != I.weight) return weight < I.weight;
        else if (type != I.type) return type < I.type;
        else if (date != I.date) return date < I.date;
        else return name < I.name;
;

    }
};

/* constant */

const int INF = 1 << 30;
const int MAX = 100000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
/* main */
// Not using pair 
// Use class
int main() {

    int N; cin >> N;
    vector<Info> I(N);
    ll v, w, d;
    string t, n;
    for (int i = 0; i < N; i++) {
        cin >> v >> w >> t >> d >> n;
        I[i] = Info(v, w, t, d, n);
    }

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

    for (int i = 0; i < N; i++) {
        cout << I[i].value << ' ' << I[i].weight << ' '
             << I[i].type << ' ' << I[i].date << ' '
             << I[i].name << '\n';
    }

}


Measured memory_bytes: 17692
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    int k;
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << a[k-1] << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n1,num1[20];
    

int solve(int i,int m)
{
  int res;
  
  if(m==0){
    return 1;
  }
  if(i>=n1) return 0;

  res=solve(i+1,m);
  if(res!=1) res=solve(i+1,m-num1[i]);
  return res;
}


int main()
{
  int n2,i,num2,tf;

  scanf("%d",&n1);
  for(i=0;i<n1;i++) scanf("%d",&num1[i]);

  scanf("%d",&n2);
  for(i=0;i<n2;i++){
    scanf("%d",&num2);
    tf=solve(0,num2);
    if(tf==1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

  



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,m,l;
    cin>>n>>m>>l;
    vector<vector<ll>> wf1(n,vector<ll>(n,LINF));
    rep(i,n) wf1[i][i]=0;
    auto wf2=wf1;
    rep(_,m){
        ll a,b,c;cin>>a>>b>>c;a--,b--;
        wf1[a][b]=c;
        wf1[b][a]=c;   
    }
    rep(k,n)rep(i,n)rep(j,n) wf1[i][j]=min(wf1[i][j],wf1[i][k]+wf1[k][j]);
    rep(i,n){
        rep(j,n){
            if(wf1[i][j]<=l) wf2[i][j]=1;
        }
    }
    rep(k,n)rep(i,n)rep(j,n) wf2[i][j]=min(wf2[i][j],wf2[i][k]+wf2[k][j]);
    ll q;cin>>q;
    while(q--){
        ll s,t;cin>>s>>t;s--,t--;
        if(wf2[s][t]==LINF) cout<<-1<<endl;
        else                cout<<wf2[s][t]-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3 = x2 - (y2 - y1);
    int y3 = y2 + (x2 - x1);
    int x4 = x3 - (x2 - x1);
    int y4 = y3 - (y2 - y1);
    cout << x3 << ' ' << y3 << ' ' << x4 << ' ' << y4 << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

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

int main(){
    ll n,d;
    cin >> n >> d;
    ll ans=0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3536
package main

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

func main() {

	numbers := ScanedLinetoFloat64Slice()
	//W, H, x, y and r

	W := numbers[0]
	H := numbers[1]
	x := numbers[2]
	y := numbers[3]
	r := numbers[4]

	var answer string

	if (r+r > W) || (r+r > H) {
		answer = "No"
	} else {
		if (x+r <= W) && (x-r >= 0) && (y+r <= H) && (y-r >= 0) {
			answer = "Yes"
		} else {
			answer = "No"
		}
	}

	fmt.Println(answer)

}

func ScanedLinetoFloat64Slice() []float64 {

	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	line := sc.Text()

	words := strings.Fields(line)

	var numbers []float64

	for _, v := range words {
		number, _ := strconv.ParseFloat(v, 64)
		numbers = append(numbers, number)
	}

	return numbers
}



Measured memory_bytes: 1108
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string s;
	cin>>s;
	ll ans = 0;
	int r = 0,g= 0, b= 0;
	for(int i = 0 ; i<n; i++)
	{
		if(s[i]=='R')
		{ 
			ans += g*b; 
			r++;
		}
		else if(s[i]=='G')
		{
			ans += r*b;
			g++;
		}
		else
		{
			ans += r*g;
			b++;
		}
	}
	for(int i = 1;i<=n; i++)
		for(int j = i+1; j<=n; j++)
		{
			while(s[i-1]==s[j-1])
				j++;
			int k = 2*j-i;
			if(k<=n && s[k-1]!=s[j-1] && s[k-1]!=s[i-1])
				ans--;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3664
//每天要完成的工作就是上天对你的考核还有磨练
//寒冷和痛苦是你的伙伴
//你将凭借他们击败疲惫  迎取成功
//如果天将降大任的人和普通人过着同样的生活
//你不觉得世界少了很多乐趣吗
//你是什么 取决于你能做什么
//h[]  dp[]  n  k  一个函数
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

const int maxn = 1e5 + 5;
int h[maxn] = {0};
int dp[maxn] = {0};

int Fact(int i,int k)
{
	if(i <= 1 + k)
	{
		int min = dp[1] + abs(h[i] - h[1]);
		for(int j = 1; j < i; j++)
		{
			if(dp[j] + abs(h[i] - h[j]) < min)
			{
				min = dp[j] + abs(h[i] - h[j]);
			}
		}
		return min;
	}
	else
	{
		int min = dp[i - k] + abs(h[i] - h[i - k]);
		for(int j = i - k; j < i; j++)
		{
			if(dp[j] + abs(h[i] - h[j]) < min)
			{
				min = dp[j] + abs(h[i] - h[j]);
			}
		}
		return min;
	}
}

int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d",&h[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		if(i == 1)
		{
			dp[i] = 0;
		}
		else if(i == 2)
		{
			dp[i] = abs(h[2] - h[1]);
		}
		else
		{
			dp[i] = Fact(i,k);
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

constexpr int MAX_N = 100;
int N;
int a[MAX_N];

void _main() {
  cin >> N;
  rep(i, 0, N) cin >> a[i];

  int ans = inf;
  rep(y, -100, 101) {
    int tmp = 0;
    rep(ai, 0, N) {
      tmp += pow((y-a[ai]), 2);
    }
    chmin(ans, tmp);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
n = list(map(int,input().split()))
cnt = 0

while n.count(n[0]) != len(n):
    n.sort()
    if n[0] == n[1]:
        n[0] += 1
        n[1] += 1
    else:
        n[0] += 2
    cnt += 1
print(cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main() {
    int n;
    cin >> n;
    int w[n];
    for (int i = 0; i < n; i++)
    {
        cin >> w[i];
    }
    int ans = 99999999;
    for (int i = 0; i < n; i++)
    {
        int s1 = 0;
        int s2 = 0;
        int j;
        //iまで
        for (j = 0; j <= i; j++)
        {
            s1 += w[j];
        }
        //n-1まで
        for (int k = j; k < n; k++) {
            s2 += w[k];
        }
        int tmp = s1-s2;
        ans = min(ans, abs(tmp));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
    static Scanner s = new Scanner(System.in);
    static List<Integer> list = new ArrayList<Integer>();

    public static void main(String[] args) {
        while (true){
            int n=s.nextInt();
            int k=s.nextInt();
            int m=s.nextInt();

            if(n==0 && k==0 && m==0) break;

            list.clear();
            for(int i=1;i<=n;i++){
                list.add(i);
            }
            int num = m-1;
            while (true){
                if(list.size()==1) break;
                list.remove(num);
                num+=k-1;
                if(num>=list.size()){
                    num= num%list.size();
                }
            }
            System.out.println(list.get(0));

        }
    }
}

Measured memory_bytes: 29764
#include <bits/stdc++.h>
using namespace std;
int n,k,w[100000];

bool check(int x){
  int cnt=0,idx=0;
  while(idx<n){
    cnt++;
    if(cnt>k) return 0;
    int sum=0;
    while(sum+w[idx]<=x && idx<n) sum+=w[idx],idx++;
  }
  return 1;
}

int search(){
  int L=0,M,R=1e9+1;
  while(L<R){
    M = (L+R)/2;
    if(check(M)) R=M;
    else L=M+1;
  }
  return L;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++) cin>>w[i];
  cout<<search()<<endl;
  
  return 0;
}

Measured memory_bytes: 3456
import fractions
A,B,C,D = map(int,input().split())

def ans(v1,v2,v3):
    return v1-v1//v2-v1//v3+v1//(v2*v3//fractions.gcd(v2,v3))
print(int(ans(B,C,D)-ans(A-1,C,D)))



Measured memory_bytes: 5048
import java.util.*;

public class Main {
	static long[] distances;
	static ArrayList<Road>[] lists;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		distances = new long[n];
		lists = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			distances[i] = Long.MAX_VALUE;
			lists[i] = new ArrayList<Road>();
		}
		for (int i = 0; i < n - 1; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int w = sc.nextInt();
			lists[u - 1].add(new Road(v - 1, w));
			lists[v - 1].add(new Road(u - 1, w));
		}
		int idx = 0;
		while (idx != -1) {
			search(idx, 0);
			idx = getNext();
		}
		StringBuilder sb = new StringBuilder();
		for (long x : distances) {
			if (x % 2 == 0) {
				sb.append(0);
			} else {
				sb.append(1);
			}
			sb.append("\n");
		}
		System.out.println(sb);
	}
	
	static int getNext() {
		for (int i = 0; i < distances.length; i++) {
			if (distances[i] == Long.MAX_VALUE) {
				return i;
			}
		}
		return -1;
	}
					
	static void search(int idx, long distance) {
		if (distances[idx] <= distance) {
			return;
		}
		distances[idx] = distance;
		for (Road r : lists[idx]) {
			search(r.dest, distance + r.weight);
		}
	}
	
	static class Road {
		int dest;
		int weight;
		
		public Road(int dest, int weight) {
			this.dest = dest;
			this.weight = weight;
		}
	}
}


Measured memory_bytes: 115436
#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
using namespace atcoder;



int main() {
    int N, Q; cin >> N >> Q;
    fenwick_tree<ll> bit(N+1);
    for (int i=0; i<N; i++) {
        int a; cin >> a;
        bit.add(i+1, a);
    }
    for (int q=0; q<Q; q++) {
        int d, l, r; cin >> d >> l >> r;
        if (d == 0) {
            bit.add(l+1, r);
        } else {
            cout << bit.sum(l+1, r+1) << endl;
        }
    }
}

Measured memory_bytes: 8220
#include <stdio.h>
int main(void){
int a;
int b;
scanf("%d",&a);
scanf("%d",&b);
if(a>b){
printf("a > b\n");}
else if(a<b){
printf("a < b\n");}
else if(a==b){
printf("a == b\n");}
return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N; 
	cin >> N;
	int ans = 0; 
	int saidai = 0; 
	for(int i = 0; i < N; i++){
		int p; 
		cin >> p; 
		ans += p; 
		saidai = max(saidai, p); 
	}
	cout << ans - saidai / 2 << endl; 
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	string s;
	cin >> s;
	for (auto i : s) {
		N += i - '0';
	}
	if (N % 9)cout << "No\n";
	else cout << "Yes\n";
}

Measured memory_bytes: 3664
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2;

    scanf("%lf%lf%lf%lf", &x1, &y1, &x2, &y2);

    printf("%f\n", hypot(x1 - x2, y1 - y2));

    return 0;
}

Measured memory_bytes: 3272
s=list(input())
t=list(input())
n = len(s)
m = len(t)
dp=[[0 for i in range(m+1)] for j in range(n+1)]
for i in range(n+1):
    for j in range(m+1):
        if i<n and j<m and s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1])
        if j<m:
            dp[i][j+1]=max(dp[i][j],dp[i][j+1])
        if i<n:
            dp[i+1][j]=max(dp[i][j],dp[i+1][j])
ans=[]
while(n>0 and m>0):
    if dp[n][m]==dp[n-1][m]:
        n-=1
        continue
    if dp[n][m]==dp[n][m-1]:
        m-=1
        continue
    ans.append(s[n-1])
    n-=1
    m-=1
print("".join(ans[::-1]))

Measured memory_bytes: 121436
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int count = 0;
		for (int i = 0; i < N; i++) {
			int x = scanner.nextInt();
			if (x % 2 == 0) {
				if (x % 3 != 0) {
					if (x % 5 != 0) {
						count += 1;
						//System.out.println(x);
					}
				}
			}
		}

		if (count > 0) {
			System.out.println("DENIED");
		} else {
			System.out.println("APPROVED");
		}
	}
}


Measured memory_bytes: 24148
#include<iostream>

int a[5],last=10;

int main(){

    for(int i=0;i<5;i++){
        std::cin>>a[i];
        if(a[i]%10!=0){
            if(last>a[i]%10)
            last=a[i]%10;
        a[i]=a[i]+10-a[i]%10;
        }
    }

    if(last==10)
    std::cout<<a[0]+a[1]+a[2]+a[3]+a[4]<<std::endl;
    else
    std::cout<<a[0]+a[1]+a[2]+a[3]+a[4]+last-10<<std::endl;

    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll a, b, c, d;
ll mod = 998244353;
ll memo[3030][3030];
ll rec(ll h, ll w){
    if(h == a && w == b) return 1;
    if(memo[h][w] != -1) return memo[h][w];
    ll res = 0;
    if(h - 1 >= a) res += rec(h - 1, w) * w;
    res %= mod;
    if(w - 1 >= b) res += rec(h, w - 1) * h;
    res %= mod;
    if(h - 1 >= a && w - 1 >= b) res -= rec(h - 1, w - 1) * (h - 1) * (w - 1);
    res %= mod;

    while(res < 0) res += mod;

    return memo[h][w] = res % mod;
}
int main(void){
    cin >> a >> b >> c >> d;

    rep(i, 3030){
        rep(j, 3030){
            memo[i][j] = -1;
        }
    }
    cout << rec(c,d) << endl;
}

Measured memory_bytes: 75700
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;




int N, M;  //N頂点M辺
vector<int> visited;
vector<vector<int>> G;
ll ans=0,kk=0;

void dfs(int now){
    visited[now] = 1;
    kk++;
    for(int next : G[now]){
        if(!visited[next]){dfs(next);}
    }
}


int main() {
    cin >> N >> M;
    G = vector<vector<int>>(N); // サイズを確保する
    visited = vector<int>(N, 0); // 全頂点を「未訪問」に初期化
    set<int>q[N];
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;
        // 頂点番号を 0-indexed とする
        a--;
        b--;
        q[a].insert(b);
        q[b].insert(a);
    }
    rep(i,N){
      while(!q[i].empty()){
        int e=*q[i].begin();
        q[i].erase(e);
        G[i].push_back(e);
        G[e].push_back(i);
      }
    }
    rep(i,N){
    kk=0;
    dfs(i);
    chmax(ans,kk);
    }
    cout << ans <<endl;

}

Measured memory_bytes: 42892
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n>>m;
	vint d(n, 0);
	rep(i, m){
		int a,b;cin>>a>>b;
		d[a-1] ++;
		d[b-1] ++;
	}
	rep(i, n){
		cout << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <numeric>
#include <functional>
#include <cstdlib>
#include <regex>
#include <list>
int main() {
	int n, a;
	std::cin >> n >> a;
	if (n % (2 * a + 1) == 0) {
		std::cout << n / (2 * a + 1);
	}
	else {
		std::cout << n / (2 * a + 1) + 1;
	}
		return 0;
	
}



Measured memory_bytes: 256
import Data.IORef
import Control.Monad
 
main :: IO()
main = getLine >> getContents >>= solve.map read.lines >>= print
 
solve :: [Int] -> IO Int
solve (x : y : xs) = do
                a <- newIORef (y - x)
                b <- newIORef (min x y)
                forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                readIORef a

Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> vec(n);
  rep(i,n) cin>>vec[i];
  sort(all(vec));

  cout << accumulate(vec.rbegin(), vec.rbegin()+k, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
mod=10**9+7
def c(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
def power(a,n):
    x = 1
    while n:
        if n & 1:
            x *= a%mod
        n >>= 1
        a *= a%mod
    return x
    
n,a,b=map(int,input().split())
ans=power(2,n)%mod-1-c(n,a)%mod-c(n,b)%mod
for _ in range(10):
    if ans<0:
        ans+=mod
print(ans)

Measured memory_bytes: 3064
// 0505 Questionnaire (??¢?????±??????)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0505
// by Equim on 17-02-08

'use strict';

var raw = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

while (true) {
    var size = raw.shift().split(' ').map(Number);
    if (size[0] === 0) {
        break;
    }

    var count = {};
    for (var i = 0; i < size[0]; i++) {
        var line = raw.shift().split(' ').map(Number);
        for (var j = 0; j < size[1]; j++) {
            count[j + 1] = ((j + 1) in count ? count[j + 1] : 0) + line[j];
        }
    }

    // Support Lambda pls QAQ
    var rank = Object.keys(count).sort(function(a, b) { return count[a] == count[b] ? a - b : count[b] - count[a]; });

    var output = '';
    for (var i in rank) {
        output += rank[i] + ' ';
    }
    console.log(output.trim());
}

Measured memory_bytes: 18936
import math
n = int(input())

anslist = [0] * 10**4
for i in range(1, int(math.sqrt(int(10000/3)))+1):
    x = i
    for j in range(i, int(math.sqrt(int((10000-i**2)/2)))+1):
        y = j
        for k in range(j, int(math.sqrt(10000-i**2-j**2))+1):
            z = k
            uhen = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if uhen-1 >= 10**4:
                continue
            if x == y == z:
                anslist[uhen-1] += 1
            elif x != y and x != z and y != z:
                anslist[uhen-1] += 6
            else:
                anslist[uhen-1] += 3


for i in range(n):
    print(anslist[i])

Measured memory_bytes: 9384
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n;
	cin>>n;
	si s;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		s.insert(x);
	}
	if(s.size()!=n) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void println(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    string s; cin >> s;
    bool C = false, F = false;
    rfor(c, s) {
        if(!C) {
            if(c == 'C') {
                C = true;
                continue;
            }
        } else if(!F) {
            if(c == 'F') {
                F = true;
                break;
            }
        }
    }
    if(C && F) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

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

        scanf("%d %d %d",&a,&b,&c);
        if((b-a)==(c-b))
        {
                printf("YES\n");
        }else{
                printf("NO\n");
        }

        return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>

using namespace std;

long long weight[100016] = {0};

int main() {
	int N, W;
	scanf("%d%d", &N, &W);
	for(int i=0; i<100016; ++i) {
		weight[i] = W+1;
	}
	weight[0] = 0;
	for(int i=0; i<N; ++i) {
		int w, v;
		scanf("%d%d", &w, &v);
		for(int j=100016-1-v; 0<=j; --j) {
			weight[j+v] = min(weight[j+v], weight[j]+w);
		}
	}
	for(int i=100016-1; 0<=i; --i) {
		if(weight[i]<=W) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main() {
    priority_queue<int> pq;
    string command;
    int k;

    while (1) {
        cin >> command;
        if (command == "end") break;
        if (command == "insert") {
            cin >> k;
            pq.push(k);
        } else {
            cout << pq.top() << endl;
            pq.pop();
        }
    }

    return 0;
}


Measured memory_bytes: 6976
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
    fast();
    ll j,k,n,i;
    cin>>n>>k;
    vll a(n);
    rep(i,n)
        cin>>a[i];
    ll dp[500005];
    for(i=0;i<=n;i++)
        dp[i]=MOD;
    dp[0]=0;
    for(i=0;i<n;i++)
        for(j=1;j<=k;j++)
        {
            if(i+j<n)
                dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
        }
        cout<<dp[n-1];
}

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

using namespace std;

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b, a--, b--;
        uf.unite(a, b);
    }

    int ma = 0;
    for (int i = 0; i < n; i++)ma = max(ma, uf.size(i));
    cout << ma << endl;
    return 0;
}

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

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

    if (n % 10 == 7) {
        cout << "Yes" << endl;
        return 0;
    }

    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes" << endl;
        return 0;
    }

    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620