akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

const int INF = 100000000;
const int MAX_V = 100;
int graph[MAX_V][MAX_V];
int N, k;

bool visited[MAX_V];
int cost[MAX_V];

void init_graph() {
    REP(i, N) {
        REP(j, N) {
            if (i == j) graph[i][j] = 0;
            else        graph[i][j] = INF;
        }
    }
}

void make_edge(int u, int v, int c) {
    if (c < graph[u][v]) {
        graph[u][v] = graph[v][u] = c;
    }
}

// void wf() {
//     REP(k, N) {
//         REP(i, N) {
//             REP(j, N) {
//                 graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
//             }
//         }
//     }
// }

void init_dijkstra() {
    REP(i, N) visited[i] = false;
    REP(i, N) cost[i] = INF;
}

void dijkstra(int start) {
    init_dijkstra();

    cost[start] = 0;

    while (true) {
        int mi = INF;
        int nxt = -1;
        visited[start] = true;
        REP(i, N) {
            if (visited[i]) continue;
            if (i != start) {
                int d = cost[start] + graph[start][i];
                if (d < cost[i]) {
                    cost[i] = d;
                }
            }
            if (mi > cost[i]) {
                mi = cost[i];
                nxt = i;
            }
        }
        start = nxt;
        if (nxt == -1) break;
    }
}

void solve() {

    while (true) {
        scanf("%d %d", &N, &k);

        if (N == 0 and k == 0)
            break;

        init_graph();

        REP(_, k) {
            int mode;
            scanf("%d", &mode);
            if (mode == 0) {
                int a, b;
                scanf("%d %d", &a, &b);
                a--; b--;
                dijkstra(a);
                if (cost[b] < INF) {
                    printf("%d\n", cost[b]);
                } else {
                    printf("-1\n");
                }
                // wf();
                // if (graph[a][b] < INF) {
                //     printf("%d\n", graph[a][b]);
                // } else {
                //     printf("-1\n");
                // }
            } else {
                int c, d, e;
                scanf("%d %d %d", &c, &d, &e);
                c--; d--;
                make_edge(c, d, e);
            }
        }
    }
}

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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    string num; cin >> num;
    vector<int> n(4);
    rep(i,4){
        n[i] = num[i]-'0';
    }

    int ans;
    rep(i,pow(2,3)){
        int tmp = n[0];
        rep(j,3){
            if( (i >> j) & 1 ){
                tmp += n[j+1];
            }
            else{
                tmp -= n[j+1];
            }
        }
        if( tmp == 7 ){
            ans = i;
            break;
        }
    }

    cout << n[0];
    rep(i,3){
        if( (ans >> i) & 1) cout << '+';
        else cout << '-';
        cout << n[i+1];
    }
    cout << "=7" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int L;
string S[112];

int main(){
	
	cin>>N>>L;
	
	REP( i, N ) cin>>S[i];
	
	sort( S, S+N );
	
	REP( i, N ) cout<<S[i];
	
	puts("");
	
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007
// int findLowerBound(
//     vector<pair<int, int>> &arr,
//     pair<int, int> &p)
// {

//     auto low = lower_bound(arr.begin(),
//                            arr.end(), p);

//     return low - arr.begin();
// }
// int findUpperBound(
//     vector<pair<int, int>> &arr,
//     pair<int, int> &p)
// {
//     auto up = upper_bound(arr.begin(),
//                           arr.end(), p);

//     return up - arr.begin();
// }
// bool vis[200005];
// vector<int> vec[2000005];
// int child[2000005];
// int parent[2000005];
// int div1[100005];
// void dfs(int node)
// {
//     vis[node] = 1;
//     for (int i = 0; i < vec[node].size(); i++)
//     {
//         if (!vis[vec[node][i]])
//         {
//             parent[vec[node][i]] = node;
//             dfs(vec[node][i]);
//             //   child[node] += child[vec[node][i]];
//         }
//     }
// }
// void bfs(int node)
// {
//     queue<int> qu;
//     qu.push(node);
//     vis[1] = 1;
//     while (!qu.empty())
//     {
//         int top = qu.front();
//         //cout << qu.front() << "\n";
//         qu.pop();
//         vis[top] = 1;
//         for (int i = 0; i < vec[top].size(); i++)
//         {
//             if (!vis[vec[top][i]])
//             {
//                 parent[vec[top][i]] = top;
//                 qu.push(vec[top][i]);
//                 vis[vec[top][i]] = 1;
//             }
//         }
//     }
// }
// void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
// {
//     for (int i = 0; i <= n + m - 1; i++)
//     {
//         for (int j = 0; j < vec.size(); j++)
//         {
//             int u = vec[j].second.first;
//             int v = vec[j].second.second;
//             int w = vec[j].first;

//             if (dis[u] + w < dis[v])
//             {
//                 dis[v] = dis[u] + w;
//             }
//         }
//     }
// }
// int fun(int a, int b)
// {
//     if (a > b)
//         return 0;
//     if (a == b)
//         return 1;
//     else
//     {
//         return fun(a + 1, b) + fun(a, b - a);
//     }
// }
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n, greater<int>());
    int sum = arr[0];
    int i = 1;
    int count = 1;
    while (count < n)
    {
        count += 1;
        if (count >= n)
            break;
        sum += arr[i];
        count += 1;
        if (count >= n)
            break;
        sum += arr[i];
        i++;
    }
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 5196
N, M = map(int, input().split())
a = [input() for _ in range(N)]
b = [input() for _ in range(M)]

