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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int gcd(int a, int b){
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  if(b == 0){
    return a;
  }
  return gcd(b, a%b);
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  if((B-A) % 2){
    cout << "Borys" << endl;
  }
  else{
    cout << "Alice" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){ 
    int x;
    cin >> x;
    int ma = 1;
    for(int b = 2; b <= sqrt(x); b++){
        for(int p = 2; ; p++){
            int ex =  pow(b,p);
            if(ex > x){ma = max(ma,ex/b); break;}
        }
    }
    cout << ma << endl;
}

Measured memory_bytes: 256
n=int(input())
xy=[]
for i in range(n):
  a=int(input())
  xy.append([list(map(int,input().split())) for j in range(a)])

ans=[]
for i in range(2**n):
  honest=[]
  for j in range(n):
    if (i>>j)&1:
      honest.append(1)
    else:
      honest.append(0)
  p=0
  q=0
  for j,k in enumerate(honest):
    if k==1:
      q=q+1
      r=0
      for l in xy[j]:
        if honest[l[0]-1]==l[1]:
          r=r+1
      if r==len(xy[j]):
        p=p+1
  if p==q:
    ans.append(p)
print(max(ans))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	cin >> n >> m;
	if(m>=n){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	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>;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  bool bl = false;
  if (s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) bl = true;
  if (bl) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N,i;
	scanf("%d",&N);
	int l[N+1];
	for(i=1;i<=N;i++){
		scanf("%d",&l[i]);
	}
	int maxl=1;
	int nomaxl;
	for(i=1;i<=N;i++){
		if(maxl<l[i]){
			maxl=l[i];
			nomaxl=i;
		}
	}
	int suml=0;
	for(i=1;i<=N;i++){
		if(nomaxl!=i) suml=suml+l[i];
	}
	if(maxl<suml) printf("Yes");
	if(maxl>=suml) printf("No");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    int N, C;
    cin >> N >> C;
    vector<int> vec(1e5*2+2, 0);
    vector<multiset<int> > ccc(1e5+1);
    for(int n=0; n<N; n++) {
        int s, t, c;
        cin >> s >> t >> c;

        if(ccc[s].count(c)) {
            vec[s*2]++;
            vec[t*2]--;
            continue;
        } else if(ccc[t].count(c)) {
            vec[s*2-1]++;
            vec[t*2-1]--;
            continue;
        }
        
        ccc[s].insert(c);
        ccc[t].insert(c);

        vec[s*2-1]++;
        vec[t*2]--;
    }
    int ans=vec[0];
    for(int n=0; n<vec.size()-1; n++) {
        vec[n+1] += vec[n];
        
        ans = max(vec[n+1], ans);
    }
    
    cout << min(ans, C) << endl;


    return 0;
    
}

Measured memory_bytes: 15104
n, a, b, c = map(int, input().split())
bamb = [int(input()) for _ in range(n)]
objective = [a, b, c]
ans = float("inf")
for i in range(4 ** n):
    tmp = 0
    material = [[] for _ in range(3)]
    for j in range(n):
        flag = (i >> (2 * j)) & 3
        if flag == 0:
            material[0].append(bamb[j])
        elif flag == 1:
            material[1].append(bamb[j])
        elif flag == 2:
            material[2].append(bamb[j])
    if len(material[0]) > 0 and len(material[1]) > 0 and len(material[2]) > 0:
        for k in range(3):
            tmp += (len(material[k]) - 1) * 10
            tmp += abs(sum(material[k]) - objective[k])
        ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;

int main(){
  pair<pair<string,int>, int> p[100];
  int n;
  cin >> n;
  string str;
  int num;
  for(int i=0;i<n;i++){
    cin >> str >> num;
    p[i] = make_pair(make_pair(str,-num),i+1);
  }
  sort(p,p+n);
  for(int i=0;i<n;i++){
    cout << p[i].second << endl;
  }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e2 + 10;
int a[N];
int b[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	while (cin >> n >> m)
	{
		if (n == 0 && m == 0) break;
		MEM(a, 0);
		MEM(b, 0);
		int ans = 0, x;
		for (int i = 0; i < n; i++) cin >> x, a[x]++;
		for (int i = 0; i < m; i++) cin >> x, b[x]++;
		for (int i = 0; i < N; i++)
		{
			ans += max(a[i], b[i])*i;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3088
using System;

public class hello
{
    public static void Main()
    {
        var a = "a1%&()khK";
        var s = Console.ReadLine().Trim();
        var s1 = s.Replace("peach", a);
        s = s1.Replace("apple", "peach");
        s1 = s.Replace(a,"apple");
        Console.WriteLine(s1);
    }
}

Measured memory_bytes: 8684
MOD=10**9+7
N=int(input())

dp=[[[[0]*5 for i in range(5)] for i in range(5)] for i in range(N+1)]

dp[0][0][0][0]=1

for i in range(N):
    for j in range(5):
        for k in range(5):
            for l in range(5):
                for m in range(1,5):
                    if (k==1 and l==2 and m==3) or (k==2 and l==1 and m==3) or (k==1 and l==3 and m==2):
                        continue
                    if (j==1 and k==2 and m==3) or (j==1 and l==2 and m==3):
                        continue
                    dp[i+1][k][l][m]=(dp[i+1][k][l][m]+dp[i][j][k][l])%MOD
ans=0
for k in range(5):
    for l in range(5):
        for m in range(5):
            ans=(ans+dp[N][k][l][m])%MOD
print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <algorithm>
#include <queue>

using namespace std;

typedef struct point {
  int x;
  int y;
  int c;
} POINT;

int h, w;
int cost[50][50];
int minc[50][50];
queue<POINT> que;

bool input() {
  int i, j;
  char str[51];

  scanf("%d %d", &h, &w);
  if (!h && !w) return false;
  fill(minc[0], minc[0] + 50*50, 1000);
  for (i = 0; i < h; i++) {
    scanf("%s", str);
    for (j = 0; j < w; j++) {
      cost[i][j] = str[j] - '0';
    }
  }

  while (!que.empty()) que.pop();

  return true;
}

int main() {
  POINT a, b;

  input();
  a.x = 0;
  a.y = 0;
  a.c = 0;
  que.push(a);
  while (!que.empty()) {
    a = que.front();
    que.pop();
    if (h <= a.y || w <= a.x) continue;
    if (minc[a.y][a.x] <= a.c + cost[a.y][a.x]) continue;
    minc[a.y][a.x] = a.c + cost[a.y][a.x];
    /*
    printf("a:%d %d %d\n", a.x, a.y, a.c + cost[a.y][a.x]);
    for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
    printf("%d ", minc[i][j]);
    }
    printf("\n");
    }
    */
    b.x = a.x + 0;
    b.y = a.y + 1;
    b.c = a.c + cost[a.y][a.x];
    que.push(b);
    b.x = a.x + 1;
    b.y = a.y + 0;
    b.c = a.c + cost[a.y][a.x];
    que.push(b);
  }
  printf("%d\n", minc[h - 1][w - 1]);


  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int a[52];
long long dp[52][2];//1:ji 0:ou
int main()
{
    int n,p;
    scanf("%d%d",&n,&p);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }

    if(a[0]%2==0)
    {
        dp[0][0]=2;
        dp[0][1]=0;
    }
    else
    {
        dp[0][0]=1;
        dp[0][1]=1;
    }

    for(int i=1;i<n;i++)
    {
        if(a[i]%2==0)
        {
            dp[i][0]=2*dp[i-1][0];
            dp[i][1]=2*dp[i-1][1];
        }
        else
        {
            dp[i][0]=dp[i-1][1]+dp[i-1][0];
            dp[i][1]=dp[i-1][0]+dp[i-1][1];
        }
    }
    cout<<dp[n-1][p];
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  
  if(N%1000%111==0)
    cout<<"Yes"<<endl;
  else if(N/10%111==0)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<string,ll>mp;
map<ll,ll>mpp;
vector<ll>v;
#define Y cout<<"YES"<<endl
#define N cout<<"NO"<<endl

int main()
{
   ll a,b,c,d,i,j;

   cin>>a>>b>>c>>d;


   i=0;
   while(1){

    if(i%2==0){

        c=c-b;

        i++;
        if(c<=0){
            cout<<"Yes"<<endl;
            break;
        }
    }

    else{

        a=a-d;

        i++;
        if(a<=0){
            cout<<"No"<<endl;
            break;
        }
    }


   }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int memo[15][2];

int main(){
    int n;
    cin >> n;
    rep(i, n){
        int a;
        cin >> a;
        int tr=0, fal=0;
        rep(j, a){
            int x, y;
            cin >> x >> y;
            if(y){
                tr += 1<<(x-1);
            }else{
                fal += 1<<(x-1);
            }
        }
        memo[i][1] = tr;
        memo[i][0] = fal;
    }

    int total = 1<<n, ans=0;
    bool flag=true;
    rep(i, total){
        rep(j, n){
            if((i>>j)&1){
                if((i & memo[j][1]) != memo[j][1]){
                    flag = false;
                    break;
                }
                if((~i & memo[j][0]) != memo[j][0]){
                    flag = false;
                    break;
                }
                if(!flag){
                    break;
                }
            }
        }
        if(flag){
            // cout << i << endl;
            ans = max(ans, __builtin_popcount(i));
        }
        flag = true;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>

int main(void){
    int n, k;
    std::cin >> n >> k;
    int h;
    int ans = 0;
    for(int i = 0; i < n; i++){
        std::cin >> h;
        if(h >= k) ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define int long long
#define pii pair<int, int>
  
using namespace std;
const int inf = 1e9 + 7;


signed main() {
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/

    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2;
}

Measured memory_bytes: 256
# coding: utf-8
N = int(input())
A = [int(x) for x in input().split(" ")]

# j 番目からリストの最後までの間で x があるか確かめ、ある場合は最小のインデックスを返し、ない場合は "n" を返す
def search(A, j, N, x):
    for i in range(j, N):
        if A[i] == x:
            return i
    return "n"


k = 0
tempk = -1
for i in range(1, N+1):
    k = search(A, k, N, i)
    if k == "n":
        break
    else:
        tempk = k

if tempk == -1:
    print(tempk)
else:
    print(N - A[tempk])

Measured memory_bytes: 74588
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N, M, V, P;
  cin >> N >> M >> V >> P;
  vi A(N);
  cin >> A;

  sort(rrng(A));

  i64 l = P-1;
  i64 r = N;
  i64 m;

  while(l + 1 < r){
    m = (l + r) / 2;
    if(A[m] + M < A[P - 1]) {
      r = m;
      continue;
    }

    i64 MV = M * V;

    rep(i, N){
      if(i < P - 1 or i == m) MV -= M;
      else MV -= min(A[m] + M - A[i], M);
    }

    if(MV <= 0) l = m;
    else r = m;
  }

  cout << r << "\n";
}

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

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

int main()
{
	int n,flag=0;
	cin>>n;
	set<string> st;
	string s,s1;
	cin>>s1;
	st.insert(s1);
	for(int i=1;i<n;i++)
	{
		cin>>s;
		if(st.find(s)!=st.end())
			flag=1;
		if(s[0]!=s1[s1.length()-1])
			flag=1;
		st.insert(s1);
		s1=s;
	}
	if(flag)
		cout<<"No"<<endl;	
	else
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int m=sc.nextInt();
        int q=sc.nextInt();
        int close[] = new int[510];
        int op=0;


        int mem[][]=new int[502][502];

        for (int i=0; i<m; i++) {
            int a=sc.nextInt();
            int b=sc.nextInt();
            mem[b][a]++;
        }
        for (int i=1; i<501; i++) {
            close[i] += close[i-1];
        }

        for (int i=0; i<501; i++) {
            for (int t=500; 0<=t ; t--) {
                mem[i][t]+=mem[i][t+1];
            }
        }

       
        for (int i=0; i<q; i++) {
            int a=sc.nextInt();
            int b=sc.nextInt(), ans=0;
            for (int t=b; a<=t; t--) {
                ans+=mem[t][a];
            }
            out.println(ans);
        }

        // out.println(ans);
        out.flush();
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P implements Comparable<P>{
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
    public int compareTo(P p){
        return d-p.d; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 61464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int X = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		sc.close();

		int ans = X >= A ? 10 : 0;
		System.out.println(ans); 
	}
	

}


Measured memory_bytes: 23764
#include <stdio.h>
#include <algorithm>


int main()
{
    int n;
    int l[200];
    scanf("%d",&n);
    for(int i=0;i<2*n;i++) scanf("%d",&l[i]);
    std::sort(l,l+2*n);
    int ans=0;
    for(int i=0;i<2*n;i+=2)
    ans+=l[i];
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int k; cin >> k;
	int a = 0;
	for(int i = 1; i <= 10 * k; ++i) {
		a *= 10;
		a += 7;
		a %= k;
		if(a == 0) {
			cout << i << '\n';
			return 0;
		}
	}
	cout << -1 << '\n';
	return 0;
}


Measured memory_bytes: 3636
X = int(input())

XX = X%100
A = []
for i in range(20):
  for j in range(25):
    for k in range(100):
      for l in range(50):
        if i*5+j*4+k*3+l*2 <= XX:
          A.append((XX-(i*5+j*4+k*3+l*2),l,k,j,i))
#print(A)
for a,b,c,d,e in A:
  if a*101+b*102+c*103+d*104+e*105 <= X:
    print(1)
    exit()
print(0)

Measured memory_bytes: 48476
#include <iostream>
#include <vector>
#include <cmath>

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

int main() {
  int N;
  std::cin >> N;
  std::vector<ll> B(N-1);
  rep(i,N-1) std::cin >> B[i];
  std::vector<ll> A(N);
  A[0] = B[0];
  for (auto i = 1;i < N;++i) {
    A[i] = std::min(B[i-1], B[i]);
  }
  A[N-1] = B[N-2];
  ll sum {};
  for (const auto& e : A) {
    sum += e;
  }
  std::cout << sum << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>

bool isPalindrome(std::string s) {

    for (int i = 0; i < (s.length() / 2); ++i) {
        if (s[i] != s[s.length() - i-1]) {

            return false;
        }
    }
    return true;
}

int main() {

    std::string S;
    std::cin >> S;

    std::string subst1 = S.substr(0, (S.length() - 1) / 2);
    std::string subst2 = S.substr((S.length() + 1) / 2);

    bool ok = isPalindrome(S) and isPalindrome(subst1) and isPalindrome(subst2);

    if (ok) {
        std::cout << "Yes" << "\n";
    } else {
        std::cout << "No" << "\n";
    }
    return 0;
}


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

using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 3e2 + 5;

int DP[N][N][N];
vector<pii> Q[N];

bool Ok(int r, int g, int b) {
	if ((r == g && r != 0) || (g == b && g != 0) || (b == r && b != 0)) return false;
	int k = max(r, max(g, b));
	for (pii p : Q[k]) {
		int x = (r >= p.first) + (g >= p.first) + (b >= p.first);
		if (x != p.second) return false;
	}
	return true;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, m, ans = 0; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, x; cin >> l >> r >> x;
		Q[r].push_back(make_pair(l, x));
	}
	DP[0][0][0] = 1;
	for (int r = 0; r <= n; r++) for (int g = 0; g <= n; g++) for (int b = 0; b <= n; b++) {
		int k = max(r, max(g, b));
		if (!Ok(r, b, g)) DP[r][g][b] = 0;
		DP[k + 1][g][b] = (DP[k + 1][g][b] + DP[r][g][b]) % MOD;
		DP[r][k + 1][b] = (DP[r][k + 1][b] + DP[r][g][b]) % MOD;
		DP[r][g][k + 1] = (DP[r][g][k + 1] + DP[r][g][b]) % MOD;
		if (k == n) ans = (ans + DP[r][g][b]) % MOD;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 110848
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

struct RollingHash {
    typedef long long ll;
    typedef pair<ll,ll> pll;

    ll base1;
    ll base2;
    ll mod1;
    ll mod2;
    vector<ll> hash1;
    vector<ll> hash2;
    vector<ll> pow1;
    vector<ll> pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();

        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }
    //[l, r)
    pll get(int l,int r) {
        ll t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        ll t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }

    RollingHash::pll concat(pll h1, pll h2, int h2_len) {
        return make_pair((h1.first*pow1[h2_len]+h2.first)%mod1, (h1.second*pow2[h2_len]+h2.second)%mod2);
    }

};

signed main(){
    string s, t;
    cin >> s >> t;
    if(s.size() < t.size()) return 0;
    RollingHash rs, rt;
    rs.init(s);
    rt.init(t);
    P p = rt.get(0, t.size());
    rep(i, 0, s.size() - t.size() + 1){
        P q = rs.get(i, i + t.size() );
        if(p.first == q.first && p.second == q.second){
            cout << i << endl;
        }
    }
}

Measured memory_bytes: 3224
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string s,t;

void solve(){
    cin >> s >> t;
    int n=s.length(),m=t.length();
    int ans=mod;
    rep(i,n-m+1){
        int dif=0;
        rep(j,m){
            if(s[i+j]!=t[j])dif+=1;
        }
        ans=min(ans,dif);
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0,a=0,b=0;
std::cin >> x>>y;
std::vector<int > v;
rep(i,x){
  std::cin >> z>>w;
  if(w<=y){
    v.pb(z);
  }
}
sort(all(v));
if(v.size()==0)std::cout << "TLE" << '\n';
else std::cout <<v[0] << '\n';
return 0;
}


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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
const int mod = 1000000007;

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

    int a, b; cin >> a >> b;

    if (a >= 1) cout << "Positive" << endl;
    else if (b >= 0) cout << "Zero" << endl;
    else {
        if ((b - a) & 1) cout << "Positive" << endl;
        else cout << "Negative" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

a,b,n = na()

if b-1 < n:
  c = b-1
  print(a*c//b-a*(c//b))
else:
  print(a*n//b-a*(n//b))

Measured memory_bytes: 9080
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        int N = nextInt();
        int x = nextInt();

        long[] A = new long[N];
        for(int i=0; i<N; i++){
            A[i] = nextInt();
        }

        Arrays.sort(A);

        long count = 0;
        for(int i=0; i<N; i++){
            x -= A[i];
            count++;
            if(x < 0 || i==N-1 && x>0){
                count -=1;
                break;
            }
        }

        println(count);
    }

    //最大公約数gcd
    static long gcd (long a, long b) {
        long temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }
    static int nextInt(){
        return Integer.parseInt(next());
    }
    static Long nextLong(){
        return Long.parseLong(next());
    }
    static String next(){
        return sc.next();
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


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

using namespace std;

int main()
{
	int r;
	cin >> r;
	if (r < 1200) {
		cout << "ABC" << endl;
	}
	else if (r < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int K;
    cin >> K;
    vector<int> array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    --K;
    cout << array[K] << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, k = map(int,input().split())
switch = 0

for i in range(k):
    if switch == 0:
        if a % 2 == 1:
            a -= 1
        b += a//2
        a = a//2
        switch = 1
    elif switch == 1:
        if b % 2 == 1:
            b -= 1
        a += b//2
        b = b//2
        switch = 0

print(a, b)


Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long 
#define f(i,n) for(int i=0;i<n;i++)
#define boost ios_base::sync_with_stdio(0)
int main()
{
	boost;
	int t=1;
	while(t--)
	{
		int n;
		cin>>n;
		int raw[n];
		int target;
		cin>>target;
		cin>>raw[0];
		int min=raw[0],max=raw[0];
		f(i,n-1)
		{
			cin>>raw[i+1];
			if(min>raw[i+1] && raw[i+1]!=0)
			{
				min=raw[i+1];
			}
			if(max<raw[i+1])
				max=raw[i+1];
		}
		while(1)
		{
			int minrem=min, maxrem=0;
			for(int i=0;i<n;i++)
			{
				int x=raw[i]%min;
				if(x!=1)
				{
					if(x<minrem && x!=0)
						minrem=x;
					if(maxrem<x)
						maxrem=x;
				}
				else
				{
					min=1;
					break;
				}
			}
			if(maxrem==0)
				break;
			else
				min=minrem;
		}
		if(target<=max)
			if(target%min==0)
				cout<<"POSSIBLE"<<endl;
			else
				cout<<"IMPOSSIBLE"<<endl;
		else
			cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
int main(){
int n;cin>>n;
  vector<int> arr(n);
  int count=0;
  for(int i=0;i<n;++i)cin>>arr[i];
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      if(arr[i]==arr[j])continue;
      for(int k=j+1;k<n;++k){
			//int maxi=max(arr[i],max(arr[j],arr[k]));
        if(arr[i]==arr[k]||arr[j]==arr[k])continue;	
        vector<int> b;
        b.push_back(arr[i]);
        b.push_back(arr[j]);b.push_back(arr[k]);
        stable_sort(b.begin(),b.end(),greater<int>());
       // cout<<b[0<<" "<<arr[1]<<" "<<arr[2]<<endl;
        if(b[0]<b[1]+b[2])++count;
      }
    }
}
	cout<<count<<endl;
}

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

int main() {
int a, b, c;
cin >> a >> b >> c;
if (a < b) {
if (b < c) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
else {
cout << "No" << endl;
}
return 0;

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
ll k;
ll f(ll a,ll b){
	if(b==0)return 1;
	if(b%2==0){
		ll t=f(a,b/2);
		return t*t%k;
	}
	return a*f(a,b-1)%k;
}


signed main(){
	cin>>k;
	if(k%2==0){
		cout<<-1<<endl;
		return 0;
	}
	if(k%7==0)k/=7;
	ll j=0;
	ll cnt=0;
	ll ans=-2;
	rep(i,0,1000000){
		j+=f(10,cnt);
		if(j==k){
			ans=cnt;
			break;
		}
		cnt++;
		j%=k;
		//cout<<j<<endl;
	}
//	if(k==ans)ans--;
	cout<<++ans<<endl;



	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main()
{
    int n,cou,m=0,s1=0,s;
    while(cin>>n)
    {
        s1=0;
        for(int i=1;i<=n;i++)
        {
            m=i;
            cou=0;
            while(m%2==0)
                {
                    m/=2;
                    cou++;
                }
            if(s1<=cou)
                {
                    s=i;
                    s1=cou;
                }


        }
    cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef vector<int> vi;
typedef pair<int, int> pi;
#define SQ(a) (a) * (a)
#define deb(x) cout << #x << " = " << x << '\n'
#define deb2(x, y) cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
 
 
int main(int argc, char const *argv[])
{
 
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int x,k,d;
    cin>>x>>k>>d;
    x= abs(x);
    ll int num = x/d;
    // deb(num);
    if(num>k){
        ll int ans = x - k*d;
        cout<<ans;
    }
    else{
        ll int rem= k-num;
        ll int ans;
        if(rem%2==0){
            ans = x%d;

        }
        else{
            ans = d-x%d;
        }
        cout<<ans;

    }
    return 0;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B + C == 17){
    if (A == 5 || B == 5 || C == 5){
      if (A == 7 || B == 7 || C == 7){
        cout << "YES" << endl;
      }
    }
  }
  else {
    cout << "NO" << endl;
  }
  
  
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000007
typedef long long int lint;

int main() {
  int N;
  cin >> N;
  co(N*(N + 1)/2);
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A.sort()


def gcd(x, y):
    if y == 0:
        return x
    x, y = y , x % y
    return gcd(x, y)


for i in range(N-1):
    A[i+1] = gcd(A[i+1], A[i])

print(A[N-1])


Measured memory_bytes: 14224
use std::io;

fn main() {
    let mut buf = String::new();

    io::stdin().read_line(&mut buf).expect("oo");
    let mut iter = buf.split_whitespace();

    let N: i32 = iter.next().unwrap().parse().unwrap();
    let i: i32 = iter.next().unwrap().parse().unwrap();

    println!("{}", N-i+1);
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    ll X;
    cin >> X;

    ll c = 100;
    ll n = 0;
    while (c < X && c > 0) {
        double cc = (double)c * 1.01;
        c = (ll)cc;
        n++;
    }
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3636
import heapq
N, M = map(int, input().split())
a_list = [-float(i) for i in input().split()]
heapq.heapify(a_list)
for _ in range(M):
    _ = heapq.heapreplace(a_list, a_list[0]/2.0)
ans = sum([-int(i) for i in a_list])
print(ans)

Measured memory_bytes: 13384
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m, a1=0, a2=0; 
    cin >> n >> m;
    vector<bool>ac(n);
    vector<int>wa(n);
    for(int i=0; i<n; i++){
        wa[i]=0;
        ac[i]=0;
    } 
    int c;
    string s;
    for(int i=0; i<m; i++){
        cin >> c >> s;
        if(s[0]=='W') wa[c]++;
        else{
            if(!ac[c]){
                ac[c]=1;
                a1++;
                a2 += wa[c];
            }
        } 
    }
    printf("%d %d\n",a1,a2);
    return 0;
}

Measured memory_bytes: 3812
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin >> n;
    vec a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll temp=0;
    reps(i,1,n){
        if(a[i]<a[i-1]){
            temp+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<temp<<endl;
    return 0;
}

Measured memory_bytes: 4840
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	if (a == b)cout << "EQUAL" << endl;
	else {
		if (a.length() > b.length())cout << "GREATER" << endl;
		else if (a.length() < b.length())cout << "LESS" << endl;
		else {
			for (int i = 0; i < a.length(); i++) {
				if (a[i] > b[i]) {
					cout << "GREATER" << endl;
					return 0;
				}
				if (a[i] < b[i]) {
					cout << "LESS" << endl;
					return 0;
				}
			}
			cout << "EQUAL" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int K;
  int i;
  int l=0;
  int A,B;
  scanf("%d",&K);
  scanf("%d%d",&A,&B);
  while(1){
    l+=K;
    if(A<=l&&l<=B){
      printf("OK");
      break;
    }
    if(l>B){
      printf("NG");
        break;
    }
  }
  
  return 0;
}

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

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;
}

int main() {
  int N;
  long long ans;
  cin >> N;
  ans = modpow(10, N, 1000000007) -modpow(9, N, 1000000007)*2 +modpow(8, N, 1000000007);
  ans =  ans%1000000007;
  if (ans < 0) ans += 1000000007;
  cout << ans << endl;  
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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; }

typedef long long ll;

using namespace std;
struct sieve{
  int p=0;
  vector<bool> furui;
  sieve(int n){
    furui.resize(n,1);
    furui[0]=0;
    furui[1]=0;
    for(int i=2;i<n;i++)if(furui[i])for(int j=i*2;j<n;j+=i)furui[j]=0;
  }
  bool isprime(int m){return furui[m];}
};
sieve si(300000);

bool check(vector<int>a)
{
  int l=a.size();
  rep(i,l)
  {
    repi(j,i+1,l)
    {
      repi(k,j+1,l)
      {
        repi(x,k+1,l)
        {
          repi(y,x+1,l)
          {
            //cout<<i<<j<<k<<x<<y<<endl;
            if(si.isprime(a[i]+a[j]+a[k]+a[x]+a[y]))return 0;
          }
        }
      }
    }
  }
  return 1;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>pri;
  rep(i,55556)if(si.isprime(i))pri.push_back(i);
  vector<vector<int>>res(10);
  for(auto t:pri)res[t%10].push_back(t);
  rep(i,10)if(res[i].size()>n)
  {
    rep(j,n){cout<<res[i][j]<<endl;}
    return 0;
  }


  return 0;

}


Measured memory_bytes: 384
characteristic=10**9+7
def plus(input1,input2):
    return (input1+input2)%characteristic
def minus(input1,input2):
    return (input1-input2)%characteristic
def times(input1,input2):
    return (input1*input2)%characteristic
def exponen(input1,input2):
    return pow(input1,input2,characteristic)
def divide(input1,input2):
    return times(input1,exponen(input2,characteristic-2))
N=int(input())
Fact=[1 for i in range(N+1)]
Finv=[1 for i in range(N+1)]
for i in range(1,N+1):
    Fact[i]=times(Fact[i-1],i)
    Finv[i]=divide(1,Fact[i])
ans=0
SGL=[0 for i in range(N)]
for K in range(N):
    if 2*K-N<0:
        continue
    SGL[K]=times(times(Fact[K],Finv[2*K-N]),Fact[K-1])
for K in range(1,N):
    ans=plus(ans,times(SGL[K]-SGL[K-1],K))
print(ans)


Measured memory_bytes: 129784
N = int(input())
W = []
flag = True
for i in range(N):
    Wi = input()
    W.append(Wi)
    if 1<= i:
        if W[i-1][-1] == Wi[0]:
            pass
        else:
            flag = False
if len(set(W))==len(W):
    pass
else:
    flag = False
if flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b[]=new int[a];
		int c[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		for(int i=0;i<a;i++) {
			c[i]=scan.nextInt();
		}
		double min=0;
		double man=0;
		double yuu=0;
		double tye=0;
		for(int i=0;i<a;i++) {
			double sa=Math.abs(b[i]-c[i]);
			min+=Math.pow(sa, 1);
			man+=Math.pow(sa, 2);
			yuu+=Math.pow(sa, 3);
			tye=Math.max(tye, sa);
		}
		System.out.println(min);
		System.out.println(Math.pow(man,0.5));
		System.out.println(Math.pow(yuu, 0.33333333333));
		System.out.println(tye);
	}
}


Measured memory_bytes: 26664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,c,d,e;
ll s,t,ss,tt,sss,ttt;
ll sum1,sum2,sum3,ans;
ll lcm(ll x,ll y){
	ll u=x,v=y;
	if(x<y) swap(x,y);
	ll r=x%y;
	while(r){
		x=y;
		y=r;
		r=x%y;
	}
	return u*v/y;
}
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	if(a%c==0||b%c==0){
		if(a%c==0){
			s=a-c+1;
			t=b;
		}
		else if(b%c==0){
			s=a;
			t=b+c-1;
		}
	}
	else{
		s=a-a%c+1;
		t=b-b%c;
	}
	sum1=(t-s+1)/c;
	if(a%d==0||b%d==0){
		if(a%d==0){
			ss=a-d+1;
			tt=b;
		}
		else if(b%d==0){
			ss=a;
			tt=b+d-1;
		}
	}
	else{
		ss=a-a%d+1;
		tt=b-b%d;
	}
	sum2=(tt-ss+1)/d;
	e=lcm(c,d);
	if(a%e==0||b%e==0){
		if(a%e==0){
			sss=a-e+1;
			ttt=b;
		}
		else if(b%e==0){
			sss=a;
			ttt=b+e-1;
		}
	}
	else{
		sss=a-a%e+1;
		ttt=b-b%e;
	}
	sum3=(ttt-sss+1)/e;
	ans=sum1+sum2-sum3;
	ans=b-a+1-ans;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import math
import string
import collections
from collections import Counter
from collections import deque


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

# d:現在の桁数
# val:現在の値
# dist:ここに格納


def func(d, val, dist):
    dist.append(val)
    if d == 10:
        return
    for i in range(-1, 2):
        add = (val % 10)+i
        if(0 <= add and add <= 9):
            func(d+1, val*10+add, dist)
    return dist


N = int(input())
dist = []
for i in range(1, 10):
    func(1, i, dist)
    #print(func(1, i, dist))
ans = sorted(dist)
print(ans[N-1])


Measured memory_bytes: 14444
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    while 1:
        try:
            n = int(input())
            T, X, Y = [], [], []
            for _ in range(n):
                tmp1, tmp2, tmp3 = LI()
                T.append(tmp1)
                X.append(tmp2)
                Y.append(tmp3)

            T.insert(0, 0)
            X.insert(0, 0)
            Y.insert(0, 0)
            for i in range(n):
                if X[i + 1] == X[i] and Y[i + 1] == Y[i]:
                    raise EndLoop
                time = T[i + 1] - T[i]
                dis = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
                if not ((time == dis) or (time > dis and (time - dis) % 2 == 0)):
                    raise EndLoop

            print("Yes")
            break
        except:
            print("No")
            break


solve()

Measured memory_bytes: 11820
$array=Array.new(4).map{Array.new(3).map{Array.new(10,0)}}
N=gets.to_i
for i in 1..N do
 b,f,r,v=gets.chomp.split(" ").map(&:to_i)
 $array[b-1][f-1][r-1]=$array[b-1][f-1][r-1]+v
end
for i1 in 0..3 do
 for i2 in 0..2 do
 for i3 in 0..9 do
  print(" #{$array[i1][i2][i3]}")
 end
  print "\n"
 end
if(i1==3)
 break
end
print("####################\n")
end


Measured memory_bytes: 6892
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

int main(){
  int n, w; cin >> n >> w;
  int ww[n], v[n];
  REP(i, n) cin >> ww[i] >> v[i];

  ll dp[n+1][w+1];
  memset(dp, 0, sizeof(dp));

  REP(i, n)REP(j, w+1){
    dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
    if(j + ww[i] <= w) 
      dp[i+1][j+ww[i]] = max(dp[i+1][j], dp[i][j] + v[i]);
  }

  cout << dp[n][w] << endl;

  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define INF 0x3f3f3f3f
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
const ll mod=1000000007;
const double PI = acos(-1.0);
const double epsilon = PI / 180.0;//角度转弧度 
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
const int N = 1e5+10;
const int M = 4e5+10;
struct Edge {
	int from, to, dist;
	Edge() {
	}
	Edge(int _from, int _to, int _dist):from(_from), to(_to), dist(_dist) {
	}
};
Edge ed[M];
int n, m;
int he[N], ne[M], etop = 1;
void addedge(int u, int v, int w) {
	ed[etop] = Edge(u, v, w);
	ne[etop] = he[u];
	he[u] = etop++;
}
int vis[N];
int fa[N];
void bfs() {
	queue<int> q;
	q.push(1);
	vis[1] = 1;
	fa[1] = 0;
	while(!q.empty()) {
		int now = q.front();
		q.pop();
		for(int i = he[now];i;i = ne[i]) {
			Edge &e = ed[i];
			if(vis[e.to]) continue;
			fa[e.to] = now;
			q.push(e.to);
			vis[e.to] = 1;
		}
	}
}
int main() {
	cin>>n>>m;
	rep(i, 0, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		addedge(a, b, 1);
		addedge(b, a, 1);
	}
	bfs();
	vector<int> v;
	rep(i, 2, n + 1) {
		if(fa[i]) v.pb(fa[i]);
	}
	if(v.size() != n - 1) {
		cout<<"No\n";
	} else {
		cout<<"Yes\n";
		rep(i, 0, v.size()) {
			cout<<v[i]<<"\n";
		}
	}
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	int A, B, C, D, l = 0;
	D = N % 10;
	C = (N - D) / 10 % 10;
	B = (N - D - C * 10) / 100 % 10;
	A = (N - D - C * 10 - B * 100) / 1000;

	if (A == B)l++;
	if (B == C)l++;
	if (C == D)l++;

	if (l >= 2 && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

    return 0;
}

Measured memory_bytes: 256