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

const int MOD = 998244353;

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

long long modinv(long long a) {
    return modpow(a, MOD - 2);
}


int main() {
    int N, S; cin >> N >> S;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<vector<ll>> memo(N, vector<ll>(S+1, 0));

    memo[0][0] = modpow(2, N);
    if (A[0] <= S) memo[0][A[0]] = (memo[0][0] * modinv(2)) % MOD;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= S; j++) {
            memo[i][j] = memo[i-1][j];
            if (j - A[i] >= 0) {
                memo[i][j] += (memo[i-1][j-A[i]] * modinv(2)) % MOD;
                memo[i][j] %= MOD;
            }
        }
    }
    // for (int i = 0; i < N; i++) {
    //     for (int j = 0; j <= S; j++) {
    //         cout << memo[i][j] << ' ';
    //     }
    //     cout << endl;
    // }
    cout << memo[N-1][S] << endl;
}

Measured memory_bytes: 73680
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define mod 1000000007
#define inf 9999999999999999ll
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,k;
    cin>>a>>b>>k;
    ll x=min(a,k);
    a-=x;
    k-=x;
    x=min(b,k);
    b-=x;
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
/*input
 
*/
 
 
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ll N = 1e6+5;
const ll mod=1e9+9; 
int solve()
{
	ll n;cin>>n;
	vi a(n-1);
	rep(i,0,n-1) cin>>a[i];
	ll ans=a[n-2];
	for(ll i=n-3;i>=0;i--)
		ans+=min(a[i],a[i+1]);
	ans+=a[0];
	cout<<ans<<"\n";
	return 0;
}
 
int main()
{
	auto start = chrono::high_resolution_clock::now();
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 
	ll test_cases=1;
	// cin>>test_cases;
	while(test_cases--)
		solve();
 
	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    weeks = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    print(7 - weeks.index(S))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S.strip())


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
  ll n,a,b,c,d;cin>>n;
  a=b=c=d=0;
  rep(i,0,n){
    string s;cin>>s;
    if(s=="AC"){a++;}
    if(s=="WA"){b++;}
    if(s=="TLE"){c++;}
    if(s=="RE"){d++;}
  }
  cout<<"AC x "<<a<<endl;
  cout<<"WA x "<<b<<endl;
  cout<<"TLE x "<<c<<endl;
  cout<<"RE x "<<d<<endl;
  
}






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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int32 n;
int64 a[200000+1];

int32 binarySearch(int32 l, int32 r, int32 x, int32 y){
    while(r - l >= 3){
        int32 nx = (l + r) / 2;
        if(a[nx] - a[x] == a[y] - a[nx]){
            l = nx;
            r = nx;
        }else if(a[nx] - a[x] < a[y] - a[nx]){
            l = nx;
        }else{
            r = nx;
        }
    }
    int64 mn = abs(a[y] - 2 * a[r] + a[x]);
    int32 retval = r;
    FOR(i,l,r){
        int64 diff = abs(a[y] - 2 * a[i] + a[x]);
        if(diff < mn){
            mn = diff;
            retval = i;
        }
    }
    return retval;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    a[0] = 0;
    REP(i,n){
        int32 ai;
        cin >> ai;
        a[i+1] = a[i] + ai;
    }
    // int32 y = binarySearch(2, n - 2, 0, n);
    // int32 x = binarySearch(1, y - 1, 0, y);
    // int32 z = binarySearch(y + 1, n - 1, y, n);
    // cout << x << " " << y << " " << z << endl;
    // vector<int32> p(4);
    // p[0] = a[x];
    // p[1] = a[y] - a[x];
    // p[2] = a[z] - a[y];
    // p[3] = a[n] - a[z];
    // REP(i,4)cout << p[i] << " ";
    // cout << endl;
    // sort(ALL(p));
    // ANS(p[3] - p[0]);
    int64 ans = LLINF;
    FOR(y,2,n-1){
        int32 x = binarySearch(1, y - 1, 0, y);
        int32 z = binarySearch(y + 1, n - 1, y, n);
        vector<int32> p(4);
        p[0] = a[x];
        p[1] = a[y] - a[x];
        p[2] = a[z] - a[y];
        p[3] = a[n] - a[z];
        sort(ALL(p));
        ans = min(ans, p[3] - p[0]);
    }
    ANS(ans);
    return 0;
}

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

