akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  int N;cin>>N;
  vector<int> a(N,0);
  rep(i,N) cin>>a[i];
  ll ans = 0;
  map<int,ll> dic;
  rep(i,N) {
    const auto & pf = prime_factorize(a[i]);
    for(auto p : pf) {
      if(dic[p.first] < p.second) {
	dic[p.first] = p.second;
      }
    }
  }
  ll lcm = 1;
  for(auto it = dic.begin();it!=dic.end();++it) {
    lcm = (lcm * modpow(it->first,it->second,MOD)) % MOD;
  }
  rep(i,N) {
    ans += lcm * modinv(a[i],MOD);
    ans %= MOD;
  }
  cout<<ans<<endl;
}


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

int main(){
    int n,d,x; cin >>n>>d>>x;
    int ans=x;
    for(int i=0; i<n; ++i){
        int a; cin >> a;
        ans+=(d-1)/a+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N, C;
int num[210000];

typedef pair<int,int> pint;
vector<pint> inp[35];

int main() {
	while (cin >> N >> C) {
        for (int i = 0; i < 35; ++i) inp[i].clear();
        for (int i = 0; i < N; ++i) {
            int s, t, c;
            cin >> s >> t >> c;
            inp[c].push_back(pint(s, t));
        }
        for (int i = 0; i < 35; ++i) {
            sort(inp[i].begin(), inp[i].end());
        }
        
        for (int i = 0; i < 35; ++i) {
            for (int j = 0; j < (int)inp[i].size() - 1; ++j) {
                if (inp[i][j].second == inp[i][j+1].first) {
                    inp[i][j+1].first = inp[i][j].first;
                    inp[i][j] = pint(1, 0);
                }
            }
        }
        
        for (int i = 0; i < 35; ++i) {
            for (int j = 0; j < inp[i].size(); ++j) {
                inp[i][j].first--;
            }
            
            if (!inp[i].empty()) {
                //COUT(i); COUT(inp[i]);
            }
        }
        
        memset(num, 0, sizeof(num));
        for (int i = 0; i < 35; ++i) {
            for (int j = 0; j < inp[i].size(); ++j) {
                num[inp[i][j].first]++;
                num[inp[i][j].second]--;
            }
        }
        
        for (int i = 0; i <= 100000; ++i) {
            num[i+1] += num[i];
        }
        
        int res = 0;
        for (int i = 0; i <= 100000; ++i) {
            chmax(res, num[i]);
            //if (i < 100) cout << i << ": " << num[i] << endl;
        }
        
        cout << res << endl;
	}
}




















Measured memory_bytes: 2304
#include <iostream>
#include<vector>
using namespace std;
int main()
{
	int n;
	cin >> n;

	
	for (int i = 0; i < n; i++) {
		char s;
		cin >> s;
		if (s == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

struct UnionFind {
  vector<int> parent, size;
  UnionFind(int n) : parent(n), size(n, 1) {
    rep(i,n) parent[i] = i;
  }
  int root(int v) {
    while(parent[v] != v) {
      parent[v] = parent[parent[v]];
      v = parent[v];
    }
    return v;
  }
  void unite(int v, int u) {
    v=root(v), u=root(u);
    if(size[u] < size[v]) swap(u,v);
    parent[v] = u;
    size[u] += size[v];
  }
  int find(int v, int u) {
    return root(v) == root(u);
  }
};

signed main() {
  int n; cin >> n;
  vector<int> x(n), y(n);
  rep(i,n) cin >> x[i] >> y[i];
  vector<int> xs(n), ys(n);
  rep(i,n) xs[i] = i, ys[i] = i;

  sort(xs.begin(), xs.end(), [&](int i,int j){return x[i] < x[j];});
  sort(ys.begin(), ys.end(), [&](int i,int j){return y[i] < y[j];});

  priority_queue<tuple<int, int, int>> q;
  rep(i,n-1) {
    q.emplace(-(x[xs[i+1]] - x[xs[i]]), xs[i], xs[i+1]);
    q.emplace(-(y[ys[i+1]] - y[ys[i]]), ys[i], ys[i+1]);
  }

  ll ans = 0;
  UnionFind uf(n);
  while (q.size()) {
    int c = -get<0>(q.top());
    int i = get<1>(q.top());
    int j = get<2>(q.top());
    q.pop();
    if(uf.find(i,j)) continue;
    ans += c;
    uf.unite(i,j);
  }
  cout << ans << endl;
}


Measured memory_bytes: 7960
#include <iostream>
#include <stdio.h>
#define ll long long
using namespace std;

const int p = 50;

int main(void){
    ll k;
    cin >> k;
    int flag = k % p;
    ll cnt = (k + p - 1) / p;
    cnt += p - 1;
    cout << p << endl;
    if(flag == 0){
        for(int j = 0; j < p; j++){
            cout << cnt << " ";
        }
        cout << endl;
        return 0;
    }
    for(int i = 1; i < p; i++){
        if(i != flag) continue;
        for(int j = 0; j < p; j++){
            if(j < i) cout << cnt + p - i << " ";
            else cout << cnt - (1 + i) << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
s = gets.chomp.chars
i = 0
min = 1000
while i < s.size - 2
  num = (s[i].to_s + s[i+1].to_s + s[i+2].to_s).to_i
  if (num - 753).abs < min
    min = (num - 753).abs
  end
  i += 1
end
puts min

Measured memory_bytes: 14184
//﻿#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	string s; cin >> s;
	string t = "";
	while (t.size() <= s.size()) {
		t += "hi";
		if (t == s) {
			cout << "Yes\n";
			return;
		}
	}
	cout << "No\n";
	return;
}

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




    int main()
    {
        string s;
        int n, cnt =0;
        std::cin >> s;

        n = s.length();
        for (int i = 0; i < n/2; ++i)
        {
            if (s[i] != s[n-i-1])
            {
                cnt++;
            }
        }
        std::cout << cnt << "\n";
        return 0;
    }


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

enum Color {
	GRAY, BROWN, GREEN, CYAN, BLUE, YELLOW, ORANGE, RED, FREE
};

Color getColor(int r) {
	if (r < 400)
		return GRAY;
	else if (r < 800)
		return BROWN;
	else if (r < 1200)
		return GREEN;
	else if (r < 1600)
		return CYAN;
	else if (r < 2000)
		return BLUE;
	else if (r < 2400)
		return YELLOW;
	else if (r < 2800)
		return ORANGE;
	else if (r < 3200)
		return RED;
	else
		return FREE;
}

int main() {
	int N;
	cin >> N;
	map<Color, int> C;
	C[FREE] = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		C[getColor(a)]++;
	}
	int c = C.size() - 1;
	cout << max(c,1) << " " << c + C[FREE] << endl;
	return 0;
}


Measured memory_bytes: 256
#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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N; string A, B, C;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> A >> B >> C;

    int ans = 0;
    rep(i, 0, N) {
        set<char> c;
        c.insert(A[i]);
        c.insert(B[i]);
        c.insert(C[i]);

        if (c.size() == 1) continue;
        else if (c.size() == 2) ans++;
        else ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        String[] c = new String[h];
        Arrays.setAll(c, i -> sc.next());
        sc.close();

        // 主処理
        List<String> list = new ArrayList<>();
        for (int i = 0; i < h; i++) {
            list.add(c[i]);
            list.add(c[i]);
        }

        String result = String.join("\n", list);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
  ld a,b,n;
  cin>>a>>b>>n;
  ld x=min(n,b-1);
  cout<<floor(a*x/b)-a*floor(x/b)<<endl;
return 0;
}


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

int main()
{
  string S;
  cin >> S;
  
  int total = 700;
  
  rep(i, 3){
    if ('o' == S[i]){
      total += 100;
    }
  }

  cout << total;
    
  return 0;
}

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

ll niz[10050];
long long mod=1000000007;
int cnt_max[1000040];

void faktor(int x){
    int i;
    for(i=2;i*i<=x;i++){
        int br=0;
        while(x%i==0){
            br++;
            x/=i;
        }
        cnt_max[i]=max(cnt_max[i],br);
    }
    cnt_max[x]=max(cnt_max[x],1);
}

ll stepen(ll a, ll st)
{
    if(st == 0) return 1;
    ll res = stepen(a, st/2);
    res %= mod;
    res *= res;
    res %= mod;
    if(st % 2 == 1)
    {
        res *= a;
        res %= mod;
    }
    return res;
}
ll mul(ll a, ll b)
{
    a %= mod;
    b %= mod;
    return (a*b)%mod;
}

int main()
{
    int n;
    cin>>n;
    int maxi=INT_MIN;
    for(int i=0;i<n;i++){
        cin>>niz[i];
        faktor(niz[i]);
        if(maxi<niz[i])maxi=niz[i];
    }
    ll zs=1;
    for(int i=1;i<=maxi;i++)
    {
        zs=mul(zs,stepen(i,cnt_max[i]));
        zs%=mod;
    }
    ll res=0;
    for(int i=0;i<n;i++)
    {
        res+=mul(zs,stepen(niz[i],mod-2));
        res%=mod;
    }
    cout<<res;

    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

const int limit = 100010;
using edge = struct{int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v,int p, ll d){
    depth[v] = d;
    for( auto &e : tree[v]){
        if (e.to == p) continue;
        dfs(e.to,v,d+e.cost);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    REP(i,n-1){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        tree[a].push_back({b,c});
        tree[b].push_back({a,c});
    }

    int q,k;
    cin>>q>>k;
    k--;
    dfs(k,-1,0);
    REP(i,q){
        int x,y;
        cin>>x>>y;
        x--;y--;
        cout<<depth[x]+depth[y]<<endl;
    }
}

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


int main() {
  string s;
  cin >> s;
  if (s == "SUN") cout << 7;
  else if (s == "MON") cout << 6;
  else if (s == "TUE") cout << 5;
  else if (s == "WED") cout << 4;
  else if (s == "THU") cout << 3;
  else if (s == "FRI") cout << 2;
  else if (s == "SAT") cout << 1;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  if (N[0] == '7') {
    cout << "Yes" << endl;
  } else if(N[1] == '7') {
      cout << "Yes" << endl;
  } else if (N[2] == '7') {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    int n,k,a;
    cin>>n>>k;
    rep(i,n)cin>>a;
    a=0;
    for(;n>1;)a++,n-=k-1;
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
height = list(map(int,input().split()))
# print(height)
bridge = [[] for i in range(n)]

for i in range(m):
	a,b = map(int,input().split())
	bridge[a-1].append(b-1)
	bridge[b-1].append(a-1)

# print(bridge)
good = [None for i in range(n)]
# print(good)

flag = True
for i in range(n):
	flag = True
	if good[i] == None:
		# print(str(i+1)+'番目の展望台を調べます。')
		for tembo in bridge[i]:
			# print(str(tembo+1)+'番目の展望台につながっています。')
			if height[i] <= height[tembo]:
				# print(str(tembo+1)+'のほうがい高いので良くない')
				flag = False
		good[i] = flag
		if good[i]:
			for tembo in bridge[i]:
				good[tembo] = False

# print(good)
ans = 0
for x in good:
	if x:
		ans += 1
print(ans)

Measured memory_bytes: 30364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e7 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e16
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;



ll ar[105];
int main() {
    fast;

    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    ll moves = x / d;

    ll ans = inf;
    ll dist = x - min(k, moves) * d;


    moves = k - min(k, moves);

    // cout << dist << " " << moves << "\n";
    if(moves == 0)
        ans = dist;
    else {

        if(moves & 1) {
            ans = abs(d - dist);
        }
        else {
            ans = dist;
        }

    }

    cout << ans << "\n";


    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    int n, m;
    cin >> n >> m;

    cout << (n+m)*(n+m-1)/2 - n*m << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
#define forn(a,b,c) for(int a=b;a<=c;a++)
#define ford(a,b,c) for(int a=b;a>=c;a--)
const int N=2e5+5;
int n,t;
char a[N];
pair<char,char>q[N];
bool check(int x,bool markLow){
    forn(i,1,t){
        if(q[i].f==a[x]){
           if(q[i].s=='L'){
                x--;
           }
           else{
                x++;
           }
        }
        if(x<=0){
            return markLow;
        }
        if(x>n){
            return !markLow;
        }
    }
    return false;
}
int main()
{
    scanf("%d%d",&n,&t);
    forn(i,1,n){
        scanf(" %c",&a[i]);
    }
    forn(i,1,t){
        scanf(" %c %c",&q[i].f,&q[i].s);
    }
    int lo=0,hi=n,least1=0,most1=n+1;
    /*forn(i,1,n){
        if(check(i,true)){
            least1=i;
        }
    }*/
    while(lo<hi){
        int mid=(lo+hi+1)/2;
        if(check(mid,true)){
            lo=mid;
        }
        else{
            hi=mid-1;
        }
    }
   // printf("lo:%d least1:%d\n",lo,least1);
    int least=lo;
    /*ford(i,n,1){
        if(check(i,false)){
            most1=i;
        }
    }*/
    lo=0,hi=n;
    while(lo<hi){
        int mid=(lo+hi+1)/2;
        if(check(mid,false)){
            hi=mid-1;
        }
        else{
            lo=mid;
        }
    }
    //printf("hi:%d most1:%d\n",lo+1,most1);
    int most=lo+1;
    printf("%d\n",min(n,max(0,most-least-1)));
   /* if(least1!=least||most1!=most){
        printf("counterexample:\n");
        printf("n:%d q:%d\n",n,t);
        forn(i,1,n){
            printf("%c",a[i]);
        }
        printf("\n");
        forn(i,1,t){
            printf("%c %c\n",q[i].f,q[i].s);
        }
        printf("least:%d least1:%d most:%d most1:%d\n",least,least1,most,most1);
        return 0;
    }
    if(testcase%1000==0){
        printf("ok %d\n",testcase);
    }*/
    return 0;
}


Measured memory_bytes: 768
import java.util.*

data class Edge<T: Comparable<T>>(val from: Int, val to: Int, val weight: T): Comparable<Edge<T>> {
    constructor(from: Long, to: Long, weight: T) : this(from.toInt(), to.toInt(), weight)

    override fun compareTo(other: Edge<T>) = weight.compareTo(other.weight)
}

class Graph<T: Comparable<T>>(val n: Int, val zero: T, val inf: T, val plus: (T, T) -> T) {
    val edges = Array(n) { ArrayList<Edge<T>>() }
}

inline fun <reified T: Comparable<T>>dijkstra(g: Graph<T>, s: Int): Pair<Array<T>, Array<Int>> {
    val N = g.n
    val dist = Array(N) { g.inf }
    val prev = Array(N) {-1}

    val Q = PriorityQueue<Edge<T>>()

    dist[s] = g.zero
    Q.add(Edge(-2, s, g.zero))

    while(Q.isNotEmpty()) {
        val e = Q.peek()
        val v = e.to
        Q.poll()

        if (prev[v] != -1) continue
        prev[v] = e.from
        for (i in g.edges[v]) {
            val d = g.plus(dist[v], i.weight)
            if (dist[i.to] > d) {
                dist[i.to] = d
                Q.add(Edge(i.from, i.to, d))
            }
        }
    }

    return Pair(dist, prev)
}

fun main(args: Array<String>) {
    val INF = 1e16.toLong()

    val N = readLine()!!.toInt()
    val g = Graph(N, 0L, INF) { a: Long, b: Long -> a + b }
    for (i in 1..N-1) {
        val (a, b, w) = readLine()!!.split(" ").map { it.toLong() }
        val u = (a - 1).toInt()
        val v = (b - 1).toInt()

        g.edges[u].add(Edge(u, v, w))
        g.edges[v].add(Edge(v, u, w))
    }

    val (dist, prev) = dijkstra(g, 0)

    for (d in dist) {
        println(d % 2)
    }
}


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

int main(){
    string S;
    cin >> S;
    int n = S.size();
    bool res = true;
    rep(i, n){
        if(i%2 == 0){
            if(S[i] == 'L'){
                res = false;
                break;
            }
        }
        else{
            if(S[i] == 'R'){
                res = false;
                break;
            }
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	char c=getchar();int t=0,f=1;
	while((!isdigit(c))&&(c!=EOF)){if(c=='-')f=-1;c=getchar();}
	while((isdigit(c))&&(c!=EOF)){t=(t<<3)+(t<<1)+(c^48);c=getchar();}
	return t*f;
}
int n;
int a[20];
int dfs(int l,int r,int xl,int xr){
	if(r-l<=1)return 0;
	int ans=1e18;
	for(int i=l+1;i<=r-1;i++){
		ans=min(ans,dfs(l,i,xl,xr+xl)+dfs(i,r,xl+xr,xr)+a[i]*(xl+xr));
	}
	return ans;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++)a[i]=read();
	printf("%lld\n",a[1]+a[n]+dfs(1,n,1,1));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n>>k;
	arrin(arr,n);
	for(i=k;i<n;i++)
	{
	    if(arr[i]>arr[i-k])
	    cout<<"Yes\n";
	    else
	    cout<<"No\n";
	}
	
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vector<string> v(n);
    rep(i,n)cin>>v[i];
    sort(all(v));dupli(v);
    out(v.size());
}

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

n = int(raw_input())
S = map(int, raw_input().split())
q = int(raw_input())
T = map(int, raw_input().split())
count = 0
for i in range(q):
    for j in range(n):
        if T[i] == S[j]:
            count += 1
            break
print count

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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 1; i < N; i++)
        A[i] += A[i - 1];

    long long res = 1e18;
    for (int i = 0; i < N; i++) {
        long long len = A[i] * 2;
        res = min(res, abs(A[N - 1] - len));
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(){
    int n,x;
    cin>>n;
    for(int i=1;i<=n;i++){
        x=i;
        if(x%3==0){
            cout<<" "<<i;
        }else{
            while(x){
                if(x%10==3){
                    cout<<" "<<i;
                    break;
                }
                x/=10;
            }
        }
    }
    cout<<endl;
    
}



Measured memory_bytes: 3032
(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n1 = Number(lines.shift());
  const arr1 = lines.shift().split(' ').map(Number);
  const n2 = Number(lines.shift());
  const arr2 = lines.shift().split(' ').map(Number);

  const memo = (func) => {
    var cache = {};
    const innerFunc = (x, y) => {
          if (!cache[[x, y]]) cache[[x, y]] = func(x, y);
          return cache[[x, y]]
    };
    return innerFunc;
  }

  const solve = (i, m) => {
    if (m == 0) return true;
    if (i >= n1) return false;
    return solve(i + 1, m) || solve(i + 1, m - arr1[i]);
  };

  const solveWithMemo = memo(solve);
  arr2.map(m => solveWithMemo(0, m) ? 'yes' : 'no').forEach(res => console.log(res));
})();



Measured memory_bytes: 17336
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;

//各桁の和を出力
long long Sum(long long n) {
  long long m = 0;
  while (n) {
    m += n % 10;
    n /= 10;
  }
  return m;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void Comuse() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

#define comuse Comuse()
// nCk(comuseを使え)
long long combi(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// pCk(comuseを使え)
long long perm(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] % MOD) % MOD;
}

//最小公倍数(aとbの)
long long lcm(long long a, long long b) {
  long long n;
  n = a / __gcd(a, b) * b;
  return n;
}

// auto A = div(n)
vector<long long> div(long long n) {
  vector<long long> ret;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) {
        ret.push_back(n / i);
      }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

//(aのn乗をmodで割ったあまり)
long long modpow(long long a, long long n, long long mod) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) {
      ans = ans * a % mod;
    }

    a = a * a % mod;

    n >>= 1;
  }

  return ans;
}

void solve();

const int MAX_N = 131072;
// segment tree
int NN;
int seg[MAX_N * 2 - 1];
void seguse() {
  for (int i = 0; i < 2 * NN - 1; i++) {
    seg[i] = INT_MAX;
  }
}

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

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

string S;
int Q;
bool hanten;
vector<vector<string>> query(200000, vector<string>(3));
void solve() {
  cin >> S >> Q;
  for(int i = 0; i < Q; i++){
    cin >> query.at(i).at(0);
    if(query.at(i).at(0) == "1"){
      hanten = !hanten;
    }
    if(query.at(i).at(0) == "2"){
      cin >> query.at(i).at(1) >> query.at(i).at(2);
      if(query.at(i).at(1) == "1" && hanten || query.at(i).at(1) == "2" && !hanten){
        S += query.at(i).at(2);
      } else{
        S.insert(0, query.at(i).at(2));
      }
    }
  }
  for(int i = 0; i < S.size(); i++){
    if(hanten){
      cout << S[S.size()-1-i];
    } else{
      cout << S[i];
    }
  }
}


Measured memory_bytes: 39952
from collections import defaultdict
from heapq import heappush, heappop
N,K,*L = map(int, open(0).read().split())
dic = defaultdict(list)
ls = []
for i,(t,d) in enumerate(zip(*[iter(L)]*2)):
  dic[t].append(d)
  heappush(ls,(-d,t))
S = set()
pre = []
ans = 0
num = 0
for i in range(K):
  d,t = heappop(ls)
  ans -= d
  if t not in S:
    num += 1
    S.add(t)
  else:
    heappush(pre,-d)

ans += num*num
if pre==[]:
  print(ans)
  exit()
m = ans
for i in range(N-K):
  d,t = heappop(ls)
  if t in S:
    continue
  S.add(t)
  m -= heappop(pre)
  m += -d+2*num+1
  num += 1
  ans = max(ans,m)
  if pre==[]:
    break
print(ans)

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

int main() {
    int i, N, C0 = 0, C1 = 0, C2 = 0, C3 = 0;
    char s[3];
    scanf("%d", &N);
    for(i = 0;i < N;i++){
        scanf("%s", s);
        if(strcmp("AC", s) == 0) {
            C0++;
        } else if(strcmp("WA", s) == 0) {
            C1++;
        } else if(strcmp("TLE", s) == 0) {
            C2++;
        } else if(strcmp("RE", s) == 0) {
            C3++;
        }
    }
    printf("AC x %d\n", C0);
    printf("WA x %d\n", C1);
    printf("TLE x %d\n", C2);
    printf("RE x %d\n", C3);
    return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,m,D[100005],f[100005],ans,a,b;
vector < int > v[100005];
void Dfs(int x) {
	f[x]=1;
	for (int i=0; i<v[x].size(); i++) {
		if (!f[v[x][i]])Dfs(v[x][i]);
		D[x]=max(D[x],D[v[x][i]]+1);
		ans=max(ans,D[x]);
	}
}

main () {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin>>n>>m;
	for (int i=1; i<=m; i++) {
		cin>>a>>b;
		v[a].pb(b);
	}
	
	for (int i=1; i<=n; i++) 
		if (!f[i]) Dfs(i);
	cout<<ans<<endl;
}

Measured memory_bytes: 8576
import numpy as np
N = int(input())

cnt = np.zeros((10,10))

for x in map(str,range(0,N+1)):
    cnt[int(x[0]),int(x[-1])] += 1

ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += cnt[i,j] * cnt[j,i]

print(int(ans))

Measured memory_bytes: 27088
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/**
 * @author dwij
 */

#include <bits/stdc++.h>

#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>

using namespace std;

//******* Debugging Class Template *******/
#define sim template <class c
#define ris return *this
#define dor > deb& operator<<
#define eni(x) \
    sim > typename enable_if<sizeof dud<c>(0) x 1, deb&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct deb {
#ifdef LOCAL
    ~deb() { cerr << endl; }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
}
;
#define log(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// End of weird debugging stuff.

typedef long long ll;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>

#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(), c.end()
#define mem(a, val) memset(a, val, sizeof(a))
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define endl "\n"

void solution() {
    // deb() << log();
    int n;
    cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }

    vector<string> ss;
    ss.pb("AC");
     ss.pb("WA");
    ss.pb("TLE");
    ss.pb("RE");
    for (string a : ss) {
        if (!mp[a]) {
            cout << a << " x " << 0 << endl;
        } else {
            cout << a << " x " << mp[a] << endl;
        }
    }
}

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

    int T = 1;
    // cin >> T;
    // cin.ignore(); must be there when using getline(cin, s)
    for (int tt = 1; tt <= T; tt++) {
        // cout << "Case #" << tt << ": ";
        solution();
    }

    return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>     
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define rev(i,n) for(ll i=n-1;i>=0;--i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
//cout << fixed << setprecision(10) << num << endl;
int a[100], b[100], c[100];
signed main() {
	int n;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, n) {
		cin >> b[i];
		ans += b[i];
	}
	rep(i, n - 1) {
		cin >> c[i];

	}
	rep(i, n) {
		if (i > 0) {
			if (a[i] == a[i - 1] + 1) {
				ans += c[a[i] - 2];
			}
		}
	}
	cout << ans << endl;
}

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

int main()
{
	int n,m;
	cin>>n>>m;
	vector<int> h(n);
	for(size_t i = 0; i<n; i++)
	{
		cin>>h[i];
	}
	vector<vector<int>>ab(n);
	for(size_t i = 0; i<m; i++)
	{
		int a,b;
		cin>>a>>b;
		ab[a-1].push_back(b);
		ab[b-1].push_back(a);
	}
	int ans = 0;
	for(size_t i = 0; i<n; i++)
	{
		int tf = 1;
		for(size_t ii = 0; ii<size(ab[i]); ii++)
		{
			if(h[i]<=h[ab[i][ii]-1])
			{
				tf = 0;
			}
		}
		if(tf==1)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8804
// A. 

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	int n, p;
	cin >> n >> p;
	LL dp[2][2] = {1};
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if (a % 2) {
			dp[(i % 2) ^ 1][0] = dp[i % 2][0] + dp[i % 2][1];
			dp[(i % 2) ^ 1][1] = dp[i % 2][0] + dp[i % 2][1];
		} else {
			dp[(i % 2) ^ 1][0] = dp[i % 2][0] * 2;
			dp[(i % 2) ^ 1][1] = dp[i % 2][1] * 2;
		}
	}
	cout << dp[n % 2][p] << 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, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  char c;
  cin>>c;
  if('A'<=c&&c<='Z'){
    cout<<"A"<<endl;
  }
  else{
    cout<<"a"<<endl;
  }
  return(0);
}

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

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

using namespace std;
using lint=long long;

class mint{
	static const int MOD=1e9+7; // 998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int main(){
	int h,w; scanf("%d%d",&h,&w);

	vector<bool> row(h*w),col(h*w);
	rep(i,h){
		int a; scanf("%d",&a); a--;
		if(row[a]) return puts("0"),0;
		row[a]=true;
	}
	rep(j,w){
		int b; scanf("%d",&b); b--;
		if(col[b]) return puts("0"),0;
		col[b]=true;
	}

	mint ans=1;
	lint cnt1=0,cnt2=0;
	rep(t,h*w){
		int num=h*w-t-1;
		if(row[num] && col[num]){
			cnt1++;
			cnt2++;
		}
		else if(row[num]){
			ans*=cnt2;
			cnt1++;
		}
		else if(col[num]){
			ans*=cnt1;
			cnt2++;
		}
		else{
			if(cnt1*cnt2<t) return puts("0"),0;
			ans*=cnt1*cnt2-t;
		}
	}
	printf("%d\n",ans.to_int());

	return 0;
}


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

const int DIM = 524289;
const int MOD = 924844033;

vector<int> edg[DIM];

int fct[DIM], inv[DIM], szt[DIM];
int pol1[DIM], pol2[DIM], ans[DIM];

void dfs( int x, int f, int n ) {
    szt[x] = 1;
    
    for( int y : edg[x] ) {
        if( y == f )
            continue;
        
        dfs( y, x, n ); szt[x] += szt[y];
        pol1[szt[y]] --; pol1[n - szt[y]] --;
    }
    
    return;
}

int lgput( int x, int n ) {
    if( n == 0 )
        return 1;
    
    int y = lgput( x, n >> 1 );
    y = ( 1LL * y * y ) % MOD;
    
    if( n & 1 )
        y = ( 1LL * y * x ) % MOD;
    
    return y;
}

void dft( int pol[DIM], int sz, int sgn ) {
    int lg = 0;
    while( (1 << lg) < sz )
        lg ++;
    
    for( int i = 0; i < sz; i ++ ) {
        int x = 0;
        for( int j = 0; j < lg; j ++ )
            if( i & (1 << j) ) x |= (1 << (lg - j - 1));
        
        if( i < x )
            swap( pol[i], pol[x] );
    }
    
    for( int len = 2; len <= sz; len <<= 1 ) {
        int rot = lgput( 5, ( MOD - 1 + sgn * (MOD - 1) / len) % (MOD - 1) );
        
        for( int i = 0; i < sz; i += len ) {
            int stp = 1;
            
            for( int j = i; j < i + (len >> 1); j ++ ) {
                int x = pol[j], y = ( 1LL * stp * pol[j + (len >> 1)] ) % MOD;
                
                pol[j] = ( x + y ) % MOD;
                pol[j + (len >> 1)] = ( x - y + MOD ) % MOD;
                
                stp = ( 1LL * stp * rot ) % MOD;
            }
        }
    }
    
    if( sgn == -1 ) {
        int aux = lgput( sz, MOD - 2 );
        
        for( int i = 0; i < sz; i ++ )
            pol[i] = ( 1LL * pol[i] * aux ) % MOD;
    }
    
    return;
}

void ntt( int pol1[DIM], int pol2[DIM], int sz1, int sz2, int n ) {
    int sz = 1;
    while( sz < sz1 + sz2 - 1 )
        sz <<= 1;
    
    dft( pol1, sz, 1 );
    dft( pol2, sz, 1);
    
    for( int i = 0; i < sz; i ++ )
        pol1[i] = ( 1LL * pol1[i] * pol2[i] ) % MOD;
    dft( pol1, sz, -1 );
    
    return;
}

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 2; i <= n; i ++ ) {
        int x, y;
        cin >> x >> y;
        
        edg[x].push_back( y );
        edg[y].push_back( x );
    }
    
    dfs( 1, 0, n );
    
    fct[0] = inv[0] = 1; pol1[n] = n;
    for( int i = 1; i < DIM; i ++ )
        fct[i] = ( 1LL * fct[i - 1] * i ) % MOD;
    
    inv[DIM - 1] = lgput( fct[DIM - 1], MOD - 2 );
    for( int i = DIM - 2; i >= 1; i -- )
        inv[i] = ( 1LL * inv[i + 1] * (i + 1) ) % MOD;
    
    for( int i = 0; i <= n; i ++ ) {
        pol2[i] = inv[n - i];
        pol1[i] = ( pol1[i] + MOD ) % MOD;
        pol1[i] = ( 1LL * pol1[i] * fct[i] ) % MOD;
    }
    
    ntt( pol1, pol2, n + 1, n + 1, n );
    for( int i = 1; i <= n; i ++ )
        cout << ( 1LL * inv[i] * pol1[i + n] ) % MOD << "\n";
    
    return 0;
}


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

int main() {
    long n, t, ans;
    cin >> n >> t;
    ans = t;
    vector<long> time(n);
    rep(i, n) cin >> time.at(i);
    rep(i, n - 1) ans += min(t, time.at(i + 1) - time.at(i));
    cout << ans << endl;
}

Measured memory_bytes: 1792
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){
    string s,t;
    cin>>s>>t;
    vector<ll> ans;
    for(auto i=0; i<=(ll)s.size()-(ll)t.size(); i++){
        ll mis = 0;
        for(auto j=0; j<(ll)t.size(); j++){
            if(s[i+j] != t[j]) mis++;
        }
        ans.push_back(mis);
    }

    cout<<*min_element(ans.begin(),ans.end());
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3656