exists = []
for i in range(0, len(a)):
  exists.append([i, a[i].find(b[0])])

for x, y in exists:
  ari = []
  for i in range(0, len(b)):
    if x+i < len(a):
      ari.append(a[x+i][y:y+M])
  if "".join(ari) == "".join(b):
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N (600009)
using namespace std;

struct Node
{
	int num,dis;
	bool operator < (const Node &a) const {return dis>a.dis;}
};
struct Edge{int to,next,len;}edge[N<<1];
int n,m,u,v,c,cnt,dis[N],vis[N];
int head[N],num_edge;
priority_queue<Node>q;
map<pair<int,int>,int>Map;

void add(int u,int v,int l)
{
	edge[++num_edge].to=v;
	edge[num_edge].next=head[u];
	edge[num_edge].len=l;
	head[u]=num_edge;
}

void Dijkstra(int s)
{
	memset(dis,0x7f,sizeof(dis));
	dis[s]=0; q.push((Node){s,0});
	while (!q.empty())
	{
		int x=q.top().num; q.pop();
		if (vis[x]) continue; vis[x]=1;
		for (int i=head[x]; i; i=edge[i].next)
			if (!vis[edge[i].to] && dis[x]+edge[i].len<dis[edge[i].to])
			{
				dis[edge[i].to]=dis[x]+edge[i].len;
				q.push((Node){edge[i].to,dis[edge[i].to]});
			}
	}
}

int getid(int x,int y)
{
	if (Map.find(make_pair(x,y))!=Map.end()) return Map[make_pair(x,y)];
	return Map[make_pair(x,y)]=++cnt;
}

int main()
{
	cin>>n>>m; cnt=n;
	for (int i=1; i<=m; ++i)
	{
		cin>>u>>v>>c;
		int id1=getid(u,c),id2=getid(v,c);
		add(id1,id2,0); add(id2,id1,0);
		add(u,id1,1); add(id1,u,1);
		add(v,id2,1); add(id2,v,1);
	}
	Dijkstra(1);
	cout<<(dis[n]>2e9?-1:dis[n]/2)<<endl;
}

Measured memory_bytes: 47356
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Solve(N int, S []string) {
  k := len(S)
  A := make([]string, k)
  for i := range A {
    A[i] = ""
    for j := 0; j < N / k; j++ {
      A[i] += S[i]
    }
  }
  for i := 0; i < N; i++ {
    Write(A[i % k])
  }
}

func Solve2(N int) {
  S := make(map[int][]string)
  S[4] = []string{"aacd", "bbcd", "cdaa", "cdbb"}
  S[5] = []string{"aabbd", "bc..d", "bc..e", "c.ffe", "cddgg"}
  S[7] = []string{"aabbaa.", "bc....a", "bc....a", "a..ab..", "a..ab..", ".aa.caa", "..bbcbb"}
  P := make([]int, N / 4)
  for i := range P {
    P[i] = 4
  }
  if N % 4 == 1 {
    P[0] = 5
  } else if N % 4 == 2 {
    P[0] = 5
    P[1] = 5
  } else if N % 4 == 3 {
    P[0] = 7
  }
  blank := 0
  for _, p := range P {
    for i := 0; i < p; i++ {
      s := ""
      for j := 0; j < blank; j++ { s += "." }
      s += S[p][i]
      for j := blank + p; j < N; j++ { s += "." }
      Write(s)
    }
    blank += p
  }
}

func main() {
  N := NextInt()
  if N % 3 == 0 {
    Solve(N, []string{"a..", "a..", ".aa"})
  } else if 4 <= N {
    Solve2(N)
  } else {
    Write(-1)
  }
  Output()
}

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

int main() {
    int n,m;
    cin>>n>>m;
    int count[n+1];
    for(int i=0; i<n+1; i++) count[i]=0;

    int ac = 0;
    int pena = 0;
    for(int i=0; i<m; i++) {
        int p;
        string s;
        cin>>p>>s;
        if(s=="AC" && count[p]!=-1) {
            ac++;
            pena += count[p];
            count[p] = -1;
        }
        if(s=="WA" && count[p]!=-1) {
            count[p]++;
        }
    }

    cout<<ac<<' '<<pena<<endl;

    return 0;
}

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

public class hello
{
    public static void Main()
    {
        var plist = GeneratePrime(50000);
        var sb = new StringBuilder();
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var count = 0;
            for (int i = 0; plist[i] <= n / 2; i++)
            {
                var w = n - plist[i];
                var s = plist.BinarySearch(w);
                if (s >= 0) count++;
            }
            sb.Append(string.Format("{0}\n", count));
        }
        Console.Write(sb);
    }
    public static List<int> GeneratePrime(int m)
    {
        var plist = new List<int>();
        int prime;
        var sqrtMax = Math.Sqrt(m);
        var searchList = Enumerable.Range(2, m - 1).ToList();
        do
        {
            prime = searchList.First();
            plist.Add(prime);
            searchList.RemoveAll(n => n % prime == 0);
        }
        while (prime < sqrtMax);
        plist.AddRange(searchList);
        return plist;
    }
}



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