int main() {
	long long a[100];
	long long N;
	long long p;
	long long kabu;
	long long q;

	cin >> N;

	p=1000;
	kabu=0;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < N - 1; i++) {
		if (a[i] < a[i+1]) {
			q=p/a[i];
			kabu=kabu+q;
			p=p-q*a[i];
		}
		if (a[i] > a[i+1]) {
			p=p+kabu*a[i];
			kabu=0;
		}
	}
	p=p+kabu*a[N-1];
	cout << p << endl;
	return 0;
}


Measured memory_bytes: 3624
import java.io.*;
class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader reader = 
			new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		while ((line = reader.readLine()) != null) {
			String[] values = line.split(" ");
			if (values.length < 8) break;
			
			double x1 = Double.parseDouble(values[0]);
			double y1 = Double.parseDouble(values[1]);
			double x2 = Double.parseDouble(values[2]);
			double y2 = Double.parseDouble(values[3]);
			double x3 = Double.parseDouble(values[4]);
			double y3 = Double.parseDouble(values[5]);
			double xp = Double.parseDouble(values[6]);
			double yp = Double.parseDouble(values[7]);
			
			double area12 = area(xp, yp, x1, y1, x2, y2);
			double area23 = area(xp, yp, x2, y2, x3, y3);
			double area31 = area(xp, yp, x3, y3, x1, y1);
			double area123 = area(x1, y1, x2, y2, x3, y3);
			
			String result = area12 + area23 + area31 - area123 < 0.0001 ? "YES" : "NO";
			System.out.println(result);
		}
		
	}
	
	static double area(double x1, double y1, double x2, double y2, double x3, double y3) {
		return 0.5 * Math.abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
	}
	
}

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

using namespace std;

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

int main()
{
  string s;
  int q;
  cin >> s >> q;
  
  deque<string> deq;
  rep(i, s.length())
  {
	 deq.push_back(string(1, s[i]));
  }
  bool isRev = false;
  rep(x, q)
  {
    int t;
    cin >> t;
    if(t == 1)
    {
      isRev = !isRev;
    }
    else
    {
      string c;
      int f;
      cin >> f >> c;
      if(isRev)
      {
        if(f == 1)
        {
          deq.push_back(c);
        }
        else
        {
          deq.push_front(c);
        }
      }
     else
     {
        if(f == 1)
        {
           deq.push_front(c);
        }
        else
        {
          deq.push_back(c); 
        }       
     }
    }

  }
  
  if(!isRev)
  {
    rep(i, deq.size())
    {
       cout << deq[i];
    }
  }
  else
  {
    for(int i = deq.size() -1; i >= 0; i--)
    {
      cout << deq[i];
    }
  }
  
  cout << endl;
  
	return 0;
}

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

using ll = long long;

using namespace std;
#define int ll

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}


void init()
{
	vector<int> x(5);
	rep(i, 5) cin >> x[i];
	int k;
	cin >> k;
	sort(all(x));
	if (x[4] - x[0] <= k) {
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}
}

