akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)

                    
using ll = long long;
using ull = unsigned long long;
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; }
const ll mod = 1e9+7;
void chmod(ll &M){
  if(M >= mod) M %= mod;
  else if(M < 0){
     M += (abs(M)/mod + 1)*mod;
    M %= mod;
}
}
ll modpow(ll x, ll n){
   if(n==0) return 1;
  ll res=modpow(x, n/2);
 if(n%2==0) return res*res%mod;
else return res*res%mod*x%mod;
}
int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  else return GCD(b, a % b);
}

using namespace std;
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
int main()
{
    string S;
    cin >> S;
    int count_a = 0;
    int count_b = 0;
    rep(i, 3) {
        if(S[i] == 'A') count_a++;
        if(S[i] == 'B') count_b++;
    }
    if((count_a != 0) && (count_b != 0)) {cout << "Yes" << endl;}
    else cout << "No" << endl;
    
}



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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll solve(ll n)
{
    ll m = 0;
    while (n > 0)
    {
        n /= 10;
        m++;
    }
    return m;
}

int main()
{
    ll N;
    cin >> N;
    ll n = 0;
    FOR(i, N + 1, 1)
    {
        ll m = solve(i);
        if (m % 2 == 1)
            n++;
    }
    cout << n << endl;
    return 0;
}

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

int main(){
   int N;
  cin >> N;
  string s;
  
  vector <string> S(N);
//vector<vector<int>> count(10,vector<int>);
  vector <bool> torf(N,true);
  
  rep(i,N){
    cin >> S.at(i);
  }
  
  /*rep(i,10){
    rep(j,(int)count.at(i).size()-1){
      for(int k=j+1,k<count.at(i).size();k++){
    	if(count.at(i).at(j)==count.at(i).at(k))
    
    
      }
    }
  }
  
  
  
  */
  
  int i=0;
  sort(S.begin(),S.end());
  
   while(i<N-1){
     if(S.at(i)==S.at(i+1))
       torf.at(i+1)=false;
     
     i++;
       
  }
    
  int count=0;
  rep(i,N){
    if(torf.at(i)==true)
      count++;
  }
    
  /*  
    S.push_back(s);
    rep(j,i){
      if(S.at(j)==S.at((int)S.size()-1)){
        S.pop_back();
        break;
      }
        
    }
    
  }*/
  
  cout << count << endl;

  
}




Measured memory_bytes: 9524
import sys


N, M = map(int, input().split())

d = {i:0 for i in range(1, N+1)}

for i in range(M):
  a, b = map(int, input().split())
  d[a] += 1
  d[b] += 1
  
for v in d.values():
  if v % 2 == 0:
    continue
  else:
    print("NO")
    sys.exit()
    
print("YES")

Measured memory_bytes: 53348
import math
import numpy as np
a,b,x = list(map(int, input().split()))
s = x/a

def cvt(val):
    return np.rad2deg(np.arctan(val))

if x > a*a*b/2:
    print(cvt((2*a*b-2*s)/(a*a))) # ??
else:
    print(cvt(b*b/(2*s)))

