akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int m = ri();
	int a[n];
	for (auto &i : a) i = -1;
	bool possible = true;
	for (int i = 0; i < m; i++) {
		int index = ri() - 1;
		int val = ri();
		if (a[index] != -1 && a[index] != val) possible = false;
		a[index] = val;
	}
	if (!possible) {
		puts("-1");
		return 0;
	}
	if (n == 1) printf("%d\n", a[0] == -1 ? 0 : a[0]);
	else if (!a[0]) puts("-1");
	else {
		for (int i = 0; i < n; i++) {
			int res = a[i] == -1 ? 0 : a[i];
			if (!i && !res) res++;
			printf("%d", res);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
cnt = 0
for i in range(n):
    b,c = mp()
    if b==c:
        cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        cnt = 0
print("No")





Measured memory_bytes: 62364
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""




s = input()

a = len(s)-1


print("x"*a)

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

int n, m;
vector<vector<int>> cave(101010, vector<int>(0));
vector<bool> visited(101010, false);
int ans[101010];

bool bfs()
{
  queue<int> que;
  que.push(0);
  visited[0] = true;
  
  while(que.size())
  {
    int a = que.front();
    que.pop();
    for(int x : cave[a])
    {
      if(visited[x]) continue;
      visited[x] = true;
      que.push(x);
      ans[x] = a;
    }
  }
  rep(i, n)
  {
    if(!visited[i])
      return false;
  }
  
  return true;
}

int main()
{
  cin >> n >> m;
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    a--; b--;
    cave[a].emplace_back(b);
    cave[b].emplace_back(a);
  }
  
  if(bfs()) cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
    return 0;
  }
  
  rep(i, n - 1) cout << ans[i + 1] + 1 << "\n";
  
  return 0;
}

Measured memory_bytes: 10256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N;
set<int> st;
signed main(){
	cin >> N;
	rep(i, N){
		int t;
		cin >> t;
		st.insert(t);
	}
	if(st.size() == N) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x, k, d, kk, X;
  cin >> x >> k >> d;
  kk = k;
  if(x == 0) {
    if(k&1) {
      cout << d << '\n';
    } else {
      cout << 0 << '\n';
    }
    return 0;
  }
  ll tt = (abs(x))/d;
  k -= tt;
  if(k < 0) {
    if(x<0) {      
      cout << abs(x + kk*d) << '\n';
    } else {
      cout << abs(x - kk*d) << '\n';
    }
    return 0;
  }
  if(x<0) {
    X = -x;
    X %= d;
    x = -X;
    if(k&1) {
      cout << abs(x + d) << '\n';
    } else {
      cout << abs(x) << '\n';
    }
    return 0;
  }
  x %= d;
  if(k&1) {
    cout << abs(x-d) << '\n';
  } else {
    cout << abs(x) << '\n';
  }
  return 0;
}
    
  
 


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<string> words;

