akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

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

        TreeSet<Integer>[] sets = new TreeSet[26];
        for(int i=0; i<26; i++) {
            sets[i] = new TreeSet<>();
        }

        char[] s = sc.next().toCharArray();
        int[] c = new int[n];
        for(int i=0; i<n; i++) {
            c[i] = s[i]-'a';
            sets[c[i]].add(i);
        }

        int q = sc.nextInt();
        for(int i=0; i<q; i++) {
            int com = sc.nextInt();
            if(com == 1) {
                int ind = sc.nextInt()-1;
                int num = sc.next().charAt(0) - 'a';
                if(c[ind] != num) {
                    sets[c[ind]].remove(ind);
                    sets[num].add(ind);
                    c[ind] = num;
                }
            } else {
                int l = sc.nextInt()-1;
                int r = sc.nextInt()-1;
                int sum = 0;
                for(int j=0; j<26; j++) {
                    Integer h = sets[j].higher(l-1);
                    if(h != null && h<=r) sum++;
                }
                System.out.println(sum);

            }

        }

    }

}

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

int64_t cnt = 0;
void merge(vector<int64_t>& S, int64_t left, int64_t mid, int64_t right) {
    int64_t n1 = mid - left;
    int64_t n2 = right - mid;
    vector<int64_t>L(n1+1);
    vector<int64_t>R(n2+1);
    for (int i=0; i < n1; i++) {
        L.at(i) = S[left + i];
    }

    for (int i=0; i < n2; i++) {
        R.at(i) = S[mid + i];
    }

    L[n1] = INT64_MAX;
    R[n2] = INT64_MAX;
    int i = 0;
    int j = 0;
    for (int k = left; k < right; k++) {
        cnt += 1;
        if (L[i] <= R[j]) {
            S[k] = L[i];
            i+= 1;
        } else {
            S[k] = R[j];
            j += 1;
        }
    }

}

void mergeSort(vector<int64_t>& S, int64_t left, int64_t right) {
    if (left + 1 < right) {
        int64_t mid = (left + right) / 2;
        mergeSort(S, left, mid);
        mergeSort(S, mid, right);
        merge(S, left, mid, right);
    }
}

