akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N;
int M=3;
int ans;
vector<int>A;

void dfs(vector<int> &B) {
    // 数列の長さが N に達したら打ち切り
    if (B.size() == N) {
        // 処理
        bool condition = false;
        for (int i=0; i<N; i++){
            if(B[i]%2 == 0)condition = true;
        }
        if (condition) ans++;
        return;
    }

    for (int v = 0; v < M; ++v) {
        int bi;
        if (v == 0)bi = A[B.size()]+1;
        else if (v == 1)bi = A[B.size()];
        else  bi = A[B.size()]-1;
        
        B.push_back(bi);
        dfs(B);
        B.pop_back();
    }
}


int main() {
    cin >> N;
    ans = 0;
    A.resize(N);
    for (int i=0; i<N; i++)cin >> A[i];
    
    vector<int>B;
    dfs(B);
    
    cout << ans << endl;
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000001)
#define MOD (1000000007)
#define PI (acos(-1))

int main(){
  int n,k;
  cin >> n >> k;
  cout << n-k+1 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
char a[1005], b[1005];
int main()
{
	scanf("%s %s", a, b);
	int n = strlen(a);
	int m = strlen(b);
	if(n < m)printf("LESS\n");
	else if(n > m)printf("GREATER\n");
	else{
		for(int i = 0; i < n; i++){
			if(a[i] > b[i]){printf("GREATER\n");return 0;}
			else if(a[i] < b[i]){printf("LESS\n"); return 0;}
		}
		printf("EQUAL\n");
	}
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"strings"
)

func isHash(s string) int {
	if s == "#" {
		return 1
	}
	return 0
}

// 前後左右斜めが＃かどうか判定する関数
func checkAround(p [][]string, i int, j int, h int, w int) int {
	count := 0
	for k := i - 1; k <= i+1; k++ {
		for l := j - 1; l <= j+1; l++ {
			if k >= 0 && k < h && l >= 0 && l < w {
				if !(k == i && l == j) {
					count += isHash(p[k][l])
				}
			}
		}
	}
	return count
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	var p [][]string
	for i := 0; i < h; i++ {
		var l string
		fmt.Scan(&l)
		p = append(p, strings.Split(l, ""))
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if isHash(p[i][j]) == 1 {
				fmt.Print("#")
			} else {
				fmt.Print(checkAround(p, i, j, h, w))
			}
		}
		fmt.Println()
	}
}


Measured memory_bytes: 640
n,k=map(int,input().split())
s=map(int,list(input()))
ans=0
if k==2 or k==5:
    for i,p in enumerate(s):
        if p%k==0:
            ans+=i+1
else:
    inv10=pow(10,k-2,k)
    inv=10
    total=0
    S=[0]*k
    S[0]=1
    for i,p in enumerate(s):
        inv*=inv10
        inv%=k
        total+=p*inv
        total%=k
        ans+=S[total]
        S[total]+=1
print(ans)

Measured memory_bytes: 61936
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.8.2)

import math
import statistics
import numpy as np
import queue
import itertools
import functools 

ans = 0
s, t = input(), input()
for p in range(len(s)):
	if s[p] != t[p]:
		ans += 1
print(ans)


Measured memory_bytes: 27472
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, K,W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  if (N==1) cout <<"Hello World" << endl;
  else {
    cin >> A >> B;
    cout <<A+B<<endl;
  }
}


Measured memory_bytes: 256
import sys


class UnionFind:
    def __init__(self, node_size):
        self._node = node_size
        self.par = [i for i in range(self._node)]
        self.rank = [0] * self._node

    def find(self, ver):
        if self.par[ver] == ver:
            return ver
        else:
            self.par[ver] = self.find(self.par[ver])
            return self.par[ver]

    def unite(self, ver1, ver2):
        ver1, ver2 = self.find(ver1), self.find(ver2)
        if ver1 == ver2:
            return
        if self.rank[ver1] < self.rank[ver2]:
            ver1, ver2 = ver2, ver1
        self.par[ver2] = ver1
        if self.rank[ver1] == self.rank[ver2]:
            self.rank[ver1] += 1

    def same(self, ver1, ver2):
        return self.find(ver1) == self.find(ver2)