int main() {
    words = {"dream", "dreamer", "erase", "eraser"};
    string S;
    cin >> S;
    int pointer = S.length() - 1;
    while(pointer > 0) {
        if(S[pointer] == 'm') {
            // dream
            if(S[pointer - 4] == 'd' and S.substr(pointer - 4, 5) == "dream") {
                pointer -= 5;
            } else {
                cout << "NO" << endl;
                return 0;
            }
        } else if(S[pointer] == 'e') {
            // erase
            if(S[pointer - 4] == 'e' and S.substr(pointer - 4, 5) == "erase") {
                pointer -= 5;
            } else {
                cout << "NO" << endl;
                return 0;
            }
        } else if(S[pointer] == 'r') {
            // eraser
            if(S[pointer - 5] == 'e' and S.substr(pointer - 5, 6) == "eraser") {
                pointer -= 6;
            } else if(S[pointer - 6] == 'd' and
                      S.substr(pointer - 6, 7) == "dreamer") {
                pointer -= 7;
            } else {
                cout << "NO" << endl;
                return 0;
            }
        } else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  sort(s.begin(),s.end());
  vector<int> c(n,1);
  for(int i=0;i<n-1;i++){
    if(s.at(i)==s.at(i+1)){
      c.at(i+1)+=c.at(i);
    }
  }
  vector<pair<int,string>> p;
  for(int i=0;i<n;i++){
    p.push_back(make_pair(c.at(i),s.at(i)));
  }
  sort(p.begin(),p.end());
  for(int i=0;i<n;i++){
    if(p.at(i).first==p.at(n-1).first){
      cout << p.at(i).second << endl;
    }
  }
}

Measured memory_bytes: 19696
#include<bits/stdc++.h>
#define LL long long
#define M 200020
#define mod 1000000007
using namespace std;
namespace IO{
    const int BS=(1<<22)+5; int Top=0;
    char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
    inline char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
    inline void write(int x){
        if(!x){putchar('0');return;} if(x<0) x=-x,putchar('-');
        while(x) SS[++Top]=x%10,x/=10;
        while(Top) putchar(SS[Top]+'0'),--Top;
    }
    inline int read(){
        int nm=0; char cw=Getchar(); for(;!isdigit(cw);cw=Getchar());
        for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0'); return nm;
    }
}
using namespace IO;
#define mul(x,y) (LL)(x)*(y)%mod
#define upd(x,y) x=((x)+(y)>=mod)?(x)+(y)-mod:(x)+(y)
int n,m,fs[M],nt[M<<1],to[M<<1],tmp,ans=1,EG,top,ind[M],node[M];
int S[M],c[M],fa[M],nxt[M],fst[M],tar[M],cur,cnt,sz[M],inv[M],vis[M];
inline void link(int x,int y){
    nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;
    nt[tmp]=fs[y],fs[y]=tmp,to[tmp++]=x;
}
inline void edge(int x,int y){nxt[cur]=fst[x],fst[x]=cur,tar[cur++]=y;}
void init(int x,int last){
    node[++cnt]=x,S[++top]=x,ind[x]=1,S[top+1]=0;
    for(register int i=fs[x];~i;i=nt[i],EG++){
        if(to[i]==last) continue;
        if(!ind[to[i]]){init(to[i],x);continue;}
        if(m) continue;
        while(S[top+1]!=to[i]) vis[c[++m]=S[top--]]=true; c[0]=to[i];
    } top--,ind[x]=2;
}
void build(int x,int last){
    for(register int i=fs[x];~i;i=nt[i]){
        if(vis[to[i]]||to[i]==last) continue;
        fa[to[i]]=x,build(to[i],x);
    }
}
int dfs(int x){
    if(sz[x]) return 1; int res=sz[x]=1;
    for(register int i=fst[x];i!=-1;i=nxt[i]){
        res=mul(res,dfs(tar[i])),sz[x]+=sz[tar[i]];
    } return mul(res,inv[sz[x]]);
}
inline int calc(){
    for(int i=1;i<=cnt;i++) fst[node[i]]=-1,sz[node[i]]=0; cur=0; int res=1;
    for(int x=1;x<=cnt;x++) for(register int i=fs[node[x]];i!=-1;i=nt[i]) if(to[i]<fa[node[x]]) edge(node[x],to[i]);
    for(int x=1;x<=cnt;x++) if(!sz[node[x]]) res=mul(res,dfs(node[x])); return res;
}
inline int solve(int x){
    top=0,init(x,0); if(EG!=(cnt<<1)) puts("0"),exit(0);
    for(int i=1;i<=m;i++) build(c[i],0); int res=0;
    for(int i=1;i<=m;i++) fa[c[i-1]]=c[i]; upd(res,calc());
    for(int i=1;i<=m;i++) fa[c[i]]=c[i-1]; upd(res,calc());
    return res;
}
int main(){
    n=read(),ans=inv[1]=1,memset(fs,-1,sizeof(fs));
    for(int i=2;i<=(n<<1);i++) ans=mul(ans,i),inv[i]=mul(inv[mod%i],mod-(mod/i));
    for(int i=1;i<=(n<<1);i++) link(read()+n,read());
    for(int i=1;i<=(n<<1);i++) if(!ind[i]) cnt=m=EG=0,ans=mul(ans,solve(i));
    printf("%d\n",ans); return 0;
}

Measured memory_bytes: 21248
#include <iostream>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int main(){
    string str;
    cin >> str;
    int n = str.size();
    for(auto i : irange(0, n, 2)){
        cout << str[i];
    }
    cout << "\n";
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll Inf = 1e18;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    cout << (1 + n - 1) * (n - 1) / 2 << endl;
    
    return 0;
}



Measured memory_bytes: 256
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <functional>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define	MIN_QWORD				((QWORD)0x0000000000000000)
#define	MAX_SQWORD				((SQWORD)0x7FFFFFFFFFFFFFFF)
#define	MIN_SQWORD				((SQWORD)0x8000000000000000)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long			DWORD;
typedef unsigned long long int	QWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	// 入力
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	int cnt = 0;
	REP(i, N) {
		if (S[i] == 'I') {
			cnt++;
		} else if (S[i] == 'D') {
			cnt--;
		}
		ans = max(ans, cnt);
	}

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



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

