akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define Mod 998244353
using namespace std;
struct Tree{
	int fa;
	int ch[2];
	int dp;
}T[1000010];int tot;
inline int newnode(int fa)
{
	tot++;
	T[tot].fa=fa;
	T[tot].ch[0]=T[tot].ch[1]=0;
	T[tot].dp=-1;
	return tot;
}
inline int g(int u,int c)
{
	if(!T[u].ch[c])T[u].ch[c]=newnode(u);
	return T[u].ch[c];
}
inline int w(int u)
{
	return T[T[u].fa].ch[1]==u;
}
int tmp[110][110];
int run(int* s,int len)
{
	int cur=0;
	for(int i=0;i<len;i++)
		cur=g(cur,s[i]);
	return cur;
}
int solve(int u,int cur)
{
	if(u==0)return 1;
	if(T[u].dp!=-1)return T[u].dp;
	T[u].dp=solve(T[u].fa,cur)*(w(u)+1)%Mod;
	int d=0,t=u;
	while(t){
		t=T[t].fa;
		d++;
	}
	for(int i=1;i<d;i++)
	{
		t=u;
		for(int j=0;j<i;j++)
			tmp[cur][j]=1;
		for(int j=0;j<d;j++)
		{
			tmp[cur][j%i]&=w(t);t=T[t].fa;
			if(j>=i&&j%i==(i-1))T[u].dp=(T[u].dp+(long long)solve(t,cur+1)*solve(run(tmp[cur],i),cur+1))%Mod;
		}
	}
	return T[u].dp;
}
char str[110];
int main()
{
	scanf("%s",str);
	int n=strlen(str);
	int cur=0;
	for(int i=0;i<n;i++)
		cur=g(cur,str[i]-'0');
	printf("%d\n",solve(cur,0));
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <cassert>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    int n = (int)s.size();
    vvi spt(n + 1, vi(22));
    vi ans(n + 1);
    fore(i, 0, n) {
        if (s[i] == 'L') spt[i][0] = i - 1;
        if (s[i] == 'R') spt[i][0] = i + 1;
    }
    fort(j, 1, 20) fore(i, 0, n) spt[i][j] = spt[spt[i][j - 1]][j - 1];
    fore(i, 0, n) ++ans[spt[i][20]];
    fore(i, 0, n) cout << ans[i] << ' ';
    return 0;
}