int main(){

  int n,s,a;

  cin >> n;
  while(n != 0){
    int su = 0;
    a = 0;
    for(int i = 0;i < n;i++){
      cin >> s;
      if(s >= 1){
        su += 1;
      }

      if(s >= 2){
        a = 1;
      }

    }

    if(a == 1 && su >= 1){
      cout << su+1 << endl;
    }else{
      cout << "NA" << endl;
    }
    cin >> n;
  }

  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];

    ll ans = INF;
    rep(i, 101) {
        ll sum = 0;
        rep(j, N) {
            sum += (X[j] - i) * (X[j] - i);
        }
        chmin(ans, sum);
    }

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

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

using namespace std;

const int MAX_N = 5050, mod = 1e9 + 7;

int n, head[MAX_N], current, g[MAX_N], dp[MAX_N][MAX_N], siz[MAX_N], tmp[MAX_N];

struct edge
{
    int to, nxt;
} edges[MAX_N << 1];

void addpath(int src, int dst)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    head[src] = current++;
}

void dfs(int u, int fa)
{
    siz[u] = 1, dp[u][1] = 1;
    for (int i = head[u]; i != -1; i = edges[i].nxt)
        if (edges[i].to != fa)
        {
            dfs(edges[i].to, u);
            for (int j = 0; j <= siz[u]; j++)
                tmp[j] = dp[u][j], dp[u][j] = 0;
            for (int j = 0; j <= siz[u]; j++)
                for (int k = 0; k <= siz[edges[i].to]; k++)
                    dp[u][j + k] = (0LL + dp[u][j + k] + 1LL * tmp[j] * dp[edges[i].to][k] % mod) % mod;
            siz[u] += siz[edges[i].to];
        }
    for (int i = 0; i <= siz[u]; i++)
        dp[u][0] = (0LL + dp[u][0] + mod - 1LL * dp[u][i] * g[i] % mod) % mod;
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d", &n);
    for (int i = 1, u, v; i <= n - 1; i++)
        scanf("%d%d", &u, &v), addpath(u, v), addpath(v, u);
    g[0] = 1;
    for (int i = 2; i <= n; i += 2)
        g[i] = 1LL * g[i - 2] * (i - 1) % mod;
    dfs(1, 0), printf("%d\n", mod - dp[1][0]);
    return 0;
}

Measured memory_bytes: 98432
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] {
			res = a[i]
		}
	}
	return res
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()

	_, _ = fmt.Fprintf(writer, "%d", max(a+b, a-b, a*b))
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


ll N;
map<ll,int> GM;
ll fact[11];
int S[6][121][32];

int G(ll n) {
	if(n==1) return 0;
	if(GM.count(n)) return GM[n];
	int k;
	for(k=1;k<=n;k++) if(n<=(1LL<<k)-max(0,G(k))) {
		return GM[n]=k;
	}
	return -1;
}

int check(vector<int> C,int K) {
	int did[1<<5]={};
	FORR(c,C) did[c]=1;
	int i;
	for(i=1;i<fact[K];i++) {
		int same=1;
		FORR(c,C) if(did[S[K][i][c]]==0) same=0;
		if(same) return 0;
	}
	return 1;
}


int go(int K,int N,int nex,vector<int>& C) {
	if(N==0) return check(C,K);
	
	ll ret=0;
	for(int i=nex;i<1<<K;i++) {
		if(ret>1001*fact[K]) break;
		C.push_back(i);
		ret+=go(K,N-1,i+1,C);
		C.pop_back();
	}
	return ret;
}

