akhauriyash/Code-Regression huggingface dataset:
S=input()
K=int(input())
N=len(S)
flag=1
if K>100:
    for i in range(N):
        if not(S[i]=="1"):
            print(S[i])
            break
else:
    for i in range(K):
        if not(S[i]=="1"):
            print(S[i])
            flag=0
            break
    if flag==1:
        print("1")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,m,d[200000]={},t[200000]={},f=0;
 cin>>n;
 for(int i=0;i<n;i++)cin>>d[i];
 cin>>m;
 for(int i=0;i<m;i++)cin>>t[i];
 sort(d,d+n);
 sort(t,t+m);
 int i=0,j=0;
while(1){
  if(t[i]==d[j]){i++;j++;}
  else if(t[i]<d[j])f=1;
  else {j++;}

 if(i==m)break;
 else if(f==1 || j==n){f=1;break;}
}

 if(f==0)cout<<"YES"<<endl;
 else cout<<"NO"<<endl;
return 0;
}

Measured memory_bytes: 1792
import bisect

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

#処理内容
def main():
	N = int(input())
	A = getlist()
	B = [0]
	for i in range(N):
		B.append(B[-1] + A[i])
	#print(B)
	ans = float("inf")
	for i in range(2, N - 1):
		Q = B[i]
		x = bisect.bisect_left(B, Q // 2)
		P = max(B[x], B[1])
		P = min(P, B[i - 1])
		if x >= 1:
			P2 = max(B[x - 1], B[1])
			Q2 = Q - P2
		Q3 = max(B[i] - B[i - 1], B[i] - B[x + 1])
		P3 = Q - Q3
		Q -= P

		S = B[N] - B[i]
		y = bisect.bisect_left(B, (B[i] + B[N]) // 2)
		R = max(B[y] - B[i] , B[i + 1] - B[i])
		R = min(R, B[N - 1] - B[i])
		R2 = max(B[y - 1] - B[i] , B[i + 1] - B[i])
		S2 = S - R2
		if y < N:
			S3 = max(B[N] - B[N - 1], B[N] - B[y + 1])
			R3 = S - S3
		S -= R
		ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))
		ans = min(ans, max(P3, Q3, R, S) - min(P3, Q3, R, S))
		ans = min(ans, max(P, Q, R2, S2) - min(P, Q, R2, S2))
		ans = min(ans, max(P3, Q3, R2, S2) - min(P3, Q3, R2, S2))
		if x >= 1:
			ans = min(ans, max(P2, Q2, R, S) - min(P2, Q2, R, S))
			ans = min(ans, max(P2, Q2, R2, S2) - min(P2, Q2, R2, S2))
		if y < N:
			ans = min(ans, max(P, Q, R3, S3) - min(P, Q, R3, S3))
			ans = min(ans, max(P3, Q3, R3, S3) - min(P3, Q3, R3, S3))
		if x >= 1 and y < N:
			ans = min(ans, max(P2, Q2, R3, S3) - min(P2, Q2, R3, S3))
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 98184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    //iからとjから始めたときに一致する最大の長さ
    vector<vector<int> > dp(5005, vector<int>(5005));
    
    per(i, n)per(j, n) {
        if (s[i] != s[j]) dp[i][j] = 0;
        else dp[i][j] = dp[i+1][j+1]+1;
    }
    //このままだと重なりが生じているのでj-iとminをとる
    int ans = 0;
    rep(i, n)rep(j, n) {
        if (i>=j) continue;
        int now = min(dp[i][j], j-i);
        ans = max(ans, now);
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 98432
#include <iostream>

using namespace std;

int n;
string s;

void solve() {
  int cnt = 0;
  char prev = '0';
  for (int i=0;i<n;i++) {
    if (prev != s[i]) {
      cnt++;
      prev = s[i];
    }
  }
  cout << cnt << endl;
}

int main() {
  cin >> n;
  cin >> s;
  solve();
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())

int main() {
	int n; cin >> n;
	vector<int> a(n); rep(i, 0, n) cin >> a[i];

	int ans = 0;
	SORT(a);
	rep(i, 0, n - 1) ans += a[i + 1] - a[i];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class UnionFind {
    vector<int> parent;

    public:
        UnionFind(int size) {
            parent = vector<int>(size, -1);
        }

        int find(int x) {
            if (parent[x] < 0) {
                // parent itself
                return x;
            } else {
                return parent[x] = find(parent[x]);
            }
        }

        bool unite(int x, int y) {
            int rX, rY;
            if ((rX = find(x)) == (rY = find(y))) {
                // already united
                return false;
            }
            if (size(rX) < size(rY)) {
                int tmp = rX;
                rX = rY;
                rY = tmp;
            }
            parent[rX] += parent[rY];
            parent[rY] = rX;
            return true;
        }

        int size(int x) {
            return -parent[find(x)];
        }

        bool is_same(int x, int y) {
            return find(x) == find(y);
        }

        // CAUTION!! : This method is heavy due to scanning linearly.
        int component_count() {
            int c = 0;
            for (const int x : parent) {
                if (x < 0) {
                    c++;
                }
            }
            return c;
        }
};

void solve() {
    int n;
    cin >> n;
    vi p(n);
    vi q(n);
    REP(i, n) cin >> p[i];
    REP(i, n) cin >> q[i];
    vi r(n);
    iota(ALL(r), 1);
    int a, b;
    int idx = 0;
    do {
        if (p == r) a = idx;
        if (q == r) b = idx;
        idx++;
    } while (next_permutation(ALL(r)));
    cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
score = [K-Q for _ in range(N)]


for i in range(Q):
  a = int(input())
  score[a-1] += 1

  

for i in range(N):
  if score[i] > 0:
    print("Yes")
  else:
    print("No")

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

using namespace std;
int a[1000000];
int main(){
	a[0]=1;
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	a[i]=min(a[i-1]+k,a[i-1]*2);
	cout<<a[n];
	return 0;
}

Measured memory_bytes: 256
import time
nlist = []

def findnums(lmax,lcur,num):

    if lmax < lcur :
        return
    elif lmax >= lcur :

        if lcur >= 3 :
            s = str(num)        
            if s.find('7') >= 0 and s.find('5') >= 0 and s.find('3') >= 0 :
                nlist.append(int(num))

        tmp = num + '3'
        findnums(lmax,lcur+1,tmp)
        tmp = num + '5'
        findnums(lmax,lcur+1,tmp)
        tmp = num + '7'
        findnums(lmax,lcur+1,tmp)

n = input()
keta = len(n)

t = time.time()
findnums(keta,0,'')
#print(time.time()- t)

t = time.time()
count = 0

for i in nlist:
    if int(n) >= i:
        count += 1

print(count)
#print(time.time()- t)


Measured memory_bytes: 4080
#include <stdio.h>
#include <math.h>

int main(){
  double r, circle_area, circle_circum;
   scanf("%lf", &r);
   circle_area = M_PI * r * r;
   circle_circum = 2 * M_PI * r;
   printf("%lf %lf\n", circle_area, circle_circum);
   return 0;
}

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

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define inp(x) (cin>>x,x)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

//#define lint long long
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> livec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx9[9] ={ 0,1,1,1,0,0,-1,-1,-1 },
dy9[9] ={ 1,1,0,-1,0,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

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

#define mod(a,b) (a<0?a%b+abs(b):a%b)


int main(){
	setc;

	string s;cin>>s>>s;co("A"<<s[0]<<"C");

	gc();
}

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

typedef long long ll;

int main(){
    cout << setprecision(10);
    int N;
    cin >> N;
    vector<int> v(N);
    bool flg = true;

    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
        sum += v.at(i);
        if(v.at(i) %10 != 0){
            flg = false;
        }
    }
    int ans;
    // 全部10の倍数なら、ans = 0;

    if(flg){
        ans = 0;
    } else if(sum %10 != 0){
        ans = sum;
    } else { 
        sort(v.begin(), v.end());
        for(auto x: v){
            if(x % 10 != 0){
                ans = sum - x;
                break; 
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;

const int MAX = 100000 + 5;

ll shrines[MAX], temples[MAX];

ll dist(ll* sInd, ll* eInd, ll x){
    ll Sdist;
    if ((*eInd > *sInd && *eInd < x) || (*eInd < *sInd && *eInd > x))
        Sdist = abs(*sInd - x);
    else if ((*eInd > x && *sInd < x) || (*eInd < x && *sInd > x)) {
        Sdist = min(abs(*eInd - x), abs(*sInd - x)) + abs(*eInd - *sInd);
    }
    else {
        Sdist = abs(*eInd - x);
    }
    return Sdist;
}
int main(){
    int a, b, q;
    scanf("%d%d%d", &a, &b, &q);
    for (int i = 0; i < a; i++){
        scanf("%lld", &shrines[i]);
    }
    for (int i = 0; i < b; i++){
        scanf("%lld", &temples[i]);
    }
    for (int i = 0; i < q; i++){
        ll x;
        scanf("%lld", &x);
        ll Dist = INFINITY;
        ll *sInd, *eInd;
        // S First
        sInd = lower_bound(shrines, shrines + a, x);
        eInd = lower_bound(temples, temples + b, x);
        if (sInd - shrines != 0) {
            if (sInd - shrines == a){
                if (eInd - temples != b) {
                    Dist = min(Dist, dist(sInd - 1, eInd, x));
                }
                if (eInd - temples != 0) {
                    Dist = min(Dist, dist(sInd - 1, eInd - 1, x));
                }
            }
            else {
                if (eInd - temples != b) {
                    Dist = min(Dist, dist(sInd, eInd, x));
                    Dist = min(Dist, dist(sInd - 1, eInd, x));
                }
                if (eInd - temples != 0) {
                    Dist = min(Dist, dist(sInd, eInd - 1, x));
                    Dist = min(Dist, dist(sInd - 1, eInd - 1, x));
                }
            }
        }
        else {
            if (eInd - temples != b) {
                Dist = min(Dist, dist(sInd, eInd, x));
            }
            if (eInd - temples != 0) {
                Dist = min(Dist, dist(sInd, eInd - 1, x));
            }
        }
        printf("%lld\n", Dist);
    }
}

Measured memory_bytes: 2816
import java.util.*; 
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a= sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        long ans = (long)-4e18;
        ans=Math.max(ans,1l*a*c);
        ans=Math.max(ans,1l*a*d);
        ans=Math.max(ans,1l*b*c);
        ans=Math.max(ans,1l*b*d);
        pw.println(ans);
        pw.flush();
    }
    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

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

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

Measured memory_bytes: 32904
N,M = [int(i) for i in input().split()] #Nがスイッチの数、Mは電球の数
kslist = []
for i in range(M):
    kslist.append([int(i)-1 for i in input().split()][1:])
plist = [int(i) for i in input().split()]

#print(kslist)
#print(plist)

count = 0

lamp_str = "0"*N
for i in range(2**N):
    lamp_onoff_list = [int(i) for i in lamp_str]
    iflampturnson = [0 for i in range(M)]
    for j in range(M):
        for s in kslist[j]:
            iflampturnson[j] += lamp_onoff_list[s]
    #print(lamp_onoff_list,iflampturnson)
    iflampturnson = [k%2 for k in iflampturnson]
    
    buff = True
    for k in range(M):
        if plist[k] != iflampturnson[k]:
            buff = False
    if buff == True:
        count += 1

    lamp_str = format(int(lamp_str,2) + 1,"b")
    lamp_str = lamp_str.zfill(N)

print(count)



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

ll f(ll n, ll x) {
	if (n < 0) return 0;
	else return n / x + 1;
}

int main() {
	ll a,b,x;
	cin >> a >> b >> x;

	cout << f(b,x) - f(a-1,x) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5;
int gcd(int a,int b){
	return (!b?a:gcd(b,a%b)); 
}
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll e=gcd(max(c,d),min(c,d));
	e=c/e*d;
	ll num1=b/c-(a-1)/c,num2=b/d-(a-1)/d,num3=b/e-(a-1)/e;
	cout<<(b-a+1-num1-num2+num3);
	return 0;
}

Measured memory_bytes: 256
import sys
N = int(input())
li = []
if N == 1 or N == 2:
    a = list(map(int,input().split()))
    print(1)
    sys.exit()   

for i in range(N):
    a = list(map(int,input().split()))
    li.append(a)

cross = []

##計算量に余裕があるので全探索します
for i in range(N):
    for j in range (i+1, N):
        a = [li[j][0]-li[i][0],li[j][1]-li[i][1]]
        if a[0] <= 0 and a[1] <= 0:
            b = [abs(li[j][0]-li[i][0]),abs(li[j][1]-li[i][1])]
            cross.append(b)
        elif a[0] < 0 and a[1] >= 0:
            c = li[j][1]-li[i][1]
            b = [abs(li[j][0]-li[i][0]),-c]
            cross.append(b) ####
        else:
            cross.append(a) 
lencross = len(cross)

res = 0
ans = []

for i in range (lencross):
    res = 0
    for j in range (lencross):
        if cross[i] == cross[j]:
            res += 1
    ans.append(res)
reduce = max(ans)

print(N - reduce)

Measured memory_bytes: 3192
#include <stdio.h>
#include <string.h>

int main(void)
{
	int flag[501];
	int list[2][10000];
	int i, j;
	int n, m;
	int count;
	
	while (1){
		scanf("%d %d", &n, &m);
		
		if (!n && !m){
			break;
		}
		
		memset(flag, 0, sizeof(flag));
		
		for (i = 0; i < m; i++){
			scanf("%d %d", &list[0][i], &list[1][i]);
			
			if (list[0][i] == 1 || list[1][i] == 1){
				flag[list[0][i]] = flag[list[1][i]] = 100000;
			}
		}
		
		for (i = 0; i < m; i++){
			if (flag[list[0][i]] >= 100000 || flag[list[1][i]] >= 100000){
				flag[list[0][i]]++;
				flag[list[1][i]]++;
			}
		}
		
		count = 0;
		for (i = 2; i <= n; i++){
			if (flag[i]){
				count++;
				
			}
		}
		
		printf("%d\n", count);
	}
	
	return (0);
}

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

int main(){
    int s;
    cin >> s;
    vector<int> sum(s+1,0);
    vector<int> dp(s+1,0);
    dp[3] = 1;
    dp[4] = 1;
    dp[5] = 1;
    sum[3] = 1;
    sum[4] = 2;
    sum[5] = 3;
    if (s >= 6){
        for (int i = 6; i < s+1;i++){
            dp[i] = 1 + sum[i-3];
            
            if(dp[i] >= mod){
                dp[i] = dp[i]%mod;
            }
            sum[i] = sum[i-1] + dp[i];
            if(sum[i] >= mod){
                sum[i] = sum[i]%mod;
            }
        }
    }
    cout << dp[s] << endl;
    
}

Measured memory_bytes: 3596
#!usr/bin/env python3

from math import floor


def string_two_numbers_spliter():
    a, b = [int(i) for i in input().split()]
    return a, b


def main():
    a, b = string_two_numbers_spliter()
    print('%d %d %f' % (floor(a/b), a%b, a/b))


if __name__ == '__main__':
    main()

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

typedef long long LL;
const int N=222;
int INF=0x3f3f3f3f;
int dp[N][N];
int task[N];

int main(){
	ios_base::sync_with_stdio(false);
	int n,m,R;
	int a,b,c;
	int res;
	int ans=INF;
	cin>>n>>m>>R;
	
	for(int i=1;i<=R;i++) cin>>task[i];
	
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	dp[i][j]=INF;
	
	for(int i=1;i<=m;i++){
		cin>>a>>b>>c;
		if(dp[a][b]>c) dp[a][b]=c;
		if(dp[b][a]>c) dp[b][a]=c;
	}
	
	
	for(int k=1;k<=n;k++)
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
		
	sort(task+1,task+1+R);
	do{
		res=0;
		for(int i=1;i<R;i++){
			res+=dp[task[i]][task[i+1]];
		}
		ans=min(ans,res);
	}while(next_permutation(task+1,task+1+R));//È«ÅÅÁÐ
	
	cout<<ans<<endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

void solve()
{
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    int dp[n+1][m+1] = {0};

    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= m; j++) dp[i][j] = 0;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max( dp[i-1][j], dp[i][j-1]);
        }
    }

    //for(int i = 0; i <= n; i++){
    //    for(int j = 0; j <= m; j++)
    //        cout << dp[i][j] << " ";
    //    cout << "\n";
    //}

    int i = n, j = m;
    vector<char> ans;
     
    
    while(ans.size() < dp[n][m])
    {
        //cout << "\n> " << i << " " << j << " " << ans.size() << " " << s[i-1] << t[j-1] << " " << dp[i][j-1] << " " << dp[i-1][j];

        if(s[i-1] == t[j-1])
        {
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
        else if(dp[i][j-1] >= dp[i-1][j])
            j--;
        else
            i--;
    } 
    
    if(ans.size() == 0)
        cout << "";
    else
    {
        for(int i = ans.size()-1; i >= 0; i--)
            cout << ans[i];
    }
}

int main()
{
    fastio;
    solve();
}

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

int main() {
    int k, s; cin >> k >> s;

    int ans = 0;
    for (int x = 0; x <= k && x <= s; ++x) {
        for (int y = 0; y <= k && x + y <= s; ++y) {
            int z = s - x - y;
            if (k < z) continue;
            ++ans;
        }
    }

    cout << ans << endl;
}



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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  string S,T;
  cin>>S>>T;
  ll n = S.size(),m=T.size();
  vector<int> v(n+1,0),u(m+1,0);
  rep(i,n){
    int t = S[i] - 'A';
    t++;
    v[i+1] = v[i] + t; 
  }
  rep(i,m){
    int t = T[i] - 'A';
    t++;
    u[i+1] = u[i] + t;
  }
  ll q;
  cin>>q;
  rep(i,q){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int s = (v[B]-v[A-1])%3;
    if(s<0) s+=3;
    int t = (u[D]-u[C-1])%3;
    if(t<0) t += 3;
    if(s==t) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 4292
#踏まない床を0としてフィボナッチ数列を考える
N, M = map(int, input().split())
MOD = 10 ** 9 + 7

arrs = set([int(input()) for _ in range(M)])
anss = [0, 1]
for i in range(1, N+1):
    if i in arrs:
        anss.append(0)
    else:
        anss.append((anss[-2] + anss[-1]) % MOD)
print(anss[-1] % MOD)

Measured memory_bytes: 13216
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc129/tasks/abc129_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 典型といっていいほどのdp
 
 dp[i段目] := i段目に到達可能な移動数
 ================================================================
 */

const ll MOD = 1e9+7;
template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<int> broken(N);
    for(int i = 0; i < M;i++){
        int a; cin >> a;
        broken[a] = true;
    }
    vector<ll> dp(N+2);
    dp[0] = 1;
    for(int i = 0; i < N;i++){
        if(broken[i]) continue;
        (dp[i+1] += dp[i])%=MOD;
        (dp[i+2] += dp[i])%=MOD;
    }
    res = (dp[N])%MOD;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<queue>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

vector<int> G[10];
int dp[10][1<<10];
int N, M;

int dfs(int v, int state) {
	int& ret = dp[v][state];
	if (ret >= 0) return ret;
	if (state == (1<<N)-1) return ret = 1;
	ret = 0;
	for (int el : G[v]) {
		if ((state>>el)&1) continue;
		ret += dfs(el, state|(1<<el));
	}
	return ret;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	memset(dp, -1, sizeof(dp));
	cout << dfs(0, 1) << endl;
	return 0;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    string s; cin >> s;

    cout << (s[0] == s[2] ? "Yes" : "No");
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# -*- coding: utf-8 -*-


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [1]* (n+1)
        self.size = [1]* (n+1)
        
    # search parents of tree
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    
    # union tree
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # parent same
        if x == y:
            return False
        
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            return True
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            return True
    # check
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    # size
    def sizes(self, x):
        x = self.find(x)
        return self.size[x]
    
#[N,M] = [6,5]
#A = [2, 1, 5, 3, 4]
#B = [3, 2, 6, 4, 5]
[N,M] = list(map(int,input().split()))
A = [0]*M
B = [0]*M
for i in range(M):
    [a,b] = list(map(int,input().split()))
    A[i], B[i] = a, b

A.reverse()
B.reverse()
uf = UnionFind(N)
ans_list = [0]*M
ans_list[0] = (N*(N-1))//2
ans = ans_list[0]
for i in range(M-1):
    if uf.same(A[i], B[i]) == True:
        ans = ans
    else:
        ans = ans - uf.sizes(A[i])*uf.sizes(B[i])
    uf.unite(A[i],B[i])
    ans_list[i+1] = ans
    
ans_list.reverse()
for i in range(M):
    print(ans_list[i])

Measured memory_bytes: 18504
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int main () {
  long long a=1;
  long long n;
  cin >> n;
  for (long long i=1; i<= n; i++) {
    a=(a*i)%1000000007;
  }
  cout << a << endl;
  return 0;
}

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

using namespace std;

using u32 = uint32_t;
using u64 = uint64_t;
using i64 = int64_t;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= a; i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second

bool c7(int N) {
  while (N > 0) {
    if (N % 10 == 7) {
      return true;
    }
    N /= 10;
  }
  return false;
}

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

  int N;
  cin >> N;

  cout << (c7(N) ? "Yes" : "No");
}


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

#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)

#define MOD 1000000007
#define INF 1000000000

using ll = long long int;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}

int main() {
    ll N,M; cin >> N >> M;
    vector<ll> a(N);
    rep(i,N) cin >> a[i];
    rep(i,N) a[i] /= 2;

    vector<ll> b = a;
    bool flag = true;
    while(flag){
        flag = (b[0]%2 == 0);
        rep(i,N){
            if((b[i]%2 == 0) == !flag){
                cout << 0;
                return 0;
            }
            b[i] /= 2;
        }
    }

    ll lcmmin = a[0];
    rep(i,N-1){
        lcmmin = lcm(lcmmin, a[i+1]);
        if(lcmmin > M){
            cout << 0;
            return 0;
        }
    }

    ll ans = (M + lcmmin)/(lcmmin*2);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
//AUTHOR:- Avinash//
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long int
#define lll long long
#define fo(i,n) for(int i=0;i<n;i++)
#define take(a,i,n) for(int i=0;i<n;i++) cin>>a[i]
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long long double
#define d1(x) cout<<(x)<<endl
#define T int t;cin>>t;while(t--)
#define hell 1000000007
#define ex endl;
#define F first
#define maxn 200001
#define pi 3.14159265
#define S second
#define P pair<int,int>
#define PP pair<int,pair<int,int>>
#define pb push_back
#define in insert
#define vec vector<ll>
#define vec2 vector<vector<int>>
#define s(a,n) sort(a,a+n);
#define sv(a) sort(a.begin(),a.end());
#define MAX 1000
//Author:-Avinash//
ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(ll a, ll m)
{
    return power(a, m-2, m);
}
int main(){
   FAST
   string a,b,c;
   cin>>a>>b>>c;
   cout<<a[0]<<b[0]<<c[0]<<endl;
   return 0;
}

Measured memory_bytes: 3652
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    hoge = defaultdict(int)
    for _ in range(N):
        s = input()
        hoge[s] += 1
    print("AC x", hoge["AC"])
    print("WA x", hoge["WA"])
    print("TLE x", hoge["TLE"])
    print("RE x", hoge["RE"])

if __name__ == '__main__':
    main()


Measured memory_bytes: 10584
import java.util.*
import java.math.*

fun main(args: Array<String>) {

//    var (N, K) = readLine()!!.split(" ").map { it.toInt() }
    var N = readLine()!!.toLong()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }
//    val A = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    var ans = 0L
    var n = Math.sqrt(N.toDouble()).toLong()

    for (m in 1..n) {
        if (N%m != 0L) continue
        val d = N/m

        if (m!=1L && N/(m-1) == N%(m-1)) ans += m-1
        if (d!=1L && N/(d-1) == N%(d-1)) ans += d-1
    }

    println(ans)
}

Measured memory_bytes: 31688
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll x;
    cin >> x;
    ll div = x / 11L;
    ll ans = div * 2;
    x -= 11L * div;
    if (x >= 1) {
        x -= 6;
        ans++;
    }
    if (x >= 1) {
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int H, W, K;
vector<string> fi;

int solve() {
    int res = 1<<29;
    for (int bit = 0; bit < (1<<(H-1)); ++bit) {
        //COUT("----------"); COUT(bit);
        
        bool gok = true;
        int N = 0;
        vector<int> ord(H, 0);
        for (int i = 0; i < H-1; ++i) {
            if (!(bit & (1<<i))) ord[i+1] = ord[i];
            else ord[i+1] = ord[i]+1, ++N;
        }
        int add = 0;
        vector<int> nums(N+1, 0);

        //COUT(N);
        
        for (int w = 0; w < W; ++w) {
            vector<int> adds(N+1, 0);
            bool ok = true;
            for (int h = 0; h < H; ++h) {
                adds[ord[h]] += fi[h][w] - '0';
                nums[ord[h]] += fi[h][w] - '0';
                if (nums[ord[h]] > K) ok = false;
                if (adds[ord[h]] > K) gok = false;
            }
            if (!ok) {
                ++add;
                nums = adds;
            }
            //cout << w << ": " << add << ",, " << nums << endl;
        }
        //COUT(add);
        
        if (gok) chmin(res, N + add);
    }
    return res;
}

int main() {
    while (cin >> H >> W >> K) {
        fi.resize(H);
        for (int i = 0; i < H; ++i) cin >> fi[i];
        cout << solve() << endl;
    }
}

















Measured memory_bytes: 256
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcd(gcd(a,b),c)
print(ans)

Measured memory_bytes: 79700
#include <iostream>

using namespace std;

unsigned long long A[100005],B, N, c;
int main()
{
    cin>>N;
    for (int i=1; i<=N+1; i++)
        cin>>A[i];

    for (int i=1; i<=N; i++)
    {
        cin>>B;
        if (B)
        {
            if (B<=A[i])
            {
                c+=B;
                A[i]-=B;
                B=0;
            }
            else if (A[i])
            {
                c+=A[i];
                B-=A[i];
                A[i]=0;
            }
        }

        if (B)
        {
            if (B<=A[i+1])
            {
                c+=B;
                A[i+1]-=B;
                B=0;
            }
            else if (A[i+1])
            {
                c+=A[i+1];
                B-=A[i+1];
                A[i+1]=0;
            }
        }
    }
    cout<<c;
}


Measured memory_bytes: 1024
#       )                         .MMdMMM;                    .M#(,dM]                        .:
#       )                        .M@d@d#Mb                    dMGMM(MN                        .:
#       )                        dM1MCdbMM_                  .M@MSN;dM-                       .:
#       )                       .M#(#?d#(Mb.. ...............JMIMIMLdM]                       .:
#       )                      ..M#?NHM# ?MMMMMMMMMH"""""""HMM@(Nad#(Mb                       .:
#       )                  .(MMMMH=..-(Jg[   `               daggmp  MNm,                     .:
#       )                ..MMY`     !qN;                       (J     ?MMN,                   .:
#       )               (MMD`       .MM@                      .MM{      .WMN,                 .:
#       )              dM@`         dMM%                      .MM}        (MMm                .:
#       )             .M#`          dMN!                      .MM}        ~(MMr               .:
#       )            .MM:           dM#                       .MM}        ..JM#               .:
#       )      ``    .M@            dMF                       .MM}        .~(M#   `  .        .:
#       )      ?MMMMMMMNgJ,         .7`                        T"!       .JJjMNgNNMMMB^       .:
#       )            dMr ?Mm,                                            7YYMM#!`             .:
#       )            dMb   ?`                  .,   ` ..                 ~.(MM%               .:
#       )         ..JgMMNNN)                  .Mn.(Mm-JM{               dHHMMNag.,            .:
#       )         ("!  ?MN,..,                (NM@"`~OMM}             ..~-(M@` _?"M[          .:
#       )               ,MMM#_                .M#    .M#`           .~.~JMMMNg-..             .:
#       )           ..gMB"?TMMNJ..              `     _`         .~~.(JdM#^  _"TMMNgJ-,       .:
#       )        .gMB=`      _7WMMNaJ...                 ....__-(JJgMMMM^          ?T"^       .:
#       )           ............  ?TWMMMMNNNNgggggggggggggNNMMMMMMBY7`...                     .:
#       )           WMMMMMMMMMMMMMNgJ,   (dMMMM#"TYYYYYYMMMMMMMNgMMMMMMMMMMMNNgJ-,            .:
#       )            -?TMNmuuuuUWMMMMMMNNMM@g@MMmJ--_(JMMg@g@@gMMMMMMWUXXXUWMMMMMMNe.         .:

def push(k,v):
    if k in dic:
        dic[k] = min(dic[k],v)
    else:
        dic[k] = v
n,x,y = map(int,str(input()).split(' '))
dic = {}
for i in range(0,n):
    a = list(map(int,str(input()).split(' ')))
    k,v =a[0]*y-a[1]*x,a[2]
    l = []
    for j in dic:
        l.append([j,dic[j]])
    for jj in l:
        push(jj[0]+k,jj[1]+v)
    push(k,v)
if 0 in dic:
    print(dic[0])
else:
    print('-1')


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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans += (n/(a+b)) *a;
    ll r = n%(a+b);
    if(r > a) ans += a;
    else ans += r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int K;
	string S;
	cin >> K >> S;
	string str;
	if (S.length() <= K)
		cout << S << endl;
	else
	{
		S.erase(S.begin()+K,S.end());
		cout << S << "..." << endl;
	}

}

/*
ライブラリ
・string
::::str.at(0)
::::str.length()
::::str.pop_back();
・vector<int>
::::vector<int> a(n,-1);
::::vector<int> s;  s.push_back()
::::vector<vector<int>> A(N,vector<int>(M));  A[i][j] = i;
・map<string,int>
・sort(a.begin(),a.end());

関数
・rep_2(i,0,1<<n) … ２のN乗ループ
・while(node[v] == -1) … ノードの探索と生成
・gcd(int, int) … 最大公約数 int
・find_string(str, str) … 文字列検索 bool
*/

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

int main(){
    long long K, count=0;
    int N, ai, bi, i, ans, maxN=100000;

    long long arr[maxN];
    for (i=0; i<maxN; i++) {
        arr[i] = 0;
    }

    cin >> N >> K;

    for (i=0; i<N; i++) {
        cin >> ai >> bi;
        arr[ai-1] += bi;
    }

    for (i=0; i<maxN; i++) {
        if (count >= K) {
            break;
        } else {
            count += arr[i];
            ans = i + 1;
        }
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 1024
import numpy as np
from itertools import product

h, w, k = map(int, input().split())

mod = 1000000007

ami = []
for a in product(range(2), repeat=w-1): # w-1
    for i, j in zip(a[:-1], a[1:]):
        if i and j:
            break
    else:
        ami.append(a)

temp = np.eye(w, dtype=np.int)
adj = np.zeros_like(temp)
for a in ami:
    adj_tmp = temp.copy()
    for i, l in enumerate(a):
        if l:
            adj_tmp[[i, i+1]] = adj_tmp[[i+1, i]]
    adj += adj_tmp
    
now = np.zeros(w, dtype=np.int)
now[0] = 1

for _ in range(h):
    now = np.dot(now, adj) % mod

print(now[k-1])

Measured memory_bytes: 12508
/* A Brute Force */

#include<stdio.h>

int A[20]; /*0~20, n<=20*/
int n;

int solve(int,int);

int main(){
  int q, M, i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

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

int solve(int p, int t){
  int temp1,temp2;
 
  if(t<0)return 0;
  if(t==0)return 1;
  if(p>=n)return 0;

  temp1=solve(p+1,t-A[p]);
  temp2=solve(p+1,t);
  
  if(temp1==1||temp2==1)return 1;
  else return 0;
}

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

int main()
{
    long N,A,B;
    std::cin >> N >> A >> B;
    if((B-A)%2==0){
        std::cout << (B-A)/2 << std::endl;
    }else{
        long result=0;
        long edge = std::min(A-1,N-B);
        result+=edge;
        result++;
        A++;
        result+=(B-A)/2;
        std::cout << result<< std::endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 303;

int N, K;
ll M, comb[MAX_N][MAX_N], F[MAX_N][MAX_N];

int main() {
    scanf("%d%d%lld", &N, &K, &M);
    for (int i = 0; i <= N; i++) {
        comb[i][0] = 1;
        for (int j = 1; j <= i; j++) comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % M;
    }
    F[0][0] = 1;
    for (int i = 1; i <= K; i++) {
        ll G[MAX_N];
        fill_n(G, N + 1, 0);
        G[0] = 1;
        for (int j = 1; j <= N; j++) {
            for (int k = 1; k <= j; k++) {
                (G[j] += G[j - k] * F[i - 1][k - 1] % M * comb[j - 1][k - 1]) %= M;
            }
        }
        for (int j = 0; j <= N; j++) {
            for (int k = 0; k <= j; k++) {
                (F[i][j] += F[i - 1][j - k] * G[k] % M * comb[j][k]) %= M;
            }
        }
    }
    printf("%lld\n", F[K][N]);
}


Measured memory_bytes: 1664
def set1():
    N,M = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    set_N = set([i for i in range(1, N+1)])
    for i in range(M):
        A,B = [int(i) for i in input().split()]
        if H[A-1] < H[B-1]:
            if A in set_N:
                set_N.remove(A)
        elif H[B-1] < H[A-1]:
            if B in set_N:
                set_N.remove(B)
        else:
            if A in set_N:
                set_N.remove(A)
            if B in set_N:
                set_N.remove(B)
    print(len(set_N))

if __name__ == "__main__":
    set1()

Measured memory_bytes: 23640
import java.util.Scanner;

public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void task() {
        int min = this.mx[0];
        int max = this.mx[1] - this.mx[0];
        for(int i = 1; i < this.size; i++){
            if(max < this.mx[i] - min){ max = this.mx[i] - min; }
            if(min > this.mx[i]){ min = this.mx[i]; }
        }
        System.out.println(max);
    }

    public static void main(String[] args) {
        Main prime = new Main();
        prime.scan();
        prime.task();
    }
}


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

int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())

res = {}
for i in range(1, N):
    res[i] = 0

for i in range(1, N):
    for j in range(i+1, N+1):
        if i <= X and j >= Y:
            min_dis = min(j-i, (X-i)+(j-Y)+1)
        elif i <= X and j < Y:
            min_dis = min(j-i, (X-i)+(Y-j)+1)
        elif i > X and j >= Y:
            min_dis = min((j-i), (i-X)+(j-Y)+1)
        elif i > X and j < Y:
            min_dis = min((j-i), (i-X)+(Y-j)+1)

        res[min_dis] += 1

for i in range(1, N):
    print(res[i])


Measured memory_bytes: 3572
x=int(input())

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

    # divisors.sort()
    return divisors

tmp = make_divisors(x)
l = len(tmp) // 2
#print(tmp)

ans=0

for i in range(l):
  flg = 0
  a=tmp[2*i]
  b=0
  while flg == 0:
    t = a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    #print(a,b,t)
    if t == tmp[2*i+1]:
      ans=[a,b]
      flg=1
    if t > tmp[2*i+1]:
      flg=2
    a += 1
    b += 1

  a=tmp[2*i]
  b=0
  c=a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
  while flg == 2:
    t=a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4
    #print(a,b,t,2)
    if t == tmp[2*i+1]:
      ans=[a,b]
      flg=1
    if t > c:
      flg=3
    a -= 1
    b -= 1
  
  if flg==1:
    break

if x==1:
  print(0,-1)
else:
  print(ans[0],ans[1])

Measured memory_bytes: 9556
#include <cstdio>
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <string>

using namespace std;
using ll = long long;

ll N;

void input() {
    cin >> N;
}

void solve() {
    vector<ll> divisors(N+1);
    for (ll n = 2; n <= N; n++) {
        ll cn = n;
        for (ll k = 2; k <= n; k++) {
            while (cn % k == 0) {
                divisors[k]++;
                cn /= k;
            }
        }
    }
    for (ll i = 2; i < N+1; i++)
        cerr << "div[" << i << "=" << divisors[i] << endl;
    auto num_of_greater_divs = [&divisors](ll n) {
        ll res = 0;
        for (auto d : divisors) {
            if (d >= n-1)
                res++;
        }
        return res;
    };
    ll n75 = num_of_greater_divs(75);
    ll n25 = num_of_greater_divs(25);
    ll n15 = num_of_greater_divs(15);
    ll n5 = num_of_greater_divs(5);
    ll n3 = num_of_greater_divs(3);
    ll ans = n75 + n25 * (n3-1) + n15 * (n5-1) + n5 * (n5-1) * (n3-2) / 2;
    cout << ans << endl;
}

int main() {
    input();
    solve();
    
    return 0;
}



Measured memory_bytes: 256