akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
map<string,int> a;
int main()
{
	int n,num=0;
	string s;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		if(a[s]==0)
		{
			num++;
			a[s]++;
		}
		else 
		a[s]++;
	}
	cout<<num;
    return 0;
}

Measured memory_bytes: 19084
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


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

	int N, x;
	cin >> N >> x;

	if (x == 1 || x == 2 * N - 1) {
		cout << "No" << endl;
		return 0;
	}
	if (N == 2 && x == 2) {
		cout << "Yes" << endl;
		rep(i, 3)cout << i + 1 << endl;
		return 0;
	}

	cout << "Yes" << endl;
	int ppp = 2;
	int counter = 3;
	if (x == 2) {
		ppp = 3;
		counter = 4;
	}

	for (int i = 1; i < N - 1; i++) {
		if (x == counter)counter++;
		cout << counter++ << endl;
	}
	cout << 2 * N - 1 << endl;
	cout << x << endl;
	cout << 1 << endl;
	cout << ppp << endl;
	for (int i = N + 3; i <= N * 2 - 1; i++) {
		if (x == counter)counter++;
		cout << counter++ << endl;
	}


	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;

ll n;
string s;

void input(void){
   cin>>n>>s;
}

void solve(void){
    ll ans=1,a=0;
    vl v;
    rep(i,n*2){
        if(s[i]=='W')v.push_back(0);
        else v.push_back(1);
    }
    rep(i,n*2){
        if((a+v[i])%2==1)a++;
        else {
            ans=(ans*a)%MOD;
            a--;
        }
    }
    if(a!=0)ans=0;
    for(ll i=1;i<n+1;i++){
        ans=(ans*i)%MOD;
    }
    cout<<ans<<endl;

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

Measured memory_bytes: 2700
h, w = map(int, input().split())
A = [str(input()) for _ in range(h)]

min_ = 0
max_ = 0
for i in range(h):
    flag = 1
    for j in range(w):
        if flag == 1 and A[i][j] == '#':
            min_ = j
            if min_ < max_:
                print('Impossible')
                exit()
            flag = 0
        if flag == 0 and A[i][j] == '#':
            max_ = j
else:
    print('Possible')


Measured memory_bytes: 38256
import java.util.Scanner;

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

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.lastIndexOf('Z') - s.indexOf('A') + 1;
    }
}

Measured memory_bytes: 26764
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int INF = 0xFFFFFFF;
	static long[][] hash = new long[32][32];
	static int[][][] buf = new int[2][8192][32];
	static long finish;

	public static void main(String[] args) {
		Random rnd = new Random();
		for (int i = 0; i < 32; ++i) {
			for (int j = 0; j < 32; ++j) {
				hash[i][j] = rnd.nextLong();
			}
		}
		for (int i = 0; i < 4; ++i) {
			for (int j = 2; j <= 7; ++j) {
				finish ^= hash[(j - 1) * 4 + i][i * 8 + j];
			}
		}
		int T = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < T; ++i) {
			sb.append(solve() + "\n");
		}
		System.out.print(sb);
	}

	static int solve() {
		ArrayList<Board> cur = new ArrayList<Board>();
		HashSet<Long> hashes = new HashSet<Long>(30000);
		cur.add(new Board(buf[0][0]));
		if (cur.get(0).h == finish) return 0;
		hashes.add(cur.get(0).h);
		int i = 1;
		ArrayList<Board> next = new ArrayList<Board>();
		for (; !cur.isEmpty(); ++i) {
			//			System.out.println("turn:" + i + " size:" + cur.size());
			next.clear();
			for (Board b : cur) {
				for (int j = 4; j < 32; ++j) {
					if (b.f[j] == INF && (b.f[j - 4] & 7) != 7) {
						Board created = new Board(buf[i & 1][next.size()], b, j);
						if (hashes.contains(created.h)) continue;
						if (created.h == finish) return i;
						hashes.add(created.h);
						next.add(created);
					}
				}
			}
			ArrayList<Board> tmp = cur;
			cur = next;
			next = tmp;
		}
		return -1;
	}

	static class Board {
		int[] f;
		long h;

		Board(int[] buf) {
			f = buf;
			for (int i = 0; i < 4; ++i) {
				for (int j = 1; j <= 7; ++j) {
					String v = sc.next();
					int suit = v.charAt(0) - '1';
					int num = v.charAt(1) - '0';
					int card = suit * 8 + num;
					if (num == 1) {
						f[j * 4 + i] = INF;
						f[suit] = card;
					} else {
						f[j * 4 + i] = card;
						h ^= hash[j * 4 + i][card];
					}
				}
			}
		}

		Board(int[] buf, Board orig, int pos) {
			this.f = buf;
			System.arraycopy(orig.f, 0, this.f, 0, 32);
			this.h = orig.h;
			final int target = orig.f[pos - 4] + 1;
			for (int i = 0; i < 32; ++i) {
				if (orig.f[i] == target) {
					this.f[i] = INF;
					this.h ^= hash[i][target];
					break;
				}
			}
			this.f[pos] = target;
			this.h ^= hash[pos][target];
		}
	}
}

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