int main() {
    int N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int i=0; i < N; i++) {
        cin >> vec.at(i);
    }

    mergeSort(vec, 0, N);
    for (int i=0; i < N; i++) {
        if (i) {
            cout << " ";
        }
        cout << vec[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 10568
#include <iostream>

using namespace std;

int n,k,actuel;

int main(){
	int actuel=1;
	cin >> n >> k;
	
	for(int i=0;i<n;i++){
		
		if(actuel>=k) actuel+=k;
		else actuel*=2;
	}
	
	cout << actuel << endl;
}
		
	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e17;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
 
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

int A,B,C,D,E,F,G,H,I,J,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,K;
string s,t;

signed main()
{
	IOS();
	cin>>N;
	vector<pair<pair<string,int>,int>>v(N);
	for(int i = 0;i < N;i++){
		cin>>v[i].fi.fi>>v[i].fi.se;
		v[i].fi.se*=-1;
		v[i].se = i;
	}
	sort(all(v));
	for(auto e:v){
		cout<<e.se+1<<endl;
	}

}

Measured memory_bytes: 256
program main
  
  implicit none
  integer(16) :: n, k, i, now, cyc,tmp, num
  integer(16),allocatable :: a(:), b(:), bo(:), cnt(:)
  
  read(*,*) n,k
  allocate(a(n))
  allocate(b(n))
  allocate(bo(n))
  allocate(cnt(n))
  read(*,*) a
  
  ! initialize  
  b  = 0
  bo = 0
  cyc = 0
  cnt = 0
  num = 0

  now = 1
  b(now) = 0
  bo(now) = 0
  cnt(now) = 1

  if( k > n ) then
    do i = 1, k+1
      cnt(a(now)) = cnt(a(now)) + 1
      if( cnt(a(now)) == 2 )then
        cyc = i - bo(a(now))
        num = 1
        exit
      end if
      now = a(now)
      b(now) = i
      bo(now) = b(now)
    end do
    !print*, cyc, now, b(now), bo(a(now)), bo(now), k

    if( num == 1 ) then
      !print*, mod(k-b(now),cyc)
      do i = 1, mod(k-b(now),cyc)
        now = a(now)
      end do
    end if
  else
    now = 1
    do i = 1, k
      now = a(now)
    end do
  end if
  
  print*, now
  
  
end program main



Measured memory_bytes: 15528
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll max(ll a,ll b)
{
  if(a>=b)
    return a;
  else
    return b;
}
int main()
{
 ll a,b,c,d;
  ll ans=0;
  cin>>a>>b>>c>>d;
   if(a>=0)
  {
    if(c>=0)
      ans=b*d;
    else if(d<0)
      ans=a*d;
    else if(c<0&&d>=0)
      ans=b*d;
  }
    if(a<0&&b>=0)
  {
    if(c>=0)
      ans=b*d;
    else if(d<0)
      ans=a*c;
    else if(c<0&&d>=0)
      ans=max(a*c,b*d);
  }
   if(b<0)
  {
    if(c>=0)
      ans=b*c;
    else if(d<0)
      ans=a*c;
    else if(c<0&&d>=0)
      ans=a*c;
  }
 
   cout<<ans<<"\n"; 
   
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<string, ll> msl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
typedef std::vector<pl> vpl;
const long double EPS = 1e-9;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prl2(a,b) cout << (a) << " " << (b) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))
#define beto(a,b,c) (a) < (b) && (b) < (c)
#define betc(a,b,c) (a) <= (b) && (b) <= (c) 
#define rsort(a,n) sort(a,a+n,greater<>())
#define Forchar(c,a,z) for(char (c) = (a); (c) <= (z); (c)++) 
#define cntchar(s,c) count(all((s)), c)

const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100000;

int main(void){
    ll n;
    ll a[MAX_N];
    mll cnt;

    in1(n);
    rin1(i,n,a);
    cnt[0] = 0;
    cnt[1] = 0;
    cnt[2] = 0;
    cnt[3] = 0;

    rep(i,n) cnt[a[i]%4]++;
    yn(cnt[0] >= cnt[1] + cnt[3] || (cnt[0] + 1 == cnt[1] + cnt[3] && cnt[2] == 0));
 
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main{
   
  public static void main(String[] args)
  {
     
   Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    long totalWt=s.nextLong();
    long wt[]=new long[n];
   int profit[]=new int[n];
    int sum=0;
    for(int i=0;i<n;i++ )
    {
    	wt[i]=s.nextLong();
    	profit[i]=s.nextInt();
    	
    }
    for(int i=0;i<n;i++)
    	sum+=profit[i];
    
    long dp[][]=new long[n][sum+1];
    for(int i=0;i<n;i++)
    {
    	for(int j=0;j<=sum;j++)
    		dp[i][j]=0;
    }
    dp[0][profit[0]]=wt[0];
    
    for(int i=1;i<n;i++)
    {
    	
    	for(int j=0;j<=sum;j++)
    	{
    		
           		if(j-profit[i]>=0)
           		{
           			if(dp[i-1][j]!=0&&dp[i-1][j-profit[i]]!=0)
           			dp[i][j]=Math.min(wt[i]+dp[i-1][j-profit[i]], dp[i-1][j]);
           			else if((j-profit[i]==0)&&(dp[i-1][j]!=0))
           				dp[i][j]=Math.min(wt[i]+dp[i-1][j-profit[i]], dp[i-1][j]);
                   else if(j-profit[i]==0)
                     dp[i][j]=wt[i]+dp[i-1][j-profit[i]];
           			else if(dp[i-1][j-profit[i]]!=0)
           				dp[i][j]=wt[i]+dp[i-1][j-profit[i]];
           			else
           				dp[i][j]=dp[i-1][j];
           				
           		
           		}
           		else
           			dp[i][j]=dp[i-1][j];
    	}
    }
    

    
    for(int p=sum;p>0;p--)
    {
    	if(dp[n-1][p]!=0&&dp[n-1][p]<=totalWt)
    	{
    		System.out.println(p);
    		break; 
    	}
    }
   
  
    s.close();
    
  }
}


Measured memory_bytes: 129148
//Author:xht37
#include <bits/stdc++.h>

#define ui unsigned int
#define ll long long
#define ul unsigned ll
#define ld long double

#define pi pair <int, int>
#define fi first
#define se second
#define mp make_pair

#define ls (p << 1)
#define rs (ls | 1)
#define md ((t[p].l + t[p].r) >> 1)

#define vi vector <int>
#define pb push_back
#define pq priority_queue

#define dbg(x) cerr << #x" = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)

#define fl(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)

using namespace std;

namespace io {
	const int SI = 1 << 21 | 1;
	char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
	int f, t;
	#define gc() (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)
	inline void flush() {
		fwrite(OB, 1, OS - OB, stdout), OS = OB;
	}
	inline void pc(char x) {
		*OS++ = x;
		if (OS == OT) flush();
	}
	template <class I>
	inline void rd(I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = gc());
		x *= f;
	}
	template <class I>
	inline void rd(I &x, I &y) {
		rd(x), rd(y);
	}
	template <class I>
	inline void rd(I &x, I &y, I &z) {
		rd(x), rd(y), rd(z);
	}
	template <class I>
	inline void rda(I *a, int n) {
		for (int i = 1; i <= n; i++) rd(a[i]);
	}
	inline void rdc(char &c) {
		for (c = gc(); c < 33 || c > 126; c = gc());
	}
	inline void rds(char *s, int &x) {
		for (c = gc(); c < 33 || c > 126; c = gc());
		for (x = 0; c >= 33 && c <= 126; s[++x] = c, c = gc());
		s[x+1] = '\0';
	}
	template <class I>
	inline void print(I x, char k = '\n') {
		if (!x) pc('0');
		if (x < 0) pc('-'), x = -x;
		while (x) ch[++t] = x % 10 + '0', x /= 10;
		while (t) pc(ch[t--]);
		pc(k);
	}
	template <class I>
	inline void print(I x, I y) {
		print(x, ' '), print(y);
	}
	template <class I>
	inline void print(I x, I y, I z) {
		print(x, ' '), print(y, ' '), print(z);
	}
	inline void printc(char c) {
		pc(c);
	}
	inline void prints(string s) {
		int x = s.length();
		while (t < x) pc(s[t++]);
		pc('\n'), t = 0;
	}
	struct Flush {
		~Flush() {
			flush();
		}
	} flusher;
}
using io::rd;
using io::rda;
using io::rdc;
using io::rds;
using io::print;
using io::printc;
using io::prints;

#define Fail print(-1), exit(0);
const int N = 1e5 + 7;
int n, p[N], s[N], f[N];
ll d[N], ans;
vi e[N];
map<ll, int> c;

void dfs(int x, int o) {
	ans += o;
	for (int y : e[x]) dfs(y, o + 1);
}

int main() {
	rd(n), rda(d, n);
	for (int i = 1; i <= n; i++) p[i] = i;
	sort(p + 1, p + n + 1, [&](int i, int j) { return d[i] < d[j]; });
	for (int i = 1; i <= n; i++) c[d[i]] = i, s[i] = 1;
	for (int i = n; i > 1; i--) {
		int u = p[i], fa;
		c.erase(d[u]);
		if (!(fa = c[d[u]-n+2*s[u]])) Fail;
		f[u] = fa, e[fa].pb(u), s[fa] += s[u];
	}
	dfs(p[1], 0);
	if (ans != d[p[1]]) Fail;
	for (int i = 1; i <= n; i++)
		if (f[i]) print(i, f[i]);
	return 0;
}

Measured memory_bytes: 17408
using System;

    class NIKKEIA
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int a = int.Parse(input[1]);
            int b = int.Parse(input[2]);

            int max;
            if (a >= b)
                max = b;
            else
                max = a;

            int min;

            if (a + b - n >= 0)
                min = a + b - n;
            else
                min = 0;

            Console.WriteLine("{0} {1}",max, min);
        }
    }


