akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.next();
    if(str.charAt(0) == str.charAt(1) && str.charAt(1) ==str.charAt(2)){
      System.out.println("Yes");
    }else if(str.charAt(1) == str.charAt(2) && str.charAt(2) ==str.charAt(3)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

#define N 101111

int n;
vector <int> E[N];
unsigned long long ha[N];
const unsigned long long P = 19260817, Q = 233;

void dfs(int x, int fa = -1) {
	for (auto v : E[x]) if (v != fa) {
		dfs(v, x);
		ha[x] += ha[v];
	}
	ha[x] *= P;
	ha[x] += Q;
}

map <unsigned long long, int> G;
int main() {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		E[v].push_back(u);
	}
	dfs(1);
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		ans += G[ha[i]];
		G[ha[i]] += 1; 
	}
	cout << ans << endl;
}



Measured memory_bytes: 21980
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 1e5+5;
ii a[N];

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n,m; cin>>n>>m;
    FOR(i, 0, n) {
    	cin>>a[i].ff>>a[i].ss;
    }
    sort(a, a+n);
    priority_queue<int> pq;
    int ans = 0, idx = 0;
    FOR(day, 0, m) {
    	while(idx < n && a[idx].ff == day + 1) {
    		pq.push(a[idx].ss); idx++;
    	}
    	if (!pq.empty())
    	{
    		ans += pq.top(); pq.pop();	
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1660
# coding: utf-8


def solve(*args: str) -> str:
    x, y = map(int, args[0].split())
    ret = 0
    mod = 1000000007

    if (x+y) % 3 == 0 and not (x > 2*y or y > 2*x):
        ret = 1
        a = (2*y-x)//3
        b = (2*x-y)//3
        for n in range(a+b, a, -1):
            ret = (ret * (n % mod)) % mod

        div = 1
        for k in range(b, 1, -1):
            div = (div * (k % mod)) % mod

        ret = (ret * pow(div, mod-2, mod)) % mod

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>

using namespace std;
//author_name:
//date://
//title:
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define ep emplace_back
#define mp make_pair
//ÒòÎªÇÓÅ³£¬ËùÒÔÌÓ±ÜÉúÃü£¬ÒÔ²»µÖ¿¹ÔÚ×îºÚ°µµÄ³ÁÂÙÖÐÉú³ö½¾°Á£¬ÒòÎª½¾°Á£¬ËùÒÔ²»Ñ¡ÔñÉú£¬ËùÒÔ¾Ü³â´Ö±ÉµÄÀÖ¹ÛÖ÷Òå¡£
//Ìì²ÅµÄ±¯¾çµØÓÚ±»Ð¡¶øÊæÊÊµÄÃûÍûËùÊø¸¿¡£
//It's human to lie. Most of the time we can't even be honest with ourselves.
typedef long long ll;
typedef pair<int,int> pii;

vector<pair<int,pii>> query;

int n,m,q;
vector<int> g[100010];
int max_d[100010];
int col[100010];

inline void dfs(int u,int d,int c)
{
	if(max_d[u]>=d) return;
	max_d[u]=d;
	if(col[u]==-1) col[u]=c;
	for(int i=0;i<g[u].size();i++)
		dfs(g[u][i],d-1,c);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		query.push_back(mp(a,mp(b,c)));
	}
	reverse(query.begin(),query.end());
	memset(max_d,-1,sizeof max_d);
	memset(col,-1,sizeof col);
	for(int i=0;i<q;i++)
		dfs(query[i].first,query[i].second.first,query[i].second.second);
	for(int i=1;i<=n;i++)
		printf("%d\n",col[i]==-1?0:col[i]);
	return 0;
}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;

bool isPrime[MAX_N];

bool sieve(int n){
    fill(isPrime, isPrime+n+1, true);
    isPrime[0] = isPrime[1] = false;
    for(int i=2;i*i<=n;i++){
        if(isPrime[i]){
            for(int j=i*i;j<=n;j+=i){
                isPrime[j] = false;
            }
        }
    }
}

bool dp[35][MAX_N];

int main() {
    sieve(1e6);
    int n, x;
    while(cin >> n >> x, n){
        int v[30];
        for(int i=0;i<n;i++) cin >> v[i];
        for(int i=0;i<=n;i++) fill(dp[i], dp[i]+x+1, false);
        dp[0][0] = true;
        for(int i=0;i<n;i++){
            for(int j=0;j<=x;j++){
                dp[i+1][j] |= dp[i][j];
                if(j+v[i]<=x){
                    dp[i][j+v[i]] |= dp[i][j];
                }
            }
        }
        int ans = -1;
        for(int i=2;i<=x;i++){
            if(dp[n][i] && isPrime[i]) ans = i;
        }
        if(ans > 0){
            cout << ans << endl;
        }
        else{
            cout << "NA" << endl;
        }
    }
    return 0;
}





Measured memory_bytes: 34240
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [-1] * N
    Win = [0] * N
    for i in range(1, N):
        a = int(input())
        A[i] = a - 1
        Win[a-1] += 1
    Depth = [0] * N
    SonDepth = [[] for _ in range(N)]
    q = deque()
    for i, a in enumerate(Win):
        if a == 0: q.append((i, 1))
    while q:
        cNode, cDepth = q.popleft()
        Depth[cNode] =cDepth
        pNode = A[cNode]
        if pNode == -1: break
        SonDepth[pNode].append((cDepth, cNode))
        Win[pNode] -= 1
        if Win[pNode] == 0:
            SonDepth[pNode].sort(reverse = True)
            maxDepth = 0
            for i, d in enumerate(SonDepth[pNode]): maxDepth = max(i + 1 + d[0], maxDepth)
            q.append((pNode, maxDepth))
    print(Depth[0] - 1)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 30140
#include <iostream>
using namespace std;
typedef long long ll;
ll a[100];
ll n;
int main(){
  cin>>n;
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  ll cnt = 0;
  for(int i=0;i<100000;++i){
    for(int j=0;j<n;++j){
      ll x = a[j]/n;
      a[j]%=n;
      for(int k=0;k<n;++k)
	if(k!=j)
	  a[k]+=x;
      cnt+=x;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 384
import itertools

N, M = map(int, input().split())
array = [" -> ".join(input().split()) for _ in range(M)]

permutation_list = itertools.permutations([x + 1 for x in range(N)])

count = 0
flg = True
for data in permutation_list:
    # print(data)
    if data[0] != 1:
        continue
    for i in range(1, len(data)):
        param = "{} -> {}".format(data[i - 1], data[i])
        param2 = "{} -> {}".format(data[i], data[i - 1])
        if array.count(param) > 0 or array.count(param2) > 0:
            pass
            # print("あった " + param)
        else:
            # print("なかった NG")
            flg = False
            break
    if flg is False:
        flg = True
        continue
    # print(data)
    count += 1

print(count)


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

int main() {
int n,m;
  cin >> n >> m;
  vector<string> a(n);

  for(int i=0;i<n;i++){
   cin >> a[i];
  }

  vector<bool> yoko(n,false);
  vector<bool> tate(m,false);

  for(int i=0;i<n;i++){
     for(int j=0;j<m;j++){
      if(a[i][j]=='#'){
       yoko[i]=true;tate[j]=true;
      }
     }
  }

  for(int i=0;i<n;i++){
    if(yoko[i]){
      for(int j=0;j<m;j++){
       if(tate[j])cout << a[i][j];
      }
      cout << endl;
    }
  }

}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
	int x,y;
	int s;
	int b[100];
    int  a[101][101];
	scanf("%d %d", &x, &y);
	for (int i = 0; i < x; i++){
		for (int j = 0; j < y; j++){
		scanf("%d",&a[i][j]);
		b[j] = 0;
		}
	}

	for (int i = 0; i < x; i++){
		s = 0;
		for (int j = 0; j < y; j++){
			printf("%d ", a[i][j]);
			s = s + a[i][j];
			b[j] = b[j] + a[i][j];
		}
		printf("%d\n", s);
	}
	s = 0;
	for (int i = 0; i < y; i++){
		printf("%d ", b[i]);
		s = s + b[i];
	}
	printf("%d\n", s);

	return 0;
}

Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;
struct UnionFind{
    vector<int> par; //par: -1*elements(root) number of par(not root)
    UnionFind(int n){
        par = vector<int>(n,-1);
    }
    int root(int x){
        return par[x]<0?x:(par[x]=root(par[x]));
    }
    void unite(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(par[x]<par[y]) swap(x,y);
            par[y] += par[x];
            par[x] = y;
        }
        return;
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    int size(int x){
        return -par[root(x)];
    }
};

struct Problem{
    LL n,m;
    vector<vector<int>> g;
    UnionFind uf;
    Problem(LL n, LL m):n(n),m(m),g(n),uf(n){};
    bool oddloop(int s){
        vector<int> vis(n);
        queue<int> Q;
        Q.push(s);
        while(!Q.empty()){
            int cur=Q.front();Q.pop();
            for(int v : g[cur]){
                if(vis[v]==0){
                    vis[v]=2-vis[cur];
                    Q.push(v);
                }else{
                    if(vis[cur]==vis[v])return true;
                }
            }
        }
        return false;
    }

    void solve(){
        for(int i=0; i<m; ++i){
            int a,b;
            cin >> a >> b;
            --a;--b;
            g[a].push_back(b);
            g[b].push_back(a);
            uf.unite(a,b);
        }
        vector<int> vis(n);
        LL cnt=0, conn=0, ev=0;
        for(int i=0; i<n; ++i){
            if(uf.par[i]<-1){
                if(!oddloop(i))ev++;
                conn+=uf.size(i);
                cnt++;
            }
            DBG(cnt,conn,ev)
        }
        cout << n*n-conn*conn+cnt*cnt+ev*ev <<"\n";

    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0,m;
    cin >> n >> m;
    Problem p(n,m);
    p.solve();
    return 0;
}



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

#define DEBUG 1

#if (DEBUG == 1)

#endif

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

  vector<vector<char>> pic(H+2,vector<char>(W+2, '#'));

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      cin >> pic.at(i).at(j);
    }
  }

  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      cout << pic.at(i).at(j);
    }
    cout << endl;
  }

  return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M), C(M); for(int i = 0; i < N; ++i) cin >> A[i];
    for(int i = 0; i < M; ++i) cin >> B[i] >> C[i];
    priority_queue<pair<int, int>> pq;
    for(int i = 0; i < N; ++i) pq.push(make_pair(A[i], 1));
    for(int i = 0; i < M; ++i) pq.push(make_pair(C[i], B[i]));

    ll ans = 0;
    while(N != 0){
        pair<int, int> top = pq.top();
        pq.pop();
        ans += (ll) top.first*min(top.second, N);
        N -= min(top.second, N);
    }
    cout << ans << '\n';
    return 0;
}
//Saw the editorial

