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

int main() {
  int N,cnt1,maxcnt1=0,cnt2,maxcnt2=0,answer=0;
  cin >> N;
  vector<string> s(N);
  vector<string> word;
  vector<string> delword;
  
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> t(M);
  
  for (int j = 0; j < M; j++) {
    cin >> t.at(j);
  }
  //// cout << delword.size() << endl;

  for (int o =0; o < N; o++) {
    // cout << "s.size():" << s.size() << endl;
    //　delword削除
    vector<string> S;
    if (delword.size() > 0) {
      for (int r = 0; r < s.size(); r++) {
        if (s.at(r) != delword.at(0)) {
          S.push_back(s.at(r));
              // cout << "S.size():" << S.size() << endl;
        }
      }
      s = S;
    }
      // cout << "s:" << s.at(0) << endl;
      // cout << "s.size():" << s.size() << endl;
    //　重複チェック
    maxcnt1 =0;
    for (int k = 0; k < s.size(); k++) {
      cnt1 = 0;
      for (int l = 0; l < s.size(); l++) {
        if (s.at(k) == s.at(l)) {
          cnt1++;
          // // cout << "s.at(k):"<< s.at(k) << endl;
        }
        if (maxcnt1 < cnt1) {
          maxcnt1 = cnt1;
          word = {s.at(k)};
          // cout << "wordchange:" << word.at(0) << maxcnt1 << endl;
        }
      }
    }
    // cout << "word:" << word.at(0) << endl;
    // cout << "maxcnt1:" << maxcnt1 << endl;

    //　delword削除2
    vector<string> T;
    if (delword.size() > 0) {
      for (int n = 0; n < t.size(); n++) {
        if (t.at(n) != delword.at(0)) {
          T.push_back(t.at(n));
        }
      }
      t = T;
    }
    // cout << "t.size():" << t.size() << endl;
    //　重複チェック
    maxcnt2 = 0;
    for (int m = 0; m < t.size(); m++) {
      if (word.at(0) == t.at(m)) {
        maxcnt2++;
      }
    }
    // cout << "maxcnt2:" << maxcnt2 << endl;
    // 最終チェック
    delword = word;
    if (answer < (maxcnt1 - maxcnt2)) {
      answer = maxcnt1 - maxcnt2;
      // cout << "answer:" << answer << endl;

    } 
    /*
    if (s.size() == 1 && s.at(0) == delword.at(0)) {
      // cout << "break!" <<endl;
      break;
    }
    */
    if (s.size() < answer) {
      // cout << "break!" <<endl;
      break;
    }
      // cout << "s.size():" << s.size() << endl;
    if (s.size() == 0) {
      break;
    }
      // cout << endl;

    /*
    if (maxcnt1 <= maxcnt2) {
      delword = word;
      // delword.at(0) = word.at(0);
      maxcnt1 = 0;
    // cout << "delword:" << word.at(0) << endl;
    // cout << endl;
    } else if (answer < (maxcnt1 - maxcnt2)){
      answer = maxcnt1 - maxcnt2;
      // cout << "answer:"  << answer << endl;
      //break;
    }
    */
  }
    if (answer < 0) {
      answer = 0;
    }
  cout << answer << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int main() {
  int N, K; cin >> N >> K;
  vector<int> d(K);
  vector<vector<int>> A(K);
  REP(i, K) {
    cin >> d[i];
    REP(k, d[i]) {
      int a;
      cin >> a;
      A[i].push_back(a);
    }
  }

  vector<int> snuke(N + 1);
  for(int i = 0; i < K; ++i) {
    for(int k = 0; k < d[i]; ++k) {
      snuke[A[i][k]]++;
    }
  }

  int ans = 0;
  for(int i = 1; i <= N; ++i) {
    if(snuke[i] == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
// as constraints are low O(N2) will work
#include <bits/stdc++.h>

using namespace std;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int  R,G,B,N;

    cin >> R >> G >>  B >>  N;

    int ans = 0; 

    for(int i = 0; i <= 3000; ++i){
        for(int j = 0; j <= 3000; ++j){
            int v =  i * R + j * G; 

            if (N >= v && (N- v) % B == 0) ++ans;
        }
    }

    cout << ans << "\n";
    
    
  
    return 0;
}

Measured memory_bytes: 256
s = input()
slen = len(s) - 1
sum = 0
for i in range(2 ** (slen)):
    oplist = [""]*(len(s)-1)
    for j in range(slen):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            oplist[len(s) - 2 - j] = "+"

    siki = ""
    for i in range(len(oplist)):
        siki += s[i] + oplist[i]
    siki += s[-1]
    sum += eval(siki)

print(sum)


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

void solve() 
{
    int x;cin>>x;if(x>=30)cout<<"Yes"<<endl;else cout<<"No"<<endl;
}

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

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

int main() {
  string s; cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s.at(i-1) == s.at(i)) {
      cout << i << " " << i+1 << endl;
      return 0;
    }
  }
  for (int i = 2; i < s.size(); i++) {
    if (s.at(i-2) == s.at(i)) {
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		for (int i = s.length() -1 ; i > 0 ; i--){
			String convS = s.substring(0, i);
			int len = convS.length();
			if (len % 2 == 0){
				String zenhanS = convS.substring(0, len / 2);
				String kohanS = convS.substring((len / 2), len);
				if (zenhanS.equals(kohanS)){
					System.out.println(len);
					break;
				}
			}
		}

	}

}


Measured memory_bytes: 22612
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "ctime"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<int>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	*v.rbegin() /= 2;
	cout<<accumulate(v.begin(), v.end(), 0) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    char a,b;cin >>a>>b;
    if(a=='H') cout << b << endl;
    else cout << (b=='H' ? 'D' : 'H') << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

fromLeftA = [-1]*n

for i in range(n):
    fromLeftA[i] = a[i] - i

ans = 0
ldList = [0]*(n*2)

for i in reversed(range(n)):
    if 0 <= fromLeftA[i]+n and fromLeftA[i]+n < n*2:
        ldList[fromLeftA[i]+n] += 1
    if 0 <= -1*a[i]-i+n and -1*a[i]-i+n < n*2:
        ans += ldList[-1*a[i]-i+n]

print(ans)

Measured memory_bytes: 32284
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
using namespace std;

#define N_MAX 1000

char X[N_MAX];
char Y[N_MAX];
int LCS[N_MAX+1][N_MAX+1];


int longest(int x, int y)
{
    for (int i = 0; i < x+1; i++) {
        for (int j = 0; j < y+1; j++) {
            if (i == 0 || j == 0) {
                LCS[i][j] = 0;
//                printf("0 LCS[%d][%d] = %d\n", i, j, LCS[i][j]);
            }
            else if (X[i-1] == Y[j-1]) {
                LCS[i][j] = LCS[i-1][j-1] + 1;
//                printf("1 LCS[%d][%d] = %d\n", i, j, LCS[i][j]);
            }
            else {
                LCS[i][j] = (LCS[i-1][j] > LCS[i][j-1]) ? LCS[i-1][j] : LCS[i][j-1]; 
//                printf("LCS[%d][%d] = %d\n", i, j, LCS[i][j]);
            }
        }
    }

    return LCS[x][y]; 
}

int main() {
    int q;
    int x;
    int y;

    cin >> q;

    for (int i = 0; i < q; i++) {
        scanf("%s", X);
        x = strlen(X);
        scanf("%s", Y);
        y = strlen(Y);
        cout << longest(x, y) << endl;
    }
        
    return 0;
}



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

using namespace std;

int main(){
	vector<int> x, y;
	int n, tmp, p;
	double sum, ans;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> tmp;
		x.push_back(tmp);
	}
		for(int i = 0; i < n; i++){
		cin >> tmp;
		y.push_back(tmp);
	}

	for(p = 1; p <= 3; p++){
		sum = 0;
		for(int i = 0; i < n; i++)
			sum += pow((double)abs(x[i] -y[i]),(double)p);
		ans = pow(sum,(double)1/p);
		printf("%.8lf\n",ans);
	}
	ans = 0;
	for(int i = 0; i < n; i++)
		ans = max(ans, (double)abs(x[i]-y[i]));
	printf("%.8lf\n",ans);	return 0;
}

Measured memory_bytes: 1300
#include<bits/stdc++.h>
using namespace std;
struct data{
    int frq;
    int value;
};
data Mx,My;
int n,i,x[50005],y[50005],cou,mx,my,ans;
int main(){

    scanf("%d",&n);
    n/=2;
    for(i=1;i<=n;i++){
        scanf(" %d %d",&x[i],&y[i]);
    }
    sort(x,x+n+1);
    sort(y,y+n+1);
    /*for(i=1;i<=n;i++){
        cout << x[i] << ' ';
    }
    cout << endl;
    for(i=1;i<=n;i++){
        cout << y[i] << ' ';
    }
    cout << endl;*/
    cou=0;
    for(i=1;i<=n;i++){
        cou++;
        if(x[i]!=x[i+1]){
            if(cou>Mx.frq){
                Mx.value=x[i];
                Mx.frq=cou;
            }
            cou=0;
        }
    }
    cou=0;
    for(i=1;i<=n;i++){
        cou++;
        //cout << cou;
        if(y[i]!=y[i+1]){
            if(cou>My.frq){
                My.value=y[i];
                My.frq=cou;
            }
            cou=0;
        }
    }
    cou=0;
    for(i=1;i<=n;i++){
        if(x[i]==Mx.value){
            continue;
        }
        cou++;
        if(x[i]!=x[i+1]){
            mx=max(mx,cou);
            cou=0;
        }
    }
    cou=0;
    for(i=1;i<=n;i++){
        if(y[i]==My.value){
            continue;
        }
        cou++;
        if(y[i]!=y[i+1]){
            my=max(my,cou);
            cou=0;
        }
    }
    ans+=n*2;
    if(Mx.value != My.value){
        ans -= Mx.frq;
        ans -= My.frq;
    }
    else{
        if(Mx.frq + my > My.frq + mx){
            ans -= Mx.frq;
            ans -= my;
        }
        else{
            ans -= My.frq;
            ans -= mx;
        }

    }
    //cout << Mx.frq << endl << My.frq << endl << mx << endl << my << endl;
    cout << ans;
}


Measured memory_bytes: 640
n=int(input())
li=list(map(int,input().split()))
li.sort()
a_max=li[-1]
dp=[0]*(a_max+1)
ans=0

for a in li:
  for aj in range(a,a_max+1,a):
    dp[aj]+=1
for a in li:
  if dp[a]==1:
    ans+=1
print(ans)

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

long long N, K;
long A[200005];

bool can(long long l) {
	long long num = 0;
	for(long long i = 0; i < N; i++) {
		if(A[i] % l == 0) {
			num += A[i]/l - 1;
		} else {
			num += A[i]/l;
		}
	}
	return num <= K;
}

int main(){
	cin >> N >> K;
	long start = 0;
	long end = 0;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
		end = max(end, A[i]);
	}

	while(start + 1 < end) {
		long long mid = (start + end)/2;
		if(can(mid)) {
			end = mid;
		} else {
			start = mid;
		}
	}
	cout << end << endl;
}