ll hoge(ll K,ll N) {
	if(K>N) swap(K,N);
	if(2*N>1LL<<K) return hoge(K,(1LL<<K)-N);
	if(K>5) return -1;
	
	vector<int> C;
	ll ret=go(K,N,0,C)/fact[K];
	if(ret>1000) ret=-1;
	return ret;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	fact[0]=1;
	for(i=1;i<=10;i++) fact[i]=fact[i-1]*i;
	
	for(i=2;i<=5;i++) {
		vector<int> G;
		FOR(j,i) G.push_back(j);
		int step=0;
		do {
			int mask;
			FOR(mask,1<<i) {
				FOR(j,i) if(mask&(1<<j)) S[i][step][mask] |= 1<<G[j];
			}
			
			step++;
		} while(next_permutation(ALL(G)));
	}
	
	
	cin>>N;
	
	k=G(N);
	ll ret=hoge(k,N);
	if(N==4) ret++;
	if(N==7) ret++,ret++;
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  int a, b, c, d; cin >> a >> b >> c >> d;
  if ((c+b-1)/b <= (a+d-1)/d) cout << "Yes";
  else cout << "No";
  return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		boolean[] rate = new boolean[8];
		Arrays.fill(rate,false);
		int max = 0;
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
			if(a[i] < 400){
				rate[0] = true;
			}else if(a[i] < 800){
				rate[1] = true;
			}else if(a[i] < 1200){
				rate[2] = true;
			}else if(a[i] < 1600){
				rate[3] = true;
			}else if(a[i] < 2000){
				rate[4] = true;
			}else if(a[i] < 2400){
				rate[5] = true;
			}else if(a[i] < 2800){
				rate[6] = true;
			}else if(a[i] < 3200){
				rate[7] = true;
			}else if(a[i] <= 4800){
				max++;
			}
		}
		int c = 0;
		for (boolean r:rate){
			if(r){
				c++;
			}
		}
		max+=c;
		if(c==0 && max>0){
			c = 1;
		}
		System.out.println(c + " " + max);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main(void) {
  string s;
  cin >> s;

  int len,tmp;
  len=s.length();tmp=s.length();
  bool empty=0;

  while(0<tmp){
    if(tmp-5<0){empty=1;break;}
    if(s.substr(tmp-5,5)=="dream"){tmp-=5;continue;}
    if(s.substr(tmp-5,5)=="erase"){tmp-=5;continue;}
    if(tmp-6<0){empty=1;break;}
    if(s.substr(tmp-6,6)=="eraser"){tmp-=6;continue;}
    if(tmp-7<0){empty=1;break;}
    if(s.substr(tmp-7,7)=="dreamer"){tmp-=7;continue;}
    empty=1;break;
  }

  if(empty==0){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main() {
  int hp_taka, atk_taka, hp_aoki, atk_aoki;
  
  cin >> hp_taka >> atk_taka >> hp_aoki >> atk_aoki;
  
  for (int i = 0; i < 100; i++) {
  	hp_aoki -= atk_taka;
    if (hp_aoki <= 0) {
    	cout << "Yes";
        break;
    }
    hp_taka -= atk_aoki;
    if (hp_taka <= 0) {
    	cout << "No";
      	break;
    }
  }
}

Measured memory_bytes: 3556
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s;
    cin >> s;
    int check[3];
    for(int i = 0; i < 3; i++) check[i] = 0;
    for(auto c : s){
        if(c == 'a') check[0] = 1;
        if(c == 'b') check[1] = 1;
        if(c == 'c') check[2] = 1;
    }
    bool flag = true;
    for(int i = 0; i < 3; i++){
        if(check[i] == 0) flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int N,W[1000];
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>W[i];
    }
    int ans=10000;
    for(int i=0;i<N-1;i++){
        int b=0,c=0;
        for(int j=0;j<=i;j++){
            b=b+W[j];
        }
        for(int j=i+1;j<N;j++){
            c=c+W[j];
        }
        int a=abs(b-c);
        if(a<ans){
            ans=a;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
using pqueg = priority_queue<int, vector<int>, greater<int>>;
using pquel = priority_queue<int, vector<int>, less<int>>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
int lcm(int a, int b){
  return a / __gcd(a, b) * b;
}
int r_int(int a, int b){
  return rand() % b + a;
}
const lint mod=1e9+7;



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

  cout << (s == "ABC" ? "ARC" : "ABC") << "\n";
  return 0;
}


Measured memory_bytes: 3592
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

string line;
int p, MAX_DEPTH;

// 0~9のcharならtrue
bool isNum(char c) {
    int n = c - '0';
    return 0 <= n && n <= 9;
}

// 数字のみをパース
int number() {
    int n = 0;
    while(isNum(line[p])) n = n * 10 + line[p++] - '0';
    return n;
}

// []をパース、数字はパースしない
int dfs(int depth) {
    int bkt = 0, sum = 0;
    vector<int> ret;

    while(1) {
        if ( line[p] == '[' ) {
            p++;
            bkt++;
            ret.push_back( dfs(depth+1) );
        } else if ( line[p] == ']' ) {
            bkt--;
            if ( bkt == -1 || depth == 0 ) {
                break;
            } else {
                p++;
            }
        } else {
            return number();
        }
    }

    // ソートして過半数を取り出し、過半数を計算して合計値を返す
    sort(ret.begin(), ret.end());

    // 最初の選挙区だけ得票数が過半数になる
    REP(i, ret.size()/2+1) {
        if ( depth == MAX_DEPTH ) sum += ret[i] / 2 + 1;
        else sum += ret[i];
    }
    return sum;
}

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

    while(n--) {
        MAX_DEPTH = 0;
        p = 0;
        cin >> line;

        // 最初の括弧の連続から最大の深さを計る（深さは一様）
        // 最初（最深）の計算のみ住民の投票なので過半数にする
        int i = 0;
        while(line[++i] == '[') ++MAX_DEPTH;

        cout << dfs(0) << endl;
    }  
   
    return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        long q=scan.nextLong();//0.25L
        long h=scan.nextLong();//0.5L
        long s=scan.nextLong();//1L
        long d=scan.nextLong();//2L
        long n=scan.nextLong();
        long k=0;
        long q1l=q*4;
        long q2l=q*8;
        long h1l=h*2;
        long h2l=h*4;
        long s2l=s*2;
        while(n>=2){
            n-=2;
            if(s2l<d&&s2l<q2l&&s2l<h2l){
                k+=s2l;
            }else if(q2l<d&&q2l<s2l&&q2l<h2l){
                k+=q2l;
            }else if(h2l<d&&h2l<q2l&&h2l<s2l){
                k+=h2l;
            }else{
                k+=d;
            }
        }
        if(n==1){
            if(q1l<h1l&&q1l<s){
                k+=q1l;
            }else if (h1l<q1l&&h1l<s){
                k+=h1l;
            }else{
                k+=s;
            }
        }
        System.out.println(k);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}



int main(){
    cin.tie(0);
    
    int N;
    cin >> N;
    vector<int> ans;
    int sum = 0;
    for (int i = 1; i <= N; i++){
        sum += i;
        ans.push_back(i);

        if (sum > N){
            ans[sum - N - 1] = -1;
            break;
        }
        if (sum == N){
            break;
        } 
    }
    for (auto i : ans){
        if (i != -1) cout << i << endl;
    }

    return 0;
} 


Measured memory_bytes: 384
N,M = map(int,input().split())
H = list(map(int,input().split()))
br = {num+1:[] for num in range(N)}
for i in range(M):
    a,b = map(int,input().split())
    br[a].append(b)
    br[b].append(a)
cnt = 0
for i in range(N):
    height = []
    if len(br[i+1])==0:
        cnt+=1
        continue
    for j in br[i+1]:
        height.append(H[j-1])
    if H[i]>max(height):
        cnt+=1
print(cnt)

Measured memory_bytes: 37788
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e5+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	vi m(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}


lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

lli PROD(lli a, lli b, lli mod=MOD){
	a%=mod; b%=mod;
	return a*b % mod;
}

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

vvi graph(int n, int m){
	vv(int,v,n+1,0);
	fore(i,0,m){
		int a,b; cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	return v;
}

// ---- コーディングはここから！ ('-')7

void solve(){
	string a,b; cin>>a>>b;
	bool can = sz(a)+1==sz(b);
	fore(i,0,sz(a))can&=a[i]==b[i];
	cout<<(can?"Yes":"No")<<ENDL;

}

int main(){_
//	int t; cin>>t; while(t--)
	solve();
}


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

using namespace std;

int main()
{
    string s;
    cin>>s;
    long long int a=0;
    for(int i=0;i<s.size();i++)
    {
        a+= (int)(s[i]-48);
    }
    if(a%9)cout<<"No"<<endl;
    else cout<<"Yes";

}


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

ll power(ll a, ll b)
{
    ll m = 1;
    while(b--) m *= a;
    return m;
}

int sumOfDigits(int x){
    int sum = 0;
    while(x){
        sum += x % 10;
        x /= 10;
    }

    return sum;
}

int main()
{
    ios::sync_with_stdio(false);
    int mn = 1000000005, n, i, j, k, l;
    cin >> n;
    for(i=1;i<n;i++){
        mn = min(mn, sumOfDigits(i) + sumOfDigits(n-i));
    }

    cout << mn << "\n";
    return 0;
}

Measured memory_bytes: 256
#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(){
	string s,t;
	cin >> s >> t;
	int counts = 0;
	rep(i,3) if(s[i] == t[i]) counts++;
	cout << counts << endl;
}

Measured memory_bytes: 3596
fun main(args: Array<String>) {
    readLine()
    val arr = Array('z'-'a'+1){0}
    readLine()!!.forEach { arr[it-'a']+=1 }
    var result:Long = 1
    arr.forEach {if(it>0) result= result * (it+1).toLong() % 1000000007}
    print(result-1)
}

Measured memory_bytes: 34860
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        dd: [usize; n]
    }

    let mut map = HashMap::new();
    for d in dd {
        *map.entry(d).or_insert(0) += 1;
    }

    let mut ans = 0;

    for i in 0..1<<map.len() {
        let mut times = vec![0, 24];
        for (j, (&key, &val)) in map.iter().enumerate() {
            if val > 2 {
                println!("0");
                return;
            } else if val == 2 {
                times.push(key);
                times.push(24-key);
            } else {
                if i & 1<<j == 1<<j {
                    times.push(24-key);
                } else {
                    times.push(key);
                }
            }
        }
        ans = std::cmp::max(ans, min_time(times));
    }
    
    println!("{}", ans);
}

