akhauriyash/Code-Regression huggingface dataset:
import random
import copy
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0

types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = max(ans+10**6,0)
all = sum(sc)
for _ in range(17000):
    types2 = []
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,D+1))
    #print(l)
    #print(ind,types[ind]-1)
    l.pop(ind-1)
    ind2=random.choice(l)
    spans=ind//26
    types2=copy.deepcopy(types)
    buf=types[ind]
    types[ind]=types[ind2-1]
    types[ind2-1]=buf
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = max(ans+10**6,0)
    all2 = sum(sc2)
    if all2<=all:
        types=types2
    else:
        sc=sc2
        all=all2
        sc2=[]
        #print(114514)
    #print(all)
    #input()
for i in range(D):
    print(types[i])



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


int main(void){
 
    string S;
    cin >> S;
    
    map<char,int> mp;
    string ans = "Yes";
    for(int i = 0; i < S.size(); i++){
        mp[S[i]]++;
    }
    
    
    
    if(mp['N'] == 0 && mp['S'] !=  0)ans ="No";
    if(mp['N'] != 0 && mp['S'] ==  0)ans ="No";
    if(mp['E'] == 0 && mp['W'] !=  0)ans ="No";
    if(mp['E'] != 0 && mp['W'] ==  0)ans ="No";
    cout << ans << endl;

}
 

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int,input().split()))
ab = [list(map(int, input().split())) for _ in range(m)]

good = [True]*n
for route in ab:
    a = route[0]-1
    b = route[1]-1
    if h[a] > h[b]:
        good[b] = False
    elif h[b] > h[a]:
        good[a] = False
    else:
        good[a] = False
        good[b] = False
print(len(list(filter(lambda x: x, good))))