int main() 
{
  string a,b,c; cin>>a>>b>>c;
  if(a[a.size()-1] == b[0] and b[b.size() - 1] == c[0])
    cout<<"YES";
  else
    cout<<"NO";  
  return 0;
}

Measured memory_bytes: 3572
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ret = s.size();
    for (char c = 'a'; c <= 'z'; c++)
    {
        int ans = 0;
        string t = s;
        while (true)
        {
            bool bad = false;
            for (auto d : t)
            {
                if (d != c)
                {
                    bad = true;
                    break;
                }
            }
            if (!bad)
            {
                break;
            }
            ans++;
            string f = "";
            for (int i = 0; i + 1 < (int) t.size(); i++)
            {
                if (t[i] == c || t[i + 1] == c)
                {
                    f += c;
                }
                else
                {
                    f += t[i];
                }
            }
            t = f;
        }
        ret = min(ret, ans);
    }
    cout << ret << '\n';
}


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

int main() {
  int N;
  cin >> N;
  
  int f;
  int l;
  int sum;
  sum = 0;
  
  for (int i=0; i<N; i++) {
    cin >> f >> l;
    sum = sum + l - f + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

struct MyStruct
{
	bool flag;//false=白、true=黒
	vector<pair<ll,ll>>list; //頂点番号、距離
};

int cnt = 0;
int n;
vector<MyStruct>stlist(100005);

vector<bool>tyoflag(100005, false);

int func(ll no, bool nextColor) {

	if (tyoflag[no] == true) {
		return 0;
	}

	tyoflag[no] = true;

	for (int i = 0; i < stlist[no].list.size(); i++) {
		if (nextColor == true && stlist[no].list[i].second % 2 == 0) {
			stlist[stlist[no].list[i].first].flag = true;
			func(stlist[no].list[i].first, true);
		}
		else if (nextColor == false && stlist[no].list[i].second % 2 == 1) {
			stlist[stlist[no].list[i].first].flag = true;
			func(stlist[no].list[i].first, true);
		}
		else if (nextColor == true && stlist[no].list[i].second % 2 == 1) {
			stlist[stlist[no].list[i].first].flag = false;
			func(stlist[no].list[i].first, false);
		}
		else if (nextColor == false && stlist[no].list[i].second % 2 == 0) {
			stlist[stlist[no].list[i].first].flag = false;
			func(stlist[no].list[i].first, false);
		}
	}

	return 0;
}

signed main() {
	
	cin >> n;

	for (int i = 0; i < n - 1; i++) {
		ll n1, n2, n3;
		cin >> n1 >> n2 >> n3;
		stlist[n1].list.push_back(make_pair(n2, n3));
		stlist[n2].list.push_back(make_pair(n1, n3));
	}

	stlist[1].flag = true;

	func(1, true);

	for (int i = 1; i <= n; i++) {
		cout << stlist[i].flag << endl;
	}

	return 0;
}

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

int binarySearch(int* array,int n,int key){
	int currRangeEnd = n;
	int currRangeFirst = 0;
	while(true){
		int currRangeCenter = (currRangeEnd + currRangeFirst) / 2;
		if(array[currRangeCenter] == key)
			return currRangeCenter;
		if(array[currRangeCenter] <= key){
			currRangeFirst = currRangeCenter;
		}else{
			currRangeEnd = currRangeCenter;
		}
		if(currRangeEnd - currRangeFirst <= 1)
			break;
	}
	if(array[currRangeFirst] == key)
		return currRangeFirst;
	return -1;
}

int main(){
	int n;
	cin >> n;
	int* s = new int[n];
	for(int i = 0;i < n;i++){
		cin >> s[i];
	}
	int q;
	cin >> q;
	int* t = new int[q];
	for(int i = 0;i < q;i++){
		cin >> t[i];
	}

	int c = 0;
	for(int i = 0; i < q;i++){
		if(binarySearch(s,n,t[i]) >= 0){
			c++;
		}
	}

	cout << c << endl;

	return 0;
}



Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()	{
  int x, y, z;
  cin >> x >> y >> z;
  int res = 0;
  // if there are n people, there are n * y and (n + 1) * z gaps
  while (res * y + (res + 1) * z <= x)	res++;
  if (res * y + (res + 1) * z > x) res--;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		long n = sc.nextLong(), m = sc.nextLong();
		long ans = 0;
		if(n * 2 == m) {
			ans = n;
		}else if(n*2 > m) {
			ans = m/2;
		}else {
			ans = n + (m - n*2)/4;
		}
		System.out.println(ans);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

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

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

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

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

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


Measured memory_bytes: 32588
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>
#include <fstream>
#include <cfloat>

int main() {
	const auto s = [](const int x) {return x * x; };
	int n; std::cin >> n;
	int count{ 0 };
	std::vector<int> result(n + 1, 0);
	for (auto x = 1; x <= 200; ++x) {
		for (auto y = 1; y <= 200; ++y) {
			for (auto z = 1; z <= 200; ++z) {
				const auto sum = s(x + y) + s(y + z) + s(z + x);
				if ((sum & 1) == 0 && (sum >> 1) <= n) {
					result[sum >> 1] ++;
				}
			}
		}
	}
	for (auto i = 1; i <= n; ++i) {
		std::cout << result[i] << '\n';
	}
}


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

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T>
using MaxHeap = priority_queue<T, vector<T>, less<T>>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline void input(vector<T> &vec) {
    for (auto &e: vec) {
        cin >> e;
    }
}

template <class T>
inline void input(vector<vector<T>> &mat) {
    for (auto &vec: mat) {
        input(vec);
    }
}

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

template <class T>
inline bool chmax(T &a, const T &b) noexcept {
    return b > a && (a = b, true);
}

template <class T>
inline bool chmin(T &a, const T &b) noexcept {
    return b < a && (a = b, true);
}

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

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

    var(size_t, N);

    vector<intmax_t> a(N);
    input(a);

    sort(all(a));

    print(diff(a.front(), a.back()));

    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    ll N,C;
    cin >> N >> C;
    ll x[N+2],v[N+1],SL[N+1],SR[N+1],ML[N+1],MR[N+1];
    x[0] = SL[0] = SR[0] = ML[0] = MR[0] = 0;
    x[N+1] = C;
    for(int i=1; i<=N; i++){
    	cin >> x[i] >> v[i];
    }
    for(int i=1; i<=N; i++){
    	SL[i] = SL[i-1]+v[N-i+1];
    	SR[i] = SR[i-1]+v[i];
    	ML[i] = max(ML[i-1],SL[i]-C+x[N-i+1]);
    	MR[i] = max(MR[i-1],SR[i]-x[i]);
    }
    ll ans = 0;
    for(int r=N; r>=0; r--){
    	ans = max(ans,ML[N-r]+SR[r]-x[r]*2);
    }
    for(int l=N; l>=0; l--){
    	ans = max(ans,MR[N-l]+SL[l]-C*2+x[N-l+1]*2);
    }
    cout << ans;
}

Measured memory_bytes: 4992
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int a,b,h;
int main(){
	cin>>a>>b>>h;


	cout<<(a+b)*h/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 10000000
#define ll long long
using namespace std;

int main(){
    ll n; cin>>n;
    vector<ll> que;
    ll a; cin>>a; que.push_back(a);
    ll count=1;
    for(ll i=0; i<n-1; i++){
        ll x; cin>>x;
        if(x>que.back()){
            que.back()=x;
            continue;
        }
        
        if(x<=que.front()){
            que.insert(que.begin(),x);
            count++;
            continue;
        }
        
        auto it=lower_bound(que.begin(),que.end(),x);
        ll index=it-que.begin();
        que[index-1]=x;
    }
    
    cout<<count<<endl;
}

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

int main(){
    ll a;
    long double b;
    cin >> a >> b;
 
    long double ans;
    ans = a * b;
    ll n = ans;
  
    cout << n << endl;
    return 0;
}

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

int main()
{
  int N = 0;
  cin >> N;
  
  vector<int64_t> array(90);
  array.at(0) = 2;
  array.at(1) = 1;
  
  for(int i = 2; i <= N; i++)
  {
  	array.at(i) = array.at(i -1) + array.at(i - 2);
  }
  cout << array.at(N) << endl;
  return(0);
}

Measured memory_bytes: 256
import java.util.*;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		Node[] nodes=new Node[n];
		Edge[] edges=new Edge[n-1];
		
		for(int i=0;i<n;i++) {
			nodes[i]= new Node();
			nodes[i].no=i;
		}
		

		for (int i=0;i<n-1;i++) {
			Edge e=new Edge();
			int a=sc.nextInt();
			int b=sc.nextInt();
			e.from=nodes[a-1];
			e.to=nodes[b-1];
			nodes[a-1].edges.add(e);
			nodes[b-1].edges.add(e);
			edges[i]=e;
		}
		List<Node>path = new ArrayList<Node>();
		path.add(nodes[0]);
		path=dfs(nodes,edges, path, nodes[n-1], new boolean[n]);
		
		for(int i=0;i<path.size();i++) {
			if(i*2<path.size()) {
				path.get(i).color=1;
			}
			else {
				path.get(i).color=-1;
			}
		}
		
		dfs2(nodes,edges,nodes[0], new boolean[n],(byte)1);
		dfs2(nodes,edges,nodes[n-1], new boolean[n],(byte)-1);

		int fennec=0;
		int snuke=0;
		for(int i=0;i<n;i++) {
			if(nodes[i].color==1) {
				fennec++;
			}
			else {
				snuke++;
			}
		}
		System.out.println(fennec>snuke ? "Fennec" : "Snuke");
	}
	
	static List<Node> dfs(Node[] nodes, Edge[] edges, List<Node> path, Node destination, boolean[] looked) {
		Node current=path.get(path.size()-1);
		if(current==destination) {
			return path;
		}
		else {
			looked[current.no]=true;
			for (Edge e : current.edges) {
				Node next= e.from==current ? e.to : e.from;
				if(!looked[next.no]) {
				path.add(next);
				return dfs(nodes, edges, path, destination, looked);
				}
			}
			path.remove(path.size()-1);
			return dfs(nodes,edges,path,destination,looked);
		}
	}
	
	static void dfs2 (Node[] nodes, Edge[] edges, Node current, boolean[] looked, byte color) {
		looked[current.no]=true;
		current.color=color;
		for(Edge e : current.edges) {
			Node next= e.from==current ? e.to : e.from;
			if(!looked[next.no] && color*next.color!=-1) {
			dfs2(nodes, edges, next, looked, color);
			}
		}
	}
}

class Node {
	int no;
	List<Edge> edges=new ArrayList<Edge>();
	byte color;
}

class Edge {
	Node from;
	Node to;
}

Measured memory_bytes: 111544
#include<bits/stdc++.h>
using namespace std;
int d[10000];

int main(){
    int n,x,y;cin>>n>>x>>y;
    for(int i=1;i<n;i++){
        for(int j=i+1;j<n+1;j++){
            int dd=min(j-i,abs(i-x)+1+abs(j-y));
            d[dd]++;
        }
    }
    for(int i=1;i<n;i++) cout<<d[i]<<endl;
}

Measured memory_bytes: 256
import sys 
input = sys.stdin.readline
import itertools

def Washall_Floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    return d

n, m, r = map(int, input().split())
R = list(map(int, input().split()))
f_inf = float('inf')
dist = [[f_inf]*n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    dist[a][b] = c
    dist[b][a] = c

Washall_Floyd(dist)

S = list(itertools.permutations(R, r))
cnt = f_inf
for s in S:
  tmp = 0
  for i in range(len(s)-1):
    tmp += dist[s[i]-1][s[i+1]-1]
  cnt = min(cnt, tmp)
print(cnt)

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

int main()
{
    int x;
    cin >> x;
    
    if(x>=1800 && x<=1999)
    {
        cout << 1;
    }
     if(x>=1600 && x<=1799)
    {
        cout << 2;
    }
     if(x>=1400 && x<=1599)
    {
        cout << 3;
    }
 if(x>=1200 && x<=1399)
    {
        cout << 4;
    }
 if(x>=1000 && x<=1199)
    {
        cout << 5;
    }
 if(x>=800 && x<=999)
    {
        cout << 6;
    }
 if(x>=600 && x<=799)
    {
        cout << 7;
    }
     if(x>=400 && x<=599)
    {
        cout << 8;
    }

 

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=1005;
const int maxn=1e5+5;
ll a[N],v[N];
ll dp[maxn];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i]>>v[i];
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;++i)
		for(int j=maxn-5;j>=v[i];--j)
			dp[j]=min(dp[j-v[i]]+a[i],dp[j]);
	ll ans=0;
	for(int i=1;i<=maxn-5;++i)
		if(dp[i]<=k) ans=max(ans,(ll)i);
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int (i)=0;(i)<(n);(i)++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
bool custom1 (pair<int, int> a, pair<int, int> b) {
  return (a.first < b.first);
}
bool custom2(pair<int, int> a, pair<int, int> b) {
  return (a.second < b.second);
}

const int MAX = 200005;
const long long MOD = 1000000007;
const long long MODMOD = 998244353;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> digit(n, -1);
  bool yes = true;
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    s--;
    if(digit[s] == -1) digit[s] = c;
    else if(digit[s] != c) yes = false;
  }
  if(!yes) {
    cout << -1 << endl;
    return 0;
  }
  if(n == 1) {
    if(digit[0] == -1) cout << 0 << endl;
    else cout << digit[0] << endl;
  }
  else if(n == 2) {
    if(digit[0] == -1) digit[0] = 1;
    else if(digit[0] == 0) yes = false;
    if(digit[1] == -1) digit[1] = 0;
    if(yes) cout << digit[0] << digit[1] << endl;
    else cout << -1 << endl;
  }
  else {
    if(digit[0] == -1) digit[0] = 1;
    else if(digit[0] == 0) yes = false;
    if(digit[1] == -1) digit[1] = 0;
    if(digit[2] == -1) digit[2] = 0;

    if(yes) cout << digit[0] << digit[1] << digit[2] << endl;
    else cout << -1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int ans;
    if(n%1000==0)
    {
        ans=0;
    }
    else
    {
        ans=1000-(n%1000);
    }
   // int ans=1000-(n%1000);
    cout<<ans;
}



