akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <iostream>

using namespace std;

namespace {

struct Process {
  char name[10];
  // required time to process this task.
  int time;
};

// Ring-buffer based queue. Enqueue and dequeue run in O(1).
template <int N>
class Queue {
 public:
  // Note: leave one element empty so that we can distinguish
  // that the ring buffer is empty or full.
  Queue() : size_(N + 1),
            head_(0), tail_(0) {}

  void Enqueue(Process p) {
    assert(!IsFull());
    data_[tail_] = p;
    tail_ = next(tail_);
  }

  Process Dequeue() {
    assert(!Empty());
    auto p = data_[head_];
    head_ = next(head_);
    return p;
  }

  bool IsFull() const {
    return head_ == next(tail_);
  }

  bool Empty() const { return head_ == tail_; }

 private:
  int next(int a) const {
    return (a + 1) % size_;
  }

  Process data_[N + 1];
  const int size_;
  int head_;
  int tail_;
};

} // namespace

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

  Queue<100000> queue;
  for (int i = 0; i < n; ++i) {
    Process p;
    cin >> p.name >> p.time;
    queue.Enqueue(p);
  }

  int current_time = 0;
  while (!queue.Empty()) {
    auto p = queue.Dequeue();
    const int used = min(p.time, q);
    p.time -= used;
    current_time += used;

    if (p.time <= 0) {
      cout << p.name << " " << current_time << endl;
      continue;
    }
    queue.Enqueue(p);
  }
  return 0;
}

Measured memory_bytes: 4604
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  if(s[0]=='S')cout << "Cloudy" << endl;
  else if(s[0]=='R')cout << "Sunny" << endl;
  else cout << "Rainy" << endl;
}  


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<stack>

using namespace std;

int main() {
	long long a, b, d ,r;
	double f;
	cin >> a >> b;
	d = a / b;
	r = a%b;
	f = (double)a / (double)b;
	printf("%lld %lld %.10f", d, r, f);
	return 0;
}

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

int main() {
  int L, R;
  cin >> L >> R;
  int l = L % 2019;
  int r = R % 2019;
  if (L / 2019 != R / 2019){
    cout << 0 << endl;
  }
  else{
    int minimum = 2018;
    for(int i = l; i < r + 1; i++){
      for (int j = i + 1; j < r + 1; j++){
        minimum = min(minimum, i * j % 2019);
      }
    }
    cout << minimum << endl;
  }
}


Measured memory_bytes: 256
N, K = map(int, input().split())
Vs = list(map(int, input().split()))

ans = 0
for x in range(1, min(K, N)+1):
    for i in range(x+1):
        Ts = Vs[:i] + Vs[N-(x-i):]
        sumOut = sum(Ts)
        Ts.sort()

        for T in Ts[:K-x]:
            if T < 0:
                sumOut -= T
            else:
                break

        ans = max(ans, sumOut)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001],n,k;

ll solve(int arr[],int idx)
{
    if(idx>=n-1) return 0;
    if(dp[idx]!=-1) return dp[idx];
    dp[idx]=solve(arr,idx+1)+abs(arr[idx]-arr[idx+1]);
    for(int i=idx+1;i<=idx+k && i<n;i++) dp[idx]=min(dp[idx],abs(arr[i]-arr[idx])+solve(arr,i));
    return dp[idx];
}

int main()
{
   cin>>n>>k;
   int arr[n]; for(int i=0;i<n;i++) cin>>arr[i];
   memset(dp,-1,sizeof(dp));
   cout<<solve(arr,0);
   return 0;
}


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

int main() {
	int S, s1, s2, s3;
	cin >> S;
  	
  	s1 = S / 100;
  	s2 = (S - 100 * s1) / 10;
  	s3 = (S - 100 * s1 - 10 * s2);
   
	cout << s1 + s2 + s3;
}

