akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL n,k;
    string s;
    cin >> n >> k >> s;
    VI g(n+1);
    int cnt = 1;
    REP(i,1,n) {
        if (s[i] == s[i-1]) ++cnt;
        else {
            g[cnt]++;
            cnt = 1;
        }
    }
    g[cnt]++;
    int sum = 0;
    REP(i,2,n+1) sum += (i-1) * g[i];
    cout << min(n-1, sum + k * 2) << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

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

		if (Math.abs(a-b) % 2 == 0) {
			System.out.println(Math.abs(a-b) / 2 + Math.min(a, b));
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cmath>
#include <bitset>
#define N 85
using namespace std;

int h, w, a[N][N], d[N][N];
bitset<25600> bs[N][N];

int main() {
	int i, j;
	cin >> h >> w;
	for(i=0; i<h; i++) for(j=0; j<w; j++) cin >> a[i][j];
	for(i=0; i<h; i++) for(j=0; j<w; j++) {
		cin >> d[i][j];
		d[i][j] = abs(a[i][j] - d[i][j]);
	}
	bs[0][0][12800+d[0][0]] = 1;
	for(i=0; i<h; i++) for(j=0; j<w; j++) {
		bs[i][j+1] |= bs[i][j]<<d[i][j+1] | bs[i][j]>>d[i][j+1];
		bs[i+1][j] |= bs[i][j]<<d[i+1][j] | bs[i][j]>>d[i+1][j];
	}
	for(i=0; !bs[h-1][w-1][12800+i]; i++);
	for(j=0; !bs[h-1][w-1][12800-j]; j++);
	cout << min(i, j);
	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;


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

int main(){
    int n;
    cin>>n;
    int c00=0;
    map<pair<ll,ll>,pii>m;
    rep(i,0,n){
        ll a,b;
        cin>>a>>b;
        if(a==0 and b==0){
            c00++;
            continue;
        }
        ll const g=__gcd(a,b);
        //cout<<g<<endl;
        //cout<<abs(__gcd(a,b))<<endl;
        a/=g,
        b/=g;
        //cout<<a<<' '<<b<<endl;
        if(b<0)a=-a, b=-b;
        if(a<=0) m[{b,-a}].second++;
        else m[{a,b}].first++;
        /*for(auto p:m){
         cout<<'{'<<p.first.first<<','<<p.first.second<<"} "<<p.second.first<<' '<<p.second.second<<endl;
    }*/
    }
    /*     for(auto p:m){
         cout<<'{'<<p.first.first<<','<<p.first.second<<"} "<<p.second.first<<' '<<p.second.second<<endl;
    }*/
    ll ans=1;
    for(auto p:m){
        ans=(ans*(mod+modpow(2,p.second.first,mod)+modpow(2,p.second.second,mod)-1)%mod)%mod;
    }

    cout<<(mod+ans+c00-1)%mod<<endl;
return 0;
}


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

int main(){
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define RREP(i, n, m) for(int i = 0;i < n;i+=m)
    #define REPM(i, n) for(int i = n;i > 0;i--)
    #define REPP(i,l,n) for(int i = l;i<n;i++)

    int sum=0;
    string n;
    cin >> n;

    REP(i,4){
        if(n[i]=='+'){
            sum++;
        }else{
            sum--;
        }
    }

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int k;
  cin >> k;
  ll res = 0;
  for(int a = 1; a <= k; a++){
    for(int b = 1; b <= k; b++){
      for(int c = 1; c <= k; c++){
        res += __gcd(c, __gcd(a, b));
      }
    }
  }
  cout << res;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, idx, i, j, k, ans,curr;
    char arr[20];
    scanf("%s",arr);
    int len = strlen(arr);
    int diff = 753;
    ans = 1e9;
    for(i=0;i<len-2;i++)
    {
        curr = 0;
        curr += (arr[i]-'0')*100;
        curr += (arr[i+1]-'0')*10;
        curr += (arr[i+2]-'0');
        ans = min(ans,abs(curr-diff));
    }
    printf("%d\n",ans);
    return 0;
}


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

int main(){
    ll a, b;
    cin >> a >> b;
    if (a*b<=0) cout << "Zero" << endl;
    else if (b<0 && (b-a)%2==0) cout << "Negative" << endl;
    else cout << "Positive" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ans=0
s=0
r=0
for l in range(n):
  while r<n and s^a[r]==s+a[r]:
    s+=a[r]
    r+=1
  ans+=r-l
  s-=a[l]
print(ans)

Measured memory_bytes: 24840
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String n=sc.next();
    if(n.charAt(n.length()-1)=='2'||n.charAt(n.length()-1)=='4'||n.charAt(n.length()-1)=='5'||
       n.charAt(n.length()-1)=='7'||n.charAt(n.length()-1)=='9'){
         System.out.println("hon");
       }

       if(n.charAt(n.length()-1)=='0'||n.charAt(n.length()-1)=='1'||n.charAt(n.length()-1)=='6'||
          n.charAt(n.length()-1)=='8'){
            System.out.println("pon");
          }

          if(n.charAt(n.length()-1)=='3'){
               System.out.println("bon");
             }
  }
}


Measured memory_bytes: 26948
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

template< typename Monoid >
class SegmentTree {
public:
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }

  template< typename C >
  int find_subtree(int a, const C &check, Monoid &M, bool type) {
    while(a < sz) {
      Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
      if(check(nxt)) a = 2 * a + type;
      else M = nxt, a = 2 * a + 1 - type;
    }
    return a - sz;
  }


  template< typename C >
  int find_first(int a, const C &check) {
    Monoid L = M1;
    if(a <= 0) {
      if(check(f(L, seg[1]))) return find_subtree(1, check, L, false);
      return -1;
    }
    int b = sz;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) {
        Monoid nxt = f(L, seg[a]);
        if(check(nxt)) return find_subtree(a, check, L, false);
        L = nxt;
        ++a;
      }
    }
    return -1;
  }

  template< typename C >
  int find_last(int b, const C &check) {
    Monoid R = M1;
    if(b >= sz) {
      if(check(f(seg[1], R))) return find_subtree(1, check, R, true);
      return -1;
    }
    int a = sz;
    for(b += sz; a < b; a >>= 1, b >>= 1) {
      if(b & 1) {
        Monoid nxt = f(seg[--b], R);
        if(check(nxt)) return find_subtree(b, check, R, true);
        R = nxt;
      }
    }
    return -1;
  }
};