Measured memory_bytes: 3628
#include <iostream>
using namespace std;
 
int main(){

    int a, b, c;

	cin >> a >> b >> c;

    int lest, move;
    lest = a - b;
    move = c - lest;

    if(0 > move)
        cout << 0 << endl;
    else
        cout << move << endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;

	if ((a < c && b > c) || (a > c&& b < c)) puts("Yes");
	else puts("No");

	return 0;
}

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

ll a[100000];
ll cs[100001] = {0};

const ll Q = 1000000007;//  1,000,000,007

ll climbStairs(ll n) {
  if (n > 2) {
    //cout << "csn" << cs[n] << endl;
    if (cs[n] != (ll)0) return cs[n];
    else {
      //cout << ":" << n << endl;
      cs[n] = (climbStairs(n-1)%Q + climbStairs(n-2)%Q)%Q;
      return cs[n];
    }
  } else return n;
}

void Main()
{
  ll N, M;
  cin >> N >> M;
  if (M==0) {cout << climbStairs(N) % Q << endl; return;}
  
  rep(i,M){
  	cin >> a[i];
  }
  rep(i,M-1){
    if (a[i+1]-a[i]==1) {cout << 0 << endl; return;}
  }
  //rep(i,100000){
  //	cout << cs[i] << endl;
  //}
  ll pattern = 0;
  if (a[0] != 1) pattern = climbStairs(a[0]-1) % Q;
  else pattern = 1;
  //cout << pattern << endl;
  for(int i = 1; i < M; i++){
    pattern = (pattern * (max(climbStairs(a[i]-a[i-1]-2),(ll)1)%Q)) % Q;
    //cout << pattern << endl;
  }
  //cout << climbStairs((ll)3) << endl;
  pattern = (pattern * (max(climbStairs(N-a[M-1]-1),(ll)1)%Q)) % Q;
  cout << pattern << endl;
}

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