Measured memory_bytes: 6476
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int R = l[0], G = l[1], B = l[2], N = l[3];

            var ans = 0;
            for (var r = 0; r <= N; r++)
            {
                var rR = (r * R);
                for (var g = 0; g <= N; g++)
                {
                    var rG = (g * G);
                    var rB = N - rR - rG;
                    if (rB < 0) break;
                    if (rB % B != 0) continue;

                    var diff = rR + rG + rB;
                    if (diff == N) ans++;
                }
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
def d_recording(N, C, R):
    """
    N:録画する番組の数
    C:テレビが受信できるチャンネルの数
    R:録画する番組の情報 [開始時刻s,終了時刻t,チャンネルc]
    """
    s = [row[0] for row in R]
    t = [row[1] for row in R]
    c = [row[2] for row in R]

    # いつまで録画機を動かすか。0.5を単位時間とするので*2
    # 時刻を0からスタートさせるので+2
    l = max(t) * 2 + 2
    sm = [0 for _ in range(l)]  # ある時刻に動いている録画機の数が格納される

    for i in range(1, C + 1):
        tt = [0 for _ in range(l)]  # チャンネルiを録画しているか否かを格納
        # 累積和を取る
        for j in range(N):
            if c[j] == i:
                # 録画開始時刻の0.5前を+1,終了時刻を-1
                #(終了時刻は含まないという録画機の条件より、このようにする)
                tt[s[j] * 2 - 1] += 1
                tt[t[j] * 2] -= 1
        for j in range(1, l):
            tt[j] += tt[j - 1]
        # あるチャンネルを録画している時間帯では、録画機を1個使わねばならない
        for j in range(l):
            if tt[j] > 0:
                sm[j] += 1
    ans = max(sm)
    return ans

N,C = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(N)]
print(d_recording(N, C, R))