ll check(vector<pair<ll,ll>>&v,ll X){
    ll N=v.size();
    ll ret=0;
    for(int i=0;i<N;i++){
        ret+=v[i].first*(X-v[i].second);
    }
    return ret;
}

ll check2(vector<pair<ll,ll>>&v,ll X){
    ll N=v.size();
    ll ret=0;
    for(int i=0;i<N;i++){
        ret+=v[i].first*abs(X-v[i].second);
    }
    return ret;
}


int main(){
    init();
    int a,b;cin>>a>>b;
    for(int i=0;i<max(a,b);i++)cout<<min(a,b);
    cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const int mod=1000000007;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
int dyy[]={0,-1,0,1};
int dxx[]={-1,0,1,0};

#define int ll
signed main(){
    int n;
    cin>>n;
    int copy_n=n;
    int t=2;
    int cnt=1;
    while(n>=t*t){
        if(n%(t*t)==0)n/=(t*t),cnt*=t;
        else t++;
    }
    int x=copy_n/cnt;
    int h=x;
    int ans=0;
    while(x>0){
        x/=10;
        if(x>=0)ans++;
    }
    if(n==1){
        cout<<ans<<endl;
        return 0;
    }
    int ans1=111111111111;
    rep(i,1,pow(10,ans/2)){
        if(h%i==0)ans1=min(ans1,h/i);
    }
    int ans2=0;
    while(ans1>0){
        ans1/=10;
        ans2++;
    }
    cout<<ans2<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DistributionCenter solver = new DistributionCenter();
        solver.solve(1, in, out);
        out.close();
    }

    static class DistributionCenter {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            final int MAX = 100001;
            final int n = in.nextInt();
            final int m = in.nextInt();
            int[] x = new int[m];
            int[] y = new int[m];
            int[] ar = new int[MAX];
            for (int i = 0; i < m; i++) {
                x[i] = in.nextInt();
                y[i] = in.nextInt();
                ar[x[i]] = y[i];
            }
            int[] left = new int[n];
            int[] right = new int[n];
            for (int i = 0; i < n; i++) {
                left[i] = right[i] = i;
            }

            for (int i = 0; i < MAX; i++) {
                if (ar[i] != 0) {
                    right[ar[i] - 1] = right[ar[i]];
                    left[ar[i]] = left[ar[i] - 1];
                }
            }

            for (int i = 0; i < n; i++) {
                if (i + 1 == n) out.println((right[i] - left[i] + 1));
                else out.print((right[i] - left[i] + 1) + " ");
            }
        }

    }
}