Measured memory_bytes: 4224
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c) cout<<"Yes"<<'\n';
    else cout<<"No"<<'\n';
    return 0;
    }

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

using namespace std;

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

    long long black = 0, answer = 0;
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s[i] == 'B')
            black++;
        else
            answer += black;
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>


using namespace std;

int n, m;
int p[100005];
int x[100005], y[100005];

int P[100005];
void init(int N){
  for(int i = 0; i < N; ++i){
    P[i] = i;
  }
}

int root(int a){
  if(P[a] == a) return a;
  return(P[a] = root(P[a]));
}

bool is_same_set(int a, int b){
  return root(a) == root(b);
}

void unit(int a, int b){
  P[root(a)] = root(b);
}

int main(){
  cin >> n >> m;
  init(n);
  for(int i = 0; i < n; ++i){
    cin >> p[i];
  }
  for(int i = 0; i < m; ++i){
    cin >> x[i] >> y[i];
    unit(x[i], y[i]);
  }
  int cnt = 0;
  for(int i = 0; i < n; ++i){
    if(is_same_set(p[i], i + 1)){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 1792
# AtCoder Beginner Contest 155 - B
# -*- encoding: UTF-8 -*-

n = int(input())
aList = list(map(int, input().split()))

result = "APPROVED"

for a in aList :
  if a % 2 == 0 :
    if a % 6 != 0 and a % 10 != 0 :
      result = "DENIED"
      break

print(result)


Measured memory_bytes: 2940
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M,K;
	scan(N);scan(M);scan(K);
	rep(i,N+1){
		rep(j,M+1){
			int kosu=(N-i)*j+(M-j)*i;
			if(kosu==K){
				prin("Yes");
				return 0;
			}
		}
	}
	prin("No");
	return 0;
}


Measured memory_bytes: 764
//10:12-24+26+10
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace __gnu_pbds; using namespace std;
typedef long long ll;
typedef tree<double,null_type,less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
double a[40040],b[40040],c[40040],cut[40040],INF=-2e8;pair<double,int> pm[40040];int n,j;ll med;
inline void solve() {
    for (int i=0;i<n;i++) pm[i]=make_pair((double)(c[i]-(a[i]*INF))/b[i],i);
    sort(pm,pm+n);
    double lo=INF,hi=-lo,mid;int cnt=63;
    while (cnt--) {
        mid=(lo+hi)*0.5; ordered_set aa; ll inv=0;
        for (int i=0;i<n;i++) j=pm[i].second,cut[j]=((double)(c[j]-(a[j]*mid))/b[j]);
        for (int i=n-1;i>=0;i--) j=pm[i].second,aa.insert(cut[j]),inv+=(aa.order_of_key(cut[j]));
        if (inv<med) lo=mid; else hi=mid;
    }
    cout<<fixed<<setprecision(12)<<lo;
}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n; med=(n*(n-1))/2; med=(med+1)/2;
    for (int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    solve(); swap(a,b); cout<<" "; solve();
}

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

int main() {
	int A, B, N;
	cin >> A >> B >> N;
	
  	int count = 0;
  	for (int i = 0; i < N; i++){
      if(count % 2 == 0){
        if( A % 2 == 1 ) A--;
        B += A/2;
        A -= A/2;
        count ++;
      }
      else{
        if( B % 2 == 1 ) B--;
        A += B/2;
        B -= B/2;
        count ++;
      }
    }
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 384
# 191027 B
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
divs = make_divisors(N)
for i in range(len(divs)):
    if divs[i] < 10 and N / divs[i] < 10:
        print("Yes")
        exit(0)
print("No")




Measured memory_bytes: 3060
X, Y = map(int, input().split())
MOD = 10 ** 9 + 7

if (X + Y) % 3 != 0:
    print(0)
    exit()
if abs(X - Y) > (X + Y) // 3:
    print(0)
    exit()
    
n = (X + Y) // 3 + 1
k = ((X - Y) + n + 1) // 2
SIZE = max(n, k)

g1 = [1, 1]      # 元テーブル
g2 = [1, 1]      # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

def comb(n, r, mod):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod

for i in range(2, SIZE):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

print(comb(n - 1, k - 1, MOD))

Measured memory_bytes: 82464
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

ld c[3003]; ld dp[3003][3003];

ld solve(ll n , ll heads , ll tails)
{
	if(n==0)
	{
		if(heads>tails)return 1.0;
		else return 0.0;
	}

	if(dp[n][heads]!=-1) return dp[n][heads];
	ld hp = c[n-1];  ld tp = 1.0-hp; 

	return dp[n][heads]= hp*solve(n-1,heads+1,tails) + tp*solve(n-1,heads,tails+1);
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n; cin>>n; forA(i,0,n,1)cin>>c[i];
	forA(i,0,3003,1)forA(j,0,3003,1) dp[i][j]=-1;
	ld ans = solve(n,0,0);
	cout<<fixed<<setprecision(10)<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 74440
#include<bits/stdc++.h>
using namespace std;
int ans[51][51] = {0};
int n, m;
void fboom(int ans[51][51], int i, int j) {
	if (i>0) for (int k=j-1; k<=j+1; k++) {
		if (ans[i-1][k]!=-1) ans[i-1][k]++;
	}
	if (i<n-1) for (int k=j-1; k<=j+1; k++) {
		if (ans[i+1][k]!=-1) ans[i+1][k]++;
	}
	if (j>0) if (ans[i][j-1]!=-1) ans[i][j-1]++;
	if (j<m-1) if (ans[i][j+1]!=-1) ans[i][j+1]++;
}
int main () {
	cin >> n >> m;
	char map[51][51];
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			char c; cin>>c;
			if (c=='#') {
				ans[i][j]=-1;
				fboom(ans, i, j);
			}
		}
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			if (ans[i][j]==-1) cout << "#";
			else cout << ans[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3604
import java.io.*;
class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		while ((line = reader.readLine()) != null) {
			String[] values = line.split(" ");
			if (values.length < 8) break;
			double x1 = Double.parseDouble(values[0]);
			double y1 = Double.parseDouble(values[1]);
			double x2 = Double.parseDouble(values[2]);
			double y2 = Double.parseDouble(values[3]);
			double x3 = Double.parseDouble(values[4]);
			double y3 = Double.parseDouble(values[5]);
			double xp = Double.parseDouble(values[6]);
			double yp = Double.parseDouble(values[7]);
			double area12 = area(xp, yp, x1, y1, x2, y2);
			double area23 = area(xp, yp, x2, y2, x3, y3);
			double area31 = area(xp, yp, x3, y3, x1, y1);
			double area123 = area(x1, y1, x2, y2, x3, y3);
			String result = area12 + area23 + area31 - area123 < 0.0001 ? "YES" : "NO";
			System.out.println(result);
		}
	}
	static double area(double x1, double y1, double x2, double y2, double x3,    double y3) {
			return 0.5 * Math.abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
	}
}

Measured memory_bytes: 9732
from itertools import product, permutations
n, c = map(int, input().split())
D = [list(map(int, input().split())) for _ in range(c)]
C = [list(map(int, input().split())) for _ in range(n)]

X = [[0] * c for i in range(3)]

for i, j in product(range(n), range(n)):
    # グリッドにある色を余りごとにカウント
    X[(i + j + 2) % 3][C[i][j] - 1] += 1

cost = [[0] * c for _ in range(3)]
for i, j in product(range(c), range(c)):
    # cost[0][k] -> 余りが0になる場所の色をkに変えるときのコスト
    cost[0][j] += X[0][i] * D[i][j]
    cost[1][j] += X[1][i] * D[i][j]
    cost[2][j] += X[2][i] * D[i][j]

ans = []
for s, t, u in permutations(range(c), r=3):
    ans.append(cost[0][s] + cost[1][t] + cost[2][u])
print(min(ans))

Measured memory_bytes: 6644
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for i in range(N):
    d = []
    for j in range(M):
        d.append(abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]))
    print(d.index(min(d)) + 1)

Measured memory_bytes: 3064
from itertools import combinations 
N = int(input())
L = list(map(int,input().split()))


ans = list(combinations(L,3))
ans1 = 0
for i in ans:
    if (i[0]+i[1]>i[2] and i[0]+i[2]>i[1] and i[1]+i[2]>i[0] and i[0]!=i[1] and i[0]!=i[2] and i[1]!=i[2]):
        ans1+=1

print(ans1)

Measured memory_bytes: 20352
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
    int n = 0, x=0;
    cin >> n;

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

    cout << endl;
    return 0;
}


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