Measured memory_bytes: 13140
q,h,s,d = map(int,input().split())
lis = [1, 2, 4, 8]
score = [q,h,s,d]
n = int(input())
all_s = 4*n

tmp_li = [8*q,4*h,2*s,d]
tmp_2 = tmp_li[:]
tmp_2.sort()

jun = []
for t in tmp_2:
    jun.append(tmp_li.index(t))
#print('tmp_li',tmp_li,'tmp_2',tmp_2,'jun',jun,'lis',lis)
#[3, 1, 2, 0]

ans = 0
for j in jun:
    a = all_s // lis[j]
    b = all_s % lis[j]
    #print(all_s,a,b,lis[j])
    all_s -= a*lis[j]
    ans += score[j]*a
print(ans)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m;
    cin>>n>>m;
    vector<int> ans(n,-1);
    vector<vector<int>> p(n);
    rep(i,m){
        int a,b; cin>>a>>b;
        a--;  b--;
        p[b].push_back(a);
        p[a].push_back(b);
    }
    deque<int> que;
    que.push_back(0);
    while(!que.empty()){
        int a=que[0];
        for(auto& v: p[a]){
            if(ans[v]==-1){
                ans[v]=a;
                que.push_back(v);
            }
        }
        que.pop_front();
    }
    bool ok=true;
    for(int i=1; i<n; ++i){
        if(ans[i]==-1) ok=false;
    }
    if(!ok){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
        for(int i=1; i<n; ++i) cout<<ans[i]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 10088
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int n;
  cin >> n;
  vector <ll> a;
 
  ll c = 0;
  REP(i,n){
    ll b;
    cin >> b;
    a.pb(b);
    
    
  }
  
  //ll r = 1;
  
  
  
  a.pb(10000000);
  
  ll sum = a[0];
  ll sumx = a[0];
  //cout << sum << endl;
  ll l = 0,r = 0;
  ll s = 0;
  
  while(1){
    
    bool f = false;
    /*
    if(r != n){
      sum += a[r];
      sumx ^= a[r];
      }*/
    if(r == n){
      while(l != n){
	s += r-l;
	l++;
      }
      break;
    }
    
    while(sum == sumx){
      r++;
      //cout << sum << "   " << sumx << endl;
      if(r == n ){
	f = true;
	break;
	
      }
      sum += a[r];
      sumx ^= a[r];
      //r++;
      if(sum != sumx){
	break;
      }
    }
    //cout << l <<  r << endl;
    //cout << "!"<< endl;
    while((sum) != (sumx)){
      sum -= a[l];
      //cout << "  sum = " << sum << "  a[l] " << a[l] << endl;
      sumx ^= a[l];
      s += r-l;
      l++;
    }
    //cout << "sum = " << sum << endl;
    //cout << "!!" << l << r << endl;
    //cout << "s = " << s << endl;
    if(r == n && l == n){
      break;
    }
    
  }
  cout << s << endl;
  
  
  return 0;
}


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


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

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=(res*x)%MOD;y=y>>1;x=(x*x)%MOD;}return res%MOD;} // modular exponent
const int N=2e5+5;
ll a[N],b[N];
ll n;
pair<ll,ll> getm(ll idx)
{
    ll x=a[idx];
    ll y=b[idx];
    if(x==0 && y==0) return mp(0,0);
    ll g=gcd(x,y);
    x/=g;
    y/=g;
    if(y<0)
    {
        x*=-1;
        y*=-1;
    }
    if(x==0) y=1;
    if(y==0) x=1;
    return mp(x,y);
}
pair<ll,ll> opp(pair<ll,ll> p)
{
    ll x=p.se;
    ll y=p.fi;
    x*=-1;
    if(y<0)
    {
        x*=-1;
        y*=-1;
    }
    if(x==0) y=1;
    if(y==0) x=1;
    return mp(x,y);
}
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    cin>>n;
    map<pair<ll,ll>,ll> m;
    repA(i,1,n)
    {
        cin>>a[i]>>b[i];
        m[getm(i)]++;
    }
    ll ans=1;
    map<pair<ll,ll>,ll> vis;
    for(auto &it:m)
    {
        if(vis[it.fi]) continue;
        pair<ll,ll> x=mp(0,0);
        if(it.fi == x) continue;
        x=opp(it.fi);
        if(m.count(x))
        {
            vis[x]=1;
            ll cnt1=it.se;
            ll cnt2=m[x];
            ans*=(power(2,cnt1)+power(2,cnt2)-1);
            ans%=MOD;
        }
        else
        {
            ans*=(power(2,it.se));
            ans%=MOD;
        }
    }
    ans-=1;
    ans+=m[{0,0}];
    ans+=MOD;
    ans%=MOD;
    cout<<ans<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 31724
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (ll i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (ll i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string s;
    cin >> s;
    ll total = 0;
    for (auto &c : s)
        total += c - '0';
    cout << (total % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3772
#include<stdio.h>
#include<string.h>
 
#define N 3
#define LIM 32
#define HN 362897
 
struct dep{
    int depth,key;
};
 
int ans[N][N]={
    {1,2,3},
    {4,5,6},
    {7,8,0}};
 
int min = LIM;
struct dep h[HN];
 
int hash1(int k)
{
    return k % HN;
}
int hash2(int k)
{
    return 1 + k%(HN-1);
}
int hash(int k, int i)
{
    return (hash1(k) + i*hash2(k))%HN;
}
 
 
void dfs(int p[N][N], int n)
{
    int i,j,i1,j1,a=0,b=1;
    int f=0;
    int tmp[N][N];
    //printf("A\n");
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            if(ans[i][j]!=p[i][j])f++;
            if(p[i][j]==0)
            {
                i1=i;
                j1=j;
            }
            a+=p[i][j]*b;
            b*=10;
        }
    }
     
    if(f==0)
    {
        if(min>=n)
        {
            min=n;
        }
        return;
    }
    if(n>min) return;
    i=0;
    while(1)
    {
        b=hash(a, i);
        if(h[b].key == 0)
        {
            h[b].key=a;
            h[b].depth=n;
            break;
        }
        else if(h[b].key == a)
        {
            if(h[b].depth>n)
            {
                h[b].depth=n;
                break;
            }
            else return;
        }
        i++;
    }
     
    if(i1>0 && i1<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i1][j1];
        tmp[i1][j1]=tmp[i1-1][j1];
        tmp[i1-1][j1]=f;
        dfs(tmp, n+1);
    }
    if(j1>0 && j1<N)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i1][j1];
        tmp[i1][j1]=tmp[i1][j1-1];
        tmp[i1][j1-1]=f;
        dfs(tmp, n+1);
    }
     
    if(i1>=0 && i1<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i1][j1];
        tmp[i1][j1]=tmp[i1+1][j1];
        tmp[i1+1][j1]=f;
        dfs(tmp, n+1);
    }
    if(j1>=0 && j1<N-1)
    {
        memcpy(tmp,p,sizeof(int)*N*N);
        f=tmp[i1][j1];
        tmp[i1][j1]=tmp[i1][j1+1];
        tmp[i1][j1+1]=f;
        dfs(tmp, n+1);
    }
     
}
 