Measured memory_bytes: 5172
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	cout<<shosu(3);
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f){
		double tmp=a*e-b*d;
		double ansx=(c*e-b*f)/tmp;
		double ansy=(a*f-c*d)/tmp;
		if(ansx==-0) ansx=0;
		if(ansy==-0) ansy=0;
		cout<<ansx<<' '<<ansy<<endl;
	}
}

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

int main()
{
	int n,l[10],maxv=0,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l[i];
		maxv=max(maxv,l[i]);
		sum+=l[i];
	}
	
	cout<<((maxv<sum-maxv)? "Yes":"No")<<endl;
	
	return 0;
}


Measured memory_bytes: 256
def chk(mat,exp,y,x)
  if mat[y][x]==1
    exp.push([x,y])
    mat[y][x]=0
  end
  return mat,exp
end
ds,cnt=gets.to_i,0
ds.times do
  mat,=[],gets
  8.times{mat << gets.chomp.split("").map(&:to_i)}
  exp=[[gets.to_i-1,gets.to_i-1]]
  while !exp.empty?
    e=exp.pop
    mat[e[1]][e[0]]=0
    3.times do |i|
      mat,exp=chk(mat,exp,[e[1]-3+i,0].max,e[0])
      mat,exp=chk(mat,exp,e[1],[e[0]-3+i,0].max)
      mat,exp=chk(mat,exp,[e[1]+1+i,7].min,e[0])
      mat,exp=chk(mat,exp,e[1],[e[0]+1+i,7].min)
    end
  end
  puts "Data #{cnt+=1}:"
  mat.each{|i|
    puts i.join
  }