Measured memory_bytes: 102964
K, N = map(int,input().split())
A = [a for a in map(int,input().split())]

dis = 0

for i,j in zip(range(0,N),range(-1,N-1)):
    if i==0:
        temp = K-A[j]+A[i]
    else:
        temp = abs(A[i]-A[j])
    if temp > dis:
        dis = temp
print(K-dis)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}
ll n;
void dfs(string s,char mx)
{
	ll x=s.size();
	if(x==n)
	cout<<s<<'\n';
	else
	{
		repi(ch,'a',mx)
		dfs(s+(char(ch)),(ch==mx)?char(mx+1):mx);
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll k,i,j,l,m,h,w,q;
    	cin>>n;
    	dfs("",'a');
	}
	return 0;
}

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

ll gcd(ll a, ll b)
{
    if (a < b)
        swap(a, b);
    if (a % b == 0)
        return b;
    return gcd(a % b, b);
}

int main()
{
    ll n, k;
    cin >> n >> k;
    ll m = 0, g = 0;
    //0と任意の数nとのGCDはn

    rep(i, n)
    {
        ll a;
        cin >> a;
        g = gcd(a, n);
        m = max(m, a);
    }

    if (k <= m && k % g == 0)
    {
        cout << "POSSIBLE" << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 3608
package main

import (
	"fmt"
	"os"
)

func run() int {
	var n int
	var s, t string
	fmt.Scanf("%d\n", &n)
	fmt.Scanf("%s %s\n", &s, &t)

	for i := 0; i < n; i++ {
		fmt.Print(string(s[i]))
		fmt.Print(string(t[i]))
	}
	fmt.Println()

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;


int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll A = 0;
    for(ll n = 1; n*n <= N; n++){
        A = n*n;
    }
    cout << A << endl;
    return 0;
}


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

template<typename T>
void fill_all(T& i, const T& v){
	i = v;
}
template<typename U, typename T, size_t N>
void fill_all(T (&arr)[N], const U& v){
	for(auto& i : arr){
		fill_all(i, v);
	}
}

#if 1
int N=0;
char TOP[5010];
std::string BTM;
int BACE;
int16_t dp[2][2][2][12][2][500][1000];//is_zero, is_bef_less, is_bef_biger, ??´???, is_upper, ??´????????§???mod, i ??¶?´?????????????i??\??????????????°
int16_t func(bool is_zero, bool is_bef_less, bool is_bef_biger, int8_t bef, bool is_upper, int16_t mod, int16_t i);
int16_t func_run(bool is_zero, bool is_bef_less, bool is_bef_biger, int8_t bef, bool is_upper, int16_t mod, int16_t i)
{	
	#ifdef DEBUG
	std::cout << "in[" <<(is_zero?1:0)<<' '<<(is_bef_less?1:0)<<' '<<(is_bef_biger?1:0)<<' '<<(int)(bef)<<' '<<(is_upper?1:0)<<' '<<(mod)<<' '<<(i)<<"]\n";
	#endif
	
	auto call = [&](bool l,bool b, int8_t v){return func(false,l,b,v,!is_upper, (mod*10+v)%BACE, i+1);};
	int res = 0;
	int fend = 9;//[]????????¨???
	int fbegin = 0;
	if(is_zero)
	{
		//????°??????????????????????0????¶????
		if('0'==BTM[i]){res += func(true, true, false, 0, false, 0, i+1);}
		//0????????°??????????????????
		if(i<N-1){res += func(false, is_bef_less, is_bef_biger, -1, true, 0, i);}
		mod = 0;
		fend = 9; fbegin = 1;
	}
	else
	{
		if(is_upper){
			fbegin = bef + 1;
		}
		else{
			fend = bef - 1;
		}
	}
		
	if(!is_bef_less){
		//?????§???
		auto top = TOP[i]-'0';
		if(fbegin <= top && top <= fend){
			res += call(false, is_bef_biger||BTM[i]<TOP[i], top);
		}
		fend = std::min(fend, top-1);
	}
	if(!is_bef_biger){
		//????°????
		auto btm = BTM[i]-'0';
		if(fbegin <= btm && btm <= fend){
			res += call(is_bef_less||BTM[i]<TOP[i], false, btm);
		}
		fbegin = std::max(fbegin, btm+1);
	}
	for(int i = fbegin;i <= fend;++i){
		res += call(true, true, i);
	}
	
	#ifdef DEBUG
	std::cout << "out[" <<(is_zero?1:0)<<' '<<(is_bef_less?1:0)<<' '<<(is_bef_biger?1:0)<<' '<<(int)(bef)<<' '<<(is_upper?1:0)<<' '<<(mod)<<' '<<(i)<<"]\n";
	std::cout << "...res="<<res%10000<<"\n";
	#endif
	return (res%10000);
}
inline int16_t func(bool is_zero, bool is_bef_less, bool is_bef_biger, int8_t bef, bool is_upper, int16_t mod, int16_t i)
{
	if(i >= N){
		return (is_zero || mod%BACE)?0:1;
	}
	if(is_zero)
	{
		bef=0;is_upper=false;mod=0;
	}
	
	auto& memo = dp[is_zero?1:0][is_bef_less?1:0][is_bef_biger?1:0][bef+1][is_upper?1:0][mod][i];
	if(memo>=0){return memo;}
	return memo = func_run(is_zero, is_bef_less, is_bef_biger, bef, is_upper, mod, i);
}
int main()
{
	fill_all<int16_t>(dp,-1);
	std::cin >> BTM>>TOP>>BACE;
	
	while(TOP[N] != '\0'){++N;}
	BTM.insert(BTM.begin(), N-BTM.size(), '0');
	
	#ifdef DEBUG
	std::cout <<"BTM="<<BTM<<"\n";
	std::cout <<"TOP="<<TOP<<"\n";
	std::cout <<"N="<<N<<"\n";
	std::cout <<"BACE="<<BACE<<"\n";
	#endif
	int res = 0;
	res += func_run(true, false,false,0,false, 0, 0);
	std::cout << res%10000 << std::endl;
}
#endif

Measured memory_bytes: 190712
import collections

n,m=map(int,input().split())
l=list(map(int,input().split()))
l[0]%=m
for i in range(n-1):
    l[i+1]+=l[i]
    l[i+1]%=m
c=collections.Counter(l)
ans=0
for k,v in c.items():
    if k==0:
        ans+=v
    if v>=2:
        ans+=v*(v-1)//2
print(ans)

Measured memory_bytes: 14920
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	int a,b;
	String s = buf.readLine();
	String[] strlAry =s.split(" ");
	for(int i=0;i<strlAry.length;i++){
	}	
	a= Integer.parseInt(strlAry[0]);
	b= Integer.parseInt(strlAry[1]);
	if(a>b){
		System.out.println("a > b");
	}
	else if(a<b){
		System.out.println("a < b");	
	}
	else{
		System.out.println("a == b");
	}
}
}