int main(void){
  // ??°???S???????????????
  int n;
  cin >> n;
  vector<int> s(n);
  for(int i = 0; i < n; i++)
    cin >> s[i];

  // ?????¨?????????
  int q, t, ans = 0;
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> t;

    // S?????????T??????????????????????????¢??¢?´¢
    for(int i = 0; i < n; i++){
      if(s[i] == t){
        ++ans;
        break;
      }
    }
  }

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

Measured memory_bytes: 3088
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = sc.nextInt()
    val a = sc.nextInt()
    val h = (0 until n).map { sc.next().toInt() }
    println(problem113b(n, t, a, h))
}

fun problem113b(n: Int, t: Int, a: Int, h: List<Int>): Int {
    var tmp = Double.MAX_VALUE
    var ans = 0
    for (i in 0 until n) {
        val temple = t - h[i] * 0.006
        val new = Math.abs(a - temple)
        if(tmp > new) {
            ans = i + 1
        }
        tmp = Math.min(tmp, new)
    }
    return ans
}

Measured memory_bytes: 31388
main = do
    s <- getLine
    let abc = filter (`elem` s) ['a'..'z']
    print . minimum $ map (shrink 0 s) abc

shrink k s a | all (== a) s = k
             | otherwise = shrink (k+1) s' a
    where s' = zipWith (\x y -> if x == a || y == a then a else x) s (tail s)

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e9+7
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 long long int gcd(long long int m,long long int n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
long long int lcm(long long int number1,long long int number2){
	return number1 * number2 / gcd(number1,number2);	

}
int main(){
  ll N;
  cin>>N;
  
  vector<vector<ll>>F(N,vector<ll>(10));
  vector<vector<ll>>P(N,vector<ll>(11));
 
  
  rep(i,N){
    rep(j,10){
      cin>>F[i][j];
    }
  }
  
  rep(i,N){
rep(j,11){
  cin>>P[i][j];
}
  }

  ll max=-10000000000;
  
  for(ll i=1;i<power(2,10);i++){
    vector<ll>date(N);
    ll sum=0;
    bitset<10>A(i);
    string B=A.to_string();
      
      rep(j,10){
      rep(k,N){
      if(B[j]=='1'&&F[k][j]==1){
date[k]++;
      }
      }
    }
      
      rep(l,N){
        sum+=P[l][date[l]];
      }
      
      if(sum>max){
        max=sum;
      }
    }
    
    cout<<max<<endl;
  }



Measured memory_bytes: 256