Measured memory_bytes: 12624
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;
lint c[5000][5000];
int main(){
  int N,M;
  cin>>N>>M;
  int K=1<<N;
  
  lint inf=1e10;
  REP(i,K)REP(j,K)c[i][j]=inf;
  REP(i,M){
    lint a,b;
    cin>>a>>b;
    int key=0;
    REP(j,b){
      int c;
      cin>>c;
      c--;
      key|=1<<c;
    }
    // cerr<<key<<endl;
    REP(j,K){
      if((j|key)!=j)c[j][j|key]=min(a,c[j][j|key]);
    }
  }
  // REP(i,K){
  //   REP(j,K)cerr<<c[i][j]<<" ";
  //   cerr<<endl;
  // }
  priority_queue<pair<lint,int>,vector<pair<lint,int> >,greater<pair<lint,int> > > q;
  q.push(make_pair(0,0));
  lint d[K];
  REP(i,K)d[i]=inf;
  d[0]=0;
  while(!q.empty()){
    int p=q.top().second;
    int cost=q.top().first;
    q.pop();
    if(d[p]<cost)continue;
    // cerr<<p<<endl;
    FOR(i,p+1,K)if(c[p][i]<inf){
      if(d[i]>d[p]+c[p][i]){
        d[i]=d[p]+c[p][i];
        q.push(make_pair(d[i],i));
      }
    }
  }
  REP(i,K)cerr<<d[i]<<endl;
  if(d[K-1]<inf)cout<<d[K-1]<<endl;
  else cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 162176
import sys
input = sys.stdin.buffer.readline
H,W,K= map(int,input().split())
s = [input().decode().strip() for i in [0]*H]

num = 0
no_berry_row = []
prev_row = []
first_no_berry_row = 0
first_no_berry_flag = True
for i,row in enumerate(s):
    num += 1
    first_berry = True 
    row_ans = []
    for c in row:
        if c == "#":
            first_no_berry_flag = False
            if first_berry:
                first_berry = False
            else:
                num += 1
        row_ans.append(num)
    if first_berry: # no berry
        if first_no_berry_flag:
            first_no_berry_row += 1
        no_berry_row.append(i)
        print(*prev_row)
        num -= 1
    else:
        for j in range(first_no_berry_row):
            print(*row_ans)
            first_no_berry_row = 0
        print(*row_ans)
        prev_row = row_ans








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

int main()
{
    char f[105];
    ll i,a,b=0;
    cin>>f;
    for(i=0,a=strlen(f)-1;i<strlen(f),a>=0;i++,a--)
    {
        if(f[i]!=f[a])b++;
    }
    cout<<b/2<<endl;
}


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



int main() {
    int n;
    cin>>n;
    string s;
    unordered_map<string,int>mp;
    while(n--) {
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
}


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

class Main{
  public static void main(String[] args){
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = br.readLine();
      String[] str2 = str.split(" ");
      int a = Integer.parseInt(str2[0]);
      int b = Integer.parseInt(str2[1]);
      int c = Integer.parseInt(str2[2]);
      if (a < b && b < c){
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    } catch(IOException e) {
      System.err.println(e.toString());
    }
  }
}


Measured memory_bytes: 24200
import collections

N = int(input())
A = list(map(int, input().split()))

B = []
cnt = 0
for i in range(N):
    if A[i] >= 3200:
        cnt += 1
    else:
        B.append(A[i]//400)

c = collections.Counter(B)

small = len(c) if len(c) != 0 else 1
big = len(c)+cnt

print(small, big)

Measured memory_bytes: 3316
#include<stdio.h>

int D[107][7],i,j,N;
int G[55][6]={
	{1,2,3},{1,3,5},{1,5,4},{1,4,2},
	{2,1,4},{2,4,6},{2,6,3},{2,3,1},
	{3,1,2},{3,2,6},{3,6,5},{3,5,1},
	{4,1,5},{4,2,1},{4,6,2},{4,5,6},
	{5,1,3},{5,3,6},{5,4,1},{5,6,4},
	{6,2,4},{6,4,5},{6,5,3},{6,3,2}};

int ch(int a,int b)
{
	int i;
	for(i=0;i<24;i++)
	{
		if(D[a][1]==D[b][G[i][0]]&&
		   D[a][2]==D[b][G[i][1]]&&
		   D[a][3]==D[b][G[i][2]]&&
		   D[a][6]==D[b][7-G[i][0]]&&
		   D[a][5]==D[b][7-G[i][1]]&&
		   D[a][4]==D[b][7-G[i][2]])
		return 1;
	}
	return 0;
}

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)
		for(j=1;j<=6;j++)
			scanf("%d",&D[i][j]);
	for(i=0;i<N;i++)
		for(j=i+1;j<N;j++)
		{
			if(ch(i,j))
			{
				puts("No");
				return 0;
			}
		}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef pair<int, int> pii;

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class A {
	int a, b, c, d;
public:
	A()
	{
		cin >> a >> b >> c >> d;
	}
	void solve()
	{
		if (a + b < c + d)
			cout << "Right";
		else if (a + b == c + d)
			cout << "Balanced";
		else
			cout << "Left";
		cout << endl;
	}
};


int main()
{
	A solution;
	solution.solve();

	return 0;
}

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

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

n=int(input())
l=list(map(int, input().split()))
l.sort()
cnt=0
for i in range(n-2):
    for j in range(i,n-1):
        for k in range(j,n):
            if l[i]!=l[j]!=l[k] and max(l[i],l[j],l[k])<l[i]+l[j]+l[k]-max(l[i],l[j],l[k]):
                cnt+=1
print(cnt)

Measured memory_bytes: 9200
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		Map<Integer, Integer> map = new TreeMap<Integer,Integer>();
		int[] city = new int[n+1];			//県ごとの順番を記録
		int[] P = new int[m];
		int[] Y = new int[m]; 
		for(int i = 0;i < m;i++){
			int p = sc.nextInt();
			int y = sc.nextInt();
			P[i] = p;
			Y[i] = y;
			map.put(y, p);
		}
		for(Integer key : map.keySet()){
			int cc = map.get(key);				//県
//			System.out.println(cc);
//			System.out.println(map.get(key));

			map.put(key, city[cc]+1);
			city[cc]++;				//県での順番を+1
		}

		for(int i = 0;i < m;i++){
			System.out.println(String.format("%06d%06d",  P[i], map.get(Y[i])));
		}
	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



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

int main(){
    int n, ans;
    string s;
    cin >> n >> s;
    
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i + 1]) {
            s[i] = '0';
        }
    }
    ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] != '0') {
            ans++;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

struct wtf {
    int l, r, ans, id;
} q[500010];

bool cmp(wtf &a, wtf &b) {
    return a.r<b.r;
}

bool bk(wtf &a, wtf &b) {
    return a.id<b.id;
}

int c[500010], bit[500010];
int pv[500010];

void update(int p, int n, int val) {
    for (;p<=n;p+=p&(-p)) bit[p] += val;
}

int query(int p) {
    int res = 0;
    for (;p;p-=p&(-p)) res += bit[p];
    return res;
}

int main() {
    ios_base::sync_with_stdio(0);
    int n, m; cin >> n >> m;
    for (int i=1;i<=n;i++) cin >> c[i];
    for (int i=0;i<m;i++) {
        cin >> q[i].l >> q[i].r;
        q[i].id = i;
    }
    sort(q, q+m, cmp);

    for (int i=1;i<=n;i++) pv[i] = -1;
    int p = 0;
    for (int i=0;i<m;i++) {
        while (p<q[i].r) {
            p++;
            if (pv[c[p]]!=-1) update(pv[c[p]], n, -1);
            update(p, n, 1); pv[c[p]] = p;
        }
        q[i].ans = query(q[i].r) - query(q[i].l-1);
    }
    sort(q, q+m, bk);
    for (int i=0;i<m;i++) cout << q[i].ans << endl;
}


Measured memory_bytes: 17460
#include<bits/stdc++.h>
using namespace std;
const int pi=3.1415926535897932384626433832795;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
#define ll long long
#define inf int(1e9+7)
#define pb push_back
#define mp make_pair
double a[105],s;
int n;
struct data
{
	double x;
	int id;
}k[105];
bool cmp(data a,data b)
{
	return(a.x<b.x||(a.x==b.x)&&(a.id<b.id));
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int x;
		scanf("%d",&x);
		a[i]=x;
		s+=x;
	}
	s/=(double)n;
	for(int i=0;i<n;i++)
	{
		k[i].x=fabs(a[i]-s);
		k[i].id=i;
	}
	sort(k,k+n,cmp);
	//for(int i=0;i<n;i++)
	//	cout<<k[i].x<<' ';
	cout<<k[0].id;
	return 0;
}