Measured memory_bytes: 16892
using System;
using System.Linq;

class E
{
	static void Main()
	{
		Func<int[]> read = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
		var h = read();
		var n = h[0];
		var p2 = Enumerable.Range(0, n + 1).Select(i => 1 << i).ToArray();
		var k = new int[h[1]].Select(_ => new { a = read()[0], f = read().Sum(x => p2[x - 1]) }).ToArray();

		var M = int.MaxValue;
		var dp = Enumerable.Repeat(M, p2[n]).ToArray();
		dp[0] = 0;
		for (int f = 0, f2; f < p2[n]; f++)
		{
			if (dp[f] == M) continue;
			foreach (var x in k)
			{
				if ((f2 = f | x.f) == f) continue;
				dp[f2] = Math.Min(dp[f2], dp[f] + x.a);
			}
		}
		Console.WriteLine(dp.Last() < M ? dp.Last() : -1);
	}
}


Measured memory_bytes: 13524
from math import tan, radians

def water(a, b, t):
    if a * tan(radians(t)) < b:
        water = a*a*b - a*a*a*tan(radians(t))*0.5
        
    else:
        water = 0.5 * b * b*tan(radians(90 - t)) * a
    
    return water    


def main():
    a, b, x = map(int, input().split())
    min = 0
    max = 90
    for _ in range(10000):
        tmp = (min + max) / 2
        if water(a, b, tmp) < x:
            max = tmp
        else:
            min = tmp
    print(min)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

string S;
int N;

ll dp[100010][15];

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