Measured memory_bytes: 12500
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=1;i<=n;i++)
#define pb push_back
#define pf push_front
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
int a[10005];
int ans[105][105];
int mov[2]={1,-1};
int main()
{
	ios::sync_with_stdio(false);
	int n,h,w;
	cin>>h>>w>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	int to=0,ni=1,nj=0;
	for (int i=1;i<=n;i++){
		while (a[i]!=0){
			a[i]--;
			nj+=mov[to];
			if (nj<=0){
				nj=1;
				ni++;
				to=0;
			}
			else if (nj>w){
				nj=w;
				ni++;
				to=1;
			}
			ans[ni][nj]=i;
		}
	}
	for (int i=1;i<=h;i++){
		for (int j=1;j<=w;j++) cout<<ans[i][j]<<" ";
		cout<<endl;
	}
	//cout<<ans[3][0];
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007
#define BOX 200000

typedef long long ll;

#define rep(i, s, e) for(unsigned int i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)
#define so(a) sort(begin(a), end(a))
#define soR(a) sort(begin(a), end(a), greater<ll>())
#define uni(a) a.erase(unique(begin(a), end(a)), end(a))
#define sum(a) accumulate(begin(a), end(a), 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; }

bool search(int i, int ii, int iii, string S) {
    string::size_type pos1 = S.find(i + '0');
    if (pos1 == string::npos) return false;
    string::size_type pos2 = S.find(ii + '0', pos1 + (string::size_type)1);
    if (pos2 == string::npos) return false;
    string::size_type pos3 = S.find(iii + '0', pos2 + (string::size_type)1);
    if (pos3 == string::npos) return false;
    return true;
}



int main() {
    ll N;
    string S;
    cin >> N >> S;

    ll cnt = 0;
    rep(i, 0, 10) {
        rep(ii, 0, 10) {
            rep(iii, 0, 10) {
                if (search(i, ii, iii, S)) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 256
//This code was made by Chinese_zjc_
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
inline int rd(int &ddd)
{
	char tmp=getchar();
	int xxx=1;
	ddd=0;
	while(('0'>tmp||tmp>'9')&&tmp!='-'&&tmp!=EOF)
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	if(tmp=='-')
	{
		xxx=-1;
		tmp=getchar();
	}
	while('0'<=tmp&&tmp<='9')
	{
		ddd=(ddd<<3)+(ddd<<1)+(tmp^48);
		tmp=getchar();
	}
	return ddd*=xxx;
}
inline char rd(char &ddd)
{
	char tmp=getchar();
	while(tmp==' '||tmp=='\n')
	{
		tmp=getchar();
	}
	if(tmp==EOF)
	{
		return EOF;
	}
	return ddd=tmp;
}
inline int max(const int &A,const int &B)
{
	return A<B?B:A;
}
inline int min(const int &A,const int &B)
{
	return A<B?A:B;
}
int n,h[100001];
signed main()
{
	rd(n);
	for(int i=1;i<=n;++i)
	{
		rd(h[i]);
	}
	for(int i=n-1;i>0;--i)
	{
		if(h[i]<=h[i+1])
		{
			continue;
		}
		if(h[i]-1<=h[i+1])
		{
			--h[i];
			continue;
		}
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1024
import java.io.*;

class Main
{
 public static void main(String args[])throws IOException
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  for(;;)
  {
   int cnt = 0;
   String str_n = br.readLine();
   if(str_n == null) break;
   int n = Integer.parseInt(str_n);
   for(int a = 0; a <= 9; a++){
    for(int b = 0; b <= 9; b++){
     for(int c = 0; c <= 9; c++){
      for(int d = 0; d <= 9; d++){
       if(a+b+c+d == n)
        cnt++;
      }
     }
    }
   }
   System.out.println(cnt);
  }
 }
}

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

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

    int N;
    cin >> N;
    
    int count = 0;
    for(int i=1; i<=N; i++){
        if(i % 2 == 1) count++;
    }
    
    printf("%.9f", (double) count / N);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long n,k,dice,x;
	double ans=0.0,y;
	cin >> n >> k;
	for(dice=1;dice<=n;dice++){
		x = dice;
		y = 1.0;
		while(x<k){
			x *= 2;
			y /= 2.0;
		}
	ans += y/n;
	}
	printf("%.12f\n",ans);
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args)
	{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		D solver = new D();
		solver.solve(1, in, out);
		out.close();
	}
	
	static class UnionFind
	{
		int[] par;
		int[] n_nodes;
		int max = 1;
		
		public UnionFind(int n)
		{
			par = new int[n];
			n_nodes = new int[n];
			for( int i=0; i<n; i++ )
			{
				par[i] = i;
				n_nodes[i] = 1;
			}
		}
		
		int root(int x)
		{
			if( par[x] == x ) return x;
			return par[x] = root(par[x]);
		}
		
		void unite(int x, int y)
		{
			int rx = root(x);
			int ry = root(y);
			if( rx == ry ) return;
			par[rx] = ry;
			n_nodes[ry] += n_nodes[rx];
			max = Math.max(max, n_nodes[ry]);
		}
		
		boolean same(int x, int y)
		{
			int rx = root(x);
			int ry = root(y);
			return rx == ry;
		}
	}
	
	static class D
	{
		public void solve(int n, MyScanner in, PrintWriter out)
		{
			int N = in.nextInt();
			int M = in.nextInt();
			UnionFind tree = new UnionFind(N);
			for( int i=0; i<M; i++ )
			{
				int a = in.nextInt();
				int b = in.nextInt();
				tree.unite(a-1, b-1);
			}
			out.println(tree.max);
		}
	}
	
	static class C
	{
		public void solve(int n, MyScanner in, PrintWriter out)
		{
			int mod = (int) 1e9 + 7;
			
			int N = in.nextInt();
			int[] a = new int[N];
			long sum = 0;
			for( int i=0; i<N; i++ )
			{
				a[i] = in.nextInt();
				sum += a[i];
			}
			long ans = 0;
			for( int i=0; i<N; i++ )
			{
				sum -= a[i];
				long add = ((sum % mod) * a[i]) % mod;
				ans = (ans + add) % mod;
			}
			out.println(ans);
		}
	}
	
	static class B
	{
		public void solve(int n, MyScanner in, PrintWriter out)
		{
			String S = in.next();
			String T = in.next();

			char[] s = S.toCharArray();
			char[] t = T.toCharArray();
			
			int min = t.length;
			for( int i=0; i<=s.length - t.length; i++ )
			{
				int cnt = 0;
				for( int j=0; j<t.length; j++ )
				{
					if( s[i+j] != t[j] ) cnt++;
				}
				min = Math.min(min, cnt);
			}
			out.println(min);
		}
	}
	
	static class A
	{
		int D;
		int T;
		int S;
		
		public void solve(int testNumber, MyScanner in, PrintWriter out)
		{
			D = in.nextInt();
			T = in.nextInt();
			S = in.nextInt();
			out.println(D <= T*S ? "Yes" : "No");
		}
	}
	
	static class MyScanner
	{
		private BufferedReader in;
		private StringTokenizer st;
		
		public MyScanner(InputStream stream)
		{
			in = new BufferedReader(new InputStreamReader(stream));
		}
		
		public String next()
		{
			while( st == null || !st.hasMoreTokens() )
			{
				try
				{
					String rl = in.readLine();
					if( rl == null )
					{
						return null;
					}
					st = new StringTokenizer(rl);
				}
				catch( IOException e )
				{
					return null;
				}
			}
			return st.nextToken();
		}
		
		public int nextInt()
		{
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 57732
#include <bits/stdc++.h>
using namespace std;
main () {
  int N;
  cin >> N;
  int H;
  for (int i = 1; i <= N; i++) {
    string S;
    cin >> S;
    
    if(S == "Y") {
      H++;
    }
  }
  if (H == 0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}
      

    


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

// #define endl            "\n"
#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int n;
int k;
vector<int> a, b, c;
int memo[100005][3];

int solve(int i, int prev) {
    if (i == n) {
        return 0;
    }
    if (memo[i][prev] != -1) {
        return memo[i][prev];
    }

    if (prev == 0) {
        return memo[i][prev] = max(b[i] + solve(i + 1, 1), c[i] + solve(i + 1, 2));
    }
    else if (prev == 1) {
        return memo[i][prev] = max(a[i] + solve(i + 1, 0), c[i] + solve(i + 1, 2));
    }
    else {
        return memo[i][prev] = max(a[i] + solve(i + 1, 0), b[i] + solve(i + 1, 1));
    }
}

int32_t main() {

    zeus();
    cin >> n;

    vector<int> x1(n), x2(n), x3(n);
    memset(memo, -1, sizeof memo);
    forn(i, 0, n) {
        cin >> x1[i] >> x2[i] >> x3[i];
    }
    a = x1;
    b = x2;
    c = x3;

    cout << max({a[0] + solve(1, 0), b[0] + solve(1, 1), c[0] + solve(1, 2)}) << endl;

    // cout << solve(1, 0) << " " << solve(1, 1) << " " << solve(1, 2) << endl;



}








Measured memory_bytes: 15080
from itertools import accumulate as acc
import sys

if __name__ == "__main__":
    s = sys.stdin.readlines()
    N, M, Q = map(int, s[0].split())
    LR = [[0]*N for _ in range(N)]
    for l, r in (map(int, e.split()) for e in s[1:M + 1]):
        LR[l - 1][r - 1] += 1

    S = [tuple(acc(reversed(s))) for s in zip(*(acc(x) for x in LR))]
    for p, q in (map(int, e.split()) for e in s[M+1:]):
        print(S[q-1][N-p])


Measured memory_bytes: 32888
import sys
sys.setrecursionlimit(10 ** 7)
#import bisect
#import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    l = []
    for i in range(N):
        s = input()
        l.append(s)

    print("AC x {}".format(l.count("AC")))
    print("WA x {}".format(l.count("WA")))


    print("TLE x {}".format(l.count("TLE")))
    print("RE x {}".format(l.count("RE")))

if __name__ == "__main__":
    main()


Measured memory_bytes: 75328
import sys,io,os
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
#I = input

n,m = map(int, I().split())
p=[-1]*(n+1)
s=[0]*(n+1)
S=n-1
def t(a):
	b = a
	while p[b] != -1:
		b = p[b]
	while p[a] != -1:
		p[a],a = b,p[a]
	return a
for _ in range(m):
	a,b=map(int, I().split())
	a,b = t(a), t(b)
	if a != b:
		S -= 1
		if s[a] > s[b]:
			a,b = b,a
		p[a] = b
		s[b] += s[a]
print(S)



Measured memory_bytes: 73024
#include "bits/stdc++.h"
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var << std::endl;
using ll = long long;
using ull = unsigned long long;
using vint = std::vector<int>;
using vvint = std::vector<std::vector<int>>;
using namespace std;
ll mod = 1e9 + 7;

/*int <= 10^9*/
/*10^5までは全探索できる*/

int main() {


  int N; cin >> N;
  vector<ll> H(N);
  rep(i, N)cin >> H[i];
  vector<array<bool, 2>> dp(N + 1);
  dp[0][0] = true;
  dp[0][1] = true;
  dp[1][0] = true;
  dp[1][1] = true;

  rep(i, N) {
	if (i > 0) {
	  dp[i + 1][0] = (((H[i] - 1 - (H[i - 1] - 1) >= 0) & dp[i][0]) | ((H[i] - 1 - H[i - 1] >= 0) & dp[i][1]));//減らす場合
	  dp[i + 1][1] = (((H[i] - (H[i - 1] - 1) >= 0) & dp[i][0]) | ((H[i] - H[i - 1] >= 0) & dp[i][1]));//減らさない場合
	}
  }

  if (dp[N][0] | dp[N][1]) {
	cout << "Yes";
  }
  else {
	cout << "No";
  }


  return 0;
}

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

int main() {
    int n;
    cin >> n;

    int a[n];
    int maxVal = 0;
    int minVal = INT_MAX;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        maxVal = max(maxVal, a[i]);
        minVal = min(minVal, a[i]);
    }

    cout << maxVal - minVal << endl;
    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
a = []
for i in range(1,int(M**0.5)+1):
    if M%i == 0:
        a.append(i)
        a.append(int(M/i))
a.sort(reverse = True)
for i in a:
    if i <= M/N:
        print(i)
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const ll INF=1e15;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)
        cin>>a[i];
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
bool isprime(ll n){
    if(n==1){
        return false;
    }
    if(n==2 || n==3){
        return true;
    }
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)
            return false;
    }
    return true;
}

//ll x[100001]={0};
//ll h[100001]={0};
//ll a[200001]={0};
//ll b[200001]={0};
//bool c[100001]={0};
//bool prime[100001]={0};
//ll prec[100011]={0};

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)
        res*=i;
    return res;
}

ll distance(ll x1,ll y1,ll x2,ll y2){
    return (ll)ceil(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

void solve(){
    ll a,b,n;
    cin>>a>>b>>n;

    cout<<(a*(min(n,b-1))/b);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(100001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
ll a,b,c,d,g,ans,N,M,tt;
ll cal(ll x1){
	return x1-x1/c-x1/d+x1/g;
}
ll gcd(ll x1,ll x2){
	if (x2==0) return x1;
	return gcd(x2,x1%x2); 
}
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	g=c/gcd(c,d)*d;
	printf("%lld\n",cal(b)-cal(a-1));
	return 0;
}

Measured memory_bytes: 256
/************************************************
 * Au: Hany01
 * Email: hany01@foxmail.com
************************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
#define rep(i, j) for (register int i = 0, i##_end_ = (j); i < i##_end_; ++ i)
#define For(i, j, k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define fir first
#define sec second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) ((int)(a).size())
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define Mod (1000000007)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define y1 wozenmezhemecaia

template <typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }

inline int read()
{
	register int _, __; register char c_;
    for (_ = 0, __ = 1, c_ = getchar(); c_ < '0' || c_ > '9'; c_ = getchar()) if (c_ == '-') __ = -1;
    for ( ; c_ >= '0' && c_ <= '9'; c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}

inline void File()
{
#ifdef hany01
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
#endif
}

int main()
{
    File();
	LL n, k, t, Ans = 0, len;
	n = read(), k = read();
	For(b, k + 1, n) {
		t = (n + 1) / b;
		len = b - k;
		Ans += t * len;
		if ((t + 1) * b - len + 1 <= n + 1) Ans += (n + 1) - ((t + 1) * b - 1 - len + 1);
		if (!k) -- Ans;
	}
	cout << Ans;
    return 0;
}

Measured memory_bytes: 384
import Control.Applicative
import Data.List (isPrefixOf)

main = containsLoop <$> getLine <*> getLine >>=
        \i -> putStrLn $ if i then "Yes" else "No"

containsLoop :: Eq a => [a] -> [a] -> Bool
containsLoop s = contains (s++s)

contains :: Eq a => [a] -> [a] -> Bool
contains [] _ = False
contains src sub = (sub `isPrefixOf` src) || contains (tail src) sub

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

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

int main() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

    ll h1 = T1 * (A1 - B1);
    ll h2 = T2 * (A2 - B2);
    if (signbit(h1) == signbit(h2)) {
        cout << 0 << endl;
        return 0;
    }

    if (h1 >= 0) {
        h1 *= -1;
        h2 *= -1;
    }

    if (h1 + h2 == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    if (h1 + h2 < 0) {
        cout << 0 << endl;
        return 0;
    }


    ll q = -h1 / (h1 + h2);
    ll m = -h1 % (h1 + h2);

    ll ans = 2 * q;
    if (m != 0) {
        ans++;
    }

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


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

int main(){
    int n;
    cin >> n;
    vector<ll> x(n);
    rep(i,n) cin>>x.at(i);
    sort(x.begin(),x.end());
    int ans=0;
    int cnt=0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                cnt++;
            if(x.at(i)+x.at(j)>x.at(k) && x.at(j)+x.at(k)>x.at(i) && x.at(k)+x.at(i)>x.at(j)){
                if(x.at(i)==x.at(j) || x.at(j)==x.at(k) || x.at(k)==x.at(i)){
                    continue;
                }else{
                ans++;
            }}
    }}}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		int n = cin.nextInt();
		int k = cin.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < l.length; i++)
			l[i] = cin.nextInt();
		Arrays.sort(l);
		int ans = Arrays.stream(l).skip(n - k).sum();
		cout.println(ans);
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

}


Measured memory_bytes: 26068
//Littleboy123 Template 1.6
#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

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

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(n) printf("%d\n", (n))
#define COUTLL(n) printf("%lld\n", (n))
#define CIN(n) scanf("%d", &(n))
#define CINLL(n) scanf("%lld", &(n))
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void infile(){
	freopen("input.in", "r", stdin);
}

void outfile(){
	freopen("output.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll tmp = modex(a, b/2, mod);
	tmp = (tmp * tmp) % mod;
	if(b & 1)
		tmp = (tmp * a) % mod;
	return tmp;
}

//End of template

const ll mod = 1e9 + 7;

int h, w;
char arr[1005][1005];
ll memo[1005][1005];

ll dp(int i, int j){
	//cout << i << ' ' << j << endl;
	if(arr[i][j] == '#'){
		return 0;
	}
	if(i == h-1 && j == w-1){
		return 1;
	}
	if(memo[i][j] != -1)
		return memo[i][j];
	if(i == h-1){
		memo[i][j] = dp(i, j+1) % mod;
	}	
	else if(j == w-1){
		memo[i][j] = dp(i+1, j) % mod;
	}
	else
		memo[i][j] = (dp(i+1, j) + dp(i, j+1)) % mod;
	return memo[i][j]; 
}

int main(){
	init();

	cin >> h >> w;
	FOR(i, 0, h){
		FOR(j, 0, w){
			cin >> arr[i][j];
		}
	}
	MEM(memo, -1);
	cout << dp(0, 0) << nl;
	return 0;	
}

Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int X, A, B;
	cin >> X >> A >> B;

	if (B <= A) cout << "delicious" << endl;
	else if (B - A <= X) cout << "safe" << endl;
	else cout << "dangerous" << endl;

	return 0;
}


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

int main()
{
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	int len1 = s1.length();
	int len2 = s2.length();
	int len3 = s3.length();
	if(s1[len1-1] == s2[0] && s2[len2-1] == s3[0])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

struct Node{int key;
        Node *parent,*left,*right;};

Node *root,*nil;

void insert(int k){
    Node *x = root;
    Node *y = nil;
    Node *z = new Node;
    z -> key = k;
    z -> left = nil;
    z -> right = nil;
    while( x != nil){
        y = x;
        if(z -> key < x -> key){
            x = x -> left;
        }else{
            x = x -> right;
        }
    }
    z -> parent = y;
    if(y == nil) root = z;
    else if(z -> key < y -> key){
        y -> left = z;
    }else{
        y -> right = z;
    }
}

Node* find(Node *x,int k){
    while(x != nil && x -> key != k){
        if( x -> key < k){
            x = x -> right;
        }else{
            x = x -> left;
        }
    }
    return x;
}

void preorder(Node* n){
    if(n == nil) return;
    cout <<" " << n -> key;
    preorder(n -> left);
    preorder(n -> right);
}

void inorder(Node* n){
    if( n == nil ) return;
    inorder(n -> left);
    cout << " " << n -> key;
    inorder(n -> right);
}

void print(){
    inorder(root);
    cout << endl;
    preorder(root);
    cout << endl;
}

Node* getMinimum(Node *x){
    while(x -> left != nil) x = x -> left;
    return x;
}

Node* getSuccessor(Node *z){
    return getMinimum(z -> right);
    /*
    if(z -> right != nil) return getMinimum(z -> right);
    Node *y = z -> parent;
    while( y!=nil && z == y -> right){
        z = y;
        y = y -> parent;
    }
    return y;
    */
}

void delete_key(Node *z){
    Node *y;// delete Node;
    Node *x; // y's child
    if( z -> left == nil || z -> right == nil){
        y = z;
    }else{
        y = getSuccessor(z);
    }
    
    if(y -> left != nil){
        x = y -> left;
    }else{
        x = y -> right;
    }
    if(x != nil) x -> parent = y -> parent;

    if(y -> parent == nil){
        root = x;
    }else if(y -> parent -> left == y){
        y -> parent -> left = x;
    }else if(y -> parent -> right == y){
        y -> parent -> right = x;
    }

    if(z != y) z -> key = y -> key;

    free(y);
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string order;
        int num;
        cin >> order;
        if(order == "insert"){
            cin >> num;
            insert(num);
        }else if(order == "find"){
            cin >> num;
            if(find(root,num) != nil) cout << "yes" << endl;
            else cout << "no" << endl;
        }else if(order == "delete"){
            cin >> num;
            delete_key(find(root,num));
        }else{
            print();
        }
    }
}


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

using namespace std;

int main()
{
  string a, b; cin >> a >> b;
  int na, nb; cin >> na >> nb;
  string s; cin >> s;
  if(a == s) --na;
  else --nb;
  
  cout << na << " " << nb;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  int g = gcd(n,m);
  int N = n/g;
  int M = m/g;
  rep(i,g) {
    if(s[i*N]!=t[i*M]) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << lcm(n,m) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
/* Solution by divyanshu0x16*/
#define int           long long 
#define setbits(x)    __builtin_popcountll(x)
#define zerobits(x)   __builtin_ctzll(x)
#define mod           1000000007 
#define modulo(a, b)  (a%b<0 ? a%b+b : a%b)
#define intpow(a,b)   (int)(pow(a,b) + 0.5)
#define gcd(a,b)      __gcd(a, b)
#define all(x)        (x).begin(), (x).end()
#define ps(x, y)      fixed<<setprecision(y)<<x
#define testcase(x)   int x; cin >> x; while(x--)
#define fastIO        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef stack<int> si;
typedef queue<int> qi;
typedef priority_queue<int> pqi;


int32_t main() {
    fastIO;
    int  t = 1;
    while(t--){
        int x; cin >> x;
        if ( x >= 30) cout << "Yes" << "\n";
        else cout << "No" << "\n"; 
    }
    return 0;
}
 

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;
const ll INF = 10010010010010010;

int main() {
    int n; cin >> n;
    vector<long double> a(n); rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    long double ans = (a[0] + a[1]) / 2;
    //cout << ans << endl;
    rep(i,n-2) {
        ans = (ans + a[i+2]) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



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

  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  int p[A], q[B], r[C];
  priority_queue<P> que;
  rep(i,A){
    cin >> p[i];
    que.push(P(p[i], 0));
  }
  rep(i,B){
    cin >> q[i];
    que.push(P(q[i], 1));
  }
  rep(i,C){
    cin >> r[i];
    que.push(P(r[i], 2));
  }
  /*
  sort(p, p+A);
  sort(q, q+B);
  sort(r, r+C);
  */
  int ans = 0;
  bool ok0{}, ok1{};

  int count0{}, count1{}, count2{};
  while(!que.empty()){

    P p = que.top();
    que.pop();
    
    int F = p.first;
    int S = p.second;
    if(S == 0){
      if(ok0) continue;
    }
    if(S == 1){
      if(ok1) continue;
    }
    ans += F;
    if(S == 0){
      count0++;
      if(count0 == X) ok0 = true;
    }
    if(S == 1){
      count1++;
      if(count1 == Y) ok1 = true;
    }
    if(S == 2) count2++;
    if(X+Y == count1 + count2 + count0) break;

  }

  cout << ans << endl;
  
}

Measured memory_bytes: 12652
# coding: utf-8
# Your code here!

A, B, C = map(str, input().split())
len_A = len(A)
len_B = len(B)
flag = 0

if A[len_A - 1] == B[0]:
    if B[len_B - 1] == C[0]:
        flag = 1
        print("YES")

if flag == 0:
    print("NO")

Measured memory_bytes: 3060
def main():
  import sys
  import math
  import collections
  n=int(input())
  word=["".join(sorted(str(input()))) for _ in range(n) ]
  dic=collections.Counter(word)
  ans=0
  for k in dic.values():
    if k>1:
      ans+=math.factorial(k)//math.factorial(k-2)//2
  print(ans)
  
if __name__=="__main__":
  main()
  

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

#define    ll     long long int

const int N = 100005;
int ara[N];
int cnt[N];

int main( )
{
    int i, j, k, n, mx = 0, c;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        cnt[ara[i]]++;
    }
    for (i = 1; i <= n; i++) {
        j = ara[i];
        c = cnt[j];
        if (j != 0) {
            c += cnt[j - 1];
        }
        c += cnt[j + 1];
        mx = max(mx, c);
    }
    cout << mx << '\n';
    return 0;
}



Measured memory_bytes: 1024
n=int(input())

res=0
if n < 10:
    res=n
elif 10 <= n and n < 10**2:
    res=9
elif 10**2 <= n and n < 10**3:
    res=9+(n-10**2)+1
elif 10**3 <= n and n < 10**4:
    res=9+900
elif 10**4 <= n and n < 10**5:
    res=9+900+(n-10**4)+1
elif n == 10**5:
    res = 9 + 900 + 90000
else:
    pass
print(res)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    char S[N+1];

    scanf("%s", S);

    int max = 0;

    for(int i = 0; i < N-1; i++){
        int x['z'-'a'+1], y['z'-'a'+1];
        for(int j = 0; j <= 'z'-'a'; j++){
            x[j] = 0;
            y[j] = 0;
        }
        for(int j = 0; j <= i; j++){
            x[S[j]-'a'] = 1;
        }
        for(int j = i+1; j < N; j++){
            y[S[j]-'a'] = 1;
        }
        int c = 0;
        for(int j = 0; j <= 'z'-'a'; j++){
            if(x[j] == 1 && y[j] == 1){
                c++;
            }
        }
        if(c > max){
            max = c;
        }
    }

    printf("%d\n", max);

    return 0;
}

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

int main(){
    int N, M; cin >> N >> M;
    deque<pair<int,int>> req;
    for(int i=0; i<M; i++){
        int l, r; cin >> l >> r;
        req.push_back(make_pair(l, r));
    }

    sort(req.begin(), req.end());
    //for(auto i : req) cout  << i.first << " " << i.second << endl;

    int bridge = M;
    while (!req.empty())
    {
        auto next_req = req.front();
        int r = next_req.second;
        req.pop_front();
        if(req.empty()) break;
        next_req = req.front();
        while(r > next_req.first){
            //cout << r << " " << next_req.first << endl;
            bridge--;
            r = min(r, next_req.second);
            req.pop_front();
            if(req.empty()) break;
            next_req = req.front();        
        }
    }
    cout << bridge << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(void) {
	string board;
	cin >> board;
	int cnt = 0;
	for (int i = 0; i < board.size() - 1; i++) {
		if (board[i] != board[i + 1]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
import itertools
import math

#math.sqrt(x)

N = int(raw_input())
xy = []
p = []
ans = float(0)
for i in range(0,N):
  tmp = list(map(int,raw_input().split()))
  xy.append(tmp)
  p.append(i)


x = 0

for v in itertools.permutations(p, N):
  #print tmp
  for j in range(0,N-1):
    #print math.sqrt((float((xy[v[j]][0]-xy[v[j+1]][0])**2) + float((xy[v[j]][1]-xy[v[j+1]][1]))**2))
    x = (xy[v[j]][0]-xy[v[j+1]][0])**2 + (xy[v[j]][1]-xy[v[j+1]][1])**2
    x = math.sqrt(int(x))
    #tmp = math.sqrt((xy[v[j]][0]-xy[v[j+1]][0])**2 - (xy[v[j+1]][j+1]-xy[v[j+1]][j])**2)
    ans += x

print ans/math.factorial(N)

Measured memory_bytes: 2692
#include <iostream>

int main() {
  int x, a, b;
  std::cin >> x >> a >> b;

  int s = abs(x - a);
  int t = abs(x - b);
  if ( s <= t ) std::cout << "A" << std::endl;
  else std::cout << "B" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;

        vector<vector<int>> dp(N+1, vector<int>(N));
        for (int i = 0; i < N; i++) {
            if (abs(v[i] - v[i+1]) < 2) {
                dp[2][i] = 1;
            }
        }
        for (int i = 4; i <= N; i += 2) {
            for (int j = 0; j + i <= N; j++) {
                if (dp[i-2][j+1] && abs(v[j] - v[j + i - 1]) < 2) {
                    dp[i][j] = 1;
                } else {
                    for (int k = 2; j + k < j + i; k += 2) {
                        if (dp[k][j] && dp[i - k][j + k]) {
                            dp[i][j] = 1;
                        }
                    }
                }
            }
        }

        vector<int> sum(N+1);
        for (int i = 0; i < N; i++) {
            if (i) sum[i] = max(sum[i], sum[i-1]);
            for (int j = 2; j <= N; j += 2) {
                if (dp[j][i]) {
                    sum[i+j] = max(sum[i+j], sum[i] + j);
                }
            }
        }

        cout << max(sum[N-1], sum[N]) << endl;
    }

    return 0;
}

Measured memory_bytes: 3212
S=list(str(input()))
if S[0]!='A':
  print('WA')
  exit()
l=len(S)
flag=0
for i in range(1,l):
  if i in range(2,l-1):
    if S[i]=='C' and flag == 0:
      flag = 1
    elif S[i]=='C' and flag == 1:
      print('WA')
      exit()
    elif S[i].isupper():
      print('WA')
      exit()
  elif S[i].isupper():
    print('WA')
    exit()
if flag == 1:
  print('AC')
else:
  print('WA')


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
using namespace std;

int main() {
  int N;
  int ans = 1;
  char S[100005] = "A";
  cin >> N >> S;
  for (int i = 0 ; i < N - 1 ; ++i) {
    if (S[i] != S[i+1]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
/*a以下の3のつく非負整数の総数を求める*/

#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define dump1d_arr(array,i) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array,i,j) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define loINF (long)10000000000
#define shINF (short)10000


using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;

int main (void){
	long N;
	short A,B;
	cin >> N >> A >> B;
	
	long num;

	LL sumval = 0;

	FOR(i,1,N+1){
		short sum = 0;
		long num = i;
		 while(num){
    		sum += num % 10;
    		num /= 10;
  		}
  		#ifdef DEBUG
  			dump(sum);
  		#endif

  		if ((A <= sum) && (sum <= B)) sumval += i;
	}

	cout << sumval << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	long long tc, a, b, m = 0, k = 0;
	cin >> tc;
	while (tc--)
	{
		cin >> a >> b;
		if (a == b)
			k++;
		else
		{
			if (k == 3)
			{
				m = 1;
			}
			k = 0;
		}
	}
	if (m || k>2)
		cout << "Yes";
	else
		cout << "No";
}


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

int main() {
    long long A,B,C;
    cin >> A >> B >> C;

    int cnt = 0;
    for( ; cnt<100; ++cnt) {
        if(A % 2 || B % 2 || C % 2) break;
        long long a = (B + C) / 2LL;
        long long b = (C + A) / 2LL;
        long long c = (A + B) / 2LL;
        A = a; B = b; C = c;
    }
    if(cnt < 100) cout << cnt << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <stack>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>

#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, nuint_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set; 
#define int long long
#define MOD 1000000007
#define what_is(x) cerr << #x << " is " << x << endl;
#define loop(i,a,n) for(int i=a;i<n;i++)

#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, szof(x))
#define sortall(x) sort(aint(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int, int> pt;
std::vector<int> arr[110000];
int dp[110000][2];
void dfs(int child,int par)
{
	dp[child][1]=1;
	dp[child][0]=1;
	int res=1,res1=1;
	for(auto u:arr[child])
	{
		if(u!=par)
		{
			dfs(u,child);
			res=res*(dp[u][1]+dp[u][0])%MOD;
			res%=MOD;
			res1=res1*(dp[u][0])%MOD;
			res1%=MOD;	
		}
	}
	dp[child][0]=res;
	dp[child][1]=res1;

	
		
}
signed main() {
	
	//fastio();
	//#define LOCAL_DEFINE
	#ifdef LOCAL_DEFINE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	//https://codeforces.com/contest/1084/problem/D
	// https://codeforces.com/contest/1155/problem/E
	//https://www.spoj.com/problems/MON2012/
	//https://codeforces.com/blog/entry/52726	
	int n;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		arr[x].pb(y);
		arr[y].pb(x);

	}
	dfs(1,-1);
	cout<<(dp[1][0]+dp[1][1])%MOD;
	return  0;


}


Measured memory_bytes: 14464
#include<iostream>
using namespace std;
int main(){
    int D; cin >> D;
    switch(D){
        case 25:
            cout << "Christmas" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
    }
}

Measured memory_bytes: 256
from collections import defaultdict
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
D = defaultdict(int)
for a in A:
  D[a] += 1
for i in range(M):
  B, C = map(int, input().split())
  D[C] += B
left = N
ans = 0
for k in sorted(D.keys(), reverse=True):
  plus = min(D[k], left)
  ans += k * plus
  left -= plus
  if left == 0:
    break
print(ans)

Measured memory_bytes: 32448
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, A[100005];

int main(){
	getint(N);
	for(register int i = 1; i <= N; i++) getint(A[i]);
	for(register int i = 2; i <= N; i++) if(A[i] < A[1]) swap(A[i], A[1]);
	for(register int i = 1; i < N; i++) if(A[i] > A[N]) swap(A[i], A[N]);
	int ans = A[N] - A[1];
	for(register int i = 2; i < N; i++) ans += abs(A[i]);
	printf("%d\n", ans);
	for(register int i = 2; i < N; i++)
		if(A[i] > 0) printf("%d %d\n", A[1], A[i]), A[1] -= A[i];
		else printf("%d %d\n", A[N], A[i]), A[N] -= A[i];
	return printf("%d %d\n", A[N], A[1]), 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    //vector<int> s(n);
    //for (int i = 0; i < n; i++)cin >> s[i];

    if(n%2 == 0){
        cout << n/2 << endl;
    }else{
        cout << (n+1)/2 << endl;
    }

    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD

struct UnionFind{
    vector<int> nxt;
    void init(int x){
        nxt.clear();
        nxt.resize(x);
        for (int i = 0; i < x;i++){
            nxt[i] = i;
        }
    }
    int find(int x){
        if(nxt[x]==x)
            return x;
        return nxt[x] =find(nxt[x]);
    }
    inline void unite(int x,int y){
        nxt[find(y)] = find(x);
    }
};


ll N,N2;
char S[1010][1010];

UnionFind uf;
ll vn[1010],pn[1010];
vector<ll> vv[1010];
ll i, j, k,ans;

ll mk[1010];
ll dk(ll a){
    queue<pll> q;
    ll i,aa=0;
    q.push({a,1});

    vector<ll> mk(N, 0);
    //printf("b");
    mk[a] = 1;
    while(q.size()){
        pll qa = q.front();
        q.pop();
        if(aa<qa.second)
            aa = qa.second;
        //printf("%lld", qa.first);
        fornum(i,0,vv[qa.first].size()){
            
            ll c = vv[qa.first][i];
            if(mk[c])
                continue;
            //printf("%lldc",c);
            q.push({c, qa.second + 1});
            mk[c] = 1;
        }
    }
    return aa;
}

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%s", S[i]);
        fornum(j,0,N){
            if(S[i][j]=='1')
                vv[i].push_back(j);
        }
    }
    N2 = N*2;
    uf.init(N2);
    fornum(i,0,N){
        fornum(j,i+1,N){
            if(S[i][j]=='0')
                continue;
            
            ll a = uf.find(j);
            ll b = uf.find(i);
            if(a==b){
                printf("-1");
               
                return 0;
            }
            else{
                uf.unite(a, (b + N) % N2);
                uf.unite((a + N) % N2, b);
            }
        }
    }
    //printf("a");
    fornum(i,0,N){
        //printf("%lld,%lld\n", i, j);
        ll a = dk(i);
        //printf("_%lld_", a);
        mk[uf.find(i)%N] = max(a, mk[uf.find(i)%N]);
    }
    //printf("a");
    fornum(i,0,N){
        if(i!=uf.find(i))
            continue;
        ans += mk[uf.find(i)%N];
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 896