using namespace std;
using llong = long long int;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

/* --------------- template start --------------- */
template <typename T> 
struct BinaryIndexTree { // [1, n]
    vector<T> array;
    int n;

    BinaryIndexTree(int _n) {
        array.resize(_n + 1, 0);
        n = _n;
    }

    T cumsum(int i) {
        T s = 0;
        while(i > 0) {
            s += array[i];
            i -= i & -i;
        }

        return s;
    }

    T sum(int i, int j) {
        T ret_i = cumsum(i - 1);
        T ret_j = cumsum(j);

        return ret_j - ret_i;
    }

    void add(int i, T x) {
        while (i <= n) {
            array[i] += x;
            i += i & -i;
        }
    }
};

template<typename T>
struct UnionFind {
    vector<int> par;
    vector<T> sz;

    UnionFind(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

    bool same(int x, int y) {
        return find_root(x) == find_root(y);
    }

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};
/* --------------- template end --------------- */

/* --------------- function start --------------- */
llong my_gcd(llong a, llong b) {
    return (a ? my_gcd(b % a, a) : b);
}
llong my_lcm(llong a, llong b) {
    return a * b / my_gcd(a, b);    
}

llong facmod(llong n) {
    if (n == 0) return 1;

    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

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

    return res;
}
llong modinv(llong n) {
    return powmod(n, MOD - 2);
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    }
    res = (res * modinv(facmod(k))) % MOD;

    return res;
}
/* --------------- function end --------------- */

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<llong> H(n);
    rep(i, n) cin >> H[i];

    sort(allr(H));

    llong ans = 0;
    rep(i, n) {
        if (i + 1 > k) ans += H[i]; 
    }

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b,c) for(int i=a;i<b;i+=c)
#define REPN(i,a,b,c) for(int i=a;i<=b;i+=c)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

vi adjList[100010];
int co[100010];
int st[100010];
int d[100010];
int c[100010];
int memo[100010][20];

void dp(int node, int dist, const int& color){
	if(memo[node][dist] != -1)return;
	if(co[node] == 0)co[node] = color;
	memo[node][dist] = 1;
	if(dist == 0)return;

	for(int nxt : adjList[node]){
		dp(nxt, dist - 1, color);
	}
}

int main(void){
	int n,m;
	sc(n);sc(m);
	FOR(i,m){
		int fr, to;
		sc(fr);sc(to);
		adjList[fr].pb(to);
		adjList[to].pb(fr);
	}

	int q;
	sc(q);
	FOR(i,q){
		sc(st[i]);sc(d[i]);sc(c[i]);
	}

	reset(memo, -1);
	for(int i = q-1;i>=0;i--){
		dp(st[i], d[i], c[i]);
	}

	for(int i = 1;i<=n;i++){
		printf("%d\n", co[i]);
	}



    return 0;
}


Measured memory_bytes: 15864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;