int main(){
  cin>>S;
  N=S.size();

  dp[0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=12;j++){
      if(S[i]!='?'){
        int num=S[i]-'0';
        int nex=(j*10+num)%13;
        add(dp[i+1][nex],dp[i][j]);
      }else{
        for(int k=0;k<=9;k++){
          int nex=(j*10+k)%13;
          add(dp[i+1][nex],dp[i][j]);
        }
      }
    }
  }

  cout<<dp[N][5]<<endl;

  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }
const ll MOD = 1000 * 1000 * 1000 + 7;
int main() {
  int N, M; cin>>N>>M;
  vector<ll> dp(N+1, 0); dp[0] = 1;
  vector<bool> ng(N+1, false);
  REP(i,M) {
    int v; cin>>v;
    ng[v] = true;
  }
  for(int i = 1; i <= N; i++) {
    if(ng[i]) continue;
    if(i-1 >= 0) dp[i] += dp[i-1];
    if(i-2 >= 0) dp[i] += dp[i-2];
    dp[i] %= MOD;
  }
  cout << dp[N] << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
        cin >> h[i];
    vector<bool> high(n, true);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        a--;
        b--;
        if (h[a] < h[b]) {
            high[a] = false;
        } else if (h[a] == h[b]) {
            high[a] = false;
            high[b] = false;
        } else if (h[a] > h[b]) {
            high[b] = false;
        }
    }
    int c = 0;
    for (int i = 0; i < n; i++)
        if (high[i])
            c++;
    cout << c;
    return 0;
}


Measured memory_bytes: 3784
class solver :
	def __init__(self) :
		self.n, self.k = map(int, input().split())
		self.initVariables()
		self.a = [int(i) - 1 for i in input().split()]
	
	def initVariables(self) :
		self.vis = [False] * self.n
 
	def solve(self) :
		cur, tot = 0, 0
		travelled = list()
		while tot < self.k and not self.vis[cur] :
			self.vis[cur] = True
			travelled.append(cur)
			cur = self.a[cur]
			tot += 1
		if tot == self.k :
			return cur + 1
		cycle = list()
		for i in travelled :
			if i == cur or len(cycle) > 0:
				cycle.append(i)
		return cycle[(self.k - tot)  % len(cycle)] + 1

print(solver().solve())



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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

/* 文字から数値に変換 */
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

/* 文字列から数値へ変換して key を生成する */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) % M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); /* 文字列を数値に変換 */
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str);
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}


Measured memory_bytes: 16092
A = Array.new(9)
3.times do |i|
  gets.split.each_with_index do |a, j|
    A[i * 3 + j] = a.to_i
  end
end
B = Array.new(gets.to_i) { gets.to_i }

B.each do |b|
  i = A.find_index {|a| a == b}
  next unless i
  A[i] = false
end

is_bingo = \
  if (!A[0] && !A[1] && !A[2])
    warn 'Row 1'
    true
  elsif (!A[3] && !A[4] && !A[5])
    warn 'Row 2'
    true
  elsif (!A[6] && !A[7] && !A[8])
    warn 'Row 3'
    true
  elsif (!A[0] && !A[3] && !A[6])
    warn 'Col 1'
    true
  elsif (!A[1] && !A[4] && !A[7])
    warn 'Col 2'
    true
  elsif (!A[2] && !A[5] && !A[8])
    warn 'Col 3'
    true
  elsif (!A[0] && !A[4] && !A[8])
    warn 'X 1'
    true
  elsif (!A[2] && !A[4] && !A[6])
    warn 'X 2'
    true
  end

puts(is_bingo ? 'Yes' : 'No')


Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int n[3]={};

	for(int i=0;i<3;i++)
		cin >> n[i];
	
	sort(n,n+3);

	cout << n[0]+n[1] << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int n;
  cin>>n;
  int d[n+5];
  set<int>st;
  for(int i=0; i<n; i++){
    cin>>d[i];
    st.insert(d[i]);
  }
  cout<<st.size()<<endl;
}

Measured memory_bytes: 256
N = int(input())
A  = [int(i) for i in input().split()]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

res = [0] * N
l = [0] * (N + 1)
r = [0] * (N + 1)

for i in range(N):
    l[i+1] = gcd(l[i], A[i])

for i in range(N, 0, -1):
    r[i-1] = gcd(r[i], A[i-1])

for i in range(N):
    res[i] = gcd(l[i], r[i+1])

print(max(res))