void solve()
{
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1
{
    class ITP1_1_C
    {
        static void Main(string[] args)
        {
            string[] valueArray = Console.ReadLine().Split(' ');

            int a = int.Parse(valueArray[0]);
            int b = int.Parse(valueArray[1]);

            int area = a * b;
            int perimeter = ((a * 2) + (b * 2));

            Console.WriteLine(area + " " + perimeter);
        }
    }
}



Measured memory_bytes: 15956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<string> s(N);
    int ac=0;
    int wa=0;
    int tle=0;
    int re=0;

    for (int i=0; i<N; i++){
        cin >> s[i];
    }

    for (int i=0; i<N; i++){
         if (s[i] == "AC") {
            ac++;
        }
        if (s[i] =="WA")  {
            wa++;
        }
        if (s[i] == "TLE") {
            tle++;
        }
        if (s[i] == "RE") {
            re++;
        }
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int main()
{
	int64_t N;
	cin >> N;

	int64_t res = N - 1;
	for (int64_t i = 2; i * i <= N; i++)
		if (N % i == 0) {
			res = min(res, (i - 1) + (N / i - 1));
		}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int n;
	while(cin>>n,n){
		map<int,int> m;
		REP(i,n){
			int a;
			cin>>a;
			if(!EXIST(m,a)){
				m[a]=0;
			}
			m[a]++;
		}
		int maxi=INT_MIN,maxv=0;
		for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
			if(it->second>maxv){
				maxv=it->second;
				maxi=it->first;
			}
		}
		if(maxv<=n/2){
			cout<<"NO COLOR"<<endl;
		}else{
			cout<<maxi<<endl;
		}
	}
}

Measured memory_bytes: 2732
# 34
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for a in range(0, A + 1):
    if 500 * a > X: continue
    for b in range(0, B + 1):
        if 500 * a + 100 * b > X: continue
        for c in range(0, C + 1):
            if 500 * a + 100 * b + 50 * c == X: ans +=1

print(ans)

Measured memory_bytes: 9128
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

a= gets.split.map(&:to_i)

a.each_with_index do |x,i|
  if x == 0
    puts (i+1)
  end
end



Measured memory_bytes: 14240
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N; cin >> N;
    vs S(N); REP(i, N) cin >> S[i];

    int ea = 0, sb = 0, ba = 0;
    int cnt = 0;
    REP(i,N) {
        int L = S[i].size();
        REP(j, L-1) {
            if (S[i][j] == 'A' && S[i][j + 1] == 'B') cnt++;
        }

        if (S[i][0]=='B' && S[i][L-1]=='A') {
            ba++;
        } else {
            if (S[i][L - 1] == 'A') ea++;
            if (S[i][0] == 'B') sb++;
        }
    }

    int ans = cnt;
    if (ba >= 2) {
        ans += ba - 1;
        ba = 1;
    }
    if (ba > 0) {
        if (ea >0 && sb>0) {
            ans+=2;
            ea--;
            sb--;
        } else if (ea>0) {
            ans++;
        } else if (sb>0) {
            ans++;
        }
    }
    ans += min(ea, sb);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 896
S=input()
T=input()
lenS=len(S)
lenT=len(T)
count=[]

for i in range(lenS-lenT+1):
    c=0
    for j in range(lenT):
        if T[j]!=S[i+j]:
            c=c+1
        j=j+1
    count.append(c)
    i=i+1
print(min(count))

Measured memory_bytes: 9020
from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = int(input())
c = Counter(prime_factorize(n))
v = list(c.values())

ans = 0
for i in v:
    k = i
    s = 0
    for j in range(1, i+1):
        s += j
        if s <= k:
            ans += 1
        else:
            break
print(ans)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,K,C;
  string s;
  cin>>N>>K>>C>>s;
  int kikan(INFint);
  int cnt(0);
  vector<int> ha;
  for(int i(0);i<N;i++){
    if (s[i] == 'o' && kikan >= C){
      cnt++;
      kikan = 0;
      ha.push_back(i);
    }else{
      kikan++;
    }
  }
  kikan = INFint;
  cnt = 0;
  reverse(s.begin(),s.end());
  for(int i(0);i<N;i++){
    if (s[i] == 'o' && kikan >= C){
      cnt++;
      kikan = 0;
      ha.push_back(N-i-1);
    }else{
      kikan++;
    }
  }
  if (cnt == K){
    int cnti[200001] = {0};
    for(int i(0);i<int(ha.size());i++){
      cnti[ha[i]]++;
    }
    for(int i(0);i<N;i++){
      if (cnti[i] == 2){
        cout << i + 1 << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 4212
#include <stdio.h>

int main(void) {
  int N,M,C,i,j,temp,ans=0;
  int B[20],A[20][20];
  scanf("%d %d %d",&N,&M,&C);

  for(i=0;i<M;i++){
    scanf("%d",&B[i]);
  }
  for(i=0;i<N;i++){
    temp=C;
    for(j=0;j<M;j++)
    {
      scanf("%d",&A[i][j]);
      temp+=A[i][j]*B[j];
    }
    if(temp>0){
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
using namespace std;
#define mp make_pair
#define pb push_back
#define FI first
#define SE second
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

int main(){
    ll N,M;
    cin >> N >> M;
    vector<pll> p(N);
    REP(i,N){
        cin >> p[i].first >> p[i].second; 
    }
    sort(all(p));
    ll ans = 0;
    auto itr = p.begin();
    while(M > 0){
        if(itr->SE == 0) itr++;
        ans += itr->FI;
        (itr->SE)--;
        M--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
					
public class Program
{
	public static void Main()
	{
		var str = Console.ReadLine();
		var split = str.Split(' ');
		var S = int.Parse(split[0]);
		var W = int.Parse(split[1]);
		if(W >= S)
			Console.WriteLine("unsafe");
		else
			Console.WriteLine("safe");
	}
}

Measured memory_bytes: 27488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    long long a, subsum[200001];
    for (long long i = 1; i <= n; i++)
    {
        cin >> a;
        if (i == 1)
            subsum[1] = a;
        else
            subsum[i] = subsum[i - 1] + a;
    }
    long long ans = 2e9;
    for (long long i = 1; i <= n - 1; i++)
    {
        long long tmp = subsum[n] - subsum[i];
        long long a = abs(subsum[i] - tmp);
        if (ans > a)
        {
            ans = a;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=j;i<=k;i++) 
#define dec(i,j,k) for(int i=j;i>=k;i--)
#define mod 1000000007 
using namespace std;
typedef long long ll;
const int N=1e6+10;
ll n,m,k,x,y,a,b,c,d,s,t,ans,q,r;
int arr [N];
const int nax = 1005;

void solve()
{  cin>>n;
  ans = 0;
   for(int i=0;i<n;i++)
   cin>>arr[i];
   for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++)
	 for(int k=j+1;k<n;k++)
	 { if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[k]!=arr[i]) 
	 if(arr[i]+arr[j]>arr[k] && arr[i]+arr[k]>arr[j]    && arr[j]+arr[k]>arr[i])
         {  //cout<<i<<" "<<j<<" "<<k<<"\n";
		    ans++;	
         }		 
	 } 
	 cout<<ans;
}
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(NULL);
	
 	
	
	int t=1;
	
 	//cin>>t; 
 
 
	int  a=0;
	while(t--)
	{ // cout<<"Case #"<<++a<<": ";
	   solve();
	   cout<<"\n"; 
	}    
	
    return 0;
}

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

int MOD = (int) 1e9 + 7;

auto solve() {
    int n;
    cin>>n;
    vector<pair<pair<string,int>,int>> st(n);
    REP(i,n){
        cin>>st[i].first.first>>st[i].first.second;
        st[i].first.second *= -1;
        st[i].second = i;
    }
    sort(all(st));

    REP(i,n) {
        cout << st[i].second+1 << endl;
    }
}


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

//    cout << solve() << endl;
    solve();
//    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}



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

using namespace std;

void bsort(int a[],int  n) {
	for (int i = n-1; i >0; i--) {
		for (int j = 0; j < i; j++) {
			if (a[j] < a[j + 1]) swap(a[j], a[j + 1]);
		}
	}
	

}
using namespace std;
int main()
{
	int N;
	int a[100];
	int score=0;

	cin >> N;
	for (int i = 0; i < N; i++)  cin >> a[i];
	bsort(a, N);
	
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) score += a[i];
		else score -= a[i];
	}
	
	cout << score << endl;
		return 0;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}




    
void test_case() {

   int n;
   cin>>n;


   while(n) {
       int val = n%10;
       if(val == 7) {
           yes;
           return;
       }
       n= n/10;
       
   }
   no;
   return;


}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<double, double > pi; 
typedef pair<pair<ll ,ll >,ll > pii; 

//to (行き先), weight の順で設定
ll ans = 0;

void dfs(vector<vector<pair<ll, ll > > > G, vector<bool > seen, ll idx, ll from = -1){
    seen[idx] = true;

    for(ll i = 0; i < G[idx].size(); i++){
        //次の行き先は？
        ll to = G[idx][i].first;
        //同じだったらもう処理しない
        //頂点に戻ってきたら
        //後戻りを許さない
        if(seen[to] == true){
            continue;
        }
 
        dfs(G, seen ,to , idx);
 
    }

    bool f = true;
    for(ll i = 0; i < seen.size(); i++){
        if(seen[i] == false){
            f = false;
            break;
        } 
    }

    if(f == true) ans++;

}

int main(){
    ll N, M;
    cin >> N >> M;
    
    //初期化
    vector<vector<pair<ll, ll > > > G;
    G.assign(N, vector<pair<ll, ll > >());
    vector<bool > seen(N, false);
 
    //グラフ入力
    for(ll i = 0; i < M; i++){
        ll u, v, w;
        w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(G ,seen ,0);

    cout << ans << endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC069A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            string[] vals = Console.ReadLine().Split(' ');

            n = int.Parse(vals[0]);
            m = int.Parse(vals[1]);

            Console.WriteLine((n - 1) * (m - 1));
        }
    }
}


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

int main(){
    int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int>a(n,0);
    rep(i,k){
        int d;
        cin>>d;
        rep(j,d){
            int t;
            cin>>t;
            a[t-1]++;
        }
    }
    int ans=0;
    rep(i,n)if(a[i]==0)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int count = 0;
            string imp = Console.ReadLine();
            int L = imp.Length;
            for(int i =0; i<L;i++)
            { 
                switch(imp[i])
                {
                    case ('2'):
                        count += 1;
                        break;
                    default:
                        
                        break;
                }
            }
            
            Console.Write(count);
             
                   
            
            //System.Threading.Thread.Sleep(1000);
        }
    }
    
}


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

using namespace std;

int main()
{

    int num,i;
    vector <int> v;

    for(i=0;i<3;i++)
    {
        scanf("%d",&num);
        v.push_back(num);
    }

    sort(v.begin(),v.end());

    long long m = v[2],sum=v[0]+v[1];

    scanf("%d",&num);

    for(i=1;i<=num;i++)
    {
        m =  m * 2;

    }

    sum = sum + m;


    printf("%lld\n",sum);



    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    deque<char> s;
    string st;
    int q;
    cin >> st >> q;
    for (int i = 0; i < st.length(); i++) {
        s.push_back(st[i]);
    }
    int flag = 0;
    while (q--) {
        int a;
        cin >> a;
        if (a == 1) flag = !flag;
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((flag + f) % 2 == 1) s.push_front(c);
            else s.push_back(c);
        }
    }
    if (flag) reverse(s.begin(), s.end());
    for (auto i : s)
        cout << i;
    return 0;
}

Measured memory_bytes: 976
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[200001];

int main(void){
	scanf("%d",&n);
	int cnt=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		a[i]--;
	}
	for(int i=0;i<n;i++){
		if(i==a[a[i]] && i<a[i])cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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



int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;
  vector<int> b(N);
  for(int i = 0; i < N; ++i){
    if(S.at(i)=='0') {
      b.at(i) = 0;
    } else {
      b.at(i) = 1;
    }
  }
  vector<int> change;
  change.push_back(0);
  for(int i = 1; i < N; ++i){
    if(b.at(i) != b.at(i-1)) change.push_back(i);
  }
  int maxi = 0;
  for(int i = 0; i < change.size(); ++i){
    if(b.at(change.at(i))==0) {
      if(i + 2*K < change.size()) {
        maxi = max(maxi,change.at(i+2*K)-change.at(i));
      } else {
        maxi = max(maxi,N-change.at(i));
      }
    } else {
      if(i + 2*K + 1 < change.size()){
        maxi = max(maxi,change.at(i+2*K+1)-change.at(i));
      } else {
        maxi = max(maxi,N-change.at(i));
      }
    }
  }
  cout << maxi << endl;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

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

  int N, M;
  cin >> N >> M;

  vector<int> A(N, -1), B(N, -1);

  for (int i = 0; i < N / 4; i++) {
    A[i] = i;
    B[i] = (N / 2) - i - 1;
  }

  for (int i = 0; i + N / 4 < N / 2; i++) {
    A[i + N / 4] = i + N / 2;
    B[i + N / 4] = ((N - 1) / 2 * 2 + 1) - i - 1;
  }

  for (int i = 0; i < M; i++) {
    cout << A[i] + 1 << " " << B[i] + 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 4344
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;
  auto l = readln.chomp.split.to!(int[]);
  l.sort();
  auto s = l[0..$-1].sum;
  if (l[$-1] < s) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/arc073/tasks/arc073_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N, W;
  cin >> N >> W;

  struct Item {
    ll w;
    ll v;
  };

  V<Item> is(N);

  rep(i, N) {
    ll w, v;
    cin >> w >> v;
    is[i] = {w, v};
  }

  ll w_diff = 3;
  ll max_w = w_diff * (N - 1);

  // dp[i][w][ct]: i >= 1 番目のアイテムまでで重さ w
  // 以下での価値の最大値. ct 個選んだ場合。 w は先頭の要素の重さとの差
  V<VVL> dp(N + 1, VVL(max_w + 1, VL(N + 1)));

  ll w_base = is[0].w;

  rep(i, N) rep(w, max_w + 1) rep(ct, N) {
    auto item = is[i];

    chmax(dp[i + 1][w][ct], dp[i][w][ct]);

    if (w + item.w - w_base <= max_w) {
      chmax(dp[i + 1][w + item.w - w_base][ct + 1], dp[i][w][ct] + item.v);
    }
  }

  ll res = 0;

  rep(ct, N + 1) {
    ll w = w_base * ct;
    if (w > W) continue;
    ll rest_w = W - w;

    chmax(res, dp[N][min(rest_w, max_w)][ct]);
  }

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int64_t modpow(int64_t a, int64_t n, const int64_t mod)
{
    int64_t result = 1;
    while (n) {
        if (n & 1) result = result * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return result;
}

int main()
{
    int64_t K;
    cin >> K;
    if (K == 2 || K == 5 || K == 10) {
        cout << -1 << endl;
        return 0;
    }
    if (K == 1 || K == 7) {
        cout << 1 << endl;
        return 0;
    }
    int64_t remainder = 0;
    for (int64_t i = 0; i < K; ++i) {
        int64_t diff = modpow(10, i, K) * 7 % K;
        remainder = (remainder + diff) % K;
        if (remainder == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  m /= __gcd(n, m);
  int ans = 1;
  for (int i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      ans *= i;
      while (m % i == 0) m /= i;
    }
  }
  ans *= m;
  cout << ans << endl;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n,m;
    cin >> n >> m;
    long long prob[n+1]={0};
    long long vis[n+1]={0};
    for(int i=0;i<m;i++){
        int x;
        string s;
        cin >> x >> s;
        //cout << "cc " << s << endl;
        if(s=="AC"){
            vis[x]=1;
        }else{
            if(!vis[x]){
                prob[x]++;
            }
        }
    }
    int c=0,p=0;
    for(int i=1;i<=n;i++){
        if(vis[i]){
            c++;
            p+=prob[i];
        }
    }
    cout << c << " " << p << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sidha(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int> 
#define pb push_back
#define st string
#define pairi pair<int,int>
#define INF 1000000007 

bool isPrime(int n){
	if(n<=1) return false;
	if(n<=3) return true;
	if(n%2==0 || n%3==0) return false;
	for(int i=5;i*i<=n;i+=6){
		if(n%i==0 || n%(i+2)==0) return false;
	}
	return true;
}

ll sum(ll n){
	ll sum=n*(n+1);
	return sum/2;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
   int n;cin>>n;
   if(n==1){
      cout<<"0";
   }
   else{
      cout<<"1";
   }
	return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>

int main(){
	int n,a,b,c,d,count;
	while(scanf("%d",&n)==1){
	count = 0;
	for(a=0;a<10;a++){
		for(b=0;b<10;b++){
			for(c=0;c<10;c++){
				for(d=0;d<10;d++){
					if(a+b+c+d == n) count = count + 1;
				}
			}
		}
	}
	printf("%d\n",count);
	}
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<long long> vals;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		long long next;
		cin >> next;
		vals.push_back(next);
		sum += next;
	}


	long long best = 1e16, cur = sum * -1;
	for (int i = 0; i < n - 1; i++) {
		cur += vals.at(i) * 2;
		if (abs(cur) < best) {
			best = abs(cur);
		}
	}

	cout << best << endl;

	return 0;

}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int a,b,c,k,cnt=0;
  cin>>a>>b>>c>>k;
  while(b<=a)
  {
    b=b*2;
    cnt++;
  }
  while(c<=b)
  {
    c=c*2;
    cnt++;
  }
  if(cnt<=k) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3644
package main

import "fmt"

func main() {
    var A int
    fmt.Scan(&A)
    B := make(map[int]struct{}, A)
    for i := 0; i < A; i++ {
        var C int
        fmt.Scan(&C)
        if _, ok := B[C]; !ok {
		    B[C] = struct{}{}
        } else {
            delete(B, C)
        }
    }
    fmt.Println(len(B))
}

Measured memory_bytes: 6324
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

const int INF = 1001001001;
int h, w, k, s[2], g[2], dx[]={1,0,-1,0}, dy[]={0,1,0,-1}, que[1001001][2], r=0, l=0;

int main(){
    scanf("%d%d%d", &h, &w, &k);
    scanf("%d%d%d%d", &s[0], &s[1], &g[0], &g[1]);
    s[0]--;s[1]--;g[0]--;g[1]--;
    char c[h+5][w+5];
    int d[h][w];
    for(int i=0; i<h; i++){
        scanf("%s", c[i]);
        for(int j=0; j<w; j++)d[i][j] = INF;
    }
    que[r][0] = s[0]; que[r][1] = s[1]; r++; r%=1001001;
    d[s[0]][s[1]] = 0;
    while(r != l){
        int x = que[l][0], y = que[l][1]; l++; l%=1001001;
        for(int i=0; i<4; i++){
            for(int j=1; j<=k; j++){
                if(0<=x+j*dx[i] && x+j*dx[i]<h && 0<=y+j*dy[i] && y+j*dy[i]<w && c[x+j*dx[i]][y+j*dy[i]]=='.' && d[x+j*dx[i]][y+j*dy[i]] >= d[x][y]+1){
                    if(d[x+j*dx[i]][y+j*dy[i]] == d[x][y]+1)continue;
                    d[x+j*dx[i]][y+j*dy[i]] = d[x][y] + 1;
                    que[r][0] = x+j*dx[i]; que[r][1] = y+j*dy[i]; r++; r%=1001001;
                    //printf("%d %d %d\n", que[r-1][0], que[r-1][1], d[x][y]+1);
                }else break;
            }
        }
    }
    if(d[g[0]][g[1]] == INF)d[g[0]][g[1]] = -1;
    printf("%d\n", d[g[0]][g[1]]);
    //for(int i=0; i<h; i++){for(int j=0; j<w; j++){if(j)putchar(32);printf("%d", d[i][j]);}putchar(10);}
    return 0;
}


Measured memory_bytes: 12396
n = int(input())
s = input()

num_black = 0
num_white = 0
# 該当部分を含まずに、「より左」にある黒の数
left_black = [0] * (n+1)
# 該当部分を含まずに、「より左」にある白の数
left_white = [0] * (n+1)
for i in range(n):
    if s[i] == '#':
        num_black += 1
    else:
        num_white += 1
    left_black[i+1] = num_black
    left_white[i+1] = num_white
# 該当部分を含んで、「より右」にある白の数
right_white = [0] * (n+1)
for i in range(n,-1,-1):
    right_white[i] = num_white - left_white[i]

# インデックスiから右（iを含む）は全て黒にする、として数える
ans = num_white
for i in range(n+1):
    num_to_change = left_black[i] + right_white[i]
    ans = min(ans, num_to_change)
print(ans)






Measured memory_bytes: 26560
#include<bits/stdc++.h>
using namespace std;
int a[200010];
int main()
{
	int x,n,i,pd=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(i=1;i<n;i++)
	if(a[i]==a[i+1])
	{
		printf("NO");
		pd=1;
		break; 
	}
	if(pd==0)printf("YES");	
} 

Measured memory_bytes: 1024
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
int n, l, m;
vector<vector<ll>> adj;    
vector<ll> constt;
map<pll, ll> key;
vector<pll> lis;
vector<bool> visited(55, false);
vll path;
ll dfs(ll idx, ll dest) {
  ll ans = 0;
  visited[idx] = true;
  if(idx == dest) ans = 1;
  for(auto it: adj[idx]) {
    if(visited[it] == true) continue;
    ans|= dfs(it, dest);
  }
  if(ans == 1) path.pb(idx);
  return ans;
}
ll tot;
ll dp[52][(1ll<<20) + 3];
ll doit(ll edge, ll mask) {
  return (constt[key[lis[edge]]]|mask);
}
ll recurse(ll edge, ll mask) {
  if(edge >= n-1 and mask == tot) return 1;
  if(edge >= n-1) return 0;
  ll &ans = dp[edge][mask];
  if(ans != -1) return ans;
  ans = 0;
  ans += recurse(edge + 1, mask);
  mask = doit(edge, mask);
  ans += recurse(edge + 1, mask); 
  return ans;
}
int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  cin >> n;
  adj.resize(n+1);
  constt.resize(n, 0);
  for(ll i = 0; i < n-1; i++){
    ll x, y;
    cin >> x >> y;
    adj[x].pb(y);
    adj[y].pb(x);
    lis.pb(mp(min(x, y), max(x, y)));
    key[lis.back()] = i;
  }
  cin >> m;
  for(ll i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    visited.assign(55, false);
    path.clear();
    dfs(x, y);
    for(ll ii = 1; ii < (ll)path.size(); ii++) {
      pll ed = mp(min(path[ii], path[ii-1]), max(path[ii], path[ii-1]));
      constt[key[ed]]+=(1LL<<i);
    }
  }
  tot = (1<<(m))-1;
  memset(dp, -1, sizeof dp);
  ll ans = recurse(0, 0);
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 426368
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(RALL(x))
#define SUM(x) accumulate(ALL(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i < n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main () {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384