Measured memory_bytes: 32552
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	ios_base::sync_with_stdio(false);
	cin>>n>>a>>b;
	if(a%2==b%2)cout<<(abs(a-b))/2<<endl;
	else
	{
		cout<<min((a+b-1)/2,(2*n-a-b+1)/2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,l=[int(i) for i in input().split()]
taste=[]
for i in range(n):
    taste.append(l+i)


sumtaste=0
if taste[0]*taste[-1]<0:
    for i in taste:
        sumtaste+=i
elif taste[0]>=0:
    del taste[0]
    for i in taste:
        sumtaste+=i
else:
    taste.pop()
    for i in taste:
        sumtaste+=i
print(sumtaste)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  double N, K;
  cin >> N >> K;
  vector<double> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  vector<double> e(N); // N個のサイコロの出る目の期待値
  for (int i=0; i<N; i++) e[i] = (1+p[i])/2;
  vector<double> s(N); // eのe[0]からe[i]までの累積和
  s[0] = e[0];
  for (int i=1; i<N; i++) s[i] = s[i-1]+e[i];
  double ans = s[K-1];
  for (int i=0; i<N-K; i++) ans = max(ans, s[i+K]-s[i]);
  cout << setprecision(12) << fixed;
  cout << ans << endl;
}

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


int main(){
  vector<int> v(5);
  cin >>v[0] >>v[1] >> v[2] >> v[3] >>v[4];

  for(int i=0; i < v.size(); i ++) {
    if(v[i] == 0) {
      cout << i+1 << endl;
    }
  }
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++)                              
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;
//const ll INF = mod * mod;

int main() {
    int n,k,r,s,p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;
    vc v(n);
    rep(i,n) {
        if(t[i] == 'r') v[i] = 'p';
        else if(t[i] == 's') v[i] = 'r';
        else v[i] = 's';
    }
    ll ans = 0;
    rep(i,n-k) {
        if(v[i] == v[i+k]) v[i+k] = 'x';
    }
    /*rep(i,n) cout << v[i];
    cout << endl;*/
    rep(i,n) {
        if(v[i] == 'r') ans += r;
        else if(v[i] == 's') ans += s;
        else if(v[i] == 'p') ans += p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; 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++)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;

ll lcs(string s, string t) {
    int n = s.length();
    int m = t.length();
    vector<vector<int>> dp(n+1, vector<int>(m+1, 0));
    dp[0][0] = 0;
    REPP(i,n) {
        REPP(j,m) {
            if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
            else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
    }
    return dp[n][m];
}

int main() {
    int q; cin >> q;
    REP(i,q) {
        string S,T; cin >> S >> T;
        cout << lcs(S,T) << endl;
    }
    return 0;
}


Measured memory_bytes: 6704
x = 10 ^ 9 + 7

main = print.reconciled.map read.words =<< getLine
reconciled [n, m]
  | n == m = mod (fact n * fact m * 2) x
  | abs (n - m) == 1 = mod (fact n * fact m) x
  | otherwise = 0
fact 1 = 1
fact n = mod (n * fact (n - 1)) x

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

struct Node{
	int x, y, d;
};

const int INF = 1e9;

char s[805][805];
int used[805][805];
queue <Node> q;
int h, w, k;

bool bfs(){
	int x, y, d;
	while (!q.empty()){
		x = q.front().x; y = q.front().y; d = q.front().d; q.pop();
		if (x == 1 || x == h || y == 1 || y == w) return true;
		if (d == k) continue;
		if (x > 1 && !used[x - 1][y] && s[x - 1][y] == '.'){
			q.push((Node){x - 1, y, d + 1});
			used[x - 1][y] = 1;
		}
		if (x < h && !used[x + 1][y] && s[x + 1][y] == '.'){
			q.push((Node){x + 1, y, d + 1});
			used[x + 1][y] = 1;
		}
		if (y > 1 && !used[x][y - 1] && s[x][y - 1] == '.'){
			q.push((Node){x, y - 1, d + 1});
			used[x][y - 1] = 1;
		}
		if (y < w && !used[x][y + 1] && s[x][y + 1] == '.'){
			q.push((Node){x, y + 1, d + 1});
			used[x][y + 1] = 1;
		}
	}
	return false;
}

int main(){
	int stx, sty, flag, ans, minx;
	scanf("%d %d %d",&h,&w,&k);
	for (int i = 1; i <= h; i++) scanf("%s", s[i] + 1);
	flag = 0;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (s[i][j] == 'S'){
				stx = i; sty = j;
				flag = 1;
				break;
			}
		}
		if (flag) break;
	}
	memset(used, 0, sizeof(used));
	q.push((Node){stx, sty, 0});
	used[stx][sty] = 1;
	if (bfs()){
		printf("1\n");
		return 0;
	}
	ans = INF;
	for (int i = 2; i <= h - 1; i++){
		for (int j = 2; j <= w - 1; j++){
			if (used[i][j]){
				minx = min(i - 1, h - i);
				minx = min(minx, j - 1);
				minx = min(minx, w - j);
				ans = min(ans, (minx + k - 1) / k + 1);
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3456
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,d;
    cin>>n>>d;
    vvi x(n,vi(d));
    rep(i,n)rep(j,d)cin>>x[i][j];
    int ans=0;
    rep(i,n)Rep(j,i+1,n){
        int s=0;
        rep(k,d)s+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        REP(k,1,20000){
            if(k*k==s)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n;
char s[1000001];

bool judge(int k){
	int a = 0, b = 0, c = 0;
	int p = k;
	for(int i = n - 1; i >= 0; --i){
		if(s[i] == 'J' && b > 0){
			--b;
			++a;
		}
		if(s[i] == 'O' && c > 0){
			--c;
			++b;
		}
		if(s[i] == 'I'){
			if(p > 0){
				++c;
				--p;
			}
			else if(b > 0){
				--b;
				++a;
			}
		}
	}
	return a == k;
}

int main(){
	scanf("%d%s", &n, s);
	int l = 0, r = n;
	while(r - l > 1){
		int m = (l + r) / 2;
		if(judge(m)){
			l = m;
		}
		else{
			r = m;
		}
	}
	printf("%d\n", l);
	return 0;
}

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

class Unionfind:
    def __init__(self, n):
        self.par = [-1]*n
        self.rank = [1]*n
    
    def root(self, x):
        r = x
        
        while not self.par[r]<0:
            r = self.par[r]
        
        t = x
        
        while t!=r:
            tmp = t
            t = self.par[t]
            self.par[tmp] = r
        
        return r
    
    def unite(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        
        if rx==ry:
            return
        
        if self.rank[rx]<=self.rank[ry]:
            self.par[ry] += self.par[rx]
            self.par[rx] = ry
            
            if self.rank[rx]==self.rank[ry]:
                self.rank[ry] += 1
        else:
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
    
    def is_same(self, x, y):
        return self.root(x)==self.root(y)
    
    def count(self, x):
        return -self.par[self.root(x)]

while True:
    n, m = map(int, input().split())
    
    if n==0 and m==0:
        exit()
        
    edges = [tuple(map(int, input().split())) for _ in range(m)]
    edges.sort(key=lambda t: t[2])
    uf = Unionfind(n)
    ans = 0
    
    for a, b, c in edges:
        if not uf.is_same(a, b):
            uf.unite(a, b)
            ans += c
    
    print(ans)


Measured memory_bytes: 5616
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力しながら答えを出してしまおう…配列面倒なので
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		int result = 0;
		for (int i = 1; i <= n; i++) {
			int x = Integer.parseInt(sc.next());
			if (x % 2 == 1 && i % 2 == 1) {
				result++;
			}
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 35748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)        (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes           out("Yes");
#define no            out("No");

int main() {
    repin(a, 5);

    rep(i, 5) {
        if (a[i] == 0) {
            out(i + 1);
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    int a,b,i;
    int w[100];
    while(cin>>a>>b&&a){
        int max=1500000;
        int min=1,res=0,dan=1;
        for(i=0;i<b;i++) {
            cin>>w[i];
            if(min<w[i]) min=w[i];
        }
        while(max-min>1){
            int hf=(max+min)/2;
            int j;
            res=0;
            dan=1;
            for(j=0;j<b;j++){
                if(res+w[j]<=hf) res+=w[j];
                else{
                    dan++;
                    res=w[j];
                }
            }
            if(dan<=a) max=hf;
            else min=hf;
        }
        int ans=min;
        res=0,dan=1;
        for(i=0;i<b;i++){
            if(res+w[i]<=ans) res+=w[i];
            else{
                dan++;
                res=w[i];
            }
        }
        if(dan<=a) cout<<ans<<endl;
        else cout<<max<<endl;
    }
    return 0;
}


Measured memory_bytes: 3004
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int n; scan(n);
  vector<char> s(n);
  scan(s);
  rep (i, n) {
    if (s[i] == 'Y') {
      print("Four");
      return 0;
    }
  }
  print("Three");

  return 0;
}


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

int main(void)
{
    int N, T, A;

    cin >> N >> T >> A;

    vector<int> vec(N);
    for(int i = 0; i < N; i++) cin >> vec.at(i);

    int ans = 0;
    double temp = abs(A - T + 0.006 * vec.at(0));

    for(int i = 1; i < N; i++)
    {
        if(temp > abs(A - T + 0.006 * vec.at(i)))
        {
            ans = i;
            temp = abs(A - T + 0.006 * vec.at(i));
        }
    }

    cout << ans + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	string a;cin>>a;
	string b;cin>>b;
	rep(i,3)
	{
		if(a[2-i]!=b[i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
  int a,b;cin>>a>>b;
  int r=0;
  for(int i=a;i<=b;i++){
    int s=i%10,t=i/10000%10;
    int u=i/10%10,v=i/1000%10;
    if(s==t&u==v)r++;
  }
  cout<<r<<endl;
}


Measured memory_bytes: 256
N=int(input())

ch=['A','G','C','T']
ban3=['AGC','GAC','ACG']
ban4=['ATGC','AGGC','AGTC']
dp=[{},{}]

mod=10**9+7

for i in range(4**3):
    s=''
    for j in range(3):
        s+=ch[(i>>(j*2))%4]
    
    if s in ban3:
        dp[0][s]=0
    else:
        dp[0][s]=1
    
    dp[1][s]=0

cnt=0

while N>3:
    for k in dp[(cnt+1)%2]:
        dp[(cnt+1)%2][k]=0
    
    for k,v in dp[cnt].items():
        for c in ch:
            nk=k+c

            if nk in ban4:
                continue

            if nk[1:] in ban3:
                continue

            dp[(cnt+1)%2][nk[1:]]+=dp[cnt][nk[:3]]
            dp[(cnt+1)%2][nk[1:]]%=mod
            
    N-=1
    cnt=(cnt+1)%2

print(sum(dp[cnt].values())%mod)

Measured memory_bytes: 73540
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(aA) (a).begin(), (a).end()
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

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

    string s[3];
    REP(i, 3) cin >> s[i];

    cout << s[0][0] << s[1][1] << s[2][2] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod; 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // #ifndef ONLINE_JUDGE
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif

    int l,r;
    cin>>l>>r;
    int d;
    cin>>d; 
    int c = 0;
    for(int i=l;i<=r;++i) {
        if(i%d == 0) ++c;
    }
    cout<<c<<"\n";

    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;


public class B
{	
	public static void Main()
	{
		string S = Console.ReadLine();
		
		int result = 0;
		int counter = 0;
		for(int i = 0; i < S.Length; i++)
		{
			switch(S[i])
			{
				case 'A':
				case 'C':
				case 'G':
				case 'T':
					counter++;
					break;
				
				default:					
					counter = 0;
					break;
			}
			result = Math.Max(result, counter);
		}
		Console.WriteLine(result);
	}
}

Measured memory_bytes: 13140
# -*- coding: utf-8 -*-
n=int(input())
W=list(map(int,input().split()))
for i in range(n):
    if sum(W[:i])>sum(W[i:]) or i==n-1:
        print(min(sum(W[i-1:])-sum(W[:i-1]),sum(W[:i])-sum(W[i:])))
        break

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

int main()
{
	int n;
	scanf("%d", &n);
	double sum{};
	for (int i{}; i < n; i++)
	{
		double x;
		std::string u;
		std::cin >> x >> u;
		if (u.front() == 'J') sum += x;
		else sum += x * 380000;
	}
	printf("%.8lf\n", sum);
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())

dp = [-1 for _ in range(10**6)]
dp[0] = 0

que = deque([0])

while que:
    v = que.popleft()
    j6 = 1
    while v+j6 <= n:
        if dp[v+j6] == -1:
            dp[v+j6] = dp[v]+1
            que.append(v+j6)
        j6 *= 6
            
    j9 = 1
    while v+j9 <= n:
        if dp[v+j9] == -1:
            dp[v+j9] = dp[v]+1
            que.append(v+j9)
        j9 *= 9
            
print(dp[n])

Measured memory_bytes: 148632
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum ^= a[i];
  }

  for(int i = 0; i < n; i++) {
    cout << (sum ^ a[i]) << " ";
  }
  cout << endl;
  return 0;
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int sum = 0;
    for(int i = 0; i < s.length(); i++) {
        sum += s[i] - '0';
        sum %= 9;
    }
    if(sum % 9 == 0) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static Scanner cin = new Scanner();

    static void Main(string[] args) {
        const int INF = (int)1e9;
        int N = cin.Int();
        int K = cin.Int();
        var h = cin.ArrayInt(N);

        var dp = new int[N];
        for (int i = 0; i < N; i++) {
            dp[i] = INF;
        }
        dp[0] = 0;
        dp[1] = Math.Abs(h[1] - h[0]);
        for (int i = 2; i < N; i++) {
            for (int j = 1; i >= K ? j <= K : j <= i; j++) {
                dp[i] = Math.Min(dp[i], dp[i - j] + Math.Abs(h[i] - h[i - j]));
            }
        }
        Console.WriteLine(dp[N - 1]);
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


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

using namespace std;

void convertToBit(int a,vector<int> & bit)
{
  bit[bit.size()-1]=1;
  rrep(i,bit.size()-2,0){
    if(!(a/2==0&&a%2==0)){
      bit[i]=a%2;
      a/=2;
    }
    else{
      bit[i]=0;
    }
  }  
}

int main(void)
{
  string s;
  cin>>s;
  long int sum=0;
  int len=s.length();
  
  vector<int> bit;
  bit.resize(len);
  
  rep(i,0,pow(2,len-1)){
    convertToBit(i,bit);
    
    int start=0;
    rep(j,0,len){
      if(bit[j]==1){
        sum+=stol(s.substr(start,j+1-start));
        start=j+1;
      }
    }
  }
  
  cout<<sum<<endl;
  
  return 0;
}

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

int main(){
  int N, X, T;
  cin >> N >> X >> T;

  int minutes = N / X;
  if (N % X != 0) minutes += 1;
  cout << minutes * T << endl;
}

Measured memory_bytes: 3556
from collections import defaultdict

N = int(input())
if N == 1:
    print(0)
    exit()
index = int(pow(N, 0.5) + 1)
ans = []
for i in range(2, index):
    while N % i == 0:
        N //= i
        ans.append(i)

if N != 1:
    ans.append(N)
if ans == []:
    print(1)
    exit()
d = defaultdict(int)
for i in ans:
    d[i] += 1
sosuLst = []
for v, c in d.items():
    cnt = 1
    while c > 0:
        c -= cnt
        cnt += 1
        if c != 0 and c < cnt:
            sosuLst.append(v ** cnt)
            break
        else:
            sosuLst.append(v ** (cnt - 1))

print(len(set(sosuLst)))

Measured memory_bytes: 9736
package main
import "fmt"
func main() {
  var n,k int
  var s,t string
  fmt.Scan(&n)
  fmt.Scan(&s)
  fmt.Scan(&k)
  t = s[k-1:k]
  for i:=0;i<n;i++ {
    if s[i:i+1] == t {
      fmt.Print(t)
    } else {
      fmt.Print("*")
    }
  }
  fmt.Println()
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
char a[100];
int main(){
	scanf("%s",a);
	int n=strlen(a);
	if(n<4){
		puts("No");
		return 0;
	}else{
		if(strncmp(a,"YAKI",4)){
			puts("No");
		}else{
			puts("Yes");
		}
	}
	return 0;
}

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

int main()
{
  string x;
  cin>>x;
  int o=0;
  int z=0;
  
  for(auto it: x)
  {
    if(it=='0') o++;
    else z++;
  }
  
  int ans=min(z,o);
  ans*=2;
  
  cout<<ans<<"\n";
  
  return 0;
}

Measured memory_bytes: 512
// @samaranand
//
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define int64 long long
#define VI vector < int >
#define VII vector < vector < int > >
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define pii pair < int , int >
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define sz(v) v.size()
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
//const long long biGinf = 9e+18;
const char nwl = '\n';

int main() {
	int a,b;
  cin>>a>>b;
  cout<<(a*b);


	return 0;
}

Measured memory_bytes: 3624
n, k = map(int, input().split())
p = [int(i) for i in input().split()]
amax = sum(p[0:k])
bmax = sum(p[0:k])
for i in range(k,n):
    bmax -= p[i-k]
    bmax += p[i]
    amax = max(amax, bmax)
print((amax+k)/2)

Measured memory_bytes: 25188
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a >= h && b >= w)
				ans++;
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 23888
// https://atcoder.jp/contests/dp/tasks/dp_s

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

// const int K_MAX = 10e10000;
const int S_MAX = 10000;
const int D_MAX = 100;
const int MOD = 1e9+7;

char S[S_MAX + 1];
int D;

int L;
int dp0[2][D_MAX];
int dp1[2][D_MAX];

void solve() {
  L = strlen(S);
  auto cur = dp0;
  auto nxt = dp1;
  cur[0][0] = 1;
  cur[1][0] = 1;
  REP(i, L) {
    fill(nxt[0], nxt[2], 0);
    int d = S[L - 1 - i] - '0';
    REP(j, D) {
      REP(k, 10) {
        nxt[0][(j + k) % D] = (nxt[0][(j + k) % D] + cur[0][j]) % MOD;
      }
      REP(k, d) {
        nxt[1][(j + k) % D] = (nxt[1][(j + k) % D] + cur[0][j]) % MOD;
      }
      nxt[1][(j + d) % D] = (nxt[1][(j + d) % D] + cur[1][j]) % MOD;
    }
    swap(cur, nxt);
  }
  printf("%d\n", (cur[1][0] + MOD - 1) % MOD);
}

void input() {
  scanf("%s", S);
  scanf("%d", &D);
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e15 + 10;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;

const int N = 2e5 + 10;
const int M = 1e3 + 10;

ll a[N];

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    fr(i, n)
        cin >> a[i];

    ll ans1 = 0, curS = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            curS += a[i];
            if (curS <= 0)
                ans1 += (-curS) + 1, curS = 1;
        }
        else {
            curS += a[i];
            if (curS >= 0)
                ans1 += curS + 1, curS = -1;
        }
    }

    ll ans2 = 0;
    curS = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 1) {
            curS += a[i];
            if (curS <= 0)
                ans2 += (-curS) + 1, curS = 1;
        }
        else {
            curS += a[i];
            if (curS >= 0)
                ans2 += curS + 1, curS = -1;
        }
    }
    cout << min(ans1, ans2);
}


Measured memory_bytes: 1024
from collections import deque


def bfs(parent, n):
    queue = deque()
    queue.append(parent)
    d = ['3', '5', '7']
    ans = 0

    while queue:
        s = queue.popleft()
        for di in d:
            t = s+di
            if n < int(t):
                return ans
            elif int(t) <= n and '3' in t \
                    and '5' in t and '7' in t:
                ans += 1

            queue.append(t)


if __name__ == "__main__":
    n = int(input())

    print(bfs('3', n)+bfs('5', n)+bfs('7', n))


Measured memory_bytes: 3768
/*author @dhanush*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
ll MOD = 1e9 + 7;
vector<ll>adj[100005];
ll col[100005];
ll vis[100005];
ll temp;
void dfs(ll n)
{
  vis[n] = 1;
  temp = min(col[n], temp);
  for (auto x : adj[n])
  {
    if (!vis[x])
    {
      dfs(x);
    }
  }
}
void icchhipadey()
{

  string s;
  cin >> s;
  int n = s.size();
  if (s[n - 1] == 's')
  {
    s += "es";
  }
  else
  {
    s += "s";
  }
  cout << s << endl;


}


int main()
{

  icchhipadey();
}









Measured memory_bytes: 5980
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1 << 21);

int n, M[N][N];
int d[N];

void bfs(int s){ //幅優先探索
	queue<int>q;
	q.push(s);
	for (int i = 0; i < n; i++)d[i] = INFTY;
	d[s] = 0;
	int u;
	while (!q.empty()) {
		u = q.front(); q.pop();
		for (int v = 0; v < n; v++) {
			if (M[u][v] == 0)continue;
			if (d[v] != INFTY)continue;
			d[v] = d[u] + 1;
			q.push(v);
		}

	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
	}
}

int main() {
	int u, v, k;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++)M[i][j] = 0;
	}

	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int i = 0; i < k; i++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}


	bfs(0);
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define Nmax 105
#define Vmax 100005
#define ll long long
using namespace std;

ll n, W, w[Nmax], v[Nmax], dp[3][Vmax];

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

    ll sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }

    for (int i = 0; i <= 2; ++i)
    for (int j = 0; j <= sum; ++j) {
        dp[i][j] = INT_MAX;
    }


    ll bigV = 0;
    for (int nr = 1; nr <= n; ++nr) {
        ll row = 1;
        if (nr % 2 == 0) {
            row = 2;
        }

        ll step = 1;
        if (nr % 2 == 0) {
            step = -1;
        }

        dp[row][v[nr]] = w[nr];

        for (int value = 1; value <= sum; value++) {
            dp[row][value] = min(dp[row][value], dp[row + step][value]);
            if (v[nr] < value) {
                dp[row][value] = min(dp[row][value], w[nr] + dp[row + step][value - v[nr]]);
            }
            if (dp[row][value] <= W && value > bigV) {
                bigV = value;
            }
        }
    }

    cout << bigV;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;

int compare(string &s, string &t) {
    int mxi = min(s.size(), t.size());
    for (int i = 0; i < mxi; ++i) {
        if (s[i] == t[i]) continue;
        return s[i] - t[i];
    }
    return s.size() - t.size();
}

int main() {
    int n, cmp, pt = 0, ph = 0;
    string t, h;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t >> h;
        cmp = compare(t, h);
        if (cmp > 0) pt += 3;
        else if (cmp < 0)ph += 3;
        else {
            pt++;
            ph++;
        }
    }
    cout << pt << ' ' << ph << endl;
    return 0;
}



Measured memory_bytes: 3156
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define MOD 1000000007
#define MAXE9 1000000000
 
int i, j, k, l;
 
int main(){
  int wd = 0;
  char str[1000007];
  char ans[1000007];
  int N = 0;
  int S = 0;
  int E = 0;
  int W = 0;
  int tate = 0;
  int yoko = 0;
  int tmp;
  
  scanf("%d", &wd);
	scanf("%s", str);
   for(i=0;i<wd;i++){
	 if(65<= str[i] && str[i] <=77) N++;
    else if(78 <= str[i] && str[i] <=90) S++;
    else if(97 <= str[i] && str[i] <=109) E++;
    else if(110 <= str[i] && str[i] <=122) W++;
  }
  tate=N-S;
  yoko=E-W;
  tmp = abs(abs(tate) + abs(yoko));
  printf("%d\n", tmp);
  if(tmp == 0){
     puts(ans);
  }else{
    if(tate>=0){
      for(i=0;i<tate;i++) ans[i] =65;
    }else if(tate < 0){
      for(i=0;i<abs(tate);i++) ans[i] =90;
    }
    if(yoko>=0){
        for(j=i;j<tmp;j++) ans[j] =97;
    }else if(yoko<0){
       for(j=i;j<abs(tmp);j++) ans[j]=122;
    }
    puts(ans);
  }
}


Measured memory_bytes: 2144
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 入力
		String s = sc.next();

		// 計算
		int n = 0;
		
		for(int i = 0; i < s.length(); i++){
			int m = Integer.parseInt(s.substring(i, i+1));
			n = n + m;
		}

		// 出力
		System.out.println(n);

	}

}




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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int L[101010];
vector<pair<int,int>> E[101010];
int N,M;
ll NL[3],NG,NE;

void dfs(int cur,int pre) {
	NL[L[cur]]++;
	FORR(r,E[cur]) {
		if(r.second==1) NE++;
		if(L[r.first]==-1) {
			L[r.first]=(L[cur]+r.second)%3;
			dfs(r.first,cur);
		}
		else {
			if(L[r.first]!=(L[cur]+r.second)%3) NG++;
		}
	}
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back({y-1,1});
		E[y-1].push_back({x-1,2});
	}
	
	MINUS(L);
	ll ret=0;
	FOR(i,N) if(L[i]==-1) {
		NL[0]=NL[1]=NL[2]=0;
		NG=NE=0;
		L[i]=0;
		dfs(i,-1);
		if(NG) ret += (NL[0]+NL[1]+NL[2])*(NL[0]+NL[1]+NL[2]);
		else if(NL[1]==0 || NL[2]==0) ret += NE;
		else ret += NL[0]*NL[1]+NL[1]*NL[2]+NL[2]*NL[0];
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 10880
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

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

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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


int main() {
	string S;
	cin >> S;
	string T = S.substr(0, 3);
	cout << T << endl;
}

Measured memory_bytes: 3596
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

X, Y, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

if (X + Y) % 3 != 0:
    print(0)
    exit()

a = (2 * X - Y) // 3
b = X - 2 * a

if a < 0 or b < 0:
    print(0)
    exit()

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print(combination(a+b,a))

Measured memory_bytes: 3316
#include<stdio.h>
#define MAX 1000000
int binarySearch(int);

int A[MAX],n;

int main(){
  int q,i,x,cnt=0;

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

  scanf("%d",&q);
  for(i=0;i <= q-1;i++){

    scanf("%d",&x);
    if(binarySearch(x)){
      cnt++;
    }}
  printf("%d\n",cnt);
  return 0;
}

int binarySearch(int key){
  int left=0,right=n,mid;
  while(right>left){
    mid=(right+left)/2;
    if(key == A[mid]){
      return 1;
    }
    if(key > A[mid]){
      left = mid +1;
    }

    else if(key < A[mid])right=mid;
  }
  return 0;
}

    



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

#define MOD 1000000007

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


int main(int argc, char const *argv[]) {
    int N;
    cin >> N;

    vector<ll> A(N);
    bool zero = false;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] == 0) zero = true;
    }

    if (zero) {
        cout << 0 << endl;
        return 0;
    }


    ll ans = 1;
    for (int i = 0; i < N; ++i) {
        // print(log10((double)ans) + log10((double)A[i]));
        if (log10((double)ans) + log10((double)A[i]) > 18 || ans * A[i] > 1000000000000000000) {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4108
x = input()
a, b = int(x[0:2]), int(x[2:4])
flag = 0
ans = ["AMBIGUOUS", "YYMM", "MMYY", "NA"]

if (a >= 1 and a <= 12) and (b >= 1 and b <= 12):
    flag = 0
elif (a == 0 and b > 12) or (b == 0 and a > 12) or (b > 12 and a > 12) or (b == 0 and a == 0):
    flag = 3
elif ((a > 0 and a <= 12) and (b >= 13)) or (b == 0 and (a >= 1 and a <= 12)):
    flag = 2
elif ((a >= 13) and (b > 0 and b <= 12)) or (a == 0 and (b >= 1 and b <= 12)):
    flag = 1


print(ans[flag])


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

#define MAXN 10000010
#define X first
#define Y second

typedef long long ll;

int N, n, m;
bool flag[MAXN];
int p[MAXN], x[200], y[200], link[200], vis[200];

vector<int> E[200], lis, a;

bool Find(int x)
{
	for (int i = 0; i < E[x].size(); ++i)
	{
		int y = E[x][i];
		if (vis[y]) continue;
		vis[y] = true;
		if (!link[y] || Find(link[y]))
		{
			link[y] = x;
			return true;
		}
	}
	return false;
}

int Hungary()
{
	int res = 0;
	for (int i = 1; i <= n; ++i)
	{
		memset(vis, 0, sizeof(vis));
		res += Find(i);
	}
	return res;
}

int main()
{
	//freopen("in.in", "r", stdin);
	//freopen("out.out", "w", stdout);
	
	flag[1] = true;
	for (int i = 2;  i < MAXN; ++i)
	{
		if (!flag[i]) p[++p[0]] = i;
		for (int j = 1; j <= p[0] && i * p[j] < MAXN; ++j)
		{
			flag[i * p[j]] = true;
			if (i % p[j] == 0)
				break;
		}
	}
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i)
	{
		int x; 
		scanf("%d", &x);
		lis.push_back(x);
	}
	sort(lis.begin(), lis.end());
	for (int i = 0; i < lis.size();)
	{
		int j = i;
		while (j + 1 < lis.size() && lis[j + 1] == lis[i] + j + 1 - i)
			++j;
		a.push_back(lis[i]);
		a.push_back(lis[j] + 1);
		i = j + 1;
	}
	sort(a.begin(), a.end());
	a.erase(unique(a.begin(), a.end()), a.end());
	for (int i = 0; i < a.size(); ++i)
	{
		if (a[i] & 1) x[++n] = a[i];
		else y[++m] = a[i];
		//cout << i << " " << a[i] << endl;
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)
		{
			int t = abs(x[i] - y[j]);
			if ((t & 1) && !flag[t])
				E[i].push_back(j);
		}
	
	int k = Hungary();
	int ans = k + ((n - k) / 2 + (m - k) / 2) * 2 + ((n - k) & 1) * 3;
	printf("%d\n", ans);
	return 0;
}

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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

ll a,x,mid,a1;

ll bs_neg(ll l,ll h)
{
    while(l<=h)
    {
        mid=(l+h)/2;
        if(a1-pow(mid,5)==x)    return mid;
        else if(a1-pow(mid,5)>x)     l=mid+1;
        else    h=mid-1;
    }
    return 1;
}

ll bs_pos(ll l,ll h)
{
    while(l<=h)
    {
        mid=(l+h)/2;
        if(a1-pow(mid,5)==x)    return mid;
        else if(a1-pow(mid,5)>x)    l=mid+1;
        else    h=mid-1;
    }
    return -1;
}

int main() {
	fast_io;
	
	ll b=0;
	cin>>x;
	for(a=1;a<1001;a++)
	{
	    a1=pow(a,5);
	    if(a1==x)
	    {
	        b=0;
	        break;
	    }
	    else if(a1<x)
	    {
	        b=bs_neg(-2000,0);
	        if(b!=1)    break;
	    }
	    else
	    {
	        b=bs_pos(0,2000);
	        if(b!=-1)   break;
	    }
	}
	cout<<a<<" "<<b<<nl;
	return 0;
}


Measured memory_bytes: 4056
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
//#include<stdlib.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	int l = s.length(),t=0;
	for (int a = 1; a < l; a++)
	{
		if (s[a] == s[a - 1])
		{
			if (s[a] == '1') { s[a] = '0'; }
			else { s[a] = '1'; }
			t++;
		}
	}
	cout << t;
	return 0;
}

Measured memory_bytes: 512