Measured memory_bytes: 14052
///
// File:  2629.cpp
// Author: ymiyamoto
//
// Created on Sun Dec 24 11:09:29 2017
//

#include <cmath>
#include <cstdint>
#include <iomanip>
#include <iostream>

using namespace std;

int32_t main()
{
  double d;
  cin >> d;

  double y = (uint32_t)d;
  cout << fixed << setprecision(12) << max(d * sqrt(2), y + 1.0) << endl;

  return 0;
}

Measured memory_bytes: 3280
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());
    
    boolean[] f = new boolean[N+1];    
    for(int i = 0; i < M; i++){
      int n = Integer.parseInt(sc.next());
      f[n] = true;
    }
    
    int l = 0, u = 0;
    for(int i = 0; i < N; i++){
      if(f[i]){
        if(i < X){
          l++;
        }else{
          u++;
        }
      }
    }
    System.out.println(Math.min(l,u));
  }
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
EPS = 10 ** -8

def bisearch_max(mn, mx, func):
    """ 条件を満たす最大値を見つける二分探索(小数用) """

    ok = mn
    ng = mx
    while abs(ok-ng) > 10**-12:
        mid = (ok+ng) / 2
        if func(mid):
            # 上を探しに行く
            ok = mid
        else:
            # 下を探しに行く
            ng = mid
    return ok

# 2次方程式の解の公式
def dim2formula(a, b, c):
    from math import sqrt

    try:
        return (-b+sqrt(pow(b, 2)-4*a*c))/(2*a), (-b-sqrt(pow(b, 2)-4*a*c))/(2*a)
    # 解なしはNoneを返却
    except ValueError:
        return (None, None)

# 3次→2次への微分
def calc1(a, b, c, d):
    a *= 3
    b *= 2
    return (a, b, c)

# ax^3+bx^2+cx+dを解く
def calc2(x):
    return a*x**3 + b*x**2 + c*x + d

# /のグラフ用
def check1(x):
    res = calc2(x)
    return res < 0

# \のグラフ用
def check2(x):
    res = calc2(x)
    return res > 0

for _ in range(INT()):
    a, b, c, d = MAP()
    ans = [0] * 2

    a2, b2, c2 = calc1(a, b, c, d)
    ans1, ans2 = dim2formula(a2, b2, c2)

    # 微分して解いた結果が解なしなら、元の式は極値なしで解は1つ
    if ans1 is None:
        if a > 0:
            # /のグラフ
            x = bisearch_max(-INF, INF, check1)
        else:
            # \のグラフ
            x = bisearch_max(-INF, INF, check2)
        # x = 0 ならカウントしない
        if abs(x) < EPS:
            pass
        elif x > 0:
            ans[0] += 1
        elif x < 0:
            ans[1] += 1
    # それ以外なら解は重解も含めると解は3つ
    else:
        ans1, ans2 = min(ans1, ans2), max(ans1, ans2)
        # /\/のグラフ
        if a > 0:
            res1 = bisearch_max(-INF, ans1, check1)
            res2 = bisearch_max(ans1, ans2, check2)
            res3 = bisearch_max(ans2, INF, check1)
        # \/\のグラフ
        else:
            res1 = bisearch_max(-INF, ans1, check2)
            res2 = bisearch_max(ans1, ans2, check1)
            res3 = bisearch_max(ans2, INF, check2)

        # 3つの解候補
        for x in [res1, res2, res3]:
            # f(x) = 0 について確認
            if abs(calc2(x)) < EPS:
                # x = 0 ならカウントしない
                if abs(x) < EPS:
                    continue
                elif x > 0:
                    ans[0] += 1
                elif x < 0:
                    ans[1] += 1
    print(*ans)



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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	int DP[2010] = { 0 };

	int S;
	cin >> S;

	DP[0] = 1;
	rep(i, 0, S)
	{
		rep(j, 0, i - 1)
		{
			DP[i + 1] += DP[j];
			DP[i + 1] %= MOD;
		}
	}

	cout << DP[S] << endl;

	return 0;
}


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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

A.sort()
ans = (A[0]+A[1]) / 2
for i in range(2, N):
    ans = (ans+A[i]) / 2
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#define MAX 100