Measured memory_bytes: 256
def run(N, C, D, c):
    '''
    マス番号に応じて3色に塗る必要がある
    (i+j)%3が0, 1, 2それぞれに対して、何色が何個あるか計算しておく
    ある色に塗るコストを計算する
    0, 1, 2それぞれのC色のコストのパターンができる
    上記コストに対してC色から3色を選択する全パターンのうち最小のコストを求める
    '''
    color0 = {}
    color1 = {}
    color2 = {}
    for k in range(C):
        color0[k] = 0
        color1[k] = 0
        color2[k] = 0
    for i in range(N):
        for j in range(N):
            color = c[i][j] - 1
            if (i+j+2) % 3 == 0:
                color0[color] += 1
            elif (i+j+2) % 3 == 1:
                color1[color] += 1
            elif (i+j+2) % 3 == 2:
                color2[color] += 1
    cost0 = {}
    cost1 = {}
    cost2 = {}
    for k in range(C):
        cost0[k] = 0
        cost1[k] = 0
        cost2[k] = 0
        for i in range(C):
            cost = D[i][k]
            cost0[k] += cost * color0[i] 
            cost1[k] += cost * color1[i] 
            cost2[k] += cost * color2[i] 
    ret = max(cost0.values()) + max(cost1.values()) + max(cost2.values())
    for i in range(C):
        for j in range(C):
            for k in range(C):
                if i == j or j == k or k == i:
                    continue
                else:
                    ret = min(ret, cost0[i]+cost1[j]+cost2[k])
    return ret


def main():
    N, C = map(int, input().split())
    D = []
    for i in range(C):
        D.append(list(map(int, input().split())))
    c = []
    for i in range(N):
        c.append(list(map(int, input().split())))
    print(run(N, C, D, c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;
const int mod = 1e9 + 7;

int main() {
        int n;
        scanf("%d", &n);
        vector<vector<int>> g(n);
        rep(i, n - 1) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        vector<long long> dp(n);
        vector<long long> dp2(n);
        function<void (int, int)> dfs = [&](int u, int prev) {
                for (auto v : g[u]) if (v != prev) {
                        dfs(v, u);
                }
                if (g[u].size() == 1 && u != 0) {
                        dp[u] = 1;
                        dp2[u] = 1;
                        return;
                }
                long long all = 1;
                long long s = 1;
                for (auto v : g[u]) if (v != prev) {
                        (all *= (dp[v] + dp2[v])) %= mod;
                        (s *= dp[v]) %= mod;
                }
                dp[u] = all;
                dp2[u] = s;
        };
        dfs(0, -1);
        printf("%lld\n", (dp[0] + dp2[0]) % mod);
        return 0;
}


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

public class Main
{
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok;

    int INF = 1000000000;

    public void go() throws IOException
    {
        ntok();
        int n = ipar();
        int m = ipar();
        int[] cost = new int[m];
        int[] cover = new int[m];
        for (int i = 0; i < m; i++)
        {
            ntok();
            cost[i] = ipar();
            int b = ipar();
            ntok();
            for (int e = 0; e < b; e++)
            {
                cover[i] |= 1 << (ipar()-1);
            }
        }
        int[][] dp = new int[m+1][1 << n];
        Arrays.fill(dp[m], INF);
        dp[m][(1 << n) - 1] = 0;
        for (int i = m-1; i >= 0; i--)
        {
            for (int e = 0; e < 1 << n; e++)
            {
                dp[i][e] = Math.min(dp[i+1][e], dp[i+1][e|cover[i]] + cost[i]);
            }
        }
        out.println(dp[0][0] == INF ? -1 : dp[0][0]);

        out.flush();
        in.close();
    }

    public void ntok() throws IOException
    {
        tok = new StringTokenizer(in.readLine());
    }

    public int ipar()
    {
        return Integer.parseInt(tok.nextToken());
    }

    public int[] iapar(int n)
    {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = ipar();
        }
        return arr;
    }

    public long lpar()
    {
        return Long.parseLong(tok.nextToken());
    }

    public long[] lapar(int n)
    {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
        {
            arr[i] = lpar();
        }
        return arr;
    }

    public double dpar()
    {
        return Double.parseDouble(tok.nextToken());
    }

    public String spar()
    {
        return tok.nextToken();
    }

    public static void main(String[] args) throws IOException
    {
        new Main().go();
    }
}


Measured memory_bytes: 52564
import java.util.Scanner;

public class Main {
	int[] A;

	public static void main(String[] args) {
		new Main().solve();
	}

	private void solve() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		A = new int[n];

		for (int i = 0; i < n; i++) {
			A[i] = scanner.nextInt();
		}
		int standard =partiton(0, n - 1);
		
		printAnswer(standard);
	}

	private int partiton(int start, int standard) {
		int x = A[standard];
		int i = start - 1;
		for (int j = start; j < standard; j++) {
			if (A[j] <= x) {
				i++;
				swapA(i, j);
			}
		}
		swapA(i+1, standard);
		
		return i+1;
	}
	
	private void printAnswer(int standard){
		boolean isZero=false;
		int i;
		for(i=0;i<standard;i++){
			if(isZero){
				System.out.print(" ");
			}
			isZero=true;
				System.out.print(A[i]);
		}
		if(isZero){
			System.out.print(" ");
		}
		System.out.print("["+A[standard]+"]");
		isZero=true;
		for(i=standard+1;i<A.length;i++){
			System.out.print(" ");
			System.out.print(A[i]);
		}
		System.out.println("");
	}

	private void swapA(int i, int j) {
		int temp = A[j];
		A[j] = A[i];
		A[i] = temp;
	}
}