int main()
{
    int i,j;
    int p[N][N];
     
    for(i=0;i<N;i++)
    {
        for(j=0;j<N;j++)
        {
            scanf("%d",&p[i][j]);
        }
    }
    dfs(p,0);
     
    printf("%d\n",min);
     
    return 0;
}

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

namespace ConsoleApp7
{
    class Program
    {
        static void MainA(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var n0 = arr[0] + arr[1];
            var n1 = arr[0] - arr[1];
            var n2 = arr[0] * arr[1];
            Console.WriteLine(Math.Max(n0, Math.Max(n1, n2)));
        }
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            List<int> nums = new List<int>();
            int start = arr[1] - arr[0] + 1;
            int end = arr[1] + arr[0] ;

            for (int i =start; i <end; i++)
            {
                nums.Add(i);
            }
            Console.WriteLine(string.Join(" ", nums));
        }

    }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  int x,y;
  cin >> x >> y;

  int nmod = (2*x-y);
  int mmod = (2*y-x);
  if(nmod < 0 || mmod < 0 || nmod%3 != 0 || mmod%3 != 0){
    puts("0");
    return 0;
  }

  int n = nmod/3;
  int m = mmod/3;

  combination c(n+m);
  mint ans = c(n+m,n);
  cout << ans.x << endl;

}