int main(){
    std::string str1, str2;
    std::cin >> str1 >> str2;

    int set[MAX];
    int i_set = 0;
    while(str1 != "."){
        int flag1 = 0;     //0:IDENTICAL 1:CLOSE 2:DIFFERENT
        int flag2 = 4;     //3:[""]の内部 4:[""]の外部
        int cnt = 0;
        int n1 = (int)str1.size();
        int n2 = (int)str2.size();
        int j1 = 0;
        int j2 = 0;
        while(j1<n1 || j2<n2){
            if(flag2==4){//外部ならば
                if((str1[j1]!=str2[j2]) || (j1==n1&&j2!=n2) || (j1!=n1&&j2==n2)){
                    flag1 = 2;
                    break;
                }
                else if(str1[j1]=='\"' && str2[j2]=='\"'){//ともに[""]の内部に入る
                    flag2 = 3;
                    if(j1<n1)  j1 += 1;
                    if(j2<n2)  j2 += 1;
                }
            }
            if(flag2==3){//内部ならば
                if(str1[j1]!=str2[j2]){
                    if(flag1!=1){
                        flag1 = 1;
                    }
                    else if(flag1==1){
                        flag1 = 2;
                        break;
                    }
                    while(str1[j1]!='\"'){
                        j1 += 1;
                    }
                    while(str2[j2]!='\"'){
                        j2 += 1;
                    }
                    flag2 = 4;
                }
                else if(str1[j1]=='\"' && str2[j2]=='\"'){
                    flag2 = 4;
                }
            }
            if(j1<n1)  j1 += 1;
            if(j2<n2)  j2 += 1;
        }
        set[i_set] = flag1;
        i_set += 1;
        str1.erase(str1.begin(), str1.end());
        str2.erase(str2.begin(), str2.end());
        std::cin >> str1;
        if(str1 != "."){
            std::cin >> str2;
        }
    }

    for(int k=0; k<i_set; k++){
        if(set[k] == 0)  std::cout << "IDENTICAL\n";
        if(set[k] == 1)  std::cout << "CLOSE\n";
        if(set[k] == 2)  std::cout << "DIFFERENT\n";
    }

    return 0;
}


Measured memory_bytes: 3048
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt() % 500;
            int A = in.nextInt();
            out.println(N <= A ? "Yes" : "No");
        }

    }
}



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

int main() {
  string a, b, c;
  cin >> a >> b;
  int d, e;
  cin >> d >> e;
  cin >> c;
  if(a == c) {
    --d;
  } else {
    --e;
  }
  cout << d << " " << e << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


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

    char a,b;
    cin >> a >> b;
    if (a<b) cout << '<' << endl;
    else if (a==b) cout << '=' << endl;
    else cout << '>' << endl; 

}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  int n,q;
  int x[100010];
  for(int r=0;r<100010;r++){
    x[r]=0;
  }
  cin>>n>>q;
  string s;
  cin>>s;
  pair<int,int> len[q];
  for(int i=0;i<q;i++){
    cin>>len[i].first>>len[i].second;
  }
  for(int i=1;i<s.size();i++){
    if(s[i-1]=='A' and s[i]=='C')
    x[i]=1+x[i-1];
    else
    x[i]+=x[i-1];
  }
  for(int i=0;i<q;i++){
    cout<<x[len[i].second-1]-x[len[i].first-1]<<endl;
  }
}


Measured memory_bytes: 2176
#include "bits/stdc++.h"
using namespace std;
int main(){
    char ch[5];
    for(int i=0;i<=4;i++)
        cin>>ch[i];
    if(ch[0]==ch[1]&&ch[1]==ch[2]){
        cout<<"Yes"<<endl;
        return 0;
        exit(0);
        goto E;
    }
    if(ch[1]==ch[2]&&ch[2]==ch[3]){
        cout<<"Yes"<<endl;
        return 0;
        exit(0);
        goto E;
    }
    cout<<"No";
    cout<<endl;
    E:
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
    int n; cin >> n;
    map<string, int> mapa;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        sort(s.begin(), s.end());
        mapa[s]++;
    }
    long long res = 0;
    for(auto par : mapa)
        res += (par.second*1LL*(par.second-1))/2;
    // res /= 2;
    cout << res << endl;
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h> 
using namespace std ;
int main () {
	int a , b , c , k ;
	cin >> a >> b >> c >> k ;
	if (k <= a) {
		cout << k ;
	}
	else if (k > a && k <= (a+b)) {
		cout << a ;
	}
	else {
		cout << a - (k-(a+b)) ;
	}
	return 0 ;
}

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