int main() {

  int n;
  cin >> n;
  vec1 w(n);
  for(int i = 0; i < n; i++) {
    cin >> w.at(i);
  }

  n--;
  int s1 = w.at(0);
  int s2 = w.at(n);
  n--;
  for(int i = 1; i <= n; i++) {
    if(s1 <= s2) {
      s1 = s1 + w.at(i);
    } else {
      s2 = s2 + w.at(n);
      n--;
      i--;
    }
  }
  if(s1 > s2) {
    cout << s1 - s2 << endl;
  } else {
    cout << s2 - s1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define CLR(a) memset(a,0,sizeof(a))
#define FOR(i,a,b) for(ll i=(a),_b=(b); i<=_b; i++)
#define FORE(i,a,b) for(ll i=(a),_b=(b); i>=_b; i--)

using namespace std;

typedef pair<int, int> II;
typedef vector<II> vi;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h / 2;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) cin >> s[i];
	int ans1 = 1e9;
	rep(i, (1 << (h - 1))){
		int ans = __builtin_popcount(i);
		vi cnt(h + 2, 0);
		vi gr(h + 2, 0);
		int ind = 0;
		rep(j, h){
			cnt[j] = ind;
			if(i & (1 << j)) ind++;
		}
		int bad = 0;
		rep(j, w){
			rep(l, h) if(s[l][j] == '1') gr[cnt[l]]++;
			rep(l, h) if(gr[l] > k){
				if(!j){
					bad = 1;
					break;
				}
				rep(m, h) gr[m] = 0;
				rep(m, h) if(s[m][j] == '1'){
					//add the current
					gr[cnt[m]]++;
				}
				ans++; //increment answer
				break;
			}
			rep(l, h) if(gr[l] > k){
				bad = 1;
				break;
			}
			if(bad) break;
		}
		if(bad) continue;
		ans1 = min(ans, ans1);
	}
	cout << ans1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int N;
int arr[101];

int main(void){
    scanf("%d", &N);
    int ans=0;
    
    

    for (int i=0;i<N;i++){
       scanf("%d", &arr[i]);
    }
    
    if (N<3) {
        printf("0\n");
        return 0;
    }

    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[k]&& arr[i]+arr[k]>arr[j]&& arr[k]+arr[j]> arr[i]){
                    if (arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[i]!=arr[k]) {
                        ans++;
                        //printf("%d %d %d\n",i,j,k);
                    }
                }
            }
         }      
        
    }
    
     printf("%d\n",ans);
  
return 0;
}


Measured memory_bytes: 1692
#include<iostream>

int main(){
	int a,b,c,d;
	int left,right;
	std::cin >> a >> b >> c >> d;
	left = a + b;
	right = c + d;
	if(left<right)std::cout << "Right";
	if(left>right)std::cout << "Left";
	if(left==right)std::cout << "Balanced";
	return 0;
}

Measured memory_bytes: 256
import sys
  
freq = {}

for s in sys.stdin:
    n = int(s.strip())
    if n not in freq:
        freq[n] = 1
    else:
        freq[n] += 1

sortedfreq = sorted(freq.items(), key=lambda x:-x[1])
modes = sorted(filter(lambda x: x[1] == sortedfreq[0][1], sortedfreq), key=lambda x:x[0])
for i in modes:
    print(i[0])


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

using namespace std ;

int main () {

    long long n , t ;

    string s ;

    cin >> s ;

    for (int i=0;i<3;i++){
        if (s[i]==s[i+1]){
            cout << "Bad\n" ;
            return 0 ;
        }
    }

    cout << "Good\n" ;

    return 0 ;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    long a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int sin=0;
    sort(a,a+n);
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1]){ 
            sin=1;
            break;
        }   
    }
    if(sin==1)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl; 
        
           
}

Measured memory_bytes: 1792
def resolve():
    A, B, C = list(map(int, input().split()))
    ans = ''
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        ans = 0
    else:
        ans = min(B * C, C * A, A * B)

    print(ans)
    return


resolve()

Measured memory_bytes: 9144
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

ll mpow(int base, int n) {
    ll b = base, ret = 1; 
    while(n) {
        if (n&1) ret *= b;
        n = n >> 1;
        b *= b; 
    }
    return ret;
}

int main() {
    int n, p; cin >> n >> p;
    int odd=0, even=0;
    rep(i, n) {
        int a; cin >> a;
        if (a&1) odd++;
        else even++; 
    } 
    ll ret = mpow(2, n-1);
    if (odd==0) {
        ret = p&1 ? 0 : mpow(2, n);
    }  
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
int dp[200010];
signed main(){
  int n;
  cin>>n;
  vector<vector<int> > v(200010);
  lp(i,n-1){
    int a,b;
    cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  queue<int> q;
  q.push(1);
  dp[1]=1;
  int ls;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    lp(i,v[now].size()){
      int next=v[now][i];
      if(dp[next]==1) continue;
      dp[next]=1;
      q.push(next);
    }
    ls=now;
  }
  q.push(ls);
  lp(i,200010) dp[i]=-1;
  dp[ls]=0;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    lp(i,v[now].size()){
      int next=v[now][i];
      if(dp[next]!=-1) continue;
      dp[next]=dp[now]+1;
      q.push(next);
    }
    ls=dp[now];
  }
  if(ls%3==1) cout<<"Second"<<endl;
  else cout<<"First"<<endl;
  return 0;
}