fn min_time(mut times: Vec<usize>) -> usize {
    times.sort();
    
    let mut min = 12;

    for i in 0..times.len()-1 {
        let sub = times[i+1] - times[i];
        min = std::cmp::min(min, sub);
    }
    min
}


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

int main()
{
    ll n, m;
    string s="zabcdefghijklmnopqrstuvwxy";
    string ans;
    cin>>n;

    while(n>0)
    {
        m=n%26;
        if(m==0)n--;
        ans+=s[m];
        n/=26;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;
}

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

typedef long long int lli;
#define pb push_back
#define gcd __gcd
#define MOD 1000000007
#define mod2 998244353
#define PI 3.141592653589793238462643383279
#define forz(i,n) for(long long int i=0;i<n;i++)

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1,u,j;
    //cin>>t;
    for(u=1;u<=t;u++){
        //cout<<sin()
        lli n,i,j,a,b,c,d,k,n1,n2,n3,current,h,m;
        cin>>a>>b>>h>>m;
        double t=(360.00000000000000/60.00000000000)*m*1.00000000;
        double p=(360.00000000000000/12.00000000000)*h*1.00000000;
        p=p+(30.00000000000000/60.00000000000)*m*1.00000000;
        if(t==0) t=min(p,360-p);
        else if(p==0) t=min(t,360-t);
        else if(t>p) t=min(t-p,360-(t-p));
        else t=min(p-t,360-(p-t));
        //cout<<t<<" "<<cos((t*PI*1.000000000000)/180.00000)<<endl;
        cout<<setprecision(20)<<sqrt(pow(a,2)+pow(b,2)-2.0000000000000*a*b*cos(t*PI/180))<<endl;
    }
}