Measured memory_bytes: 256
//code written by a living bruh moment
import java.io.*;
import java.lang.*;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    static InputReader in = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = in.nextInt();
        int[] arr = new int[n];
        boolean check = true;
        for(int i = 0; i<n; i++){
            arr[i] = in.nextInt();
            if(arr[i]%2==0){
                if(arr[i]%3!=0 && arr[i]%5!=0){
                    out.println("DENIED");
                    check = false;
                    break;
                }
            }
        }
        if(check) out.println("APPROVED");
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong()
        {
            return Long.parseLong(next());
        }
        public double nextDouble()
        {
            return Double.parseDouble(next());
        }
        public String nextLine()
        {
            try
            {
                return reader.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }
        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=reader.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            tokenizer=new StringTokenizer(next);
            return true;
        }
    }
}

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

int main() {
    string abc = "abcdefghijklmnopqrstuvwxyz";
    string w;
    vector<int> cnt(26);
    cin >> w;
    for (int i = 0; i < w.length(); i++){
        for(int j = 0; j < 26; j++){
            if (w[i] == abc[j]){
                cnt[j] += 1;
                break;
            }
        }
    }
    bool flag = true;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] % 2 != 0) {
            flag = false;
            cout << "No" << endl;
            break;
        }
    }
    if (flag) {
        cout << "Yes" << endl;
    }
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
/* }}} */
signed main() 
{
  int a,b,c;
  cin>>a>>b>>c;
  rep(i,110)
  {
    if(a*i%b==c)
    {
      print("YES");
      return 0;
    }
  }
  print("NO");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> a(N),b(N),c(N);
  for(int i=0;i<N;i++)cin>>a[i];
  for(int i=0;i<N;i++)cin>>b[i];
  for(int i=0;i<N-1;i++)cin>>c[i];
  int ans=0;
  for(int i=0;i<N;i++)ans+=b[i];
  for(int i=1;i<N;i++)if(a[i-1]+1==a[i])ans+=c[a[i-1]-1];
  fin(ans);
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
template<class S> void wAdjEdge_L(const int N, const int M, const int *A, const S *B, int **res_sz, S ***res_B, void **mem = &wmem){
  int i, j, k;
  walloc1d(res_sz, N, mem);
  for(i=0;i<(N);i++){
    (*res_sz)[i] = 0;
  }
  for(i=0;i<(M);i++){
    (*res_sz)[A[i]]++;
  }
  walloc1d(res_B, N, mem);
  for(i=0;i<(N);i++){
    walloc1d(&((*res_B)[i]), (*res_sz)[i], mem);
  }
  for(i=0;i<(N);i++){
    (*res_sz)[i] = 0;
  }
  for(i=0;i<(M);i++){
    (*res_B)[A[i]][(*res_sz)[A[i]]++] = B[i];
  }
}
char memarr[96000000];
int N;
int M;
int A[100000];
int B[100000];
int *sz;
int **arr;
int main(){
  int i, j, k, res=0;
  wmem = memarr;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(M);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
    }
  }
  wAdjEdge_L(N,M,A,B,&sz,&arr);
  k = N;
  for(i=0;i<(N);i++){
    if(k==i){
      res++;
      k = N;
    }
    for(j=0;j<(sz[i]);j++){
      chmin(k, arr[i][j]);
    }
  }
  if(k!=N){
    res++;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, M, A[1d5], B[1d5];
// int *sz, **arr;
// {
//   int i, j, k, res = 0;
//   rd(N,M,(A--,B--)(M));
//   wAdjEdge(N,M,A,B,&sz,&arr);
// 
//   k = N;
//   rep(i,N){
//     if(k==i) res++, k = N;
//     rep(j,sz[i]) k <?= arr[i][j];
//   }
//   if(k!=N) res++;
//   wt(res);
// }


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

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

int main(){
	int a;
	cin>>a;
	bool b = 0;
	rep(i, 10){
		rep(j, 10){
			if(i * j ==a){
				b = 1;
				cout<<"Yes"<<endl;
				break;
			}
		}
		if(b == 1)
			break;
	}
	if(b == 0)
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for(int i = 1; i < n; i++)
    {
        ll tmp = ans / (k - 1) + 1;
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3212
import sys
from math import *
from fractions import gcd
readints=lambda:map(int, input().strip('\n').split())

calc=[0]*55
calc[0]=1
for i in range(1,52):
    calc[i] = 3 + 2*calc[i-1]


n,x=readints()
x-=1 # 0-index


cache={}

def solve(L, i):
    if i<0:
        return 0
    if L==0:
        return 1
    else:
        if (L,i) in cache:
            return cache[(L,i)]
        m = calc[L] // 2
        res = 0
        if i>=m:
            res += solve(L-1,calc[L-1]-1) + 1
            res += solve(L-1,i-m-1)
            cache[(L,i)]=res
        else:
            cache[(L,i)]=solve(L-1, i-1)
        return cache[(L,i)]
        


print(solve(n,x))


Measured memory_bytes: 5304
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

dp = [[0] * 3 for _ in range(N + 1)]


def point(hand, n):
    n -= 1
    if hand == T[n]:
        return 0
    elif hand == "r" and T[n] == "p" or hand == "s" and T[n] == "r" or hand == "p" and T[n] == "s":
        return 0
    elif T[n] == "r":
        return P
    elif T[n] == "s":
        return R
    elif T[n] == "p":
        return S


for n in range(1, N + 1):
    if n <= K:
        dp[n][0] = point("r", n)
        dp[n][1] = point("s", n)
        dp[n][2] = point("p", n)
    else:
        dp[n][0] = max(dp[n-K][1], dp[n-K][2]) + point("r", n)
        dp[n][1] = max(dp[n-K][2], dp[n-K][0]) + point("s", n)
        dp[n][2] = max(dp[n-K][1], dp[n-K][0]) + point("p", n)

MaxPoint = 0
for k in range(K):
    MaxPoint += max(dp[N-k])

print(MaxPoint)



Measured memory_bytes: 68208
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
#include<stdio.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF = 100000000;

bool isOK(int a[],int index,int key){
    if(a[index] >= key){
        return true;
    }else{
        return false;
    }
}

int binary_search(int a[],int n,int key){
    int left = -1;
    int right = n;

    while(right-left>1){
        int mid = left + (right - left)/2;
        if(isOK(a,mid,key)){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}

int factrial(int n){
    if(n==0){
        return 1;
    }else{
        return n*factrial(n-1);
    }
}

int main(void){
    int n;
    int a,b;
    int x=1;
    cin >> n;

    vector<int> P(n);
    vector<int> Q(n);

    rep(i,n){
        cin >> P.at(i);
    }
    rep(i,n){
        cin >> Q.at(i);
    }

    vector<int> model(n);
    rep(i,n){
        model[i] = i+1;
    }

    do{
        bool flagp = true;
        bool flagq = true;
        for(int i=0;i<n;++i){
            if(P.at(i)!=model.at(i)){
                flagp = false;
            }
            if(Q.at(i)!=model.at(i)){
                flagq = false;
            }
        }
        if(flagp){
            a = x;
        }
        if(flagq){
            b = x;
        }
        x++;
    }while(next_permutation(model.begin(),model.end()));

    cout << abs(a-b) << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    long int a[N];
    long int s;
    cin >> a[0];
    s = a[0];
    
    for(int i=1; i<N; i++){
        cin >> a[i];
        s ^= a[i];
    }
    
    cout << (a[0] ^ s);
    for(int i=1; i<N; i++){
        cout << " " << (a[i] ^ s);
    }
    cout << endl;
}

Measured memory_bytes: 5092
def solve():
    n=int(input())
    ans=''
    check='abcdefghijklmnopqrstuvwxyz'
    while n!=0:
        n-=1
        ans+=check[n%26]
        n //= 26
    print(ans[::-1])
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 9108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    string N;
    cin >> N;

    int tmp = 0;
    for(auto e: N) {
        tmp += e-'0';
    }

    if(tmp % 9) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }
    return 0;
}


Measured memory_bytes: 3720
p=[]
for i in range(int(input())):
   a=input()
   p.append(a)
print("AC"+" x "+ str(p.count("AC")))
print("WA"+" x " + str(p.count("WA")))
print("TLE"+" x "+ str(p.count("TLE")))
print("RE"+ " x "+ str(p.count("RE")))

Measured memory_bytes: 16296
n=int(input())
mod1,mod2=10**9+7,998244353
mod=mod1
import sys
sys.setrecursionlimit(10**9)
memo=[{}for i in range(n+1)]
def ok(s):
    if "AGC"in s:return False
    for i in range(3):
        if "AGC"in s[:i]+s[i+1]+s[i]+s[i+2:]:
            return False
    return True
def dfs(cnt,las):
    if las in memo[cnt]:return memo[cnt][las]
    if cnt==n:return 1
    ret=0
    for nec in "AGCT":
        if ok(las+nec):
            ret=(ret+dfs(cnt+1,las[1:]+nec))%mod
    memo[cnt][las]=ret
    return ret
print(dfs(0,"TTT"))

Measured memory_bytes: 9504
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <ctype.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

int main() {
	int r, D, x;
	cin >> r >> D >> x;

	int z = x;
	vector<int>ans(10);

	int T = r * z - D;
	cout << T << endl;

	for (int i = 0; i < 10; i++) {
		z = T;
		ans[i] = r * z - D;
		T = r * z - D;
	}
	rep(i, 9) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mp make_pair
#define pb push_back
#define sz(v) (int)v.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
//const int N=1e6+7;
int n,m,k,t,ans;

int main(){
    fast;
    cin>>n>>m;
    string s;
    int a[26]={0};
    forn(i,n){
        cin>>s;
        a[s[0]-'A']++;
    }
    while(1){
        sort(a,a+26,greater<int>());
        int flag=1;
        forn(i,m){
            if(!a[i]) flag=0;
            a[i]--;
        }
        ans+=flag;
        if(!flag) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long int ll;

const ll MAX_N = 100000;

int main () {
    ll n, k, q, p;
    ll A[MAX_N] = {0};

    cin >> n >> k >> q;

    for (int i = 0; i < q; i++) {
        cin >> p;
        A[p-1]++;
    }

    for (int i = 0; i < n; i++) {
        if (k - (q - A[i]) > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 1408
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n=int(arr_data[0][0])

arr=[int(str(x)*3) for x in range(1,10)]

print(min(list(filter(lambda x : x >=n, arr))))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
#define P 1000000007
#define N_MAX 2000000
ll fac[N_MAX+1], inv[N_MAX+1], finv[N_MAX+1];
ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%P)*finv[k])%P;
}
void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%P;
    inv[i] = ((-(P/i)*inv[P%i])%P+P)%P;
    finv[i] = (finv[i-1]*inv[i])%P;
  }
}
ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}
ll pp(ll a, ll b){
  return (a * b)%P;
}
ll n, m;
string s;
//-------------------------------------------------------------------
vvl dp;
ll dfs(ll ty, ll ok){
  if(ty==n) return (ok==m?1:0);
  if(dp[ty][ok]!=-1) return dp[ty][ok];
  ll ret = 0;
  // case back
  ret = (ret + dfs(ty+1, max((ll)0, ok-1)))%P;
  // case 0,1
  ret = (ret + dfs(ty+1, ok+1))%P;
  ret = (ret + dfs(ty+1, ok+1))%P;
  return dp[ty][ok] = ret;
}
int main(int argc, char const *argv[]) {
  std::cin >> n;
  std::cin >> s; m = s.size();
  init();
  ll d = mpow(inv[2], m, P);
  dp.resize(n+1, vll(n+1, -1));
  dfs(0, 0);
  std::cout << pp(dp[0][0], d) << '\n';
  return 0;
}


Measured memory_bytes: 243072
#include<bits/stdc++.h>
using namespace std;
int a[102];

int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    	cin>>a[i];
    sort(a+1, a+1+n);
    int res=0;
    for(int i=1; i+2<=n; i++)
    for(int j=i+1; j+1<=n; j++)
    for(int k=j+1; k<=n; k++)
    res+=(a[i]!=a[j] && a[j]!=a[k] && ((a[i]+a[j])>a[k]));
    cout<<res;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<algorithm>
#include<vector>
#include <functional>
using namespace std;
//typedef long long ll;
int main(){
  int a,b;
  long long int sum=0;
  cin>>a>>b;
  long long int c[200000];
  for(int i=0;i<a;i++){
    cin>>c[i];
  }
  sort(c, c+a,greater<int>());
  for(int i=0;i<b;i++){
    c[i]=0;
  }
  for(int i=0;i<a;i++){
    sum+=c[i];
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)			for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

vector<vint> dp;

void print(vector<vint> arr){
	f(arr.size()){
		fj(arr[i].size()) cout<<arr[i][j]<<" ";
		cout<<endl;
	}
	cout<<endl;
}

int32_t main() {

    om_shree_ganeshaya_namah();

    in(n); in(k);
    vint arr(n);
    f(n) cin>>arr[i];
    sort(arr.begin(), arr.end());

    dp = vector<vint>(n, vint(k+1));

    dp[0][0] = 1;
    fn(1, k+1){
    	if(i>arr[0]){
    		dp[0][i] = dp[0][i-1];
    		continue;
    	}
    	dp[0][i]=(dp[0][i-1]+1)%mod;
    }

    for(int i=1; i<n-1; i++){
    	dp[i][0] =1;
    	for(int j=1; j<=k; j++){
    		int ans=0, index = j-min(arr[i], j);
    		if(index==0)
    			ans = dp[i-1][j];
    		else
    			ans = (dp[i-1][j]-dp[i-1][index-1])%mod;
    		if(ans<0)
    			ans+=mod;
    		dp[i][j] = (ans+dp[i][j-1])%mod;
    	}
    }

    int ans=0, index = k-min(arr[n-1], k);
    if(n!=1)
    	if(index==0)
    		ans = dp[n-2][k];
    	else
    		ans = (dp[n-2][k]-dp[n-2][index-1])%mod;
    else
    	if(k==0)
    		ans = dp[n-1][k];
    	else
    		ans = (dp[n-1][k]-dp[n-1][k-1])%mod;

    if(ans<0)
    	ans+=mod;

    cout<<ans;
}

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

using namespace std;

#define filter 1.0e9 + 7

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

	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}

	long long pattern = 1;

	if ((n + m) % 2 == 0) {
		pattern *= 2;
	}

	for (int i = 1; i <= n; i++) {
		pattern *= i;
		pattern %= (long long)filter;
	}
	for (int i = 1; i <= m; i++) {
		pattern *= i;
		pattern %= (long long)filter;
	}

	cout << pattern << endl;

	return 0;
}


Measured memory_bytes: 256
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
// https://atcoder.jp/contests/func/tasks/func_d
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(ll i=a; i<n; i++)
#define ford(i,a,n) for(ll i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 20

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

ll dp[100005][105];
ll v[105],w[105],n,W;

ll func(ll sum,ll pos){

	if(sum==0)
		return 0;

	else if(sum<0 or pos==n)
		return infll;


	else if(dp[sum][pos]!=-1)
		return dp[sum][pos];

	else{

		dp[sum][pos]=min(w[pos]+func(sum-v[pos],pos+1),func(sum,pos+1));
		return dp[sum][pos];

	}

}
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin>>n>>W;
  ll sum=0;
  fori(i,0,n)
  {
    cin>>w[i]>>v[i];
    sum+=v[i];
  }
  clr(dp,-1);
  ll ans=0;
  fori(i,1,sum+1)
  {
    if(func(i,0)<=W) ans=i;
  }
  cout<<ans<<endl;
  return 0;
}

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

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

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

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


Measured memory_bytes: 82304
//============================================================================
// Name        : training.cpp
// Author      : CoNKeR The Red Squirrel
//============================================================================
#include <bits/stdc++.h>

using namespace std;

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

	n = 1 << n;

	vector<int> A(n);
	for(int &x : A) { cin >> x; }

	vector<pair<int, int>> dp(n, {INT32_MIN, INT32_MIN});
	int sol = INT32_MIN;

	for(int i = 1; i < n; ++i) {
        set<int> choices;
		for(int mask = 1; mask <= i; mask <<= 1) {
			if(i & mask) {
				int sm = i ^ mask;
				if(sm < n) {
                    choices.insert(dp[sm].first);
                    choices.insert(dp[sm].second);
				}
			}
		}

		int first = i, second = 0;
		for(int j : choices) {
            if(j < 0) { continue; }
            if(A[j] > A[first]) { second = first, first = j; }
            else if(A[j] > A[second]) { second = j; }
		}

		sol = max(sol, A[first] + A[second]);
		dp[i] = {first, second};

		cout << sol << "\n";
	}

    return 0;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#include <math.h>

#define mod 1000000007
/*
long long int Fibo(int n) {
	return round((pow((1 + sqrt(5)) / 2, n)
		- pow((1 - sqrt(5)) / 2, n)) / sqrt(5));
}
*/
long long int Fibo(int n) {
	int i, a, b, c;
	for (i = 0, b = 1, c = 0; i < n; i++) {
		a = b;
		b = c;
		c = a + b;
		c %= mod;
	}
	return c;
}

int main(){

	int i, j, k, N, M, *a;	
    long long int sum = 1, result;

	scanf("%d %d", &N, &M);

	if (M == 0){//危険マスがない場合はスタートからゴールまですぐ計算
		printf("%lld\n", Fibo(N+1) % mod);
		return 0;
	}

	a = (int *)malloc(M * sizeof(int));

	for (i = 0; i < M; i++)
		scanf("%d", &a[i]);
	
	if (M != 1){ // 連続した危険マスが隣接していたら０を返す
		for (i = 0; i < M; i++){
			if (a[i + 1] - a[i] == 1){
				printf("0\n");
				return 0;
			}
		}
	}

	sum *= Fibo(a[0]);//スタートから最初のブロック(直前)までの総数
	sum %= mod;

	for (i = 0; i < M-1; i++){//最初のブロックから最後のブロックまでの総数計算
		sum *= (Fibo(a[i + 1] - a[i]-1) % mod);
		sum %=mod;
	}

	sum *= (Fibo(N - a[M - 1]) % mod);//最後のブロックからゴールまでの総数

	result = sum % mod;
	printf("%lld\n", result);

  return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}



int main() {
    ll N,H[100005],cnt = 0,max = 0;
    string S,T;

    cin >> N;
    rep(i,N) cin >> H[i];
    rep(i,N-1){
        if(H[i+1] <= H[i]){
            cnt++;
        }else{
            if(cnt > max){
                max = cnt;
            }
            cnt = 0;
        }
        //cout << cnt << endl;
    }
    if(cnt > max){
        max = cnt;
    }
    cout << max << endl;
    
    
    return 0;
    

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n - 1) {
        for(int j = i + 1; j < n; j++) {
            ans += (a[i] * 1ll * a[j]);
        }
    }
    cout << ans;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations
from math import factorial

n, m = map(int, input().split(' '))
edge = []
for i in range(m):
    ai, bi = map(int, input().split(' '))
    edge.append([ai, bi])

l = [i for i in range(1, n+1)]
ls = list(permutations(l))
ans = 0
for i in range(factorial(n-1)):
    y = 0
    for j in range(n-1):
        for k in edge:
            if (ls[i][j+1] in k) and (ls[i][j] in k):
                y += 1
    if y == n-1:
        ans += 1

print(ans)

Measured memory_bytes: 13968
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


int main() {
	int s, w;
	cin >> s >> w;
	if (s <= w)cout << "unsafe" << endl;
	else cout << "safe" << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_map>
using namespace std;

int main(){
    vector< pair<string,pair<int,int>> > x;
    int n, p;
    cin >> n;
    string s;
    for(int i = 0; i < n; i++){
        cin >> s >> p;
        x.push_back({ s, { p, i } });
    }
    sort(x.begin(), x.end(), [](pair<string,pair<int,int>> i, pair<string,pair<int,int>> j){
            return i.first == j.first ? i.second.first > j.second.first : i.first < j.first;
            });
    for(auto& i : x){
        cout << (i.second.second+1) << '\n';
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if((abs(a-b)<=d && abs(b-c)<=d) || abs(a-c)<=d) cout << "Yes" << "\n";      
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

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

    std::cout << (s == "ABC" ? "ARC" : "ABC") << std::endl;
}


Measured memory_bytes: 3608
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min = 0
cnt = 0
for k in b:
    min += k
j = M
for i in range(N+1):
    while(j > 0 and min > K):
        j -= 1
        min -= b[j]
    if(min > K):
        break
    cnt = max(cnt, i + j)
    if(i == N):
        break
    min += a[i]
print(cnt)


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF 1001
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M;
  cin>>N>>M;
  vector<int>a(M),b(M),c(M);
  for(int i=0;i<M;i++)cin>>a[i]>>b[i]>>c[i];
  for(int i=0;i<M;i++)a[i]--,b[i]--;
  vector<vector<ll>>Min(N,vector<ll>(N,INF));
  for(int i=0;i<M;i++){
    Min[a[i]][b[i]]=c[i];
    Min[b[i]][a[i]]=c[i];
  }


  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j)Min[i][j]=0;
    }
  }

  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(Min[i][k]+Min[k][j]<Min[i][j])Min[i][j]=Min[i][k]+Min[k][j];
      }
    }
  }

  int ans=0;
  for(int i=0;i<M;i++){
    bool ok=false;
    for(int k=0;k<N;k++){
      if(Min[k][a[i]]+c[i]==Min[k][b[i]])ok=true;
    }
    if(!ok)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384