Measured memory_bytes: 15984
from collections import deque

H, W = map(int, input().split())
score = H * W
S = [[] for i in range(H)]
for i in range(H):
    for s in input():
        if s == "#":
            score -= 1
        S[i].append(s)


ls = deque([[0, 0]])
dir = [[1,0], [-1,0], [0,1], [0,-1]]
dp = [[float("inf") for i in range(W)] for j in range(H)]
dp[0][0] = 0
while len(ls) > 0:
    x, y = ls.popleft()

    if x == H-1 and y == W-1:
        print(score-dp[H-1][W-1]-1)
        break

    for dx, dy in dir:
        if (x+dx < 0) or (x+dx > H-1) or (y+dy < 0) or (y+dy > W-1):
            continue
        else:
            if S[x+dx][y+dy] == "." and dp[x][y]+1 < dp[x+dx][y+dy]:
                dp[x+dx][y+dy] = dp[x][y] + 1
                ls.append([x+dx, y+dy])

else:
    print(-1)

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	vector<ll> A(N);
	FOR(i, 0, N)
		cin >> A.at(i);
	sort(range(A));
	FOR(i,0,N-1){
		A.push_back(A.at(i));
	}
	sort(A.begin(), A.end(), greater<ll>());
	ll sum = 0;
	FOR(i, 0, N - 1)	sum += A.at(i);
	cout << sum << endl;

	return 0;
}