Measured memory_bytes: 4244
import heapq
N,M=map(int, input().split())
A=[-a for a in map(int, input().split())]
A.sort()
for i in range(M):
    a=heapq.heappop(A)
    if a%2==1:
        heapq.heappush(A,a//2+1)
    else:
        heapq.heappush(A,a//2)
    #print(A)
print(-sum(A))

Measured memory_bytes: 14180
from math import gcd

K = int(input())

def GCD(a,b,c):
    g = gcd(a,b)
    g = gcd(g,c)
    return g

ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += GCD(a,b,c)

print(ans)


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

int main() {
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

int n;
int t[N], x[N], y[N];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d %d %d", &t[i], &x[i], &y[i]);
		if(abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) <= t[i] - t[i - 1]){
			if(((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2) ^ ((t[i] - t[i - 1]) % 2) == 1){
				puts("No");
				return 0;
			}
		}else{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
//#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
#define ld long double
ll INF = (1LL << 60);
int MOD = 1000000007;

struct UnionFind {
	vector<ll>p;
	UnionFind(ll n) {
		p.resize(n, -1);
	}
	ll find(ll x) {
		if (p[x] == -1)return x;
		else return p[x] = find(p[x]);
	}
    void unite(ll x, ll y) {
		x = find(x), y = find(y);
		if (x == y)return;
		p[x] = y;
	}
};

struct edge{
	ll u, v, cost;
};
bool comp(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}


ll V, E;
edge G[200010];

int kruskal() {
	sort(G, G + E, comp);
	UnionFind uf(V);
	ll res = 0;
	rep(i, E) {
		edge e = G[i];
		if (uf.find(e.u) != uf.find(e.v)) {
			uf.unite(e.u, e.v);
			res += e.cost;
		}
	}
	return res;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> V;
	vector<ll>x(V), y(V); rep(i, V)cin >> x[i] >> y[i];
	vector<P>a(V), b(V);
	rep(i, V) {
		a[i] = { x[i],i };
		b[i] = { y[i],i };
	}
	sort(a.begin(), a.end()); sort(b.begin(), b.end());
	rep(i, V - 1) {
		G[E] = { a[i].second, a[i + 1].second,abs(a[i].first - a[i + 1].first) };
		E++;
		G[E] = { b[i].second, b[i + 1].second,abs(b[i].first - b[i + 1].first) };
		E++;
	}
	cout << kruskal() << endl;
	return 0;
}

Measured memory_bytes: 13500
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        int N = (int) 1e5 + 5;
        BigInteger max = new BigInteger("1000000000000000000");
        BigInteger[] A = new BigInteger[N];
        int n;
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        int flag = 0, flag1 = 0;
        for (int i = 0; i < n; i++) {
            A[i] = in.nextBigInteger();
            if (A[i].compareTo(max) == 1) {
                flag = 1;
            }
            if (A[i].compareTo(new BigInteger("0")) == 0) {
                flag1 = 1;
            }
        }
        BigInteger m = new BigInteger(String.valueOf(1));
        if (flag1 == 1) {
            System.out.println("0");
        } else if (flag == 1) {
            System.out.println("-1");
        } else {
            for (int i = 0; i < n; i++) {
                m = m.multiply(A[i]);
//            System.out.println(m.compareTo(max));
                if (m.compareTo(max) == 1) {
                    flag = 1;
                    break;
                }
            }
            if (flag == 1) {
                System.out.println("-1");
            } else {
                System.out.println(m);
            }
        }


    }
}


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

std::vector<int> va(101, 0);
std::vector<int> vb(101, 0);

void enum_divisors(long long N, int aorb) {
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            if(aorb){
                va[i]++;
                if (N/i != i)va[N/i]++;
            }else{
                vb[i]++;
                if (N/i != i)vb[N/i]++;
            }

        }
    }  
    return ;
}