class Kruskal:

    class Edge:
        def __init__(self, u, v, cost):
            self.u, self.v, self.cost = u, v, cost

        def __lt__(self, another):
            return self.cost < another.cost

    def __init__(self, node_size):
        self._node = node_size
        self._edge_list = []

    def add_edge(self, u, v, cost):
        self._edge_list.append(self.Edge(u, v, cost))

    def solve(self):
        uf = UnionFind(self._node)
        res = 0
        edge_count = 0
        self._edge_list.sort()
        for e in self._edge_list:
            if not uf.same(e.u, e.v):
                uf.unite(e.u, e.v)
                res += e.cost
                edge_count += 1
                if edge_count == self._node-1:
                    break
        return res

if __name__ == '__main__':
    n, m = map(int, sys.stdin.readline().split())
    kr = Kruskal(n)
    for _ in range(m):
        s, t, w = map(int, sys.stdin.readline().split())
        kr.add_edge(s, t, w)
    print(kr.solve())



Measured memory_bytes: 33164
#include<stdio.h>
#include<stdlib.h>
int main()
{
  int n,i,a[10],b[10],aa,bb,c,x;
  scanf("%d",&n);
  for(;n--;)
    {
      a[0]=b[0]=aa=bb=0;
      for(i=x=0;i<10;i++)
	{
	  scanf("%d",&c);
	  if(x!=0)continue;
	  if(a[aa]>=c && b[bb]>=c)
	    x=-1;
	  else
	    {
	      if(a[aa]<c && (a[aa]>b[bb] || b[bb]>=c))
		aa++,a[aa]=c;
	      else if(b[bb]<c)
		bb++,b[bb]=c;
	      //	      printf("i=%d a[%d]=%d b[%d]=%d\n",i,aa,a[aa],bb,b[bb]);
	    }
	}
      puts(x?"NO":"YES");
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int H[n];
  int ans=0,max=0;
  for(int i=0;i<n;i++){
    cin >> H[i];
  }
    for(int j=0;j<n-1;j++){
      if(H[j]>=H[j+1]){
        ans++;
        if(max<ans){
          max = ans;
        }
      }else{
        ans=0;
      }
    }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int a[3];
int main(){
	int ans=0;
	for(int i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+3);
	for(int i=2;i>0;i--){
		ans=ans+a[i]-a[i-1];
	}
	printf("%d\n",ans);
	return 0;	
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        sc.close();
        PriorityQueue q=new PriorityQueue();
        long maxnum=(long)Math.sqrt(n);
        for(long i=1;i<=maxnum;i++){
            if(n%i==0){
                q.add(i-1+n/i-1);
            }
        }
        System.out.println((q.peek()==null ? 0 : q.remove()));
    }
}

Measured memory_bytes: 22612
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
            int isdec=1,isinc=1;
            int j;
            for(j=i+1;j<n;j++)
            {
                if(v[j]==v[j-1])
                    continue;
                if(v[j]>v[j-1])
                {
                    isdec=0;
                }
                else
                    isinc=0;
                if(isinc==0 && isdec==0)
                    break;
            }
            i=j-1;
            cnt++;
    }
    cout<<cnt<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15980
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var K, A, B int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d", &K, &A, &B)

	ans := 1
	// inc
	for ans < A {
		ans++
		K--
	}

	// select
	for K > 0 {
		if B-A > 2 && K >= 2 {
			ans = ans + (B - A)
			K = K - 2
		} else {
			ans++
			K--
		}
	}
	// inc if possible
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

#define MAX_V 222

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v)
{
    used[v] = true;
    for (int i = 0; i < (int)G[v].size(); i++) {
  int u = G[v][i], w = match[u];
  if (w < 0 || (!used[w] && dfs(w))) {
      match[v] = u;
      match[u] = v;
      return true;
  }
    }
    return false;
}

int bipartite_matching()
{
    int res = 0;
    memset(match, -1, sizeof(match));
    for (int v = 0; v < V; v++) {
  if (match[v] < 0) {
      memset(used, false, sizeof(used));
      if (dfs(v)) {
                res++;
            }
  }
    }
    return res;
}