Measured memory_bytes: 6368
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct line
{
    ll l, r;
    bool operator < (const line &rhs) const 
    {
        return r < rhs.l;
    } 
};
unordered_map<int, set<line>>eq;
void add(int ind, ll l, ll r)
{
    line x = {l, r};
    while (1)
    {
        auto it = eq[ind].find(x);
        if (it == eq[ind].end()) break;
        x = {min(x.l, it->l), max(x.r, it->r)};
        eq[ind].erase(it);
    }
    eq[ind].insert(x);
}
int main()
{
    ll N, X, D; scanf("%lld%lld%lld", &N, &X, &D);
    if (!D) {printf("%lld\n", X ? N + 1 : 1ll); return 0;}
    if (D < 0) 
    {
        X += (N - 1) * D;
        D = -D;
    }
    for (ll k = 0; k <= N; k++) 
    {
        int ind = (k * X) % D;
        if (ind < 0) ind += D;
        ll det = (ind - k * X) / D;
        add(ind, k * (k - 1) / 2 - det, k * (2 * N - k - 1) / 2 - det);
    }
    ll ans = 0;
    for (auto item : eq)
        for (auto x : item.second) ans += x.r - x.l + 1;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 30408
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
struct edge{int to,cost;};
vector<int> G[100005];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
std::vector<P> tree[100010];
ll i,j;
ll a,b,c;
 
int main(){
	cin>>a>>b>>c;
	if(a+b>=c)cout<<"Yes";
	else cout<<"No";
	cout<<endl;
	return 0;
}

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

template<class Ty>
Ty pow_repeat(const Ty &a, unsigned long long exp) {
	Ty buf = Ty(1);
	int i = 63;
	for (; i >= 0; i--) if (exp >> i) break;
	for (; i >= 0; i--) {
		buf = buf * buf;
		if ((exp >> i) & 1) buf *= a;
	}
	return buf;
}

struct modint {
	unsigned m_v;
	modint(unsigned v) { m_v = v; }
	modint operator*(const modint&a) {
		unsigned long long buf = (unsigned long long)m_v * a.m_v;
		return modint{ (unsigned)(buf % 1000000007) };
	}
	modint &operator*=(const modint&a) { m_v = (*this * a).m_v; return *this; }
};

int main() {
	unsigned m, n; cin >> m >> n;
	modint M = modint{ m };
	modint MN = pow_repeat(M, n);
	cout << MN.m_v << endl;
}



Measured memory_bytes: 3088
num = gets.to_i
spades, hearts, clubs, dias = [], [], [], []
card_kinds = {'S' => spades, 'H' => hearts, 'C' => clubs, 'D' => dias}
num.times do
  card = gets.split
  case card[0]
  when "S"
    spades << card[1].to_i
  when "H"
    hearts << card[1].to_i
  when "C"
    clubs << card[1].to_i
  when "D"
    dias << card[1].to_i
  end
end
card_kinds.each do |cards_name, cards_arr|
  (1..13).each do |i|
    if !(cards_arr.include?(i))
      puts "#{cards_name} #{i}"
    end
  end
end


Measured memory_bytes: 6864
#include <iostream>
#include <vector>
#include <deque>
#include <set>
#include <cmath>
#include <bits/stdc++.h>
#include <limits>

#define MOD 1000000007

using namespace std;

int main(void){
    // Your code here!
    int n;
    
    cin >> n;
    if(n / 100 == n % 10)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::map<std::string, int> map;
    for (int i = 0; i < n; ++i) {
        std::string c;
        std::cin >> c;
        ++map[c];
    }
    std::vector<std::string> ans;
    int max_count = 0;
    for(const std::pair<std::string, int> &p: map){
        if(p.second > max_count){
            max_count=p.second;
            ans.clear();
            ans.emplace_back(p.first);
        }else if(p.second == max_count){
            ans.emplace_back(p.first);
        }
    }
    for(const std::string &a: ans){
        std::cout << a << '\n';
    }
}

Measured memory_bytes: 26868
#include <stdio.h>
int main(){
  int x,y;
  while(1){
    scanf("%d%d",&x,&y);
    if(x == 0 && y == 0)break;
    if(x >= y)printf("%d %d\n",y,x);
    else printf("%d %d\n",x,y);
  }return 0;
}

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

int main() {
  int64_t A, B, C, K, count=0, f1=1;
  cin >> A >> B >> C >> K;//1 0 -1 K枚
  
  if (K>=A) count=A;
  if (K<A) {
    cout << K << endl;
    f1=0;
  }
  K=K-A-B;
  if (K>0 && f1==1) {
    count=count-K;
    cout << count << endl;
  }
  if (K<=0 && f1==1) {
    cout << count << endl;
  }
}
  

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

a1 = [int(i) for i in input().split()]
a2 = [int(i) for i in input().split()]
a3 = [int(i) for i in input().split()]

n = int(input())

b = [0] * n
for i in range(n):
    b[i] = int(input())

for v in b:
    try:
        i = a1.index(v)
        a1[i] = 0
        continue
    except:
        pass
    try:
        i = a2.index(v)
        a2[i] = 0
        continue
    except:
        pass
    try:
        i = a3.index(v)
        a3[i] = 0
        continue
    except:
        pass

def cond():
    if a1[0] == 0 and a1[1] == 0 and a1[2] == 0:
        return True
    if a2[0] == 0 and a2[1] == 0 and a2[2] == 0:
        return True
    if a3[0] == 0 and a3[1] == 0 and a3[2] == 0:
        return True
    if a1[0] == 0 and a2[0] == 0 and a3[0] == 0:
        return True
    if a1[1] == 0 and a2[1] == 0 and a3[1] == 0:
        return True
    if a1[2] == 0 and a2[2] == 0 and a3[2] == 0:
        return True
    if a1[0] == 0 and a2[1] == 0 and a3[2] == 0:
        return True
    if a1[2] == 0 and a2[1] == 0 and a3[0] == 0:
        return True
    return False

if cond():
    print('Yes')
else:
    print('No')      

Measured memory_bytes: 40544
#include<iostream>                                                                    
#include<algorithm>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)n;i++)

int n;
int A[30];
int q;
int m[300];

bool solve(int i,int m){ 
        if(m==0) return true;
        else if(i>=n) return false;
        else return solve(i+1,m)||solve(i+1,m-A[i]);
}


int main(){
        cin>>n;
        Rep(i,n) cin>>A[i];
        cin>>q;
        Rep(i,q) cin>>m[i];
        Rep(i,q){
                if(solve(0,m[i])){
                        cout<<"yes"<<endl;
                }
                else cout<<"no"<<endl;
        }
        return 0;
    



}



Measured memory_bytes: 3092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<int> d(n);
	rep(i, 0, n - 1)cin >> d[i];
	sort(all(d));
	cout << d[n / 2] - d[n / 2 - 1] << endl;
}

Measured memory_bytes: 640
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)

int main(){
	int N;
	string S;
	cin >> N >> S;
	int x = 0;
	int max = 0;
	Foreach(item, S) {
		if (item == 'I') { x++; }
		else x--;
		if (max < x) max = x;
	}
	out(max);
	return 0;
}



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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

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

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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 x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

ll n,ans=0;