int main() {
    long long a,b,k;
    cin >>a>>b>>k;
    enum_divisors(a, 1);
    //for (int x:va) cout << x << " ";
    //cout<<endl;
    enum_divisors(b, 0);
    //for (int x:vb) cout << x << " ";
    int cnt=0;
    for(int i=100;i>=1;i--){
        if(va[i]>0&&vb[i]>0){
            cnt++;
            if(cnt==k){
                cout<<i<<endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int num = 1;
		for (int i=0; i<5; i++) {
			int x = sc.nextInt();
			if (x==0) {
				break;
			}
			num++;
		}				
		System.out.print(num);
		sc.close();
	}

}


Measured memory_bytes: 27044
n=int(input())
l=list(map(int, input().split()))
m=sorted(l)
z=0
if n<3:
    print(0)
else:
    for i in range (n-2):
        for j in range (i,n-1):
            for k in range (j,n):
                if m[i]!=m[j] and m[j]!=m[k] and m[i]+m[j]>m[k]:
                    z+=1
    print(z)


Measured memory_bytes: 9192
#include <stdio.h>

int get_days(int month);

int main(void) 
{
	int month, day;
	int sum;
	int i;

	while (scanf("%d %d", &month, &day), !(month == 0 && day == 0)) {
		sum = 0;

		for (i = 1; i < month; i++) {
			sum += get_days(i);
		}

		sum += day;

		switch (sum % 7) {
		case 0:
			printf("Wednesday\n");
			break;
		case 1:
			printf("Thursday\n");
			break;
		case 2:
			printf("Friday\n");
			break;
		case 3:
			printf("Saturday\n");
			break;
		case 4:
			printf("Sunday\n");
			break;
		case 5:
			printf("Monday\n");
			break;
		case 6:
			printf("Tuesday\n");
			break;
		}
	}

	return 0;
}

int get_days(int month) 
{
	int days;

	if (month == 2) 
		days = 29;
	else if (month == 4 || month == 6 || month == 9 || month == 11) 
		days = 30;
	else 
		days = 31;

	return days;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <algorithm>
#include <stack>
#define $ if(0)

using namespace std;

//long long
long long n;
long long a[220000];
long long l[220000] , r[220000];
long long ans;
stack < long long > q;
void work () {
	long long i , j , last;
	scanf ( "%d" , &n );
	for ( i = 1 ; i <= n ; i++ ) scanf ( "%d" , &a[i] ), a[i] = -a[i];
	last = 1; q.push ( 1 );
	for ( i = 2 ; i <= n ; i++ ) {
		while ( q.size () != 0 && a[i] > a[q.top ()] ) {
			r[q.top()] = i - 1;
			q.pop ();
		}
		q.push ( i );
	}
	while ( q.size () != 0 ) {
		r[q.top()] = n; q.pop ();
	}
	last = n; q.push ( n );
	for ( i = n - 1 ; i >= 1 ; i-- ) {
		while ( q.size () != 0 && a[i] > a[q.top ()] ) {
			l[q.top()] = i + 1;
			q.pop ();
		}
		q.push ( i );
	}
	while ( q.size () != 0 ) {
		l[q.top()] = 1; q.pop ();
	}
	ans = 0;
	$ for ( i = 1 ; i <= n ; i++ ) printf ( "%lld %lld\n" , l[i] , r[i] );
	for ( i = 1 ; i <= n ; i++ ) ans += (r[i]-i+1) * (i-l[i]+1) * a[i];
	printf ( "%lld\n" , -ans );
}
int main () {
	work ();
	return 0;
}

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

#define mod 998244353

typedef long long ll;

int main(){
  ll N,K;
  cin >> N >> K;
  vector<pair<ll,ll>> lr(K);
  for(ll i=0; i<K; i++){
    ll l,r;
    cin >> l >> r;
    lr[i] = make_pair(l,r);
  }
  vector<ll> d(N,0),s(N,0);
  d[0] = 1;
  s[0] = 1;
  for(ll i=1; i<N; i++){
    for(ll j=0; j<K; j++){
      ll l,r;
      l = lr[j].first; r = lr[j].second;
      if(i - l >= 0){
        if(i - r <= 0){
          d[i] += s[i-l];
        }
        else{
          d[i] += s[i-l] - s[i-r-1];        
        }
      }
      d[i] %= mod;
    }
    s[i] = s[i-1] + d[i];
    s[i] %= mod;
    //cout << d[i] << endl;
  }
  if(d[N-1] < 0) cout << d[N-1] + mod;
  else cout << d[N-1];
  return 0;
}

Measured memory_bytes: 6372
def resolve():
    import sys
    input = sys.stdin.readline
    
    H, N = map(int, input().split())
    A = list(map(int, input().split()))

    S = sum(A)
    # print(S)

    if H - S <= 0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 13876
#include <iostream>
#include <vector>

template <class T>
T Vec(T v) { return v; }

template <class T, class... Ts>
auto Vec(size_t l, Ts... ts) {
    return std::vector<decltype(Vec<T>(ts...))>(l, Vec<T>(ts...));
}

int main() {
    int N;
    std::cin >> N;

    auto imos = Vec<int>(1001, 1001, 0);
    for (int i = 0; i < N; ++i) {
        int x1, y1, x2, y2;
        std::cin >> x1 >> y1 >> x2 >> y2;
        ++imos[x1][y1];
        --imos[x1][y2];
        --imos[x2][y1];
        ++imos[x2][y2];
    }

    for (int i = 0; i <= 1000; ++i) {
        for (int j = 1; j <= 1000; ++j) {
            imos[i][j] += imos[i][j - 1];
        }
    }

    for (int j = 0; j <= 1000; ++j) {
        for (int i = 1; i <= 1000; ++i) {
            imos[i][j] += imos[i - 1][j];
        }
    }

    int ans = 0;
    for (int j = 0; j <= 1000; ++j) {
        for (int i = 0; i <= 1000; ++i) {
            ans = std::max(ans, imos[i][j]);
        }
    }

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



Measured memory_bytes: 6828
# -*- coding:utf-8 -*-
import sys
if __name__ == "__main__":
    a, b, c, k = map(int, input().split());
    if k%2:
        ans = b-a
    else:
        ans = a-b
    if abs(ans) > 10**18:
        print("Unfair")
        sys.exit()
    print(ans)

Measured memory_bytes: 3316
#include <iostream>

int main() {
  int a,b,c;

  std::cin >> a >> b;

  c = a * b;

  if (c % 2 == 0) {
    std::cout << "Even" << '\n';
  } else {
    std::cout << "Odd" << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <unordered_map>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int k, q;
  while (cin >> k >> q) {
    vector<ll> d(k);
    for (auto& x : d) cin >> x;
    for (int qi = 0; qi < q; qi++) {
      ll n, x, m;
      cin >> n >> x >> m;
      ll eq = 0, last = x;
      for (int i = 0; i < k; i++) {
        ll y = d[i] % m;
        ll cnt = max(0ll, (n - 1 - i) + k - 1) / k;
        if (y == 0) {
          eq += cnt;
        }
        last += y * cnt;
      }
      ll less = (last / m) - (x / m);
      ll res = n - 1 - eq - less;
      cout << res << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
map<int, int> ans;
void f(int n) {
    for (int i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        while (n % i == 0) {
            n /= i;
            ans[i]++;
        }
    }
    if (n != 1) ans[n]++;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) f(i);
 
    long long A = 1;
    for (int i = 1; i <= n; i++) {
        if (ans.count(i)) {
            (A *= (ans[i] + 1)) %= MOD;
        }
    }
 
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math
a, b = input().split()
a = int(a)
ans = 0

ans = a*int(b[0])*100
ans += a*int(b[2])*10
ans += a*int(b[3])
print(ans//100)
# ans = str(ans/100)
# print(ans[0:ans.find('.')])


Measured memory_bytes: 61992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int D; cin >> D;
    vector<int> c(26+1, 0);
    for(int i = 1; i <= 26; i++) cin >> c[i];
    vector<vector<int>> s(D+1, vector<int>(26+1, 0));
    for(int i = 1; i <= D; i++)for(int j = 1; j <= 26; j++) cin >> s[i][j];
    vector<int> t(D+1);
    for(int i = 1; i <= D; i++) {
        cin >> t[i];
    }
    vector<int> last(26+1, 0);
    int ans = 0;
    auto f = [&](int d){
        int res = 0;
        for(int i = 1; i <= 26; i++){
            res += c[i] * (d - last[i]);
        }
        return res;
    };
    for(int day = 1; day <= D; day++){
        int con = t[day];
        ans += s[day][con];
        last[con] = day;
        ans -= f(day); 
        cout << ans << endl;
    }
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string a;
    cin>>a;
    for(int i=0;i<a.size();i++)
    {
        if(i%2==0)
        {
            cout<<a[i];
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>

char s[201];

int A(int p,int st,int c)
{
	if(st==2&&c==0&&s[p]==0)
		return 1;
	else if(st==1&&s[p]=='~')
		return A(p+1,st+1,c);
	else if(st==1&&s[p]=='=')
		return A(p+1,st,c-1);
	else if(st==0&&c>0&&s[p]=='#')
		return A(p+1,st+1,c);
	else if(st==0&&s[p]=='=')
		return A(p+1,st,c+1);
	else 
		return 0;
}

int B(int p,int st)
{
	if(st==3&&s[p]==0)
		return 1;
	else if(p>3&&(st==1||st==2)&&s[p]=='~')
		return B(p+1,st+1);
	else if(st==0&&s[p]=='=')
		return B(p+1,1);
	else if(st==1&&s[p]=='Q')
		return B(p+1,0);
	else 
		return 0;
}


int main()
{
	int n,i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",s);
		if(s[0]=='>'&&s[1]=='\''&&A(2,0,0))
			puts("A");
		else if(s[0]=='>'&&s[1]=='^'&&B(2,1))
			puts("B");
		else
			puts("NA");
	}
	return 0;
}

Measured memory_bytes: 584
S = list(input())
N = len(S)

odd = S[::2]
cnt1 = odd.count("1")

even = S[1::2]
cnt2 = even.count("0")

sum_num = cnt1 + cnt2
sum_num2 = N - cnt1 - cnt2

print(min(sum_num,sum_num2))


Measured memory_bytes: 4652