Measured memory_bytes: 70556
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

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

int main(){
  long long N,a=0,b=0,c=0,d=0;
  cin >> N;
  string S;
  for(int i=0;i<N;i++){
    cin >> S;
    if(S == "AC"){
      a++;
    }
    if(S == "WA"){
      b++;
    }
    if(S == "TLE"){
      c++;
    }
    if(S == "RE"){
      d++;
    }
  }
  
 
  cout << "AC " << "x "<< a << endl;
  cout << "WA " << "x "<< b << endl;
  cout << "TLE " << "x "<< c << endl;
  cout << "RE " << "x "<< d << endl;
 
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {

    int n;
    while (cin >> n) {
        if (n == 0) break;

        int sum = 0, min_ = 1001, max_ = -1;
        for (int i = 0; i < n; i++) {
            int s;
            cin >> s;
            sum += s;
            min_ = min(min_, s);
            max_ = max(max_, s);
        }

        cout << (sum - min_ - max_) / (n - 2) << endl;
    }
}



Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <unordered_map>

const int MOD = pow(10,9)+7;
typedef long long ll;

using namespace std;
int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}


ll digitsof(ll x){
    
    if (x < 10){
        return 1;
    }
    
    return 1 + digitsof(x/10);
    
}


int main() {

    ll N = lin();
    
    ll A = sqrt(N);
    
    string S;
    
    for(auto i = A; i >= 1; i--){
        
        if (N%i == 0){
            
            cout << digitsof(N/i) << endl;
            return 0;
            
        }
        
    }
    
    return 0;
    
}



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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n;
ll x[200000], s[200000];

int main() {
    cin >> n;
    rep(i,n) {
        cin >> x[i] >> s[i];
    }
    ll ans = 0;
    ll val = 0;
    rep(i,n) {
        if (i == 0) {
            ans = s[i];
            val = s[i];
            continue;
        }
        val -= x[i]-x[i-1];
        val = max(val, 0LL);
        val += s[i];
        ans = max(ans, val);
    }
    cout << ans << endl;
}


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