bool check(string s){
	map<char,bool> m;
	rep(i,SIZE(s)) m[s[i]]=true;
	if(m['3'] && m['5'] && m['7']) return true;
	else return false;
}

void dfs(ll x){
	if(check(to_string(x)) && x<=n) ans++;
	if(x<=1000000000){
		dfs(x*10+3);
		dfs(x*10+5);
		dfs(x*10+7);
	}
}

int main()
{
	cin >> n;
	dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
#include<cstdlib>
#include<cmath>
#include<deque>
#include <numeric>
#include<valarray>
typedef unsigned long long ull;
typedef  long long ll;

int main() {
	int N;

	std::cin >> N;
	std::vector< double> vx;
	vx.resize(N);
	for (int i = 0; i < N; i++)
	{
		int tmpn;
		std::cin >> tmpn;
		vx[i] = (double)tmpn;
	}
	std::sort(vx.begin(), vx.end());

	double suma = (vx[0] + vx[1])/2.0;

	for (int i = 2; i < N; i++)
	{
		suma = (suma + vx[i]) / 2.0;
	}

	std::cout << suma << std::endl;
	return 0;
}

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

int main(){
    while (1){
        int a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) break;
        else{ 
            for (int i= 0; i<a; i++){
                for (int j=0; j<b; j++){
                    if (i == 0|| i == a-1) cout << '#';
                    else if (j == 0||j == b-1) cout << '#';
                    else cout << '.';
                }
            cout << endl;
            }
          cout << endl;
        }
    }
}


Measured memory_bytes: 3080
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;


void solveCase() {
   int n, c, k;
   cin >> n >> c >> k;
   vector <int> t(n);
   for(int i = 0; i < n; i++) {
      cin >> t[i];
   }
   sort(t.begin(), t.end());

   int last_bus_time = t[0];
   int bus_count = 1;
   int pass = 0;
   for(int i = 0; i < n; i++) {
      if(t[i] - last_bus_time > k || pass == c) {
         last_bus_time = t[i];
         bus_count ++;
         pass = 1;
      } else {
         pass++;
      }
   }
   cout << bus_count << endl;
}

 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

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

int main(){
    ll INF = 1e14;
    int n,k;
    cin >> n >> k;
    ve<ll> a(n);
    rep(i,n) cin >> a[i];
    ve<ve<ll>> dp(n,ve<ll>(k+1, INF));
    ve<ve<ll>> max(n,ve<ll>(k+1,INF));
    dp[0][0] = 0;
    max[0][0] = a[0];
    for(int i = 1; i < n; i++){
        rep(j,k){
            if(a[i]>max[i-1][j]){
                max[i][j+1] = a[i];
                dp[i][j+1] = min(dp[i-1][j+1],dp[i-1][j]);
                dp[i][j] = dp[i-1][j];
            }else{
                max[i][j+1] = max[i-1][j]+1;
                dp[i][j+1] = min(dp[i-1][j+1],dp[i-1][j] + max[i-1][j]+1-a[i]);
                max[i][j] = min(max[i][j],max[i-1][j]);
                dp[i][j] = min(dp[i][j],dp[i-1][j]);
            }
        }
    }
    cout << dp[n-1][k-1] <<endl;
    return 0;
}

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

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

    int X, Y, Z, K; cin >> X >> Y >> Z >> K;

    long long A[X], B[Y], C[Z];
    for (int i = 0; i < X; ++i) cin >> A[i];
    for (int i = 0; i < Y; ++i) cin >> B[i];
    for (int i = 0; i < Z; ++i) cin >> C[i];

    vector<long long> tastes;
    for (int i = 0; i < X; ++i) 
        for (int j = 0; j < Y; ++j) 
            tastes.push_back(A[i] + B[j]);
    sort(tastes.begin(), tastes.end(), greater<long long>());

    vector<long long> ans;
    for (int i = 0; i < Z; ++i) 
        for (int j = 0; j < min((int)tastes.size(), K); ++j)
            ans.push_back(tastes[j] + C[i]);
    sort(ans.begin(), ans.end(), greater<long long>());

    for (int i = 0; i < K; ++i) cout << ans[i] << "\n";
    
    return 0;
}

Measured memory_bytes: 42948
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll GCD(ll a, ll b){
    if(b==0) return a;
    else return GCD(b,a%b);
}

vl divisor(ll k){
    vl c;
    for(ll i=1; i*i<=k; i++){
        if(k % i == 0){
            c.push_back(i);
            if((k / i) != i){
                c.push_back(k/i);
            }
        }
    }
    sort(c.begin(), c.end());
    return c;
}

