akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

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

		//入力
		int n = sc.nextInt();
		sc.nextLine();
		String[] s = new String[n];
		for(int i = 0; i < n; i++){
			s[i] = sc.nextLine();
		}
		sc.close();

		//処理
		int[] commonchars = new int[26];
		Arrays.fill(commonchars, 0);
		for(int i = 0; i < s[0].length(); i++){
			commonchars[s[0].charAt(i) - 'a']++;
		}
		for(int i = 1; i < n; i++){
			String ts = s[i];
			int[] tempchars = new int[26];
			Arrays.fill(tempchars, 0);
			for(int j = 0; j < ts.length(); j++){
				tempchars[ts.charAt(j) - 'a']++;
			}
			for(int j = 0; j < 26; j++){
				commonchars[j] = Math.min(commonchars[j], tempchars[j]);
			}
		}

		//出力	
		for(int i = 0; i < 26; i++){
			int t = commonchars[i];
			for(int j = 0; j < t; j++){
				out.print((char)('a'+i));
			}
		}
		out.println();
		out.flush();
	}
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#include <algorithm>
using namespace std;
#define INF 0x7FFFFFFF
#define ll int

ll get_num();

string s;
vector<map<ll,ll> > a;
vector<ll> b;
vector<ll> c;

int t;

//[   -1
//]   -2

void pr(vector<ll> k){
  cout <<  "x ";
  for(int i=0;i<k.size();i++){
    cout << k[i] << " ";
  }
  cout << endl;
}

int main(){
  vector<ll> z;
  map<ll,ll> m;
  cin >> s;
  while(s!="."){
    ll ans=0;
    ll an=0;
    a.assign(52,m);
    c.assign(52,0);


    while(s!="."&&ans==0){
      b.assign(0,0);
      an++;
      int f=0;
      int e=0;
      t=0;
      for(int i=0;i<(int)s.size();i++){
        if(s[i]=='['){
          b.push_back(-64);
        }
        else if(s[i]==']'){
          b.push_back(-65);
          f=0;
        }
        else if(s[i]=='='){
          b.push_back(-66);
          e++;
        }
        else if('a'<=s[i]&&s[i]<='z'){
          b.push_back(-1-(s[i]-'a'));
        }
        else if('A'<=s[i]&&s[i]<='Z'){
          b.push_back(-1-(s[i]-'A'+26));
        }
        else if('0'<=s[i]&&s[i]<='9'){
          if(f==0){
            b.push_back(s[i]-'0');
            f++;
          }
          else{
            b[b.size()-1]*=10;
            b[b.size()-1]+=s[i]-'0';
          }
        }
      }
      if(e==0){
        ll ra,rb;
        ra=-b[t]-1;
        t++;
        t++;
        rb=get_num();
        t++;
        if(rb>=0){
          //a[ra].assign(rb,-1);
          c[ra]=rb;
        }
        else{
          ans=an;
        }
      }
      else{
        ll ra,rb,rc;
        ra=-b[t]-1;
        t++;
        t++;
        rb=get_num();
        t++;
        t++;
        rc=get_num();
        t++;
        if(rb<(int)c[ra]&&rc>=0){
          a[ra][rb]=rc+1;
        }
        else{
          ans=an;
        }
      }
      cin >> s;
    }
    cout << ans << endl;
    while(s!="."){
      cin >> s;
    }
    cin >> s;
  }
}

ll get_num(){
  if(b[t]>=0){
    t++;
    return b[t-1];
  }
  else{
    ll ra,rb;
    ra=-b[t]-1;
    t++;
    t++;
    rb=get_num();
    t++;
    if(rb<c[ra]){
      return a[ra][rb]-1;
    }
    else{
      return -1;
    }
  }
}



Measured memory_bytes: 3196
def find_route(now, node, route):
    count = 0
    if min(node) == 1:
        return 1
    dist = route[now]
    for i in dist:
        if node[i] == 0:
            tmpnode = node.copy()
            tmpnode[i] = 1
            count += find_route(i, tmpnode, route)
    return count

(n, m) = list(map(int, input().split()))
route = {}
for i in range(m):
    (a, b) = list(map(int, input().split()))
    a -= 1
    b -= 1
    if a in route:
        route[a].append(b)
    else:
        route[a] = [b]
    if b in route:
        route[b].append(a)
    else:
        route[b] = [a]
count = find_route(0, [1] + [0 for _ in range(n - 1)], route)

print(count)

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