Measured memory_bytes: 13816
#include <bits/stdc++.h>
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

using namespace std;

int i;

int main(){
    double L;
    cin >> L;
    cout<<setprecision(10)<<(L / 3) * (L / 3) * (L / 3)<<endl;
    return 0;
}

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

int N;
int A[200005];

typedef long long ll;

int curr;
ll tot;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) {
		scanf("%d", A+i);
	}

	int r = 0;
	for (int l = 0; l < N; ++l) {
		while (r < N && !(curr & A[r])) curr ^= A[r++];
		tot += r - l;
		curr ^= A[l];
	}

	printf("%lld\n", tot);
}

Measured memory_bytes: 1024
def examA():
    S = SI()
    if len(S)==3:
        ans = S[::-1]
    else:
        ans = S
    print(ans)
    return

def examB():
    A, B, K = LI()
    for i in range(K):
        if i%2==0:
            B +=A//2
            A //=2
        else:
            A +=B//2
            B //=2
    print(A,B)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examB()


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    ll N; cin >> N;
    vll A(N); REP(i, N) cin >> A[i];
    vll sum(N+1); REP(i, N) sum[i+1] = sum[i] + A[i];
    map<ll, ll> count;
    REP(i, N+1)
    {
        if(count.find(sum[i]) == count.end())
        {
            count.insert(make_pair(sum[i], 0));
        }
        count[sum[i]]++;
    }
    ll ans = 0;
    for(auto itr = count.begin(); itr != count.end(); itr++)
    {
        ll n = itr->second;
        if(n >= 2)
        {
            ans += n * (n-1) / 2;
        }
    }
    cout << ans << endl;
}
    
signed main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 15872
<?php
    fscanf(STDIN, '%d', $d);

    
    if($d >=1 && $d<=9){
        $ans = $d;
    }elseif($d >=10 && $d<=99){
        $ans = 9;
    }elseif($d >=100 && $d<=999){
        $ans = 9 + ($d-99);
    }elseif($d >=1000 && $d<=9999){
        $ans = 9 + (999-99);
    }elseif($d >=10000 && $d<=99999){
        $ans = 9 + (999-99)+($d-9999);
    }else{
        $ans = 9 +(99999-9999)+(999-99);;
    }
    echo $ans;


?>

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