Measured memory_bytes: 30160
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(0, A - 2 * B) << endl;
  return 0;
}


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

const ll INF = 1001001001;

int main(){
    int n, k; cin >> n >> k;
    vector<int> a(n); 
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for(int i = 0; i < k; i++){
        ans += a[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
const double PI=3.141592;

using ll = long long;
 
int main() {
    int R;
    cin >> R;
    cout << 2 * PI * R<< endl;
 
    return 0;
}


Measured memory_bytes: 3788
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template <class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
typedef vector<int>vi;
typedef vector<vi> vvi;
typedef vector<string>vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(A) (A).begin(),(A).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i)
const double EPS=1e-10;
const double PI= acos(-1.0);

#define MAX_K 1299710

int main(){
	int k;
	vi prime(MAX_K, true);
	prime[1]=false;
	FOR(i, 2, MAX_K) {
		if(prime[i]) {
			for(int j=2*i; j < MAX_K; j += i) {
				prime[j] = false;
			}
		}
	}

	while(cin >> k, k) {
		int p_left = 0, p_right = 0;
		FOR(i, 1, k+1) {
			if(prime[i]) {
				p_left = i;
			}
		}
		FOR(i, k, MAX_K) {
			if(prime[i]) {
				p_right = i;
				break;
			}
		}
		cout << max(p_right - p_left, 0) << endl;
	}
}

Measured memory_bytes: 6220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
#define UNDEFCHAN -1
#define SUPL 1002
#define MISERU(name,value) cout<<name<<": "<<value<<endl;

int xl,yl;
char xs[SUPL],ys[SUPL];
int rss[SUPL][SUPL];

int r(int xi, int yi){
	if (rss[xi][yi]!=UNDEFCHAN) return rss[xi][yi];
	int re;
	if(xi==0) re=0;
	else if(yi==0) re=0;
	else if(xs[xi-1]==ys[yi-1]) re=r(xi-1,yi-1)+1;
	else re=max(r(xi-1,yi),r(xi,yi-1));
	rss[xi][yi]=re;
	return re;
}

int solve(){
	REP(xi,xl+1) REP(yi,yl+1) rss[xi][yi]=UNDEFCHAN;
	return r(xl,yl);
}

int main(){
	int ol;
	cin>>ol;
	REP(oi,ol){
		cin>>xs;
		cin>>ys;
		xl=strlen(xs);
		yl=strlen(ys);
		cout<<solve()<<endl;
	}
	return 0;
}

Measured memory_bytes: 5180
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Jan 20 19:50:05 2019
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K int
	fmt.Scan(&N, &K)

	m := map[int]int{}
	for i := 0; i < N; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		m[a] += b
	}

	arr := make([]int, 0)
	for k := range m {
		arr = append(arr, k)
	}
	sort.Ints(arr)

	for _, k := range arr {
		if K-m[k] <= 0 {
			fmt.Println(k)
			break
		}
		K -= m[k]
	}
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	vector<ll> sum(n + 1);
	rep(i, n) sum[i + 1] = sum[i] + a[i];
	map<ll, ll> mp;
	rep(i, n + 1) {
		mp[(sum[i] % m)]++;
	}
	ll ans = 0;
	for (auto c : mp) {
		ll tmp = c.second * (c.second - 1) / 2;
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
	int A,B,C,D,E,ans=0,mi=10;
	cin >> A >> B >> C >> D >> E;
	
	while(A%10!=0){ mi=min(mi,A%10); A+=1; }
	while(B%10!=0){ mi=min(mi,B%10); B+=1; }
	while(C%10!=0){ mi=min(mi,C%10); C+=1; }
	while(D%10!=0){ mi=min(mi,D%10); D+=1; }
	while(E%10!=0){ mi=min(mi,E%10); E+=1; }
	ans=A+B+C+D+E-(10-mi);
	cout << ans << endl;


}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
c = 0
k = sum(a)
for i in range(n):
    if (c + a[i] >= k/2):
        d = i
        break
    c += a[i]
print(min(k-2*c,2*(c+a[d])-k))


Measured memory_bytes: 26396
q = int(input())
for _ in range (q):
    bits = F'{int(input(), 16):32b}'
    sign = '-' if bits[0] == '1' else ''
    integer = sum([2**i for i, b in enumerate(bits[1:25][::-1]) if b == '1'])
    fraction = sum([0.5**i for i, b in enumerate(bits[25:], start=1) if b == '1'])
    print(sign + str(float(integer + fraction)))



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

using namespace std;
unsigned long long int dp[128][23];
int n;
int main(){
	cin >> n;
	dp[0][0] = 1;
	for(int i = 1;i <= n-1;i++){
		int k;
		cin >> k;
		for(int j = 0;j <= 20;j++){
			if(j-k >= 0)dp[i][j] += dp[i-1][j-k];
			if(j+k <= 20)dp[i][j] += dp[i-1][j+k];
			if(i == 1 && k == 0 && j == 0)dp[i][j]--;
		}
	}
	int ans;
	cin >> ans;
	//cout << dp[n-1][ans] << endl;
	printf("%lld\n",dp[n-1][ans]);
	return 0;
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = 3;
  if(a == b)
    x--;
  else if(b == c)
    x--;
  else if(a == c)
    x--;
  
  if(a == b){
    if(b == c){
    x--;}}
  cout << x << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "iomanip"
#include "algorithm"
#include "vector"
#include "cmath"

int main() {
	int n;
	std::cin >> n;
	int ans = (n % 2 == 0) ? n / 2 : n / 2 + 1;
	std::cout << ans;
}

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

namespace ITP1_8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine();
            var word = Console.ReadLine();

            target = target + target.Substring(0, word.Length - 1);
            var find = target.Contains(word);

            Console.WriteLine(find ? "Yes" : "No");
            
        }
    }
}