end

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

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

    int i = 0, j = 0;
    for(; j < n; ++j) {
        if (s[j] == '0' and (j == 0 or s[j-1] == '1')) --k;
        if (k < 0) {
            if (s[i] == '0' and s[i+1] == '1') ++k;
            ++i;
        }
    }

    cout << j - i << endl;
}


Measured memory_bytes: 512
/*                                  /   \                                 */      
/*                                 /*****\                               */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K             */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x%MOD;else return (x*n)%MOD;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}  
long long power(long long x, 
                         ll y, ll p) 
{ 
    long long res = 1; // Initialize result 
  
    x = x % p; // Update x if it is more than or 
    // equal to p 
  
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
long long modInverse(long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
long long nCrModPFermat(long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    long long fac[n + 1]; 
    fac[0] = 1; 
    for (ll i = 1; i <= n; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
    return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;


//	   cin>>t;
	      while(t--)
{
ll n,m,j,k,l,i;
cin>>n;
ll dp[100000];
fo(i,100000)
dp[i]=1;
dp[0]=0,dp[1]=0,dp[2]=0,dp[3]=1,dp[4]=1,dp[5]=1;
for(i=6;i<=n;i++)
{
	for(j=0;j<=i-3;j++)
	{
		dp[i]+=dp[j];
		dp[i]%=MOD;
	}
}
cout<<dp[n];
ee;		
}
return 0;
}









Measured memory_bytes: 4412
#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 N;
ll A,B;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	cin>>A;
	for(i=1;i<N;i++) {
		cin>>B;
		A*=B/__gcd(A,B);
	}
	cout<<A<<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: 256
import sys
input = sys.stdin.readline
N,W= map(int,input().split())
ans=[[0 for e in range(W+1)] for f in range(N+1)]
for i in range(N):
 w,v=map(int,input().split())
 for k in range(0,w):
  ans[i+1][k]=ans[i][k]
 for j in range(w,W+1):
  ans[i+1][j]=max(ans[i][j-w]+v,ans[i][j])
print(max(ans[N]))

Measured memory_bytes: 171400
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

	    int N = Integer.parseInt(scanner.next());
	    String[] S  = new String[N];
	    Map<String, Integer> m=new HashMap<String, Integer>();

	    for (int i=0; i<N; i++) {
	        String s = scanner.next();
	        char[] cs= s.toCharArray();
	        Arrays.parallelSort(cs);
	        s = new String(cs);
	        if (m.containsKey(s)) {
	            int a = m.get(s);
	        	m.put(s, a+1);
	        } else {
	        	m.put(s, 1);
	        }
	    }

	    long r=0;
	    for(Map.Entry<String, Integer> entry : m.entrySet()){
	        r+= f(entry.getValue());
	    }

        System.out.print(r);
	}

	public static long f(int n) {
		if (n==1) {
			return 0;
		} else {
			return n-1 + f(n-1);
		}
	}

}

Measured memory_bytes: 69844
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint n;
llint a[200005], cnt[200005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	for(int i = 1; i <= n; i++){
		llint tmp = ans - cnt[a[i]]*(cnt[a[i]]-1)/2;
		tmp += (cnt[a[i]]-2)*(cnt[a[i]]-1)/2;
		cout <<tmp << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4736
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int a[101];
	int n; cin>>n;
	for(int i=0; i<n; i++) cin>>a[i];
	int ans=0;
	for(int i=0; i<n; i+=2){
		if(a[i]%2==1) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

string ConvertFrom10(int value, int base)
{
    if(base < 2 || base > 36)
        return "0";

    bool isNegative = (value < 0);
    if(isNegative)
        value *= -1;

    // NOTE: it's probably possible to reserve string based on value
    string output;

    do
    {
        char digit = value % base;

        // Convert to appropriate base character
        // 0-9
        if(digit < 10)
            digit += '0';
        // A-Z
        else
            digit = digit + 'A' - 10;

        // Append digit to string (in reverse order)
        output += digit;

        value /= base;

    } while (value > 0);

    if(isNegative)
        output += '-';

    // Reverse the string - NOTE: could be done with std::reverse
    int len = output.size() - 1;
    for(int i = 0; i < len; ++i)
    {
        // Swap characters - NOTE: Could be done with std::swap
        char temp = output[i];
        output[i] = output[len-i];
        output[len-i] = temp;
    }

    return output;
}


 main()

{
    fast
    int n,k;
    cin>>n>>k;
    string ses=ConvertFrom10(n,k);
    cout<<ses.size()<<endl;
    return 0;

}













Measured memory_bytes: 256
n = int(input())
l = []
n -= 1
while True:
    l.append(n % 26)
    if n <= 25:
        break
    n //= 26
    n -= 1
l.reverse()
ans = ""
for i in range(len(l)):
    ans += chr(97 + l[i])
print(ans)

Measured memory_bytes: 9176
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int H, W;
  cin >> H >> W;
  char A[H][W];
  REP(i, H) REP(j, W) cin >> A[i][j];
  int dist[H][W];
  REP(i, H) REP(j, W) dist[i][j] = -1;
  queue<P> que;
  REP(i, H) REP(j, W) {
    if (A[i][j] == '#') {
      que.push(P(i, j));
      dist[i][j] = 0;
    }
  }
  int dy[4] = {-1, 0, 1, 0};
  int dx[4] = {0, 1, 0, -1};
  while (que.size()) {
    P p = que.front();
    que.pop();
    REP(i, 4) {
      int ny = p.first + dy[i];
      int nx = p.second + dx[i];
      if (0 <= ny && ny < H && 0 <= nx && nx < W && dist[ny][nx] == -1) {
        que.push(P(ny, nx));
        dist[ny][nx] = dist[p.first][p.second] + 1;
      }
    }
  }
  int ans = 0;
  REP(i, H) REP(j, W) ans = max(ans, dist[i][j]);
  cout << ans << endl;
  return 0;
}

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

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

#define ALL(v) v.begin(), v.end()

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

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

int main() {
  int64_t A, B;
  cin >> A >> B;

  cout << lcm(A,B) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int n, a;
vector<int> vec;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		vec.pb(a);
	}
	sort(vec.begin(), vec.end());
	//vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	int ans = 0, sz = vec.size();
	for (int i = 0; i < sz; i++) {
		for (int j = i + 1; j < sz; j++) {
			for (int k = j + 1; k < sz; k++) {
				if (vec[i] == vec[j] || vec[i] == vec[k]) continue;
				if (vec[j] == vec[k]) continue;
				if (vec[i] + vec[j] > vec[k])
					ans++;
			}
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3660
a = []
b = []
n, m, l = gets.split.map(&:to_i)
n.times {a << gets.split.map(&:to_i)}
m.times {b << gets.split.map(&:to_i)}

n.times do |ni|
	l.times do |li|
		sum = 0
		m.times do |mi|
			sum += a[ni][mi] * b[mi][li]
		end
		print ' ' if li != 0
		print sum
	end
	puts
end

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}
template<class T,class E,class F,class G,class H>
struct LazySegmentTree{
	F f;
	G g;
	H h;

	T ti;
	E ei;

	vector<T>dat;
	vector<E>put;
	int sz;
	LazySegmentTree(const T &ti,const E &ei,const F &f,const G &g,const H &h):ti(ti),ei(ei),f(f),g(g),h(h){}

	void build(const vector<T>&v){
		assert(v.size());
		sz=1;
		while(sz<v.size())sz<<=1;
		dat.resize(sz<<1,ti);
		put.resize(sz<<1,ei);
		for(int i=0;i<v.size();i++)dat[sz-1+i]=v[i];
		for(int i=sz-2;i>=0;i--)dat[i]=f(dat[i*2+1],dat[i*2+2]);
	}
	inline void push(int k,int l,int r){
		dat[k]=g(dat[k],put[k],r-l);
		if(k<sz-1){
			put[k*2+1]=h(put[k*2+1],put[k]);
			put[k*2+2]=h(put[k*2+2],put[k]);
		}
		put[k]=ei;
	}

	void modify(int a,int b,E x,int k,int l,int r){
		push(k,l,r);
		if(r<=a||b<=l)return;
		if(a<=l&&r<=b){
			put[k]=x;
			push(k,l,r);
			return;
		}
		modify(a,b,x,k*2+1,l,(l+r)/2);
		modify(a,b,x,k*2+2,(l+r)/2,r);
		dat[k]=f(dat[k*2+1],dat[k*2+2]);
	}

	inline void modify(int a,int b,E x){
		return modify(a,b,x,0,0,sz);
	}
	T query(int a,int b,int k,int l,int r){
		push(k,l,r);
		if(r<=a||b<=l)return ti;
		if(a<=l&&r<=b)return dat[k];
		return f(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2,r));
	}
	inline T query(int a,int b){
		return query(a,b,0,0,sz);
	}
};

signed main(){
	auto f=[](int a,int b){return min(a,b);};
	auto g=[](int a,int b,int l){return a+b;};
	auto h=[](int a,int b){return a+b;};
	int ti=numeric_limits<int>::max();
	int ei=0;

	LazySegmentTree<int,int,decltype(f),decltype(g),decltype(h)>seg(ti,ei,f,g,h);

	int N,Q;
	scanf("%lld%lld",&N,&Q);
	seg.build(vint(N,0));
	while(Q--){
		int p,s,t,x;
		scanf("%lld%lld%lld",&p,&s,&t);
		t++;
		if(p==0){
			scanf("%lld",&x);
			seg.modify(s,t,x);
		}
		else{
			printf("%lld\n",seg.query(s,t));
		}
	}
	return 0;
}


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 300200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int s[N];
char c[N];

void solve()
{
        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> c[i];
                s[i] = s[i - 1] + (c[i] == 'W');
        }
        int ans = n;
        for(int i = 1; i <= n; i++){
                ans = min(ans, s[i - 1] + (n - i) - (s[n] - s[i]));
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
const ll M = 1e9 + 7;

ll power(ll a, ll b) {
  ll x = 1, y = a;
  while (b > 0) {
    if (b % 2) x = (x * y) % M;
    y = y * y % M;
    b /= 2;
  }
  return x % M;
}

ll inv(ll a) {
  return power(a, M - 2);
}

int main() {
  ll n, k; cin >> n >> k;
  vector<int> a(n);
  for (auto&x : a) cin >> x;
  
  sort(a.begin(),a.end());
  
  vector<ll> fac(n + 1);
  fac[0] = 1;
  for (ll i = 1; i <= n; i++) {
    fac[i] = (fac[i - 1] * i) % M;
  }
  
  auto comb = [&](ll a, ll b) -> ll {
    ll res = fac[a];
    res = (res * inv(fac[b])) % M;
    res = (res * inv(fac[a - b])) % M;
    return res;
  };
  
  ll ans = 0;
  for (int i = n - 1; i >= k - 1; i--) {
    ll tmp = (comb(i, k - 1) * a[i]) % M;
    ans = (ans + tmp) % M;
    
    tmp = (comb(i, k - 1) * a[n - 1 - i]) % M;
    ans = (ans - tmp + M) % M;
  }
  cout << (ans+M)%M << endl;
}

Measured memory_bytes: 1408
#include<cstdio>
using namespace std;
int main(void)
{
	int y,m,d,i,j,x,d1[4],y2;
	int yy[4]={1868,1912,1926,1989},mm[4]={9,7,12,1},dd[4]={8,30,25,8};
	for(i=0;i<4;i++)	{
		d1[i]=yy[i]*10000+mm[i]*100+dd[i];
	}
	while(scanf("%d %d %d",&y,&m,&d)!=EOF)	{
		x=y*10000+m*100+d;
		if(x<d1[0])	{
			printf("pre-meiji\n");
		}
		else if(x<d1[1])	{
			y2=y-yy[0]+1;
			printf("meiji %d %d %d\n",y2,m,d);
		}
		else if(x<d1[2])	{
			y2=y-yy[1]+1;
			printf("taisho %d %d %d\n",y2,m,d);
		}
		else if(x<d1[3])	{
			y2=y-yy[2]+1;
			printf("showa %d %d %d\n",y2,m,d);
		}
		else {
			y2=y-yy[3]+1;
			printf("heisei %d %d %d\n",y2,m,d);
		}
	}
	return 0;
}


Measured memory_bytes: 1036
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  string s;
  cin>>s;
  if(s[K-1]=='A') {
    s[K-1]='a';
  }
  else if(s[K-1]=='B') {
    s[K-1]='b';
  }
  else {
    s[K-1]='c';
  }
  cout<<s<<endl;
  return 0;
}

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

using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int n, q;
ll a[100005];
ll sum[100005], sum2[100005];
int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    std::cin >> n >> q;

    for (int i = 1; i <= n; ++i) {
        std::cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        sum2[i] = sum2[i - 1];
        if (i % 2 == 1)
            sum2[i] += a[i];
    }

    for (int i = 0; i < q; ++i) {
        ll x;
        std::cin >> x;

        int l = 1, r = n;
        while (r - l > 0) {
            auto aa = (l + r) / 2;
            auto bb = (aa + n) / 2;
            auto aval = std::abs(x - a[aa]);
            auto bval = std::abs(x - a[bb]);

            if (aval < bval) {
                r = aa;
            }
            else if (aval > bval) {
                if (l == aa)
                    l = aa + 1;
                else
                    l = aa;
            }
            else {
                l = r = aa;
            }
        }

        r = l + (n - l + 1) / 2 - 1;

        ll ans = sum[n] - sum[r];
        if (n - r == r - l + 1) {
            if ((l - 1) % 2 == 1)
                ans += sum2[l - 1];
            else
                ans += sum[l - 1] - sum2[l - 1];
        }
        else if (l > 1) {
            if ((l - 2) % 2 == 1)
                ans += sum2[l - 2];
            else
                ans += sum[l - 2] - sum2[l - 2];
        }

        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<cstring>
#include<cmath>
#include<iterator>
#include<cstdlib>
#define IOS   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ses   "\n"
#define whp   " "
#define mxi 99999
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define PI acos(-1)
#define sz(a) long long(a.size())
#define ff first
#define ss second
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep0(i,a,b) for(int i=a; i<b; i++)
#define rep1(i,a,b) for(int i=a; i<=b; i++)
#define rep0in(i,a,b) for(int i=a-1; i>=b; i--)
#define rep1in(i,a,b) for(int i=a; i>b; i--)
#define repv(i,a) for(auto i=a.begin(); i!=a.end();++i)
//ostringstream str1;
 //       str1 << z;
  //      string c=str1.str();
///priority_queue <int, vector<int>, greater<int>> g
#define MS(a,b) memset(a,b,sizeof(a));

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll fx[4]= {1,-1,0,0};
ll fy[4]= {0,0,1,-1};

typedef vector<ll> vll;
typedef vector<string> vss;
typedef vector<pair<ll,ll > > vpr;
typedef vector<pair<string,ll > > vspr;
typedef list<ll> li;
typedef list<string> ls;
typedef list<pair<ll,ll> > lpr;
typedef list<pair<string,ll> > lspr;
bool rs(ll a, ll b){return(a>b);}
ll spd(ll n){ if(n%2==0)return 2; for(ll i=3; i*i<=n; i++){if(n%i==0)return i;}return n;}

int main(){
string s; cin>>s;
vll v,v2;
for(ll i=0; i<s.length(); i++){
    if(s[i]=='R')v.pb(1);
    else{
        if(v.size()>0){
        v2.pb(v.size());
        }
        v.clear();
    }
}
if(v.size()>0){
v2.push_back(v.size());
}
sort(v2.begin(),v2.end(),rs);
if(v2.size()>0)
cout<<v2[0]<<endl;
else cout<<0<<endl;

return 0;
}


Measured memory_bytes: 3624
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>

int main()
{
  int N, M;
  std::cin >> N >> M;
  
  std::vector<std::pair<long, int>> ab(N);
  for (int i = 0; i < N; ++i)
  {
    int A, B;
    std::cin >> A >> B;
    ab[i] = {A, B};
  }
  std::sort(ab.begin(), ab.end(), [](auto l, auto r) { return l.first < r.first; });
  
  long x = 0;
  for (int i = 0; M; ++i)
  {
    auto n = std::min(ab[i].second, M);
    x += ab[i].first * n;
    M -= n;
  }
  
  std::cout << x << std::endl;
}

Measured memory_bytes: 1792
n = gets.to_i

i = 1
while i <= n
  x = i
  if (x % 3).zero?
    print " #{i}"
  else
    until x.zero?
      if x % 10 == 3
        print " #{i}"
        break
      else
        x /= 10
      end
    end
  end
  i += 1
end
puts


Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define int long long
#define all(c) (c).begin(),(c).end()
#define pii pair<long long,long long>
#define endl '\n'

using namespace std;

signed main(){
    std::ios::sync_with_stdio(false);
    int a,b,c,x,y;
    cin >> x >> y >> a >> b >> c;
    vector<int> A(a,0);
    vector<int> B(b,0);
    vector <int> C(c,0);
    for(int i=0;i<a;i++){
        cin >>A[i];
    }
    for(int i=0;i<b;i++){
        cin >> B[i];
    }
    for(int i=0;i<c;i++){
        cin >> C[i];
    }
    vector<int> L(x+y,0);
    sort(all(A));
    sort(all(B));
    sort(all(C));
    for(int i=0;i<x;i++){
        L[i]=A[a-1-i];
    }
    for(int i=0;i<y;i++){
        L[i+x]=B[b-1-i];
    }
    sort(all(L));
    for(int i=0;i<min(x+y,c);i++){
        if(L[i]<C[c-1-i]){
            L[i]=C[c-1-i];
        }
        else break;
    }
    int ans=0;
    for(int i=0;i<x+y;i++){
        ans+=L[i];
    }
    cout << ans;
}


Measured memory_bytes: 3968
#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(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr 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; }

void _main() {
  int N;
  cin >> N;
  int a[N];
  rep(i, 0, N) cin >> a[i];

  int ans = 0;
  rep(i, 1, N) {
    if (a[i-1] == a[i]) {
      ++ans;
      ++i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 17:16:53 2019

@author: yuta
"""

A,B,C,X,Y = list(map(int,input().split()))

def main(a,b,c,x,y):
    if a + b - 2*c > 0:
    #min(x,y)
        set_num_min = min(x,y)
        price_min = set_num_min * 2*c #セット分
        price_min += a * max(0,x-set_num_min) #Aの残り分
        price_min += b * max(0,y-set_num_min) #Bの残り分
    #max(x,y)
        set_num_max = max(x,y)
        price_max = set_num_max * 2*c #セット分
        print(min(price_min,price_max))
    else:
        price = a*x + b*y
        print(price)
main(A,B,C,X,Y)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll tableF[200010];
ll tableI[200010];

ll modfact(ll a,ll m){
   if(tableF[a] != -1){
      return tableF[a];
   }
   if(a == 1){
      tableF[a] = 1;
      return tableF[a];
   }
   ll res = 1;
   res = a * modfact(a-1,m);
   res %= m;
   tableF[a] = res;
   return res;
}

ll modpow(ll a,ll n,ll m){//modpow(a,n,m) := a ^ n (mod m)
  ll res = 1;
  while(n > 0){
    if(n & 1)res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a,ll p){//modinv(a,p) := pを法とするaの逆元(※pは素数でなければならない)
    ll res = modpow(a,p-2,p);
    return res;
}

ll modCON(ll n,ll r,ll m){
   if(n < 200010){
   ll res = 1;
   if(n < 0 || r < 0 || n < r){
      return 0;
   }
   res *= tableF[n];
   res %= m;
   res *= tableI[r];
   res %= m;
   res *= tableI[n-r];
   res %= m;
   return res;
   }else{
   ll res = 1;//tableを持ってないときよう
   for(int i = 1;i <= n;i++){
      res *= i;
      res %= m;
   }
   for(int i = 1;i <= r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   for(int i = 1;i <= n-r;i++){
      res *= modinv(i,m);
      res %= m;
   }
   return res;
   }
}

void modfill(ll m){//忘れない　約200ms
   fill(tableF,tableF+200010,-1);
   fill(tableI,tableI+200010,-1);
   tableF[0] = 1;
   tableI[0] = 1;
   for(int i = 1;i < 200010;i++){
      tableF[i] = modfact(i,m);
      tableI[i] = modinv(tableF[i],m);
   }
}


ll N,K;
Graph G(100010);

ll ans = 1;

void dfs(ll x,ll a = -1){
    ll n = G[x].size();
    if(x == 0){
        if(K-1 < n){
            ans = 0;
            return ;
        }
        ans *= tableF[K-1];
        ans %= MOD;
        ans *= tableI[K-1-n];
        ans %= MOD;
    }else{
        if(K-1 < n){
            ans = 0;
            return;
        }
        ans *= tableF[K-2];
        ans %= MOD;
        ans *= tableI[K-1-n];
        ans %= MOD;
    }
    rep(i,n){
        if(G[x][i] == a) continue;
        dfs(G[x][i],x);
    }
    return;
}

int main(){
    cin >> N >> K;
    modfill(MOD);
    rep(i,N-1){
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    if(K == 1){
        if(N == 1){
            cout << 1 << endl;
        }else{
            cout << 0 << endl;
        }
        return 0;
    }
    ans = K;
    dfs(0);
    cout << ans % MOD << endl;
}


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

main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B < C + D)
    cout << "Right" << endl;
  else if(A + B == C + D)
    cout << "Balanced" <<endl;
    else
      cout << "Left" << endl;
}

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

cnt = 0
dist = 0
for i in range(n-1):
    xi, yi = city[i][0], city[i][1]
    for j in range(i+1, n):
        xj, yj = city[j][0], city[j][1]
        dist += ((xi - xj)**2 + (yi - yj)**2)**0.5
        cnt += 1

print(dist*(n-1)/cnt)


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

int main() {
  int N;
  cin >>N;
  
  vector<int> A(N);
  vector<int> B(N-1);
  
  for(int i =0; i <N-1; i++){
    cin >> B.at(i);
  }
  
  A.at(0) = B.at(0);
  A.at(N-1) = B.at(N-2);
  
  for(int i =1; i<N-1; i++){
    A.at(i) = min(B.at(i-1),B.at(i));
  }
  int sum =0;
  for (int i=0; i<N; i++) {
    sum += A.at(i);
  }
  cout << sum << endl;
  
    
}

Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

num = N

if num >= A:
    num = A 

if num >= B:
    num = B

if num >= C:
    num = C

if num >= D:
    num = D

if num >= E:
    num = E

if N % num == 0:
    print(N // num + 4)
else:
    print(N // num + 5)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int check (std::vector<int> v, int x) {
	auto res = find(v.begin(), v.end(),x);
	return !(res == v.end());
}
int main () {
	std::vector<int> A = {1,3,5,7,8,10,12};
	std::vector<int> B = {4,6,9,11};
	std::vector<int> C = {2};
	int x,y;
	cin >> x >> y;
	if(check(A,x) && check(A,y)){
		cout << "Yes" << endl;
		return 0;
	}
	if(check(B,x) && check(B,y)){
		cout << "Yes" << endl;
		return 0;
	}
	if(check(C,x) && check(C,y)){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;

}

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

const int dx[9] = {0, 0, 0, 1, -1, -1, -1, 1, 1};
const int dy[9] = {0, -1, 1, 0, 0, -1, 1, -1, 1};

const long long mod = 100000007;

long long mod_pow(long long m, long long k) {
	long long res = 1;
	while(k > 0) {
		if(k & 1)
			(res *= m) %= mod;

		(m *= m) %= mod;
		k >>= 1;
	}
	
	return res;
}

long long mod_combination(long long n, long long r) {
	long long res = 1;
	if(r * 2 > n)
		r = n - r;

	for(long long i = 0; i < r; ++i)
		res = res * (n - i) % mod;

	long long tmp = 1;
	for(long long i = 1; i <= r; ++i)
		tmp = tmp * i % mod;

	res = res * mod_pow(tmp, mod - 2) % mod;

	return res;
}

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

	int r, c, ax, ay, bx, by;
	cin >> r >> c >> ay >> ax >> by >> bx;

	vector<int> x(9), y(9);
	int mn = INT_MAX;
	for(int i = 0; i < 9; ++i) {
		x[i] = abs(c * dx[i] + bx - ax);
		y[i] = abs(r * dy[i] + by - ay);
		if(mn > x[i] + y[i])
			mn = x[i] + y[i];
	}

	long long ans = 0;
	for(int i = 0; i < 9; ++i)
		if(mn == x[i] + y[i])
			ans = (ans + mod_combination(x[i] + y[i], y[i])) % mod;

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
s = input()
if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)
  

 

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	map<char,vector<int>> mp;
	rep(i,n){
		mp[s[i]].push_back(i);
	}
	ll ans=0;
	ll ind=-1;
	rep(i,m){
		if(!mp.count(t[i])){
			cout<<-1<<endl;
			return 0;
		}
		auto itr=upper_bound(begin(mp[t[i]]),end(mp[t[i]]),ind);
		if(itr==end(mp[t[i]])){
			ans+=(n-1-ind);
			ind=*begin(mp[t[i]]);
			ans+=ind+1;
		}else{
			ans+=*itr-ind;
			ind=*itr;
		}
	}
	cout<<ans<<endl;
}

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

int main(){
    int N, K, Q;  cin >> N >> K >> Q;
    vector<int> A(Q), score(N,0);
    for(int i=0; i<Q; i++){
        cin >> A[i];
        A[i]--;
        score[A[i]]++;
    }
    for(int i=0; i<N; i++){
        score[i] = K - (Q - score[i]);
        if(score[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (ll i=0; i<(n); i++)
#define repi(i,a,b) for (ll i=a;i<(b);i++)
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  vector<ll> a;
  //ll b[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};
  repi(i,2,sqrt(n)+1){
    if(n%i==0){
      goto out;
    }
  }
  cout<<n+1-2<<endl;
  return 0;
    
  out:
    repi(i,1,n+1){
      if(n%i==0){
        a.push_back(i);
        a.push_back(n/i);
      }
      if(i>=n/i){
        break;
      }
    }
  
  sort(a.begin(),a.end());
  ll m = a.size();
  cout<<a[m/2]+a[m/2-1]-2<<endl;
  return 0;
}
    

Measured memory_bytes: 384
from itertools import chain, combinations

def power_set(x):
	return chain.from_iterable(combinations(x, r) for r in range(len(x)+1))

def main():
	n = int(input())
	A = input()
	#print(n)
	A = list(map(int, A.split()))
	q = int(input())
	m = input()
	ms = list(map(int, m.split()))
	powerset = power_set(A)
	sum_set = [sum(s) for s in powerset if len(s)!=0]
	
	for m in ms:
		if m in sum_set:
			print('yes')
		else:
			print('no')

if __name__ == '__main__':
	main()

Measured memory_bytes: 45104