int main(){
  ll n;
  cin >> n;
  
  map<ll, ll> mp;
  
  for(int i=0; i<n; i++){
    ll x;
    cin >> x;
    mp[x]++;
  }
  
  for(auto itr = mp.end(); itr != mp.begin();){
    if((--itr) -> second >= 4){
      cout << (itr -> first) * (itr -> first) << endl;
      return 0;
    }else if(itr -> second >= 2){
      for(auto itr2 = itr; itr2 != mp.end();){
        if((--itr2) -> second >= 2){
          cout << (itr -> first) * (itr2 -> first) << endl;
          return 0;
        }
      }
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 6528
n=int(input())
y=input().split()
for i in range(len(y)):
    y[i]=int(y[i])
count1=0
count2=0
c1=0
c2=0
t=0
ans=0
for j in range(n):
    count2+=y[j]
for k in range(n):
    count1+=y[k]
    count2-=y[k]
    if count1>count2:
        if count1-count2<abs(c1-c2):
            t=k+1
            ans=count1-count2
            break
        else:
            t=k
            ans=abs(c1-c2)
            break
    else:
        c1=count1
        c2=count2
print(ans)

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

struct Set{
    string S;
    int P;
    int I;
};

void selection_sort(vector<Set> &a){

    for(int i=0; i < a.size() - 1; ++i){
        auto minj = i;
        for(int j=i; j < a.size(); ++j){
            if(a[minj].S > a[j].S) minj = j;
        }
        if(i != minj) swap(a[i], a[minj]);
    }

    for(int i=0; i<a.size()-1; i++){
        auto minj = i;
        for(int j=i; j < a.size(); ++j){
            if(a[minj].S == a[j].S && a[minj].P < a[j].P) minj = j;
        }
        if(i != minj) swap(a[i], a[minj]);
    }
}

int main(){
    int N; cin >> N;
    vector<Set> S(N);

    for(int i=0; i<N; i++){
        cin >> S[i].S;
        cin >> S[i].P;
        S[i].I = i+1;
    }

    selection_sort(S);

    for(int i=0; i<N; i++){
        cout << S[i].I << endl;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    int a=(s[0]-'0')*10+(s[1]-'0');
    int b=(s[2]-'0')*10+(s[3]-'0');
    int ym=0,my=0;
    if(b<=12 && b>0) ym=1;
    if(a<=12 && a>0) my=1;
    if(ym && my) cout<<"AMBIGUOUS"<<endl;
    else if(ym) cout<<"YYMM"<<endl;
    else if(my) cout<<"MMYY"<<endl;
    else cout<<"NA"<<endl;
}


Measured memory_bytes: 3588
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;
/*******************************************************************************************/
const ll MAX = 1e6 + 7;
bool v[MAX];
int len, sp[MAX];

void Sieve()
{
    for (ll i = 2; i < MAX; i += 2)    sp[i] = 2;
    for (ll i = 3; i < MAX; i += 2)
    {
        if (!v[i]){
            sp[i] = i;
            for (ll j = i; (j*i) < MAX; j += 2){
                if (!v[j*i])    v[j*i] = true, sp[j*i] = i;
            }
        }
    }
}


/*******************************************************************************************/

void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    f(i,n) cin>>a[i];

    unordered_set<ll> s;
    ll mgcd=a[0];
    bool fla=1;

    f(i,n)
    {
        ll x=a[i];
        mgcd = __gcd(a[i],mgcd);

        unordered_set<ll> tx;

        while(x>1)
        {
            tx.insert(sp[x]);
            x/=sp[x];
        }

        for(auto y:tx)
        {
            if(s.find(y)!=s.end())
            {
                fla=0;
                break;
            }
            s.insert(y);
        }
    }

    if((fla==1) && (mgcd==1))
    {
        cout<<"pairwise coprime\n";
    }
    else if(mgcd== 1)
    {
        cout<<"setwise coprime\n";
    }
    else
    {
        cout<<"not coprime\n";
    }
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    Sieve();
    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 19372
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

a,b = map(int, input().split())

e = 0.08
t = 0.1

for i in range(1, 1000+1):
    if int(i * e) == a and int(i * t) == b:
        print(i)
        exit()

print(-1)


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 26;

int n, m;
int f[N][M];
char s[N], t[N];

int main()
{
	scanf("%s%s", s, t);
	n = strlen(s), m = strlen(t);
	
	memset(f, -1, sizeof f);
	
	for (int i = n - 1; i >= 0; i -- )
	{
		for (int j = 0; j < M; j ++ ) f[i][j] = f[i + 1][j];
		f[i][s[i] - 'a'] = i;
	}
	
	int a = 0, b = 0;
	for (int i = 0; i < m; i ++ )
	{
		int c = t[i] - 'a';
		if (f[0][c] == -1)
		{
			puts("-1");
			return 0;
		}
		
		if (f[b][c] == -1) a ++ , b = 0;
		b = f[b][c] + 1;
	}
	printf("%lld\n", (LL)a * n + (LL)b);
	return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d[100],e;
    cin>>a>>b>>c;
    for(int i=0;i<a;i++) cin>>d[i];
    for(int i=0;i<a;i++){
        for(int j=0;j<100;j++){
        if(d[i]*j+1<=b) e++;
        }
    }
    cout<<e+c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    int cnt=0;
    
    for(auto a:s){
        if(a=='I') cnt++;
        else cnt--;
        
        ans=max(ans,cnt);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
struct UnionFind {
public:
  int n;
  std::vector<int> par;
  UnionFind() {}
  UnionFind(int n): n(n) {
    par.resize(n, -1);
  }
  int root(int x) {
    return par[x] < 0 ? x : par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if(rx == ry) return;
    if(par[rx] < par[ry]) {
      std::swap(x, y);
      rx = root(x), ry = root(y);
    }
    par[rx] += par[ry];
    par[ry] = rx;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return -par[root(x)];
  }
};
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
vi col;
map<int, bool> notnibu;
void sch(int now, int prev, int nowcol, const vvi &g, UnionFind &uf) {
  col[now] = nowcol;
  for(auto &nxt: g[now]) {
    if(nxt == prev) continue;
    if(col[nxt] == nowcol) {
      notnibu[uf.root(now)] = true;
      return;
    } else if(col[nxt] == -1) {
      sch(nxt, now, !nowcol, g, uf);
      if (notnibu[uf.root(now)]) return;
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ll n, m; cin >> n >> m;
  vvi g(n);
  UnionFind uf(n);
  for(int i=0;i<(m);++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
    uf.unite(a, b);
  }
  col.resize(n, -1);
  int id = 0;
  for(int i=0;i<(n);++i) {
    if(col[i] != -1) continue;
    sch(i, -1, 0, g, uf);
    id++;
  }
  ll a = 0, b = 0, c = 0;
  map<int, bool> one;
  for(int i=0;i<(n);++i) {
    if(uf.size(i) == 1) {
      one[uf.root(i)] = true;
      c++;
    }
  }
  vector<bool> sel(n);
  for(int i=0;i<(n);++i) {
    int e = uf.root(i);
    if(e == -1) continue;
    if(one[e] || sel[e]) continue;
    else if(notnibu[e]) b++;
    else a++;
    sel[e] = true;
  }
  cout << (a + b) * (a + b) + a * a + n * n - (n - c) * (n - c) << endl;
}


Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
    int N,a[110000],b,c=0,d=0,e=0;
  cin>>N>>b;
    for(int i=1;i<=N;i++){
        cin >>a[i];
      if(a[i]==1)c=i;
        }
  if((N-1)%(b-1)!=0)d=1;
cout <<(N-1)/(b-1)+d;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int ans  =0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            int temp = arr[i]+arr[j];
            int pos = lower_bound(arr+j+1,arr+n,temp)-arr-j-1;
            //cout<<temp<<" "<<pos<<endl;
            ans+=pos;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int w,n,t[31][31],a,b;
char ch;
int main(){
  for(int i=0;i<31;i++){
    for(int j=0;j<31;j++){
      t[i][j]=j;
    }
  } 
  cin>>w>>n;
  for(int i=1;i<=n;i++){
    cin>>a>>ch>>b;
    t[i][a]=b;
    t[i][b]=a;
  }
  for(int j=1;j<=w;j++){
    a=j;
    for(int i=n;i>=0;i--){
      a=t[i][a];
    }
    cout<<a<<endl;
  }
  return 0;
}

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

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

ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/g*b; 
}

int main(){
  int N;
  cin>>N;
  ll ans=1LL;
  for(int i=0;i<N;i++){
    ll t;
    cin>>t;
    ans=lcm(ans,t);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	long long int x, y;
	cin >> x >> y;

	long long int x2 = y / x;

	long long int ans = 0;

	while (x2 > 0) {
		ans++;
		x2 /= 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
 
int main(){
  ll i, j;
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> b(n + 1);
  for(i = 0; i < n; i++)
    cin >> a[i];
  ll buf = 0;
  for(i = 0; i < n + 1; buf += a[i++]){
    buf %= m;
    b[i] = buf;
    //cout << b[i] << endl;
  }
  sort(ALL(b));
  //for(i = 0; i <= n; i++)
    //cout << b[i] << endl;
  ll sum = 0, countbuf;
  for(i = 0; i <= n; i++){
    for(j = i, countbuf = 0; j <= n && b[i] == b[j]; countbuf++,j++)
      //cout << b[i] spa b[j] spa i spa  j << endl
      ;
    //cout << countbuf << endl;
    i = j - 1;
    sum += countbuf * (countbuf - 1) / 2;
    //cout << b[i - 1] spa sum << endl;
  }
    
  cout << sum << endl;
 
  return 0;
}

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

ll ans = 0;
ll n;
int three,five,seven;
void dfs(ll x){
    if(x > n) return;
    three = 0; five = 0; seven = 0;
    for(int i=0; i<to_string(x).size(); i++){
        if(to_string(x).at(i) == '3') three++;
        if(to_string(x).at(i) == '5') five++;
        if(to_string(x).at(i) == '7') seven++;
    }
    if(three>0 && five>0 && seven>0) ans++;
    dfs(x*10+3);
    dfs(x*10+5);
    dfs(x*10+7);
}

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

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	ll a = in(), b = in(), c = in();
	cout << min(c, b / a) << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.IO.Pipes;
using System.ComponentModel;
using System.Drawing;
using Microsoft.VisualBasic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            int Sl = S.Length;
            int Tl = T.Length;

            int ans = Tl;
            int tmp = 0;

            for (int i = 0; i < Sl - Tl + 1; i++) 
            {
                tmp = 0;
                for (int j= 0; j < Tl; j++)
                {
                    if (T[j] != S[j + i]) 
                    {
                        tmp++;
                    } 
                }

                if (tmp < ans) 
                {
                    ans = tmp;
                }

            }

            Console.WriteLine(ans);

        }

    }
}


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

// using namespace std;

// typedef long long int ll;

// int main() 
// { 
// 	// int t; cin >> t;

// 	// while (t--)
// 	// {
// 	// 	int n,k; cin >> n >> k;
// 	// 	int i = 2;
// 	// 		while (n % i != 0)
// 	// 			i++;
		
// 	// 	int sum = n;
// 	// 	while (k--){
// 	// 		sum += i;
// 	// 		if (sum % 2 == 0)
// 	// 			i = 2;
		
// 	// 	}
// 	// 	cout << sum << endl;
		
// 	// }	

// 	int d,t,s; cin >> d >> t >> s;

// 	if ((t*s) >= d)
// 		cout << "Yes";
// 	else
// 	{
// 		cout << "No";
// 	}
	
// } 
// CPP program to find the minimum number of 
// characters to be replaced in string S2, such 
// that S1 is a substring of S2 

#include <bits/stdc++.h> 
using namespace std; 

// Function to find the minimum number of 
// characters to be replaced in string S2, such 
// that S1 is a substring of S2 
int minimumChar(string S1, string S2) 
{ 
	// Get the sizes of both strings 
	int n = S1.size(), m = S2.size(); 

	int ans = INT_MAX; 

	// Traverse the string S2 
	for (int i = 0; i < m - n + 1; i++) { 
		int minRemovedChar = 0; 

		// From every index in S2, check the number of 
		// mis-matching characters in substring of 
		// length of S1 
		for (int j = 0; j < n; j++) { 
			if (S1[j] != S2[i + j]) { 
				minRemovedChar++; 
			} 
		} 

		// Take minimum of prev and current mis-match 
		ans = min(minRemovedChar, ans); 
	} 

	// return answer 
	return ans; 
} 

// Driver Code 
int main() 
{ 
	string S1,S2;
	cin >> S1 >> S2;

	cout << minimumChar(S2, S1); 

	return 0; 
} 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  auto add=
    [&](string s,string t){
      int n=max(s.size(),t.size());
      s.resize(n,'0');
      t.resize(n,'0');
      string a(n,'0');
      int u=0;
      for(int i=0;i<n;i++){
	int x=s[i]-'0',y=t[i]-'0';
	a[i]+=(x+y+u)%10;
	u=(x+y+u)/10;
      }
      if(u) a.push_back('0'+u);
      return a;
    };

  string b=s;
  b=add(b,b);
  b=add(b,b);
  b=add(b,b);
  s=add(s,b);
  
  auto check=
    [&](ll x){
      string t=to_string(x*9);
      reverse(t.begin(),t.end());
      string a=add(s,t);
      ll res=0;
      for(int i=0;i<(int)a.size();i++) res+=a[i]-'0';
      return res<=x*9;
    };
  
  ll l=0,r=s.size()+10;
  while(l+1<r){
    ll m=(l+r)>>1;
    if(check(m)) r=m;
    else l=m;
  }
  cout<<r<<endl;
  return 0;
}


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

int main( void ){
    int n,i;
    char s[101];
    scanf("%d", &n);
    scanf("%s", s);
    char s1[51];
    char s2[51];
    if(n%2 == 0){
        for(i = 0; i < (n/2); i++){
            s1[i] = s[i];
            s2[i] = s[(n/2)+i];
        }
        s1[n/2] = '\0';
        s2[n/2] = '\0';
         if(strcmp(s1,s2) == 0){
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128