int main() {

  int N, M;
  while(cin >> N >> M && (N|M)) {

    vector<tuple<int, int, int>> vs;
    rep(i, N) {
      int x, y, v; cin >> x >> y >> v;
      vs.push_back(make_tuple(x, y, v));
    }

    vector<tuple<int, int>> ts;
    rep(i, M) {
      int x, y; cin >> x >> y;
//      cout << "x, y " << x << ", " << y << endl;
      ts.push_back(make_tuple(x, y));
    }

    V = N + M;

    vector<tuple<double, int, int>> es;
    rep(i, N) {
      int x, y, v; tie(x, y, v) = vs[i];
      rep(j, M) {
        int tx, ty; tie(tx, ty) = ts[j];
        es.emplace_back(sqrt((x-tx)*(x-tx)+(y-ty)*(y-ty)) / v, i, N + j);
      }
    }

    double L = 0.0, R = 1e10;

    rep(_, 150) {
      double T = (L + R) / 2.0;
      rep(i, MAX_V) G[i].clear();
      rep(i, es.size()) {
        double c; int x, y; tie(c, x, y) = es[i];
        if(T >= c) {
          add_edge(x, y);
        }
      }
      if(bipartite_matching() == M) {
        R = T;
      } else {
        L = T;
      }
    }

    printf("%.20lf\n", R);
  }

  return 0;
}

Measured memory_bytes: 3480
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Linq;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class Test_153_b
{

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            var ar = ReadIntArray();
            int H = ar[0];
            int N = ar[1];
            var data = ReadIntArray();
            long sum = 0;
            for(int i=0;i<N;i++)
            {
                sum += data[i];
            }
            if (sum >= H)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }


        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }
#if TEST
#else
    }
}
#endif


Measured memory_bytes: 17632
n,k,s = map(int,input().split())

if n>k:
    ans = [s for i in range(k)]
    nokori = n-k
    for i in range(nokori):
        if s==10**9:
            ans.append(1)
        else:
            ans.append(10**9)
else:
    ans = [s for i in range(k)]
print(*ans)


Measured memory_bytes: 6680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3],x=0,y=0;
  cin >> a[0] >> a[1] >> a[2];
  for(int i=0;i<3;i++){
    if(a[i]==5){
      x++;
    }else if(a[i]==7){
      y++;
    }
  }
  if(x==2&&y==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:05:49 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

import string

A, B = na()
S = ns()

flag = True
for i in range(len(S)):
    if i == A:
        if S[i] != '-':
            flag = False
    else:
        if S[i] not in string.digits:
            flag = False

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

Measured memory_bytes: 3828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);
            int C = int.Parse(s[2]);
            
            s = Console.ReadLine().Split(' ');
            int[] B = new int[M];
            for (int i = 0; i < M; i++)
            {
                B[i] = int.Parse(s[i]);
            }

            int[,] A = new int[N, M];
            for (int i = 0; i < N; i++)
            {

                s = Console.ReadLine().Split(' ');
                for (int j = 0; j < M; j++)
                {
                    A[i, j] = int.Parse(s[j]);
                }
            }

            int ans = 0;

            for (int i = 0; i < N; i++)
            {
                long hantei = 0;

                for (int j = 0; j < M; j++)
                {
                    hantei += A[i, j] * B[j];
                }
                hantei += C;
                if (hantei > 0)
                {
                    ans++;
                }
            }

            Console.WriteLine(ans);


        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

ll dp[1024][1024];
ll comb[1024][1024];
ll dv[1024];

ll modpow(ll a,ll b){
	ll ret=1;
	while(b){
		if(b&1)	ret=ret*a%mod;
		b/=2;
		a=a*a%mod;
	}
	return ret;
}

int main(){
	ll n,a,b,c,d;	cin>>n>>a>>b>>c>>d;

	comb[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=i;j++){
			comb[i+1][j]+=comb[i][j];
			comb[i+1][j]%=mod;
			comb[i+1][j+1]+=comb[i][j];
			comb[i+1][j+1]%=mod;
		}
	}
	dv[1]=1;
	for(int i=2;i<=n;i++)	dv[i]=modpow(i,mod-2);
	
	dp[a-1][n]=1;
	for(int i=a;i<=b;i++){
		for(int j=0;j<=n;j++){
			if(dp[i-1][j]==0)	continue;
			dp[i][j]+=dp[i-1][j];	dp[i][j]%=mod;
			if(j-i*c<0)	continue;
			ll multi=1;
			for(int k=1;k<c;k++){
				multi=(multi*comb[j-i*(k-1)][i])%mod;
				multi=(multi*dv[k])%mod;
			}
			for(int k=c;k<=d;k++){
				if(j-k*i<0)	break;
				multi=(multi*comb[j-i*(k-1)][i])%mod;
				multi=(multi*dv[k])%mod;
				dp[i][j-k*i]+=(multi*dp[i-1][j])%mod;
				dp[i][j-k*i]%=mod;
			}
		}
	}
	cout<<dp[b][0]<<endl;
	return 0;
}