Measured memory_bytes: 18480
N = int(input())

sentence_count_dict = {}
for _ in range(N):
    sentence = list(input())
    sentence = ''.join(sorted(sentence))
    if sentence in sentence_count_dict:
        sentence_count_dict[sentence] += 1
    else:
        sentence_count_dict[sentence] = 1

total = 0
for v in sentence_count_dict.values():
    total += (v * (v-1)) / 2

print(int(total))

Measured memory_bytes: 17928
#include <stdio.h>
int main(){
    int a;
    int b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
        return 0;
    }

    else{
        if(a==b){
            printf("a == b\n");
            return 0;
        }
        else{
            printf("a > b\n");
            return 0;
        }
    }

}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#include<string>
#include<math.h>
using namespace std;
int main(){
    int a,b=0;
    cin>>a;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){
            if(i%2!=0&&j%2==0) b++;
        }
    }
    cout<<b<<endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    long long int n,a,b,m,ans;
    cin >> n >> a >> b;
    if(a>b||(n==1&&a!=b)) ans = 0;
    else ans = 1+(n-2)*(b-a);
    cout << ans << endl;
    return 0;
}

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

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

    string s;
    cin >>s;

    int ans=0;
    char dia=s[0];
    for(int i=1;i<n;i++){
        if(dia==s[i]){
            ans++;
        }
        dia=s[i];
    }
    ans=min(n-1,ans+k*2);
    cout<<ans;
    return 0;

}


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