bool isPrime(ll x){
    if(x==1) return true;
    bool f = true;
    for(ll i=2; i<=sqrt(x); i++){
        if(x % i == 0){
            return false;
        }
    }
    return true;
}

 
int main(){
    ll a,b; cin >> a >> b;
    ll g = GCD(a,b);
    vl div = divisor(g);
    ll ans = 0;
    for(ll i=0; i<div.size(); i++){
        if(isPrime(div[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N, K;
    string S;
    cin >> N >> K >> S;
    ll cnt = 0, ans = 0;
    for(ll i = 1; i < S.size(); i++) {
        cnt += S[i - 1] != S[i];
        ans += S[i - 1] == S[i];
    }
    ll need = (cnt + 1) / 2;
    if(need <= K) ans = N - 1;
    else ans += K * 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#![allow(unused_imports)]
#![allow(unused_macros)]
use itertools::Itertools;
use std::cmp::{max, min};
use std::collections::*;
use std::i64;
use std::io::{stdin, Read};
use std::usize;

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut s: Vec<_> = it
        .next()
        .unwrap()
        .chars()
        .map(|c| c.to_digit(10).unwrap())
        .collect();
    let mut ret = 0;
    for i in 0..1000 {
        let p = if i < 10 {
            vec![0, 0, i]
        } else if i < 100 {
            vec![0, i / 10, i % 10]
        } else {
            vec![i / 100, (i % 100) / 10, i % 10]
        };
        let mut cur = 0;
        for &j in &s {
            if j == p[cur] {
                cur += 1;
            }
            if cur > 2 {
                break;
            }
        }
        if cur > 2 {
            ret += 1;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, n) cin >> a[i];
    ll cnt = 0;

    bool judge = false;
    if (a[0] > 0) judge = true;
    rep(i, n - 1) if (a[i + 1] - a[i] > 1) judge = true;

    if (judge) {
        cout << -1 << endl;
        return 0;
    }

    ll before = 0;

    REP(i, 1, n) {
        if (before < a[i]) cnt++;
        else if (a[i] == 0);
        else cnt += a[i];
        before = a[i];
    }

    cout << cnt << endl;

    return 0;
}


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

int main(){
    int n;
    double res;
    cin >> n;
    vector<int> v(n);
    for(int i = 0;i < n;i++){
        cin >> v.at(i);
        res += 1.0/v.at(i);
    }
    res = 1.0/res;
    cout  << res << endl;
}

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

using namespace std;

int main() {
  long long X, Y;
  cin >> X >> Y;

  int cnt = 0;
  long long n = X;
  
  while (n <= Y) {
    cnt++;
    n *= 2;
  }

  cout << cnt << endl;

  return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

const int N = 55;

int n, m, q;
int a[N], b[N], c[N], d[N], e[N];

int ans = 0;

void check() {
  int sum = 0;
  for (int i = 1; i <= q; i++) {
    if (e[b[i]] - e[a[i]] == c[i]) {
      sum += d[i];
    }
  }
  ans = max(ans, sum);
}

void brute(int i) {
  for (int j = e[i - 1]; j <= m; j++) {
    e[i] = j;
    if (i == n) check();
    else brute(i + 1);
  }
}

void solve() {
  cin >> n >> m >> q;
  for (int i = 1; i <= q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  e[0] = 1;
  brute(1);
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) solve();
}


Measured memory_bytes: 3640
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    int n,A[1000];
    
    while(1){
        cin >> n;
        if(n == 0) break;
        
        for(int i=0;i<n;i++) cin >> A[i];
        int sum = 0.0;
        for(int i=0;i<n;i++) sum += A[i];
        double m = 1.0*sum/n;
        double dist = 0;
        for(int i=0;i<n;i++){
            dist += (A[i]-m)*(A[i]-m);
        }
        printf("%lf\n",sqrt(dist/n));
    }
}


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

using namespace std;

using i64 = int64_t;

#define FOR(i,start,end) for(int i=(start); i<(end); ++i)
#define REP(i,n) FOR(i,0,n)

i64 N;
i64 M;
vector<i64> A;

void solve() {
    vector<i64> sum(N+1, 0);
    partial_sum(begin(A), end(A), begin(sum)+1);
    transform(begin(sum), end(sum), begin(sum), [](auto e) { return e%M; });

    unordered_map<i64,i64> cnt;
    for(auto e : sum) {
        cnt[e] += 1;
    }

    i64 ans = 0;
    for(auto e : sum) {
        ans += cnt[e] - 1;
        --cnt[e];
    }

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

int main() {
    cin >> N;
    A.resize(N);
    cin >> M;

    REP(i, N) {
        cin >> A[i];
    }

    solve();
}


Measured memory_bytes: 5260
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

s = sinput()
n = len(s)

flag = 1
if s != s[::-1]: flag = 0
if s[:(n-1)//2] != s[:(n-1)//2][::-1]: flag = 0
if s[(n+3)//2-1:] != s[(n+3)//2-1:][::-1]: flag = 0


if flag: print("Yes")
else: print("No")


Measured memory_bytes: 20716
#include<stdio.h>
#include<stdlib.h>

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

char s[8]="AGCT";

int main(){
    int i,j,k,l,r=0;
    char t[16];
    scanf("%s",t);
    l=strlen(t);
    for(i=0;i<l;i++){
        for(j=i;j<l;j++){
            for(k=0;k<4;k++){
                if(t[j]==s[k]){k=-1;break;}
            }
            if(k!=-1){break;}
            r=max(r,j-i+1);
        }
    }
    printf("%d\n",r);
    return 0;
}


Measured memory_bytes: 128
/*Always success does not build on success,success build on failure and hardwork*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<long long>
#define map         map<long long,long long>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(long long i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const long long N=1e5+5;
int main()
{
   int n;
   scn(n);

   if(n<30)
   cout<<"No"<<endl;
   else
   cout<<"Yes"<<endl;
}

Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll a[100010];
int sign(int n) 
{
    if(n > 0) return 1;
    if(n < 0) return -1;
    return 0;
}

int main(void)
{
    ll n;
    ll res = 0;
    ll si, d;
    ll s = 0;
    ll su[2];
    cin >> n;
    REP(i, n) cin >> a[i];
    REP(j, 2) {
        si = j * 2 - 1;
        res = 0;
        s = 0;
        REP(i, n) {
            s += a[i];
            if(sign(s) != si) {
                d = si - s;
                res += abs(d);
                s += d;
            }
            si = -si;
//        cout << "i:" << i << "  d:" << d << "  res:" << res << "  s:" <<  s << endl;
        }
//        cout << "j:" << j << " res:" << res << endl;
        su[j] = res;
    }
    cout << min(su[0], su[1]) << endl;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
city = [0]*M
for i in range(M):
    city[i] = [i] * 4
    prefecture, year = map(int, input().split())
    city[i][0], city[i][1] = year, prefecture

city = sorted(city)

ite = [1] * (N+1)
for k in range(M):
    city[k][3] = ite[city[k][1]]
    ite[city[k][1]] += 1
city = sorted(city, key=lambda x: x[2])
for j in range(M):
    print("{:0=12}".format(city[j][1]*1000000+city[j][3]))  # zero padding


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

int main () {
    int n,max,min,t;
    cin >> n;
    cin >> t;
    max = min = t;
    
    for (int i=0;i<n-1;i++){
        cin >> t;
        if(t>max)max=t;
        if(t<min)min=t;
    }
    
    cout << max - min << endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

const mod = 1000000007

func main() {
	var n,m int
	fmt.Scan(&n,&m)

	a := make([]int,m)
	for i := 0; i < m; i++ {
		a[i] = scanInt()
	}

	s := make([]int,n)
	s[0] = 1
	if n>1 {
		s[1] = 1
	}
	p := 0
	for i := 0; i < n; i++ {
		if p < m {
			if a[p] == i+1 {
				s[i] = 0
				p++
			}
		}
		
		if i+1 < n {
			s[i+1] = (s[i+1] + s[i]) %mod
		}

		if i+2 < n {
			s[i+2] = (s[i+2] + s[i]) %mod
		}
	}

	fmt.Println(s[len(s)-1])
}

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}


Measured memory_bytes: 2816
X = int(input())

flag = False
for i in range(150):
    for j in range(150):
        if i**5 - j**5 == X:
            print(i,j)
            flag = True
            break
        if (-i)**5 - j**5 == X:
            print(-i,j)
            flag = True
            break
        if i**5 - (-j)**5 == X:
            print(i,-j)
            flag = True
            break
        if (-i)**5 - (-j)**5 == X:
            print(-i,-j)
            flag = True
            break
    if flag:
        break

Measured memory_bytes: 9212