int main() {
  int n; cin >> n;
  ll ans=1, lim=1000000000000000000;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
    if (a[i] == 0 ) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,n) {
    if (((lim / ans) + 1) <= a[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  if (ans > 1000000000000000000 || ans < 0) {
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 10;
int cnt[MAX], tot[MAX], a[MAX];
int main(){
	int n, m, x;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; ++i){
		scanf("%d", &x);
		a[i] = x;
		cnt[x%m]++;
		tot[x]++;
	}
	int ans = cnt[0]/2;
	cnt[0]-=ans*2;
	int lf = 1;
	int rg = m-1;	
	while(lf <= rg){
		int mi = min(cnt[lf], cnt[rg]);
		if(lf == rg)mi = cnt[lf]/2;
		cnt[lf]-=mi;
		cnt[rg]-=mi;
		++lf;
		--rg;
		ans+=mi;
	}
	for(int i = 0; i < n; ++i){
		int mi = min(tot[a[i]], cnt[a[i]%m]);
		ans+=mi/2;
			tot[a[i]]-=2*(mi/2);
			cnt[a[i]%m]-=2*(mi/2);	
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void) {
  char s;
  int count_alpha[26] = {0};
  int i;

  while ((s = getchar()) != EOF) {
    if ('a' <= s && s <= 'z') {
      count_alpha[s - 'a']++;
    } else if ('A' <= s && s <= 'Z') {
      count_alpha[s - 'A']++;
    }
  }

  s = 'a';
  for (i = 0; i < 26; i++, s++) {
    printf("%c : %d\n", s, count_alpha[i]);
  }

  return 0;
}

Measured memory_bytes: 932
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define inc(a) scanf("%c", &(a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll a, b;
    in2(a, b);
    if(a*b<=0) puts("Zero");
    else if(a>0 || (a-b)%2 ) puts("Positive");
    else puts("Negative");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  string S;
  cin >> S;
  ll r = 0, l = 0;
  vector<int> a(S.size() + 1);
  rep(i, S.size())
  {
    if (S.at(i) == '<')
    {
      a[i + 1] = max(a[i + 1], a[i] + 1);
    }
  }
  for (int i = S.size() - 1; i >= 0; i--)
  {
    if (S[i] == '>')
    {
      a[i] = max(a[i], a[i + 1] + 1);
    }
  }
  ll ans = 0;
  rep(i, S.size() + 1)
  {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll
#define endl '\n'

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 998244353;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s){
        n = s.size();
        vi mxr(n * 2 + 1), mxb(n * 2 + 1);
        REP(i, n) {
            if (s[i] == '0') mxr[i] = 2;
            if (s[i] == '1') mxr[i] = 1;
            if (s[i] == '1') mxb[i] = 1;
            if (s[i] == '2') mxb[i] = 2;
        }
        REP(i, 2 * n) {
            mxr[i + 1] += mxr[i];
            mxb[i + 1] += mxb[i];
        }
        vector<ll> dp(n * 2 + 1);
        dp[0] = 1;
        REP(i, n * 2) {
            vector<ll> nxt(n * 2 + 1);
            REP(r, i + 1) {
                int b = i - r;
                if (r <= mxr[i] && b + 1 <= mxb[i]) {
                    (nxt[r] += dp[r]) %= MOD;
                }
                if (r + 1 <= mxr[i] && b <= mxb[i]) {
                    (nxt[r + 1] += dp[r]) %= MOD;
                }
            }
            swap(dp, nxt);
        }
        cout << accumulate(ALL(dp), 0ll) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 384
class Dice3():
    def check(self,dice1,dice2):
        #縦回転
        for i in range(4):
            dice1[0],dice1[1],dice1[5],dice1[4]=dice1[4],dice1[0],dice1[1],dice1[5]
        #横回転
            for j in range(4):
                dice1[0],dice1[2],dice1[5],dice1[3]=dice1[3],dice1[0],dice1[2],dice1[5]
        #ひねり
                for k in range(4):
                    dice1[1],dice1[2],dice1[4],dice1[3]=dice1[2],dice1[4],dice1[3],dice1[1]
                    if dice1 == dice2:
                        print('Yes')
                        return 0
        return

        
#Dice3
dc3 = Dice3()
Dice1 = [int(i) for i in input().split()]
Dice2 = [int(i) for i in input().split()]
ck = dc3.check(Dice1,Dice2)
if ck != 0:
    print('No')


Measured memory_bytes: 5608