int main()
{
  int n;
  cin >> n;
  
  int s[n];
  int ans = 0;
  rep(i,n)
  {
    cin >> s[i];
    ans += s[i];
  }
  
  if(ans % 10 != 0)
  {
    cout << ans << endl;
    return 0;
  }
  
  sort(s,s+n);
  
  rep(i,n)
  {
    if((ans - s[i]) % 10 != 0)
    {
      cout << (ans - s[i]) << endl;
      return 0;
    }
  }
  
  cout << 0 << endl; 
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
char tolower(char c) {
	return (c + 0x20);
}
ld num(ld a,ld b) {
	ld c = 1;
	while (b > a) {
		a *= 2;
		c*=2;
	}
	return c;
}

int main() {
	int a, p;
	cin >> a >> p;
	p += a * 3;
	cout << p / 2 << endl;
	cin >> a;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
typedef long long ll;
const int N=1e5+5;
const ll INF=1e17+7;
const ll mod=1e9+7;
int n,m,cnt,head[N],s,t;ll d[N],num[N],rd[N],rn[N];
ll ans=0,len;
void init() {
    for(int i=1;i<=n;i++) head[i]=-1;cnt=0;
}
struct Edge {
    int to,nxt;ll w;
}edge[N<<2];
void addEdge(int from,int to,ll w) {
    edge[cnt].to=to;edge[cnt].nxt=head[from];edge[cnt].w=w;head[from]=cnt++;
}
struct Node {
    int p;ll w;
    Node(int p=0,ll w=0):p(p),w(w){};
    bool operator < (const Node &b) const {
        return w>b.w;
    }
};
std::priority_queue<Node> q;
void dijkstra(int s,ll *d,ll *num) {
    for(int i=1;i<=n;i++) d[i]=INF,num[i]=0;
    d[s]=0,num[s]=1;
    while(!q.empty()) q.pop();
    q.push(Node(s,0));
    while(!q.empty()) {
        Node c=q.top();q.pop();
        if(d[c.p]<c.w) continue;
        for(int i=head[c.p];~i;i=edge[i].nxt) {
            int v=edge[i].to;
            if(d[v]>d[c.p]+edge[i].w) d[v]=d[c.p]+edge[i].w,num[v]=num[c.p],q.push(Node(v,d[v]));
            else if(d[v]==d[c.p]+edge[i].w) num[v]+=num[c.p],num[v]%=mod;
        }
    }
}
void solve() {
    dijkstra(s,d,num);dijkstra(t,rd,rn);len=d[t];
    for(int i=1;i<=n;i++) {
        if(d[i]<<1==len&&d[i]==rd[i]) ans+=num[i]*rn[i]%mod*(num[t]-num[i]*rn[i]%mod+mod)%mod,ans%=mod;
        if(d[i]<<1<len) {
            for(int j=head[i];~j;j=edge[j].nxt) {
                int v=edge[j].to;
                if(rd[v]+d[i]+edge[j].w!=len) continue;
                if(d[v]<<1>len&&d[i]<<1<len) ans+=num[i]*rn[v]%mod*(num[t]-num[i]*rn[v]%mod+mod)%mod,ans%=mod;
            }
        }
    }
    printf("%lld\n",ans);
}
int main() {
    scanf("%d%d%d%d",&n,&m,&s,&t);
    init();int u,v,w;
    while(m--) {
        scanf("%d%d%d",&u,&v,&w);
        addEdge(u,v,w);
        addEdge(v,u,w);
    }
    solve();
    return 0;
}


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


int main() {
  int a1,a2,a3,a4,a5,a6,a7,a8,a9;
  cin>>a1>>a2>>a3>>a4>>a5>>a6>>a7>>a8>>a9;
  int N;
  cin>>N;
  string ans="No";
  set<int> S;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    S.insert(x);
  }
  if( S.count(a1)&&S.count(a2) &&S.count(a3) )ans="Yes";
  if( S.count(a4)&&S.count(a5) &&S.count(a6) )ans="Yes";
  if( S.count(a7)&&S.count(a8) &&S.count(a9) )ans="Yes";
  if( S.count(a1)&&S.count(a4) &&S.count(a7) )ans="Yes";
  if( S.count(a2)&&S.count(a5) &&S.count(a8) )ans="Yes";
  if( S.count(a3)&&S.count(a6) &&S.count(a9) )ans="Yes";
  if( S.count(a1)&&S.count(a5) &&S.count(a9) )ans="Yes";
  if( S.count(a7)&&S.count(a5) &&S.count(a3) )ans="Yes";
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define INF 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

class edge{
public:
	int t,c;
	edge(){}
	edge(int tt,int cc){
		t=tt;
		c=cc;
	}
};

class data{
public:
	int v,c;
	data(){}
	data(int vv,int cc){
		v=vv;
		c=cc;
	}
	bool operator<(const data &d)const{
		return d.c<c;
	}
};

int n,m,r,q;
vector<edge> G[100001];
int dp[10][100001];

void dijkstra(int rest){
	for(int i=1;i<=n;i++){
		if(i%r!=rest)dp[rest][i]=INF;
		else dp[rest][i]=0;
	}
	priority_queue<data> que;
	for(int i=rest;i<=n;i+=r){
		if(i>0)que.push(data(i,0));
	}
	while(que.size()){
		data q=que.top();
		que.pop();
		for(int i=0;i<G[q.v].size();i++){
			edge e=G[q.v][i];
			if(dp[rest][e.t]>dp[rest][q.v]+e.c){
				dp[rest][e.t]=dp[rest][q.v]+e.c;
				que.push(data(e.t,dp[rest][e.t]));
			}
		}
	}
}

int main(void){
	scanf("%d%d%d%d",&n,&m,&r,&q);
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		G[b].push_back(edge(a,c));
	}
	for(int i=0;i<r;i++){
		dijkstra(i);
	}
	ll res=0;
	for(int i=0;i<q;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		int plus=0;
		for(int j=0;j<r;j++){
			plus=max(plus,z-dp[j][x]-dp[j][y]);
		}
		res=(ll)res+plus;
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 12700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; scanf("%lf",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s, t;
  cin >> s >> t;
  if (s == t.substr(0,s.size()) && t.size() == s.size()+1) yn;
  return 0;
}

Measured memory_bytes: 3628
K = int(input())

if K % 2 == 0:
    print(-1)
    exit()

amari = 0

for i in range(1, 10**7):
    amari *= 10
    amari += 7
    amari %= K
    if amari == 0:
        print(i)
        exit()

print(-1)

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

using namespace std;
typedef long long ll;

ll d[10][10];

void warshallFloyd(int n) {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(void) {
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> d[i][j];
    }
  }
  warshallFloyd(10);

  ll a[210][210], cnt[10] = {};
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
      if (a[i][j] < 0 || a[i][j] == 1) continue;
      cnt[a[i][j]]++;
    }
  }

  ll ans = 0;
  for (int i = 0; i < 10; i++) {
    ans += d[i][1] * cnt[i];
  }
  cout << ans << endl;

  return 0;
}

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


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    string ans =  "";
    ans += toupper(a.front());
    ans += toupper(b.front());
    ans += toupper(c.front());
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int quick(const void *a, const void *b) {
      return *(int *)a - *(int *)b;
}