int main() {
  string s;
  cin >> s;
  rep(i, 5) cout << s[i];
  cout << " ";
  rep2(i, 6,13) cout << s[i];
  cout << " ";
  rep2(i, 14, 19) cout << s[i];
  cout << endl;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b; cin >> a >> b;
  int x=stoll(to_string(a)+to_string(b));
  bool f=false;
  int i;
  for(i=1;i*i<x;i++);
  Yes(i*i==x);

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 H,W;
	cin >>H>>W;
	SINT8 N[100][100];

	for (SINT32 i = 0; i < 100; i++) {
		for (SINT32 j = 0; j < 100; j++) {
			N[i][j] = 'A';
		}
	}

	for (SINT32 i = 0; i < H; i++) {
		for (SINT32 j = 0; j < W; j++) {
			cin >> N[i][j];
		}
	}

	for (SINT32 i = 0; i < H; i++) {
		SINT32 BUF = 0;
		for (SINT32 j = 0; j < W; j++) {
			if (N[i][j] == '#') {
				BUF = 1;
				break;
			}
		}
		if (BUF == 0) {
			for (SINT32 j = 0; j < W; j++) {
				N[i][j] = 'A';
			}
		}
	}

	for (SINT32 i = 0; i < W; i++) {
		SINT32 BUF = 0;
		for (SINT32 j = 0; j < H; j++) {
			if (N[j][i] == '#') {
				BUF = 1;
				break;
			}
		}
		if (BUF == 0) {
			for (SINT32 j = 0; j < H; j++) {
				N[j][i] = 'A';
			}
		}
	}




	for (SINT32 i = 0; i < H; i++) {
		SINT32 BUF = 0;
		for (SINT32 j = 0; j < W; j++) {
			
			if (N[i][j] == '#') {
				cout << '#';
				BUF = 1;
			} else if (N[i][j] == '.') {
				cout << '.';
				BUF = 1;
			}
		}
		if (BUF == 1) {
			cout << endl;
		}

	}

	
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

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

int main() {
  int W,H,x,y;
  cin >> W >> H >> x >> y;
  double Ws=W,Hs=H;
  double men;
  men=Ws*Hs/2;
  printf("%f"  , men);
  cout << ' ';
  if(x*2==W && y*2==H)cout << 1;
  else cout << 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  int first=a[0] ,second = a[--n];
  int i=1;
  while(i!=n){
    int mi = min(first,second);
    if(mi==first){
      first += a[i++];
    }else if(mi==second){
      second += a[--n];
    }
  }
  cout << abs(first-second) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]
money = 0

for i in range(N + 1):
    money += abs(A[i] - A[i + 1])

for i in range(1, N + 1):
    print(money - abs(A[i - 1] - A[i]) - abs(A[i + 1] - A[i]) + abs(A[i - 1] - A[i + 1]))

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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int k;
	cin >> k;

	set<string> d;
	rep(i,1,6){
		rep(j,0,s.size()){
			d.insert(s.substr(j,i));
		}
	}
	auto itr = d.begin();
	rep(i,0,k-1){
		++itr;
	}
	cout << *itr << endl;
}


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

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(){
    int N, M;
    cin >> N >> M;
    int food[M] = {};
    REP(i, N){
        int Ki;
        cin >> Ki;
        int A[Ki];
        REP(j, Ki){
            cin >> A[j];
            food[A[j] - 1]++;
        }
    }
    int ans = 0;
    REP(i, M){
        if(food[i] == N){
            ans++;
        }
    }
    printf("%d\n\r", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (3e9)

using namespace std;
typedef long long int ll;

int A, B;
int main(void){
    cin >> A >> B;
    int C, D;
    C = min(A, B);
    D = max(A, B);
    REP(i,D) cout << to_string(C);
    cout << endl;
    return 0;
}



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

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

	cin >> X >> A >> B;

	int ans = B - A;

	if( ans <= 0 ) {
		cout << "delicious" << endl;
	}
	else if( ans - X <= 0 ) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

if b < 0:
    if c <= 0:
        print(a * c)
    else:
        print(b * c)

elif a <= 0:
    if d < 0:
        print(a*c)
    elif a <= 0:
        print(max(a*c, b*d))
    else:
        print(b*d)

else:
    if d < 0:
        print(a * d)
    else:
        print(b * d)

Measured memory_bytes: 8916
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .map { line =>
        val arr = line.split(" ")
        (arr(0).toInt, arr(2).toInt, arr(1).charAt(0))
      }
      .takeWhile { case (_, _, op) => op != '?' }
      .foreach { case (a, b, op) =>
        val answer =
          op match {
            case '+' => a + b
            case '-' => a - b
            case '*' => a * b
            case '/' => a / b
            case _   => 0
          }
        println(answer)
      }
  }
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


int main() {
    int N; cin >> N;
    map<int,int> mp;
    rep(i,N){
        string si; cin >> si;
        mp[si[0]]++;
    }
    vi mp5(5, 0);
    mp5[0] = mp['M'];
    mp5[1] = mp['A'];
    mp5[2] = mp['R'];
    mp5[3] = mp['C'];
    mp5[4] = mp['H'];
    vi pat { 0, 0, 1, 1, 1 };
    ll ans = 0;
    do{
        ll x = 1;
        rep(i,5){
            if (pat[i]) x *= mp5[i];
        }
        ans += x;
    }while(next_permutation(ALL(pat)));

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


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

int main() {
    int S,D,F,G,H,J;
    cin >> S;
    D = S / 3600;
    F = S - D * 3600;
    G = F / 60;
    H = F - G * 60;
    cout << D << ":" << G << ":" << H << endl;
}
    


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
//abc114 C 755 
int dp[10][2][2][2][2][2];//dp[上からi桁][n未満:1,nちょうど:0][3を1度でもつかったか][5を使ったか][7を使ったか][0以外の数字があるか]
//dp配列の最後の添え字fを付けることがポイント。付けないで考えると、数え漏れが起こる(0000357のように、leading-zeroのもの)
//これに気づけず無限にバグらせた、使う数字357のみだしコンテスト中は素直にdfsを書こう

int main()
{ 
   string s;
   cin >> s;
   int n = s.size();
   dp[0][0][0][0][0][0] = 1;
   rep(i,n)rep(j,2)rep(k,2)rep(l,2)rep(m,2)rep(f,2){
       int x = s[i] - '0';
       rep(d,10){
           int ni = i+1,nj = j,nk = k,nl = l,nm = m,nf = f;
           if(!j && d > x)continue;//nちょうどならi+1桁目(d)は0-xまでしか選べない
           if(d < x) nj = 1;//n未満が確定
           
           if(d == 3)nk = 1,nf = 1;//3を使った、0以外の数字を書き込んだ,下二つも同様
           else if(d == 5)nl = 1,nf = 1;
           else if(d == 7)nm = 1,nf = 1;
           else if(d == 0){
               if (f)continue;//000007573...はokだが、0000750700573とかはダメ、桁を0と決めていいのは、まだ数字を書き込んでないときのみ
           }
           else continue;
           dp[ni][nj][nk][nl][nm][nf] +=dp[i][j][k][l][m][f];//状態遷移(ni,njのnはnewのn)
       }
       
   }
   int ans = dp[n][0][1][1][1][1]+dp[n][1][1][1][1][1];//3,5,7をすべて一度以上使っているもののうち、n未満とnちょうどのものの和が答え
   cout << ans << endl;

   

    return 0;
}   

Measured memory_bytes: 256
#include<iostream>
#include<cstdint>
#include<map>
#include<vector>

int const MAXN = 2e5;
int A[MAXN], sum[MAXN+1];
int N, K;

int main() {
  std::cin >> N >> K;
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  sum[0] = 0;
  for(int i = 0; i < N; ++i) sum[i+1] = (((sum[i]+A[i]-1)%K)+K)%K;
  std::map<int, std::vector<int>> m;
  for(int i = 0; i <= N; ++i) m[sum[i]].push_back(i);
  int64_t ans = 0;
  for(auto x: m) if(x.second.size() > 1){
    std::vector<int>& v = x.second;
    for(int i = 0, j = 1; i < v.size()-1; ++i) {
      if(j <= i) j = i+1;
      while(j < v.size() && v[j]-v[i]<K) ++j;
      ans += (int64_t)j-i-1;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
 
int main(int argc, const char * argv[]) {
    
    ll a; cin >> a;
    
    cout << a + a*a + a*a*a << endl;
    
    
    
    
    
    return 0;
}


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

int main() {
  string s; cin >> s;
  bool satisfy = true;
  if (s[0] != 'A') satisfy = false;
  int c = 0;
  for (int i = 2; i < s.size() - 1; i++) {
    if (s[i] == 'C') {
      c++;
    }
  }
  if (c != 1) satisfy = false;
  int upper = 0;
  for (int i = 0; i < s.size(); i++) {
    if ('A' <= s[i] && s[i] <= 'Z') upper++;
  }
  if (upper != 2) satisfy = false;
  cout << (satisfy ? "AC" : "WA") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//clock_t _t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 1010100
	typedef long long ll;
	typedef double db;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
//	void file()
//	{
//		#ifdef NTFOrz
//		freopen("a.in","r",stdin);
//		#endif
//	}
//	inline void chktime()
//	{
//		#ifndef ONLINE_JUDGE
//		cout<<(clock()-_t)/1000.0<<'\n';
//		#endif
//	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
char s[sz],t[sz];
int q[sz],l=1,r;

int main()
{
//	file();
	read(n);
	cin>>(s+1)>>(t+1);
	if (!strcmp(s+1,t+1)) return puts("0"),0;
	int ans=0,pos=n;
	drep(i,n,1)
	{
		if (t[i]==t[i-1]) continue;
		chkmin(pos,i);
		int cur=i;while (t[cur+1]==t[i]) ++cur;
		while (l<=r)
		{
			int x=q[l]-(r-l);
			if (cur>=x) break;
			++l;
		} 
		while (pos&&s[pos]!=t[i]) --pos;
		if (!pos) return puts("-1"),0;
		q[++r]=pos;
		chkmax(ans,r-l+1);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6400
from functools import reduce
from itertools import combinations
from operator import mul


def solve(string):
    n, *s = string.split()
    # num = [len([True for _s in s if _s[0] == _i]) for _i in "M A R C H".split()]
    initial = "MARCH"
    num = [0 for _ in enumerate(initial)]
    for _s in s:
        i = initial.find(_s[0])
        if i < 0:
            continue
        num[i] += 1
    return str(sum([reduce(mul, n) for n in combinations(num, 3)]))


if __name__ == '__main__':
    n = int(input())
    print(solve('{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 12392
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n);
using namespace std;
int main()
{
	MaRiaMa;
	string s,x;
	cin >> s >> x;
	string h = s + x;
	int u = stoi(h);
	double re = sqrt(u);
	if (re == int(re))
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3644
N = int(input())
h = [int(x) for x in input().split()]

def chmin(a, b):
    return a if a <= b else b

dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
        
print(dp[-1])

Measured memory_bytes: 14052
(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let x, y = Scanf.sscanf (read_line ()) "%f %f" ( fun x y -> x, y)

let kame = (y -. (2.0 *. x)) /. 2.0 
let tsuru = x -. kame
let () =
        (
                if kame = (ceil kame) && tsuru = (ceil tsuru) && kame >= 0.0 && tsuru >= 0.0 then
                        "Yes"
                else
                        "No"
        ) |> Printf.printf "%s\n"


Measured memory_bytes: 5536
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
bool judge(int a,int b,int c){
    if(a>b && b>c) return true;
    if(a<b && b<c) return true;
    return false;
}
int main(){
    int n;
    cin >> n;
    int p[n];
    rep(i,n){
        cin >> p[i];
    }
    int cnt = 0;
    for(int i = 1;i<=n-2;i++){
        if(judge(p[i-1],p[i],p[i+1])) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<int> v;

long long int d[210][210];
int INF = 1000000009;

int N,M,R;
int main () {
    for(int i=0; i<205; i++) {
        for(int j=0; j<205; j++) {
            if( i == j ) d[i][j] = 0;
            d[i][j] = INF;
        }
    }
    cin >> N >> M >> R;

    for(int i=0; i<R; i++) {
        int x;
        cin >> x;
        x--;
        v.push_back(x);
    }
    for(int i=0; i<M; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    for(int k=0; k<N; k++) {
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if( d[i][k] + d[k][j] < d[i][j] ) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
    long long int ans = INF;
    sort(v.begin(),v.end());
    do {
        long long int sum = 0;
        for(int i=0; i<R-1; i++) sum += d[v[i]][v[i+1]];
        ans = min( ans, sum);
    } while (next_permutation(v.begin(), v.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
	int k, s, result = 0;
	cin >> k >> s;
 
	for (int x = 0; x <= k; x++)
	{
		for (int y = 0; y <= k; y++)
		{
			if (s - (x + y) <= k && x + y <= s)
			{
				result++;
			}
			// for (int l = 0;l <= k; l++)
			// {
			// 	if (i + j + l == s)
			// 	{
			// 		result++;
			// 	}
			// }
		}
	}
 
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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

const int MAXC = 26;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pair<string, char>> S;
	vector<vector<int>> L(n, vector<int>(MAXC, -1)); 
	map<char, ll> C;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		reverse(all(s));
		if (s.size() == 1) C[s[0]]++;
		else {
			string X = s.substr(0, (int) s.size() - 1);
			S.push_back({X, s.back()});
		}
	}
	sort(all(S));
	for (int i = 0; i < (int) S.size(); i++) {
		L[i][(S[i].second - 'a')] = S[i].first.size();
		for (int j = (int) S[i].first.size() - 1; j >= 0; j--) {
			int c = (S[i].first[j] - 'a');
			L[i][c] = max(L[i][c], j);
		}
	}
	//db("S");
	//for (auto s: S) {
		//cout << s.first << s.second << endl;
	//}
	ll r = 0;
	for (int i = 0; i < (int) S.size(); i++) {
		for (int j = i + 1; j < (int) S.size(); j++) {
			if (S[i].first.size() > S[j].first.size()) break;
			int si = (int) S[i].first.size();
			int last_char = S[i].second - 'a';
			bool good = true;
			for (int k = 0; k < si; k++) {
				good &= (S[i].first[k] == S[j].first[k]);
				
			}
			if (!good) break;
			if (good && L[j][last_char] != -1 &&  L[j][last_char] >= si) {
				r++;
			}
		}
	}
	for (const auto& p: C) {
		for (int i = 0; i < (int) S.size(); i++) {
			if (L[i][p.first - 'a'] != -1) {
				r += p.second;
			}
		}
	}
	cout << r << endl;
}



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

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


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  int n, k; cin>>n>>k;
  string s; cin>>s;
  int sum=0;
  rep(i,n-1)
    if(s[i]==s[i+1]) sum++;
  cout<<min(sum+2*k,n-1)<<endl;
}
  



Measured memory_bytes: 512
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

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

	int N=in();
	int M=N%10;
	if(M==2 || M==4 || M==5 || M==7 || M==9) out("hon");
	else if(M==3) out("bon");
	else out("pon");
	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n),b(n),c(n);
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n;i++)cin>>c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  vector<long long>d(n,0),e(n,0);
  int j=0;
  for(int i=0;i<n;i++){
    for(;a[j]<b[i]&&j<n;j++);
    d[i]=j;
    //printf("%d ",d[i]);
  }
  //puts("");
  j=0;
  for(int i=n-1;i>=0;i--){
    for(;b[i]<c[n-1-j]&&j<n;j++);
    e[i]=j;
    //printf("%d ",e[i]);
  }
  //puts("");
  long long ans=0;
  for(int i=0;i<n;i++){
    ans+=d[i]*e[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(void){
      return;
    };
    HOGE(CLASS1 key, CLASS2 value){
      this->key = key;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N >> M;
  vll X(M);
  REP(i, M){
    cin >> X[i];
  }

  sort(X.begin(), X.end());

  vll Y(M-1);
  REP(i, M-1){
    Y[i] = X[i+1]-X[i];
  }


  sort(Y.begin(), Y.end());

  if(M<=N){
    cout << "0" << "\n";
    return 0;
  }

  ll ans=0;
  REP(i, M-N){
    ans += Y[i];
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    int res = m;
    rep(i, n){
      int2(a, b);
      m += a - b;
      if(m < 0){
        pri(0);
        return 0;
      }
      res = max(res, m);
    }
    pri(res);


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int main(){
	int x;
	cin>>x;
	if(x>=30)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3132
import itertools

n = int(input())
x, y, h = [], [], []
for _ in range(n):
    xi, yi, hi = map(int, input().split())
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)
candidate_cx = list(range(min(x), max(x) + 1))
candidate_cy = list(range(min(y), max(y) + 1))

for cx, cy in list(itertools.product(candidate_cx, candidate_cy)):
    adapted = True
    ch = 0
    for xi, yi, hi in zip(x, y, h):
        ch = max(ch, hi + abs(xi - cx) + abs(yi - cy))
    for xi, yi, hi in zip(x, y, h):
        if hi != ch - abs(xi - cx) - abs(yi - cy):
            adapted = False
            break
    if adapted == False:
        continue
    print(cx, cy, ch, sep = ' ')
    exit(0)

Measured memory_bytes: 3700
import math
import sys
readline = sys.stdin.readline


def main():
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    n = int(readline().rstrip())
    arr = []
    a = n
    for i in range(100):
        if a % 26 == 0:
            b = a // 26 - 1
            c = 26
        else:
            b = a // 26
            c = a % 26
        a = b
        arr.insert(0, c)

        if b == 0:
            break

    string = ''
    for l in range(len(arr)):
        string += alpha[arr[l] - 1]
    print(string)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9144
#include <cstdio> 
#include <iostream>
#include<algorithm>
#include <cstring>

using namespace std;

const int maxn = 2*1000000;
int house[maxn];
int reladis[maxn];

int findm(int arr[],int n){
	int m = 0;
	for(int i = 0; i < n; i++){
		if(arr[i] > arr[m]){
			m = i;
		}
	}
	return m;
}

int main(){
	int K,N;
	int max;
	int mindis;
	scanf("%d%d",&K,&N);
	for(int i = 0; i < N; i++){
		scanf("%d",&house[i]);
		if(i > 0){
			reladis[i] = house[i] - house[i-1];
		}
	}
	reladis[0] = K-house[N-1]+house[0];
	max = findm(reladis,N);
	if(max == 0){
		mindis = house[N-1] - house[0];
	}else{
		mindis = K-house[max]+house[max-1];
	}
	printf("%d",mindis);
}

Measured memory_bytes: 5352
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

def lcm(a,b):
    d = math.gcd(a,b)
    aa = int(a/d)
    bb = int(b/d)
    return aa*bb*d

while True:
    a1,m1,a2,m2,a3,m3 = [int(i) for i in input().split()]
    if a1 == 0 and m1 == 0 and a2 == 0 and m2 == 0 and a3 == 0 and m3 == 0:
        break

    x = 1
    y = 1
    z = 1
    cnt1 = 0
    cnt2 = 0
    cnt3 = 0

    while True:
        x = a1*x % m1
        cnt1 += 1
        if x == 1:
            break

    while True:
        y = a2*y % m2
        cnt2 += 1
        if y == 1:
            break

    while True:
        z = a3*z % m3
        cnt3 += 1
        if z == 1:
            break

    print(lcm(lcm(cnt1,cnt2),cnt3))





Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
const int maxn=500+5;
int mp[maxn][maxn],vis[maxn];
int match[maxn];//表示match[1]=2表示女1和男2约上了(不一定最后是在一起的)
int n;
struct node
{
    int a,b;
}p[105],q[105];
int Find(int x)//这里x表示男生
{
    for(int i=1; i<=n; i++)//这里的i表示女生
        if(!vis[i]&&mp[i][x])//如果这个女生没有询问过而且你和这个男生认识
        {
            vis[i]=1;//标记询问过了
            if(match[i]==-1||Find(match[i]))//如果当前男孩纸是来直接找约会对象，或者是要抛弃当前女孩去找下一个女孩的(而且找到了)
            {
                match[i]=x;//当前男生和女生约上了(x男i女)
                return 1;//返回找到了~~~
            }
        }
    return 0;
}
int main()
{
    scanf("%d",&n);
    memset(mp,0,sizeof(mp));
    memset(match,-1,sizeof(match));
    for(int i=1; i<=n; i++)
        scanf("%d%d",&p[i].a,&p[i].b);
    for(int i=1; i<=n; i++)
        scanf("%d%d",&q[i].a,&q[i].b);
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(p[i].a <q[j].a && p[i].b <q[j].b)
                mp[i][j]=1;
    int ans=0;
    for(int i=1; i<=n; i++)
    {
        memset(vis,0,sizeof(vis));
        if(Find(i))
            ans++;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int count0=0;
  for(int i=0;2*i+1<=N;i++){
    int count1=0;
    for(int j=1; j<=2*i+1;j++){
      if((2*i+1)%j==0) count1++;
    }
    if(count1==8) count0++;
  }

  cout<<count0<<endl;

}


Measured memory_bytes: 256
n = int(input())
l = []
for i in range(n):
  a = input()
  l.append(a)
print(f"{'AC'} x {l.count('AC')}")
print(f"{'WA'} x {l.count('WA')}")
print(f"{'TLE'} x {l.count('TLE')}")
print(f"{'RE'} x {l.count('RE')}")

Measured memory_bytes: 16264