#define en "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fs first
#define sc second
#define size(a) (int) a.size()
#define deb(x) cerr << #x << " => " << x << en
#define debp(a) cerr << #a << " => " <<"("<<a.fs<<", "<<a.sc<<") " << en;
#define deba(x) cerr << #x << en; for (auto a : x) cerr << a << " "; cerr << en;
#define debpa(x) cerr << #x << en; for (auto a : x)cerr<<"("<<a.fs<<", "<<a.sc<<") "; cerr << en;
#define debm(x) cerr << #x << en; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << en;}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m = HELL) { int res = 1; a %= m;
while (b > 0) { if (b & 1) res = (res * a) % m; a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2)
#define mul(a, b) ((a % HELL) * (b % HELL)) % HELL

int32_t main() { fastio;
	int n; cin >> n;
	int count = 0;
	while (n--) {
		int a, b; cin >> a >> b;
		if (a == b) {
			count++;
		} else {
			count = 0;
		}
		if (count == 3) {
			cout << "Yes" << endl;
			exit(0);
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if (( (x+r) <= w) && ((y+r) <= h) && ((x-r) >= 0) && ((y-r) >= 0) && ( (w-(2*r) >=0 ) && ((h-(2*r) >=0 ))))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}



Measured memory_bytes: 3124
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
const ll maxN=2e5+5;
ll n  , a , b ;
array<ll,2> A[maxN] , B[maxN];
void solve(){
	cin>> n ;
	ll ans=n+n*n + n*n*n ;
	cout<<ans<<endl;
}

int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>>t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), k = sc.nextInt();

        int[] pow = new int[28];
        pow[0] = 1;
        for (int i = 1; i < 28; i++) {
            pow[i] = pow[i - 1] * 2;
        }

        double ans = 0;
        int x = 0;
        for (;k > pow[x]; x++) {}

        int cnt = 0;

        for (int i = 1; i <= n; i++) {
            if (k <= i) {
                ans += 1.0;
            } else {
                int c = (k + i - 1) / i;
                int t = 0;
                for (; c > pow[t]; t++) {}
                ans += (1.0 / pow[t]);
//                debug(1.0 / pow[t]);
            }
        }
        System.out.println(ans / n);
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 21844
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  cin >> s;
  int a = 0, b = 0, c = 0;
  REP(i, s.size()) {
    if(s[i] == 'a') a++;
    else if(s[i] == 'b') b++;
    else if(s[i] == 'c') c++;
  }
  if(max({a, b, c}) - min({a, b, c}) <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
mov :: (Int,Int,Int,Int,Int,Int) -> Char -> (Int,Int,Int,Int,Int,Int)
mov (p1,p2,p3,p4,p5,p6) 'N' = (p2,p6,p3,p4,p1,p5)
mov (p1,p2,p3,p4,p5,p6) 'S' = (p5,p1,p3,p4,p6,p2)
mov (p1,p2,p3,p4,p5,p6) 'W' = (p3,p2,p6,p1,p5,p4)
mov (p1,p2,p3,p4,p5,p6) 'E' = (p4,p2,p1,p6,p5,p3)

ini :: [Int] -> (Int,Int,Int,Int,Int,Int)
ini (a:b:c:d:e:f:_) = (a,b,c,d,e,f)

ans state [] = state
ans state (a:as) =
  let next = mov state a
  in
    ans next as

main = do
  d <- getLine
  m <- getLine
  let a = ini $ map read $ words d :: (Int,Int,Int,Int,Int,Int)
      p@(p1,p2,p3,p4,p5,p6) = ans a m
  print p1

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

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

constexpr ll MOD = 1000000007;

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

  int a[5];
  rep(i, 5) cin >> a[i];
  int k; cin >> k;

  if (a[4] - a[0] <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;

  return (0);
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int n,m;
int a[300000];
pair < ll , ll >  b[300000];
ll temp[300000];
int main()
{
  cin>>n>>m;
  for(int i=0;i<n;i++)
  {
      scanf("%d",&a[i]);
  }
  ll ans = 0;
  for(int i=1;i<n;i++)
  {
      ll x = a[i-1];
      ll y = a[i];
      if(y >= x)
        {
            ll dis = (y-x);
            if(dis > 1)
            {
                b[y].fr++;
                b[x+1].fr--;
                b[y].sc+=(dis-1);
            }
            ans+=(y-x);
        }
      else
      {
          ll dis = (m-x+y);
          if(dis > 1)
          {
              b[x+1].fr--;
              b[m+y].fr+=1;
              b[m+y].sc+=(dis-1);
          }
          ans+=(m-x+y);
      }
  }
  ll x1 , x2;
  x1 = 0 , x2 = 0;
  ll maxx = 0;
  for(int i=2*m;i>=0;i--)
  {
     x1+=b[i].fr;
     x2+=b[i].sc;
     temp[i%m]+=x2;
     maxx = (max(maxx , temp[i%m]));
     x2-=(x1);
   }
  cout<<ans-maxx;
}


Measured memory_bytes: 7168
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, M = map(int, input().split())

    ans = set()
    for i in range(N):
        A = set(list(map(int, input().split()))[1:])
        if i == 0:
            ans = A
        else:
            ans.intersection_update(A)
    print(len(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
N,M = map(int,input().split())
A = [int(input()) for i in range(M)]
broken = [False] * (N + 1)
dp = [0] * (N + 1)
for a in A:
    broken[a] = True

dp[0] = 1
if broken[1]:
    dp[1] = 0
else:
    dp[1] = 1


for i in range(2,N+1):
    if broken[i] and broken[i-1]:
        print(0)
        exit(0)
    if broken[i]:
        dp[i] = 0
    else:
        dp[i] = dp[i - 1] + dp[i - 2]
#print(dp)
print(dp[N] % 1000000007)
#print(13 % 4)

Measured memory_bytes: 460788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String ans = "";

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a > b && a > c) ans = "A";
		if (b > a && b > c) ans = "B";
		if (c > a && c > b) ans = "C";

		System.out.println(ans);

	}

}



Measured memory_bytes: 26240
#include<stdio.h>
#include<string.h>
int main()
{

    char in[12000]; int i,n,j; int arr[123];

    scanf("%[^\t]s",in);

    for(i=0,j=0;i<strlen(in);i++)
    {
        if(in[i]<='Z' && in[i]>='A') {in[i]=in[i]+32;}
    }

    for(n=97;n<123;n++)
    {
        for(i=0;i<strlen(in);i++)
        {
        if (in[i]==n) arr[n]++;
        else continue;
        }
    }

    for(j=1,n=97;j<=26 && n<123;j++,n++)
    {
        printf("%c : %d\n",n,arr[n]);
    }




}







Measured memory_bytes: 2692
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++)
  {
    cin >> vec[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    while (vec[i] % 2 == 0)
    {
      vec[i] /= 2;
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

using ll = long long;
using namespace std;

int main() {
    int N, H;
    cin >> N >> H;
    vector<pair<int, int>> k(N * 2);
    REP(i, N * 2) {
        if (i % 2 == 0) {
            cin >> k[i].first;
            k[i].second = -1;
        }
        else {
            cin >> k[i].first;
            k[i].second = 1;
        }
    }

    sort(k.begin(), k.end(), [](auto p1, auto p2) {return p1.first > p2.first; });
    int ans = 0;
    int index = 0;
    while (H > 0) {
        if (k[index].second == 1) {
            H -= k[index].first;
            ans++;
            index++;
        }
        else {
            int cnt = (H + (k[index].first - 1)) / k[index].first;
            ans += cnt;
            H = 0;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc115/tasks/abc115_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int d;
  string r;

  cin >> d;

  switch (d)
  {
  case 25:
    r = "Christmas";
    break;
  case 24:
    r = "Christmas Eve";
    break;
  case 23:
    r = "Christmas Eve Eve";
    break;
  case 22:
    r = "Christmas Eve Eve Eve";
  default:
    break;
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; a++) {
        for (int b = 0; b + a <= N; b++) {
            int c = N - a - b;
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    cout << res10000 <<  " " << res5000 << " " << res1000 << endl;
}

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

int _;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int n,k,a[300050],ans;

int main()
{	
	//for(scanf("%d",&_);_;_--)
	scanf("%d",&k);
	for(int i=0;i<k;i++)
		printf((i == k-1) ?"ACL\n":"ACL");
	return 0;
}

Measured memory_bytes: 3732
import math
import sys
def getN():
    return int(input())

def getIntList():
    return list(map(int, input().split()))

def main():
    
    N = getN()

    result = 0
    for i in range(1,N+1):
        if i % 5 != 0 and i % 3 != 0:
            result += i
            #print(i)
    
    print(result)

    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 9176
(let ((n (read))
    (a 0)
    (ans 0))
    (setq a n)
    (loop for i from 1 to n do
        (loop for j from a downto 1 do
            (if (< (* i j) n)
                (progn
                    ;; (format t "~D ~D ~%" i j)
                    (incf ans j)
                    (setq a j)
                    (return)
                )
                ;; (format t "NO~D ~D ~%" i j)
            )
        
        )
    
    )
    (format t "~D~%" ans)
)

Measured memory_bytes: 24396
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    int N, W;
    cin >> N >> W;
    int max_val = 100000;
    vector <vector <ll>> dp(N, vector <ll>(max_val+1, W+1));
    vector <int> w(N), v(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
        dp[i][0] = 0;
    }

    dp[0][v[0]] = w[0];
    int ans = 0;
    for (int i = 1; i < N; i++) {
      for (int j = 0; j <= max_val; j++) {
        if (j >= v[i]) {
          dp[i][j] = min(dp[i-1][j-v[i]] +w[i], dp[i-1][j]);
        } else {
          dp[i][j] = dp[i-1][j];
        }
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= max_val; j++) {
        if (dp[i][j] <= W) {
          ans = max(ans, j);
        }
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 79488
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define ump unordered_map
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define fore(i,a,n) for(int i=a;i<=n;i++)
#define len length()
#define N 200000
int main()
{
	int n;
	cin>>n;
	int arr[n];
	forl(i,0,n) cin>>arr[i];
	int dp[n];
	dp[0]=0;
	forl(i,1,n) dp[i]=INT_MAX;
	forl(i,1,n)
	{
		for(int j:{i-1,i-2})
		{
			if(j>=0)
			dp[i]=min(dp[i],dp[j]+abs(arr[j]-arr[i]));
		}
	}
	cout<<dp[n-1]<<endl;
	
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[44];

int func(int x) {
	int y = x - 1;
	for(int i = 31; i >= 0; i--) {
		if(((x >> i) & 1) != ((y >> i) & 1)) {
			return i;
		}
	}
	return 0;
}
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[func(x)] = 1;
		sum ^= x;
	}
	int ans = 0;
	for(int i = 31; i >= 0; i--) {
		if((sum >> i) & 1) {
			if(a[i] == 0) {
				cout << -1 << endl;
				exit(0);
			}
			sum ^= (1 << (i + 1)) - 1;
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct card
{
    char suit;
    int num;
};
void bubble_sort(struct card A[],int n)
{
    for(int i=0;i<n;i++)
    {
        for(int j=n-1;j>i;j--)
        {
            if(A[j].num<A[j-1].num)
            {
                card t=A[j];
                A[j]=A[j-1];
                A[j-1]=t;
               
            }
        }
       
    }
}
void selection_sort(struct card A[],int n)
{
    for(int i=0;i<n;i++)
    {
        int mini=i;
        for(int j=i;j<n;j++)
        {
            if(A[j].num<A[mini].num)
            {
                mini=j;
            }
        }
        card t=A[i];
        A[i]=A[mini];
        A[mini]=t;
    }
}
void print(struct card A[],int n)
{
    for(int i=0;i<n;i++)
    {
        cout << A[i].suit<<A[i].num;
        if(i!=n-1)
        {
            cout <<' ';
        }
    }
    cout<<endl;
}
bool is_stable(struct card A[],struct card B[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(A[i].suit!=B[i].suit)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    struct card cards1[36],cards2[36];
    for(int i=0;i<n;i++)
    {
        cin>>cards1[i].suit>>cards1[i].num;
        cards2[i]=cards1[i];
    }
    bubble_sort(cards1,n);
    selection_sort(cards2,n);

    print(cards1,n);
    printf("Stable\n");
    print(cards2,n);
    if(is_stable(cards1,cards2,n)==true)
        printf("Stable\n");
    else printf("Not stable\n");
    return 0;
}



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

class Plogram
{
    static void Main()
    {

        var n = Console.ReadLine().Split();
        string H = n[0];
        string W = n[1];
        string mass;
        var list = new List<string>();
        var num = new List<int>();

        for (int i = 0; i < int.Parse(H); i++)
        {
            mass = Console.ReadLine();
            if (mass.Contains("#"))
            {
                list.Add(mass);
            }
        }

        int l = list.Count();
        for (int i = 0; i < list[0].Length; i++)
        {
            for (int j = 0; j < l; j++)
            {
                if (list[j][i] == '#') break;
                if (j == l - 1)
                {
                    for (int k = 0; k < l; k++)
                    {
                        list[k] = list[k].Remove(i, 1);
                    }
                    i--;
                }
            }
        }

        foreach (string i in list)
        {
            Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main(){
  int n;
  long a,sum[100000],cnt[2]={},b;
  scanf("%d",&n);
  scanf("%ld",&a);
  sum[0]=a;
  for(int i=1;i<n;i++){
    scanf("%ld",&a);
    sum[i]=sum[i-1]+a;
  }
  b=0;
  for(int i=0;i<n;i++){
    if(i%2==0&&sum[i]+b>=0){
      cnt[0]+=sum[i]+b+1;
      b-=sum[i]+b+1;
    }
    else if(i%2==1&&sum[i]+b<=0){
      cnt[0]-=sum[i]+b;
      cnt[0]++;
      b+=1-(sum[i]+b);
    }
  }
  b=0;
  for(int i=0;i<n;i++){
    if(i%2==0&&sum[i]+b<=0){
      cnt[1]-=sum[i]+b;
      cnt[1]++;
      b+=1-(sum[i]+b);
    }
    else if(i%2==1&&sum[i]+b>=0){
      cnt[1]+=sum[i]+b+1;
      b-=sum[i]+b+1;
    }
  }
  if(cnt[0]<cnt[1]) printf("%ld\n",cnt[0]);
  else printf("%ld\n",cnt[1]);
}
    

Measured memory_bytes: 896
N = int(input())
w = [input() for _ in range(N)]

bigram = [(w[i-1], w[i]) for i in range(1, len(w))]
valid  = len(set(w)) == len(w) and \
         all(a[-1] == b[0] for a, b in bigram)

print('Yes' if valid else 'No')

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int n,m,cnt,ans;
int w[110][110],v[110][110];
bool flag=1,fl;
int main()
{
	//freopen("ans.txt","w",stdout);
	int i,s,a,b,j,k,c;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
	for(s=1;s<=m;s++)
	{
		scanf("%d",&w[i][s]);
		for(k=0;k<=100;k++)
		for(j=0;j<=100;j++)v[k][j]=max(v[k][j],w[i][s]-i*k-s*j);
	}
	for(i=1;i<=n && flag;i++)
	for(s=1;s<=m && flag;s++)
	{
		c=1e9;
		for(k=0;k<=100;k++)
		for(j=0;j<=100;j++)c=min(v[k][j]+i*k+s*j,c);
		if(c!=w[i][s])flag=0;
	}
	if(!flag){printf("Impossible");return 0;}
	printf("Possible\n202 10401\n");
	for(i=1;i<=100;i++)printf("%d %d X\n",i,i+1),printf("%d %d Y\n",i+101,i+102);
	for(i=0;i<=100;i++)
	for(s=0;s<=100;s++)printf("%d %d %d\n",1+i,102+s,v[i][100-s]);
	printf("1 202");
	return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#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 <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(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 FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

typedef vector<string> vs;

vs getNames(string line) {
	vs res;
	string name;
	REP(i, line.size()) {
		switch(line[i]) {
		case ':':
		case ',':
		case '.':
			res.push_back(name);
			name = "";
			break;
		default:
			name += line[i];
			break;
		}
	}

	return res;
}

int main() {
	int n;
	while(cin >> n, n) {
		vs lines(n), group(n);
		int count = 0;
		REP(i, n) {
			cin >> lines[i];
			group[i] = getNames(lines[i])[0];
		}

		stack<string> S;
		vs names = getNames(lines[0]);
		FOR(i, 1, names.size()-1) {
			S.push(names[i]);
		}
		set<string> ans, visited;
		while(!S.empty()) {
			string name = S.top();
			S.pop();

			if(visited.find(name) == visited.end()) {
				visited.insert(name);
				bool find = false;
				FOR(i, 1, n-1) {
					if(group[i] == name) {
						vs members = getNames(lines[i]);
						FOR(j, 1, members.size()-1) {
							S.push(members[j]);
						}
						find = true;
						break;
					}
				}

				if(!find) {
					ans.insert(name);
				}
			}
		}

		cout << ans.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1412
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxx = 110;
const int INF = 1 << 30;
int main()
{
	int n, p[maxx], m[maxx][maxx];

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

	for (int i = 1; i <= n; i++)
		m[i][i] = 0;


	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = INF;
			for (int k = i; k <= j - 1; k++)
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);

		}
	}
	printf("%d\n", m[1][n]);
	return 0;
}

Measured memory_bytes: 3236
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 3e5 + 5, mod = 1e9 + 7;
int trans[][2] = {
	{2, 1}, {4, 3}, {6, 5}, {3, 3}, {7, 1}, {2, 1}, {2, 2}, {4, 4}
};
int dp[maxn][10], n;
char rs[maxn], *s;

int main() {
	scanf("%s", rs), n = strlen(rs), s = rs - 1, dp[0][0] = 1;
	for(register int i = 0; i < n; ++i) {
		for(register int j = 0; j < 8; ++j) {
			if(s[i + 1] != '0') 
				(dp[i + 1][trans[j][1]] += dp[i][j]) %= mod;
			if(s[i + 1] != '1') 
				(dp[i + 1][trans[j][0]] += dp[i][j]) %= mod;
		}
	}
	printf("%d", (dp[n][1] + dp[n][3]) % mod);
	return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
ll x[L], y[L], idx[L];
bool comp(int a, int b)
{
	return x[a] < x[b];
}
int children[L], parent[L];
int component(int x)
{
	if(parent[x] == x)return x;
	return parent[x] = component(parent[x]);
}
void merge(int a, int b)
{
	int pa = component(a);
	int pb = component(b);
	// debug(a,b,x[a], y[a], x[b], y[b], pa, pb);
	if(pa == pb)return;
	if(children[pa] > children[pb])
	{
		children[pb] += children[pa];
		parent[pa] = pb;
	}
	else
	{
		children[pa] += children[pb];
		parent[pb] = pa;
	}
	return;
}
void fff()
{
	ll n;
	cin >> n;
	pbds prv, nxt;
	std::vector<int> v;
	FOR(i,0,n)
	{
		parent[i] = i;
		children[i] = 1;
		cin >> x[i] >> y[i];
		idx[y[i]] = i;
		v.pb(i);
	}
	sort(all(v), comp);
	trace(v, i)
	{
		nxt.insert(y[i]);
	}
	int x;
	int co = 0, tmp;
	trace(v, i)
	{
		co = 0;
		nxt.erase(y[i]);
		x = nxt.order_of_key(y[i]);
		if(sz(nxt) == x)continue; 
		tmp = *nxt.find_by_order(x);
		merge(i, idx[tmp]);
		while(co<10)
		{
			x++;
			co++;
			if(sz(nxt) == x)break; 
			tmp = *nxt.find_by_order(x);
			// debug(y[i], tmp, idx[tmp]);
			merge(i, idx[tmp]);
		}
	}
	reverse(all(v));
	trace(v, i)
	{
		nxt.insert(y[i]);
	}
	trace(v, i)
	{
		co = 0;
		nxt.erase(y[i]);
		x = nxt.order_of_key(y[i]);
		if(x == 0)continue; 
		tmp = *nxt.find_by_order(x-1);
		merge(i, idx[tmp]);
		// debug(i,idx[tmp]);
		while(co<10)
		{
			x--;
			co++;
			if(x <= 0)break; 
			tmp = *nxt.find_by_order(x-1);
			// debug(y[i], tmp, idx[tmp]);
			merge(i, idx[tmp]);
		}
	}
	FOR(i,0,n)cout << children[component(i)]<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 19728
N, K = map(int,input().split())
R, S, P = map(int,input().split())
T = list(input())
MAX = 0
for i in T:
    if i == "r":
        MAX+=P
    elif i == "s":
        MAX+=R
    else:
        MAX+=S
ans = MAX
for i in range(K):
    index = i+K
    tmp = T[i]
    while index<=len(T)-1:
        if tmp == T[index]:
            if tmp == "r":
                ans-=P
            elif tmp == "s":
                ans-=R
            else:
                ans-=S
            tmp = None
        else:
            tmp = T[index]
        index+=K

print(ans)

Measured memory_bytes: 4084
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    r = I()
    print(2*r*3.14159265358979)
    return


if __name__ == "__main__":
    solve()

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

int main(){
	int a,b,c,k,d;
	cin >> a >> b >> c >> k;
	d = k-(a+b);

	if (a>k){
		cout << k << endl;
	}
	else if ((a+b)>=k) cout << a << endl;
	else cout << a-d << endl;
}

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

int main(){
    int r, g, b;
    cin >> r >> g >> b;
    int numero=(r*100)+(g*10)+b;
    if (numero%4==0){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long m=1e9+7;
long long fact[1000001],inv[1000001];

long long modRecursive(long long a,long long b,long long c)
{
	if(b == 0) return 1;
	if(b%2 ==0) return modRecursive((a*a)%c,b/2,c);
	else return ((a%c)*(modRecursive((a*a)%c,b/2,c)))%c;
}
int main()
{
    string S;
    cin >> S;

    for(int i = 0; i + 1 < S.size(); i++)
    {
        if(S[i] == S[i + 1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }

        if(i + 2 < S.size() && S[i] == S[i + 2])
        {
            cout << i + 1 << " " << i + 3;
            return 0;
        }
    }

    cout << "-1 -1";
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265358979323846264338327950L
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl '\n'
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1)
    {
        cerr << name << " = " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args)
    {
        const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " = " << arg1 << " || ";
        __f(comma+1, args...);
    }
#else
#define debug(...)
#endif
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ; ";
    return os << "}";
}
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
ll power(ll x, ll y, ll p)
{ 
    ll res = 1;  
    x = x % p;
    while (y > 0) { 
        if (y & 1) res = (res * x) % p; 
        y = y >> 1;
        x = (x * x) % p;   
    } 
    return res; 
}
const ll L = 3e5 + 5;
vector <ll> ad[L];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll h, w, m;
	cin >> h >> w >> m;
	ll u, v;
	set <pll, greater<pll> > cts;
	map <ll, ll> val;
	for (ll i = 0; i < m; i++) {
		cin >> u >> v;
		ad[u].pb(v);
		if (val[v] != 0)
			cts.erase({val[v], v});
		val[v]++;
		cts.insert({val[v], v});
	}
	ll ans = 0;
	for (ll i = 1; i <= h; i++) {
		for (ll y : ad[i]) {
			cts.erase({val[y], y});
			val[y]--;
			if (val[y] != 0) cts.insert({val[y], y});
		}
		ll temp = sz(ad[i]);
		if (sz(cts) > 0) {
			temp += (*cts.begin()).fi;
		}
		ans = max(ans, temp);
		for (ll y : ad[i]) {
			if (val[y] != 0)
				cts.erase({val[y], y});
			val[y]++;
			cts.insert({val[y], y});
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 57544
#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,u[100010],v[100010];
L a,b,x[100010];
struct dp
{
    int a[100010],b[100010],t;
    inline int& operator[](int i)
    {
        if(b[i]<t)
          b[i]=t,a[i]=0;
        return a[i];
    }
}f,g;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d%lld%lld",&n,&a,&b);
	for(i=1,j=0,k=0;i<=n;i++)
	  {
	   scanf("%lld",&x[i]);
	   while(x[i]-x[j+1]>=a)
	     j++;
	   while(x[i]-x[k+1]>=b)
	     k++;
	   u[i]=j;
	   v[i]=k;
      }
    f[0]=g[0]=1;
    for(i=0;i<n;i++)
     f.b[i]=g.b[i]=i+1;
    for(i=2;i<=n;i++)
      {
       f[i-1]=g[min(u[i],i-2)];
       g[i-1]=f[min(v[i],i-2)];
       if(u[i]<i-1)
         f.t=i;
       if(v[i]<i-1)
         g.t=i;
       f[i-1]=(f[i-1]+f[i-2])%q;
       g[i-1]=(g[i-1]+g[i-2])%q;
      }
    printf("%d\n",(f[n-1]+g[n-1])%q);
	return 0;
}


Measured memory_bytes: 3328
//************************
//** author  :  Alex Hu **
//************************

//  _______        __________         ________        __
//  \      \   ____\______   \ ____  /  _____/  _____/  |_
//  /   |   \ /  _ \|       _// __ \/   \  ____/ __ \   __\
// /    |    (  <_> )    |   \  ___/\    \_\  \  ___/|  |
// \____|__  /\____/|____|_  /\___  >\______  /\___  >__|
//         \/              \/     \/        \/     \/

#include<bits/stdc++.h>

using namespace std;

#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mkp make_pair
#define pb push_back
#define rept(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define fi first
#define se second
#define sqr(a) ((a)*(a))

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

const ll mod=1e9+7;
const int INF=0x3f3f3f3f; 
const int maxn=1e5+10;
pair<ll, ll> p[maxn];

ll par[maxn];
ll s[maxn];
ll sum,n,m;
ll ans[maxn];

ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

int main() 
{
	cin>>n>>m;
    rept(i,1,n+1)
	{
        par[i]=i;
        s[i]=1;
    }
    rept(i,0,m) cin>>p[i].first>>p[i].second;
    sum=1LL*n*(n-1)/2;
    for (int i = m - 1; i >= 0; i--)
    {
        ans[i] = sum;
        int x = find(p[i].first), y = find(p[i].second);
        if (x != y)
        {
            par[y] = x;
            sum -= s[x] * s[y];
            s[x] += s[y];
        }
    }
    rept(i,0,m) printf("%lld\n", ans[i]); 
    return 0;
}

Measured memory_bytes: 5248
import java.util.*;

public class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            int[] h = new int[200];
            int[] r = new int[200];

            int idx = 0;
            for(; idx<n; idx++){
                h[idx] = sc.nextInt();
                r[idx] = sc.nextInt();
            }
            int m = sc.nextInt();
            for(; idx<n+m; idx++){
                h[idx] = sc.nextInt();
                r[idx] = sc.nextInt();
            }

            int[] dp = new int[n+m];
            Arrays.fill(dp,1);
            for(int k=0; k<n+m; k++){
                for(int i=0; i<n+m; i++){
                    for(int j=0; j<n+m; j++){
                        if(h[i]<=h[j] || r[i]<=r[j]) continue;
                        dp[i] = Math.max(dp[i],dp[j]+1);
                    }
                }
            }

            int ans = 0;
            for(int i=0; i<n+m; i++) ans = Math.max(ans, dp[i]);

            System.out.println(ans);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 22320
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#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 <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(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 FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

using namespace std;

typedef vector<ll> vd;
typedef vector<vd> vvd;

int main() {
	int N, P;
	cin >> N >> P;
	vi A(N);
	REP(i, N) {
		cin >> A[i];
	}

	vvd dp(N+1, vd(5001, 0));
	dp[0][0] = 1;
	FOR(i, 1, N) {
		FOR(j, 0, 100 * (i-1)) {
			if (dp[i-1][j] != 0) {
				dp[i][j] += dp[i - 1][j];
				dp[i][j + A[i - 1]] += dp[i-1][j];
			}
 		}
	}

	ll ans = 0;
	FOR(i, 0, 5000) {
		if (i % 2 == P && dp[N][i] != 0) {
			ans += dp[N][i];
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 2304
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int H, W;
string G[22];

int solve_maze(int sx, int sy, int gx, int gy) {
	Vec<Vec<int>> cnt(H, Vec<int>(W, -1));
	cnt[sy][sx] = 0;
	
	queue<pii> que;
	que.push(pii(sx, sy));
	
	while (!que.empty()) {
		pii p = que.front(); que.pop();
		int x = p.first, y = p.second;
		if (x == gx and y == gy) break;
		for (int d=0; d<4; ++d) {
			int nx = x + dx[d];
			int ny = y + dy[d];
			if (!in_range(nx, 0, W)) continue;
			if (!in_range(ny, 0, H)) continue;
			if (G[ny][nx] == '#') continue;
			if (cnt[ny][nx] == -1) {
				cnt[ny][nx] = cnt[y][x] + 1;
				que.push(pii(nx, ny));
			}
		}
	}
	
	return cnt[gy][gx];
}

int main() {
	cin >> H >> W;
	for (int i=0; i<H; ++i) cin >> G[i];
	
	int ans = 0;
	for (int sy=0; sy<H; ++sy) for (int sx=0; sx<W; ++sx) {
		for (int gy=0; gy<H; ++gy) for (int gx=0; gx<W; ++gx) {
			if (G[sy][sx] != '#' and G[gy][gx] != '#') ans = max(ans, solve_maze(sx, sy, gx, gy));
		}
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  long int n,b[n-1],a[n];
  long int c=0;
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  a[0]=b[0];
  a[n-1]=b[n-2];
  for(int i=0;i<n-2;i++){
    a[i+1]=min(b[i],b[i+1]);
  }
  for(int i=0;i<n;i++){
    c+=a[i];
  }
  cout<<c;
  return 0;
}


Measured memory_bytes: 2304
import sys

n, y = list(map(int, input().split()))

for i in range(n+1):
    for j in range(n-i+1):
        if 10000*i+5000*j+1000*(n-i-j) == y:
            print(i, j, n-i-j)
            sys.exit(0)
print(-1, -1, -1)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

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

    int a,b;
    cin >> a >> b;
    cout << lcm(a,b) << endl;

        
}

Measured memory_bytes: 256
module Main where

import Debug.Trace

main :: IO ()
main = do
  a <- map read . words <$> getLine
  --a `traceShow`
  print $ solve a


solve :: [Int] -> Int
solve s = check $ zip [1, 2, 3, 4, 5] s

check :: [(Int, Int)] -> Int
check [] = undefined
check ((a, 0):ps) = a
check (_:ps) = check ps


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}



int main(){ 
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n)cin >> a[i];

  rep(j,k){
    vector<int> b(n);
    for(int i = 0; i < n;i++){
      int l = max (0, i - a[i]);
      int r = min (n-1, i + a[i]);
      b[l]++;
      // 加算範囲＋1した部分に-1を加えることで範囲の区切りとしてる
      if(r+1 < n)b[r+1]--;
    }
    for(int i = 0;i < n-1;i++)b[i+1] += b[i]; 
    if(a == b)break;
    a = b;
  }
  rep(i,n)cout << a[i] << " ";
  cout << endl;
  return 0;
}



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

int main()
{
    long long Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    long long one_l = 4 * Q;
    one_l = min(one_l, 2 * H);
    one_l = min(one_l, S);

    long long ans = 0;
    if (one_l * 2 > D) {
        ans += N / 2 * D;
        ans += (N % 2) * one_l;
    } else {
        ans = N * one_l;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

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

	ans := 0
	for i := 1; i <= n; i++ {
		if !(i%5 == 0 || i%3 == 0) {
			ans += i
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1768