int main(void) {
      int a[6], k, max = 0, min = 124;

      for(int i = 0; i < 5; i++) {
            if(scanf("%d", &a[i]) == 1);
            if(a[i] > max) {
                  max = a[i];
            }
            if(a[i] < min) {
                  min = a[i];
            }
      }
      if(scanf("%d", &k) == 1);

      if(max - min <= k) {
            printf("Yay!");
      } else {
            printf(":(");
      }

      return 0;
}

Measured memory_bytes: 128
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    int N, Y;
    readf("%d %d", &N, &Y);
    Y /= 1000;

    foreach (i; 0..N+1) {
        foreach (j; 0..N-i+1) {
            if (Y == i*10 + j*5 + (N-i-j)) {
                writefln("%d %d %d", i, j, (N-i-j));
                return;
            }
        }
    }
    writeln("-1 -1 -1");
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for (int i = 0; i < n; ++i) {
			int count = 1;
			int y = s.nextInt(), m = s.nextInt(), d = s.nextInt();
			count += ((y % 3 < 1 || m % 2 > 0) ? 20 : 19) - d;

			count += 20 * ((10 - m) / 2);
			count += (y % 3 < 1 ? 20 : 19) * ((10 - m + 1)/ 2);

			for (++y; y < 1000; ++y) {
				count += (y % 3 < 1) ? 200 : 195;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 20640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    int sum=0,sum1=0,sum2=0,sum3=0;
    while(t--){
        string s;
        
        cin>>s;
        if(s[0]=='A')
        sum++;
        if(s[0]=='W')
        sum1++;
        if(s[0]=='T')
        sum2++;
        if(s[0]=='R')
        sum3++;
    }
    cout<<"AC x "<<sum<<endl;
    cout<<"WA x "<<sum1<<endl;
    cout<<"TLE x "<<sum2<<endl;
    cout<<"RE x "<<sum3<<endl;


    
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
#include <vector>
#include <utility>
#include <algorithm>
using P = pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
vector<bool> seen;
int main(){
    int N,t;
    cin >> N;
    vector<int> costs(N);
    vector<vector<P>> T(N,vector<P>(N));
    vector<int> v(N);
    vector<int> ved(N);
    P pa;
    rep(i,N){
       cin >> t;
       cin >> v[i];
       rep(j,v[i]){
           cin >> T[i][j].second >> T[i][j].first;
       }
       sort(T[i].begin(),T[i].begin()+v[i]);
    }
    seen.assign(N, false);
    costs.assign(N,1e9);
    seen[0] = true;
    costs[0] = 0;
    rep(i,N-1){
        pa.first = 1e9;
        rep(j,N){
            rep(k,v[j]){
                if(seen[T[j][k].second])continue;
                if(pa.first > costs[j]+T[j][k].first){
                    pa.first = costs[j]+T[j][k].first;
                    pa.second = T[j][k].second;
                }
            }
        }
        seen[pa.second] = true;
        costs[pa.second] = pa.first;
    }
    rep(i,N){
        cout << i << " " << costs[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
using namespace std;
int main(void)
{
    ios::sync_with_stdio(false);
    int K, A, B, i = 1;
    cin >> K >> A >> B;
    while (K * i < A)
        i++;
    if (K * i <= B)
        puts("OK");
    else
        puts("NG");
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int tc = 1;
    //cin >> tc;
    while(tc--)
    {
        int n;
        char s[105];
        cin >> n >> s;
        int sz = strlen(s);
        if(sz <= n)
            cout << s << endl;
        else{
            int i = 3, j = n;
            for(; i--; j++)
                s[j] = '.';
            s[j] = '\0';
            cout << s << endl;
        }

    }
    return 0;
}


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

void fnInput(int& rnTax8per, int& rnTax10per)
{
  cin >> rnTax8per >> rnTax10per;
}
  
int fnNonTaxKinGet(int nTax8per, int nTax10Per)
{
  vector<int> vnNonTaxKin(10);

  int nNonTax10per = nTax10Per * 10;
  for (int i = 0; i < vnNonTaxKin.size(); i++)
    vnNonTaxKin[i] = nNonTax10per++;

  for (int i = 0; i < vnNonTaxKin.size(); i++)
  {
    int nCalTax8per = vnNonTaxKin[i] * 0.08;
    if (nCalTax8per == nTax8per)
      return vnNonTaxKin[i];
  }
  return -1;
}
  
int main()
{
  int nTax8per, nTax10Per;

  fnInput(nTax8per, nTax10Per);
  cout << fnNonTaxKinGet(nTax8per, nTax10Per) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int H, N, sum=0, sum1=0, i,j;
    scanf("%d %d", &H, &N);
    int arr[N];

    for(i=0; i<N; i++)
    {
        scanf("%d", &arr[i]);

        sum = sum + arr[i];

    }


    if(sum>=H)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

char s[1001];
int l[3][1001][1001];
int main(){
	int n,m,k,a,b,c,d,cnt[3];
	const char key[]={'J','O','I'};
	scanf("%d%d%d",&m,&n,&k);
	reps(i,1,m){
		scanf("%s",s);
		rep(j,3)cnt[j]=0;
		reps(j,1,n){
			rep(k,3){
				if(s[j-1]==key[k])cnt[k]++;
				l[k][i][j]=cnt[k]+l[k][i-1][j];
			}
		}
	}
	rep(i,k){
		scanf("%d%d%d%d",&a,&b,&c,&d);
		a--;b--;
		rep(j,3)
			cnt[j]=l[j][c][d]+l[j][a][b]-l[j][a][d]-l[j][c][b];
		printf("%d %d %d\n",cnt[0],cnt[1],cnt[2]);
	}
	return 0;
}

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

int main(){
        int a, b;
        char op;
        while(1){
                cin >> a >> op >> b;

                if(op == '+')cout << a + b << endl;
                else if(op == '-')cout << a - b << endl;
                else if(op == '*')cout << a * b << endl;
                else if(op == '/')cout << a / b << endl;
                else break;  
        }
}

Measured memory_bytes: 3096
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	int n,m,a[105],p,x,i,t=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		t+=a[i];
	}
	
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d%d",&p,&x);
		int k=t-a[p]+x;
		printf("%d\n",k);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mod=1e9+7;
typedef long long ll;
const int N=2e5+5;
int main()
{int n,k;
	// std::ios::sync_with_stdio(false);std::cin.tie(0);std::cout.tie(0);
	// freopen("a.in","r",stdin);
	// int T;scanf("%d",&T);while(T--){
	scanf("%d%d",&n,&k);
	if(n>k) printf("safe\n");
	else printf("unsafe\n");
	// }
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>

using namespace std;

int main(void)
{
	static string input[1280];
	int cnt = 0;
	
	while (cin >> input[cnt]) cnt++;
	
	string data[10];
	data[0] = "* = ****";
	data[1] = "* =* ***";
	data[2] = "* =** **";
	data[3] = "* =*** *";
	data[4] = "* =**** ";
	data[5] = " *= ****";
	data[6] = " *=* ***";
	data[7] = " *=** **";
	data[8] = " *=*** *";
	data[9] = " *=**** ";
	
	for (int i = 0; i < cnt; i++){
		char output[10][10];
		string cur = "";
		
		for (int j = 0; j < 10; j++){
			for (int k = 0; k < 10; k++){
				output[j][k] = '\0';
			}
		}
		
		for (int j = 0; j < 5 - input[i].length(); j++){
			cur += '0';
		}
		cur += input[i];
		for (int j = 0; j < cur.length(); j++){
			int p = cur[j] - '0';
			for (int k = 0; k < 8; k++){
				output[k][j] = data[p][k];
			}
		}
		for (int j = 0; j < 8; j++){
			printf("%s\n", output[j]);
		}
		if (i + 1 != cnt) cout << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 1240
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] n = line.split(" ");
		int a = Integer.parseInt(n[0]);
		int b = Integer.parseInt(n[1]);

		if (a < b) {
			System.out.println("a < b");

		} else if (a > b) {
			System.out.println("a > b");

		} else {
			System.out.println("a == b");

		}
	}

}


Measured memory_bytes: 26160
icase=0
if icase==0:
    h,w=map(int,input().split())
    a=[]
    aid=["."]*w
    for i in range(h):
        ai=list(input())
        if ai!=aid:
            a.append(ai)
    b=[""]*len(a)
    for j in range(0,w):
        for i in range(len(a)):
            if a[i][j]=="#":
                break
        if a[i][j]=="#":
            for ii in range(len(a)):
                b[ii]=b[ii]+a[ii][j]
    for i in range(len(a)):
        print(b[i])
                

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

typedef long long llt;

const int MaxN = 400 + 5;
const llt INF = 0x7F7F7F7F7F7F7F7F;

int N;
llt A[MaxN], pre[MaxN];
llt dp[MaxN][MaxN];

void init() {
  memset(dp, 0x7F, sizeof dp);
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
}

llt dfs(int l, int r) {
  if (dp[l][r] != INF) return dp[l][r];
  if (l == r) return dp[l][r] = 0;
  for (int k = l; k < r; ++k)
    dp[l][r] = min(dp[l][r], dfs(l, k) + dfs(k + 1, r) + pre[r] - pre[l - 1]);
  return dp[l][r];
}

void solve() {
  for (int i = 1; i <= N; ++i) pre[i] = pre[i - 1] + A[i];
  cout << dfs(1, N) << endl;
}

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

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

int main()
{
    //freopen("FORM.inp", "r", stdin);
    //freopen("FORM.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    long long a[n+1], dp[n+1];
    for(int i = 1; i <= n; i++) cin >> a[i];
    dp[2] = abs(a[1] - a[2]);
    dp[3] = min(abs(a[1] - a[3]), abs(a[2] - a[3]) + dp[2]);
    for(int i = 4; i <= n; i++)
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i-1]), dp[i - 2] + abs(a[i] - a[i-2]));
    cout << dp[n];


}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
 int r;
 if(a<b)
	swap(a,b);
  r = a % b;
  while(r!=0){
	a = b; b = r;
	r = a % b;
  }
  return b;
}
int main(){
	int n,m,t;
  	cin >> n >> m;
  	vector<int> a(n);
  	for(int i = 0; i< n; i++)
      	cin >> a[i];
  	sort(a.begin(),a.end());
  	if(a[n-1] < m) {
    	cout << "IMPOSSIBLE\n";
      	return 0;
    }
  	t = a[0];
	for(int i = 0; i < n;i++) {
  		t = gcd(t,a[i]);
      	if(m % t == 0) {
          	cout << "POSSIBLE\n";
          	return 0;
        }
    }
  	cout << "IMPOSSIBLE\n";
}


Measured memory_bytes: 640
def main():
    n = int(input())
    s = input()
    answer = s.count("R") * s.count("G") * s.count("B")
    for i in range(n):
        for j in range(i + 1, n):
            k = 2 * j - i
            if n <= k:
                continue
            elif s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                answer -= 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

ll A[N],B[N];

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n;
	scanf("%d",&n);
	REP(i,n) scanf("%lld %lld",&A[i],&B[i]);
	ll ans = 0;
	for(int i=n-1;i>=0;i--){
		ll d = (ans+A[i])%B[i];
		d = (B[i]-d)%B[i];
		ans += d;
	}
	printf("%lld\n",ans);
	return 0;
}




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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

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