Measured memory_bytes: 14592
//
// Created by moono on 2018/10/27.
//

#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <map>
using namespace std;



int main() {
    string W;
    cin >> W;

    //
    map<char, int> c_frq_map;
    for (int i = 0; i < W.size(); ++i) {
        char c = W[i];
        if(c_frq_map.find(c) == c_frq_map.end())
            c_frq_map[c] = 1;
        else
            c_frq_map[c] = c_frq_map[c] + 1;
    }

    //
    bool is_all_even = true;
    for(auto kv: c_frq_map){
        if(kv.second % 2 != 0) is_all_even = false;
    }

    //
    if(is_all_even){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  string S;
  char A;
  int B=0;
  int C=1;
  cin>>S;
  for(int i=0;i<S.size();i++){
    A=S.at(i);
    for(int j=0;j<S.size();j++){
    if(A==S.at(j)){
      B++;
    }
}
    if(B%2==1){
    C=99;
    cout<<"No"<<endl;
    }
    if(C==99)
        break;
  }
    if(C==1){
    	cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e4 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a += b;
	c += d;
	if (a > c) puts("Left");
	if (a < c) puts("Right");
	if (a == c) puts("Balanced");
	return 0;
}

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

int main() {
    int x , y;
    cin >> x >> y;
    if(x == 1 && y == 1){
        cout << 1000000 << endl;
    }
    else{
        int yen = 0;
        if(x == 1){
            yen += 300000;
        }
        if(x == 2){
            yen += 200000;
        }
        if(x == 3){
            yen += 100000;
        }
        if(y == 1){
            yen += 300000;
        }
        if(y == 2){
            yen += 200000;
        }
        if(y == 3){
            yen += 100000;
        }
        cout << yen << endl;
    }
}


Measured memory_bytes: 256
from itertools import permutations
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    k,*rc = map(int, read().split())

    tmp = []
    ng_list_add = []
    ng_list_sub = []
    for pattern in permutations(range(8)):
        flag = True
        for r, c in enumerate(pattern):
            if r + c in ng_list_add or r - c in ng_list_sub:
                flag = False
                break
            ng_list_add.append(r+c)
            ng_list_sub.append(r-c)
        if flag:
            tmp.append(pattern)
        ng_list_add = []
        ng_list_sub = []
    
    RC = []
    for r, c in zip(*[iter(rc)]*2):
        RC.append((r, c))

    ans_place = None
    for p in tmp:
        flag = True
        for r, c in RC:
            if p[r] != c:
                flag = False
                break
        if flag:
            ans_place = p
            break

    ans = []
    for i in ans_place:
        line = "." * i + "Q" + "." * (7-i)
        ans.append(line)

    print("\n".join(ans))


if __name__ == "__main__":
    main()


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

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

    int nummax=0;
    int ans=0;

    for (int i = n; i > 0; i--){
        int tmp = i;
        int num=0;
        while(tmp%2==0){
            tmp/=2;
            num++;
        }

        if(nummax<num){
            nummax = num;
            ans = i;
        }
    }


    if(n==1){
        cout<<"1"<<endl;
    }else{
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
import math
from itertools import accumulate


def is_prime(n):
    if n == 1:
        return 0

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return 0

    return 1


Q = int(input())
L = [0]*Q
R = [0]*Q

for i in range(Q):
    L[i], R[i] = list(map(int, input().split()))

min_L = min(L)
max_R = max(R)

check = []
for i in range(min_L, max_R+1):
    if (i % 2 == 1):
        flg = (is_prime(i) and is_prime((i+1)/2))
    else:
        flg = 0
    check.append(flg)

# 累積和
check = [0] + check
check = list(accumulate(check))

for i in range(Q):
    print(check[R[i] - min_L + 1] - check[L[i] - min_L])


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

const int MAXCOM = 510000;
const int MOD = 1000000007;

// 階乗, 階乗の逆元, 逆元
int64_t fac[MAXCOM], finv[MAXCOM], inv[MAXCOM];
// 前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAXCOM; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
int64_t COM(int n, int k) {
    if (n < k)
        return 0;
    else if (n < 0 || k < 0)
        return 0;
    else
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

    COMinit();

    int N, K;
    cin >> N >> K;
    for (int i = 1; i <= K; i++) {
        cout << (COM(N - K + 1, i) % MOD) *
                (COM(K - 1, i - 1) % MOD) % MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 12160
N = gets.to_i
S = gets.chomp

ans = 0
(0..999).each do |i|
    t = format('%03d', i)
    l = S.index(t[0])
    r = S.rindex(t[2])
    next if not (l && r)
    (ans += 1) if (S[l+1..[r-1, 0].max]).index t[1]
end
p ans

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

inf = 10 ** 7


def main():
    from collections import deque
    import sys
    input = sys.stdin.readline

    n, x, y = map(int, input().split())
    x -= 1
    y -= 1
    ans = [0 for _ in range(n)]

    for i in range(n):
        dist = [inf for _ in range(n)]
        dist[i] = 0

        d = deque()
        d.append(i)

        while d:
            v = d.popleft()
            dj = dist[v]

            if v - 1 >= 0 and dist[v - 1] == inf:
                dist[v - 1] = dj + 1
                d.append(v - 1)
            if v + 1 < n and dist[v + 1] == inf:
                dist[v + 1] = dj + 1
                d.append(v + 1)
            if v == x and dist[y] == inf:
                dist[y] = dj + 1
                d.append(y)
            if v == y and dist[x] == inf:
                dist[x] = dj + 1
                d.append(x)

        for j in range(n):
            if dist[j] != inf:
                ans[dist[j]] += 1

    for k in range(n):
        ans[k] //= 2

    for ii in range(1, n):
        print(ans[ii])


if __name__ == '__main__':
    main()


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define INF 1e9

int main(int, char**)
{
  int x;
  cin >> x;
  
  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3588
#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;
typedef pair<int, int> P;

const ll INF = 1LL << 60;


int main() {
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    map<string, ll> mp;
    rep(i, N) {
        mp[S[i]]++;
    }
    cout << mp.size() << endl;
}


Measured memory_bytes: 25228
//package cp;
import java.util.*;
import java.io.*;
import java.math.*;;
public class Main {
	BigInteger bi1=new BigInteger("2");//initialize as string
//	1.BigInteger bi=new BigInteger(Readers.next());- take input as biginteger
	StringBuilder sb=new StringBuilder();
//	2.StringBuilder temp=new StringBuilder(str[i-1]);
//	3.String rev=temp.reverse().toString(); convert sb to string
//	4.if(str[i].compareTo(rev)>=0)minn=0;-compare two Strings
//  5.(Initialize as string) - (a.add(b)) - (array initialized with null and not 0)
	Integer[] ARRE=new Integer[5];//Integer sort-TLE-Initialize object elements i.e a[0].
	static final int mod1 = 1000000007;//or 1e9+7
//	6.System.exit(0); to exit from code....esp in recur 
	long gcd(long a,long b) {if(b==0)return a;else return gcd(b,a%b);}
	long ceil(double d) {return (long)Math.ceil(1.0*d);}
	int ch_int(char c) {return Integer.parseInt(String.valueOf(c));}//change char to Integer
	String ch_str(char c) {return String.valueOf(c);}
	String int_str(int num) {return Integer.toString(num);}
	void divisor(long n,int start) {
		int cnt=0;for(int i=start;i<=Math.sqrt(n);i++) {
		if(n%i==0) {if(i==n/i)cnt++;else cnt+=2;}}}
	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		Readers.init(System.in);
		//Cf_fiv obj=new Cf_fiv();
		int n=Readers.nextInt();
		int[] a=new int[n];
		for (int i = 0; i < n; i++) {
			a[i]=Readers.nextInt();
		}
		Arrays.sort(a);
		long cnt=0;
		for (int i = 0; i < n; i++) {
			for (int j = i+1; j <n; j++) {
				for (int k = j+1; k < n; k++) {
					if(a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i]) {
//						System.out.println(i+" "+j+" "+k);
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);
		out.flush();
	}

}
class Readers {
	 
    static BufferedReader reader;
 
    static StringTokenizer tokenizer;
 
 
 
    /** call this method to initialize reader for InputStream */
 
    static void init(InputStream input) {
 
        reader = new BufferedReader(
 
                     new InputStreamReader(input) );
 
        tokenizer = new StringTokenizer("");
 
    }
 
 
 
    /** get next word */
 
    static String next() throws IOException {
 
        while ( ! tokenizer.hasMoreTokens() ) {
 
            //TODO add check for eof if necessary
 
            tokenizer = new StringTokenizer(
 
                   reader.readLine() );
 
        }
 
        return tokenizer.nextToken();
 
    }
 
 
 
    static int nextInt() throws IOException {
 
        return Integer.parseInt( next() );
 
    }
 
	
 
    static double nextDouble() throws IOException {
 
        return Double.parseDouble( next() );
 
    }
    
    
    static long nextLong() throws IOException{
    	
		return Long.parseLong(next());
	}
 
}


Measured memory_bytes: 33920
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();

    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    ll ans = 0;

    for(int i=b+1; i<=w; i++){
        int H = h - a - 1;
        int W = i - 1;
        ll tmp = COM(H+W, H);

        H = a - 1;
        W = w - i;
        tmp *= COM(H+W, H);

        ans += tmp % MOD;
        ans %= MOD;
    }

    cout << ans%MOD << endl;
}

Measured memory_bytes: 12160
while True:
    中間, 期末, 再試験 = map(int, input().split())
    if 中間 < 0 and 期末 < 0 and 再試験 < 0:
        break
    合計点 = 中間 + 期末

    if 中間 < 0 or 期末 < 0:
        print("F")    
    elif 合計点 >= 80:
        print("A")
    elif 65 <= 合計点 and 合計点 < 80:
        print("B")
    elif 50 <= 合計点 and 合計点 < 65:
        print("C")
    elif 30 <= 合計点 and 合計点 < 50:
        if 再試験 >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5684
//30
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int dp[400][400];
  fill(dp[0],dp[n],-1<<30);
  while(m--){
    int a,b,c;
    cin>>a>>b>>c;
    dp[a][b]=c;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<n;k++){
	dp[j][k]=max(dp[j][k],dp[j][i]+dp[i][k]);
      }
    }
  }
  cout<<dp[0][n-1]<<endl;
  return 0;
}

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

using namespace std;

int main()
{
    int count = 0;
    int countMax = 0;

    string str;
    cin >> str;

    for (int i = 0; i < 3; i++)
    {
        if('R' == str[i])
        {
            count++;
            if(countMax < count)
            {
                countMax = count;
            }
        }
        else
        {
            count = 0;
        }
    }

    cout << countMax << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
string s;
bool c,ans;
int main()
{
    c = false; ans = false;
    cin >> s;
    for (int i = 0; i < s.size(); ++ i)
    {
        if (s[i] == 'C') c = true;
        if (s[i] == 'F' && c) ans = true;
    }
    if (ans) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力を取得
N = int(input())

# 求解処理
ans = 0
for n in range(1, N + 1, 2):
    div_count = 0
    for i in range(1, n + 1):
        div_count += (n % i == 0)

    ans += (div_count == 8)

# 結果出力
print(ans)

Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	/* code */
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

	int a,b;
	cin>>a>>b;
	if(a<=100&&b<=100)
	{
		cout<<a*b;

	}
	
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		
		int sum = 0;
		if(k <= a) {
			System.out.println(k);
		}else {
			for(int i = 0; i < a; i++) {
				sum++;
			}
			
			k = k - a - b;
			if(k <= 0) {
				System.out.println(sum);
			}else {
				System.out.println(sum - k);
			}
			
		}
		
		
	}

}


Measured memory_bytes: 35744
#include<stdio.h>

int main () {
  int n[6], i;
  double x, y;

  while(scanf("%d", &n[0]) != EOF) {
    for (i = 1; i < 6; i += 1) {                                                                                                                                                  
      scanf("%d", &n[i]);
    };
    x = (double)(n[4] * n[2] - n[1] * n[5]) / (double)(n[0] * n[4] - n[1] * n[3]);
    y = (double)((-1) * n[3] *n[2] + n[0] * n[5]) / (double)(n[0] * n[4] - n[1] * n[3]);

    if(x > -0.001 && x < 0.001) {
      x = 0;
    };
    if(y > -0.001 && y < 0.001) {
      y = 0;
    };


    printf("%1.3f %1.3f\n", x, y);
  }
    return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
#define pi 					3.1415926535897932
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int B[N];
int n ,k;

inline int mul(int a, int b) { return (a * b) % M; };
inline int add(int a, int b)
{
      int res = a + b;
      if ( res < 0 ) res += M;
      if ( res >= M) res -= M;
      return res;
}

void solve()
{
	cin >> n >> k;

	int ans = 0;

	loop(i,1,n+5)
	{
		A[i] = (i-1) + (A[i-1]);
	}

	loop(i,k,n+2)
	{
		// int k = add(A[n+1],-A[n+1-i]);
		// int r = A[i];
		// ans = add(ans,k+1);
		// ans = add(ans,-r);

		ans = (ans%M + (A[n+1]-A[n+1-i]-A[i])%M+1)%M;

		// cout << ans << endl;
	}

	cout << ans;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 5164
#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>;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans=0;
  if ((b-a)%2 == 0) ans = max(a,b)-(a+b)/2;
  else ans = min(n-max(a,b),min(a,b)-1)+1+(b-a-1)/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=[int(c) for c in input()][::-1]

dp=[[0]*2 for _ in range(len(N)+1)]
dp[0][1]=1

for i in range(len(N)):
    dp[i+1][1]=min(dp[i][0]+N[i]+1,dp[i][1]+10-N[i]-1)
    dp[i+1][0]=min(dp[i][0]+N[i],dp[i][1]+10-N[i])

print(dp[len(N)][0])

Measured memory_bytes: 227024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll X;
    cin >> X;
    ll max = 1;
    FOR(i, 1, X+1) {
        bool can = false;
        FOR(b, 1, i+1) {
            FOR(p, 2, i+1) {
                if (pow(b, p) > X) break;
                if (pow(b, p) == i) can = true;
            }
        }
        if (can) max = i;
    }
    cout << max << "\n";
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
q = int(input())
Q = list(map(int, input().split()))
 
bits = 1
for a in A:
    bits |= bits << a
 
for q in Q:
    if bits >> q & 1:
        print("yes")
    else:
        print("no")



Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <numeric>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = max(a,max(b,c)) - min(a,min(b,c));

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
using ll = long long;

using namespace std;
int main()
{/*四日目*/
	int n;cin >> n;
	ll maxx = 1e18;
	vector < ll > a(n);
	ll sum = 1;
	bool nnot = false;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
		if (a[i] == 0) {
			sum=0;
		}
	}if (sum) {
		for (int i = 0;i < n;i++) {
			if (sum * a[i] > maxx or maxx / sum < a[i]) {
				cout << "-1";
				nnot = true;
				break;
			}sum *= a[i];
		}
	}
	if (!nnot)
		cout << sum;
		
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
const int maxN = 2010;
typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;
ll n, k;
ll kk, ans = 0;
int a[maxN];

int t1[maxN], t2[maxN];
void add(int pos, int val, int t[])
{
    while (pos < maxN)
    {
        t[pos] += val;
        pos += pos & (-pos);
    }
}
ll query(int pos, int t[])
{
    ll res = 0;
    while (pos > 0)
    {
        res += t[pos];
        pos -= pos & (-pos);
    }
    return res;
}
int main()
{
    scanf("%lld %lld", &n, &k);
    kk = k * (k - 1) / 2;
    kk %= mod;
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
    {
        ans += (query(2000, t1) - query(a[i], t1))%mod * k % mod;
        ans %= mod;
        add(a[i], 1, t1);
    }
    //printf("%lld\n", ans);
    for (int i = 1; i <= n; i++)
    {
        ans += query(a[i]-1, t1) * kk % mod;
        ans %= mod;
    }
    printf("%lld\n", ans%mod);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
int N,M,Q,answer,a[51],b[51],c[51],d[51],array[10]={};
void DFS(int x)
{
  if(x>=N)
  {
    int point=0;
    rep(i,Q)if(array[b[i]]-array[a[i]]==c[i])point+=d[i];
    answer=(answer<point)?point:answer;return;
  }else{int j=array[x-1];while(j<=M)array[x]=j,DFS(x+1),j++;}
}
int main(void)
{
  answer=scanf("%d %d %d",&N,&M,&Q);
  rep(i,Q){answer=scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);a[i]--,b[i]--;}
  array[0]=1,answer=0,DFS(1);
  return printf("%d",answer),0;
}

Measured memory_bytes: 1692
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws Exception {

        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        int res = 0;
        int cnt = 0;
        for (int a = 0; a <= A; a++) {
            for (int b = 0; b <= B; b++) {
                for (int c = 0; c <= C; c++) {
                    res = 500 * a + 100 * b + 50 * c;
                    if (res == X) {
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }
}


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

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

    string N;
    cin >> N;

    if((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vll vector<ll>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    int n;
    cin>>n;
    vii v(n);
    ll sum=0,stem1,stem2,stem3;
    stem1=stem2=stem3=0;
    for(int i=0;i<n;++i)
    {
        cin>>v[i];
        sum+=v[i];
    }
    sum=sum/n;


    for(int i=0;i<n;++i)
    {
        stem1+=((v[i]-sum)*(v[i]-sum));
    }
    ++sum;
    for(int i=0;i<n;++i)
    {
        stem2+=((v[i]-sum)*(v[i]-sum));
    }
    sum-=2;
    for(int i=0;i<n;++i)
    {
        stem3+=((v[i]-sum)*(v[i]-sum));
    }






    cout<<min(min(stem1,stem2),stem3);




    return 0;
}


Measured memory_bytes: 256
n,m,x=map(int,input().split(" "))
c=[]
a=[]
for i in range(n):
    tmp=[int(i) for i in input().split(" ")]
    c.append(tmp[0])
    a.append([])
    for j in range(m):
        a[i].append(tmp[j+1])
ans=int(1e9)
for mask in range(1<<n):
    w=[0]*m
    cost=0
    for i in range(n):
        if (mask>>i)&1:
            for j in range(m):
                w[j]+=a[i][j]
            cost+=c[i]
    ok=True
    for j in range(m):
        if w[j]<x:
            ok=False
    if ok:
        ans=min(ans,cost)
if ans==int(1e9):
    print("-1")
else:
    print(ans)

Measured memory_bytes: 68364
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int N, M;

int main() {
	S2(N, M);
	priority_queue<int> a;
	R(i, N) {
		int pri = 0;
		S(pri);
		a.push(pri);
	}
	R(i, M) {
		int pri = a.top();
		a.pop();
		a.push(pri / 2);
	}
	ll ans = 0;
	R(i, N) {
		ans += a.top();
		a.pop();
	}
	PL(ans);
}
	

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

main(){

  ll n,k,q;
  cin>>n>>k>>q;
  vector<ll> a(q);
  rep(i,q)cin>>a[i];

  vector<ll> b(n,k-q);
  rep(i,q)b[a[i]-1]++;

  rep(i,n){
    if(b[i]>0)puts("Yes");
    else puts("No");
  }

}

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

int main(){
  int N;
  cin >> N;
  int count =0,ans=0;
  
  for(int i=105;i<N+1;i++){
    if(i%2==0)continue;
    for(int j=1;j<=i;j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8)ans++;
    count=0;
  }
  cout << ans << endl;
}


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

typedef long long ll;

ll X, N;
set<pair<ll, ll>> C;
pair<ll, ll> cand(ll n) { return {abs(X - n), n}; }
int main() {
  cin >> X >> N;
  for (ll n = 0; n <= 101; ++n) {
    C.insert(cand(n));
  }
  for (ll i = 0; i < N; ++i) {
    ll p;
    cin >> p;
    C.erase(cand(p));
  }
  cout << C.begin()->second << endl;
  return 0;
}


Measured memory_bytes: 3636