void solve() {
	int n; scanf("%d", &n);
	int ans = 0;
	int cur = 0;
	for (ans = 1; cur < n; ++ans) {
		cur += ans;
	}
	printf("%d", ans-1);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
while True:
  N = int(input())
  if N==0:
    break
  squa = [[0,0]]
  xmax, xmin, ymax, ymin = 0, 0, 0, 0
  for i in range(N-1):
    n, d = map(int, input().split())
    if d==0:
      squa.append([squa[n][0]-1, squa[n][1]])
      xmin = min(xmin, squa[n][0]-1)
    elif d==1:
      squa.append([squa[n][0], squa[n][1]-1])
      ymin = min(ymin, squa[n][1]-1)
    elif d==2:
      squa.append([squa[n][0]+1, squa[n][1]])
      xmax = max(xmax, squa[n][0]+1)
    elif d==3:
      squa.append([squa[n][0], squa[n][1]+1])
      ymax = max(ymax, squa[n][1]+1)
  print(xmax-xmin+1, ymax-ymin+1)


Measured memory_bytes: 5624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

void solve() {
    int x, y;
    cin >> x >> y;
    bool ok = false;
    fori (i, 0, x + 1) {
        int j = x - i;
        if ((i * 2 + j * 4) == y) {
            ok = true;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	long n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << x * min(k, n) + y * (n - k) * (n > k);
}

Measured memory_bytes: 256