akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int N = scanner.nextInt();// 本数
			if (N == 0) {
				break;
			}

			ArrayList<Train> list = new ArrayList<Train>();
			for (int i = 0; i < N; i++) {
				String[] sf = new String[2];
				sf[0] = scanner.next();
				sf[1] = scanner.next();

				int[][] times = new int[2][3];
				for (int j = 0; j < times.length; j++) {
					String[] tmp = sf[j].split(":");
					for (int k = 0; k < times[j].length; k++) {
						times[j][k] = Integer.parseInt(tmp[k]);
					}
				}
				int start = times[0][0] * 3600 + times[0][1] * 60 + times[0][2];
				int finis = times[1][0] * 3600 + times[1][1] * 60 + times[1][2];
				list.add(new Train(start, 0));
				list.add(new Train(finis, 1));
			}

			Collections.sort(list);
			int max = 0;
			int trains = 0;
			for (Train train : list) {
				if (train.type == 0) {
					trains++;
				} else {
					trains--;
				}
				max = Math.max(max, trains);
			}

			System.out.println(max);
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

	static char nextChar() {
		try {
			int b = System.in.read();
			while (b != -1 && (b == ' ' || b == '\r' || b == '\n'))
				;
			if (b == -1)
				return 0;
			return (char) b;
		} catch (IOException e) {
		}
		return 0;
	}

}

class Train implements Comparable<Train> {
	int time, type;// 出発0、帰還1とする

	Train(int time, int type) {
		this.time = time;
		this.type = type;
	}

	@Override
	public int compareTo(Train arg0) {
		if (this.time == arg0.time) {
			return arg0.type - this.type;
		}
		return this.time - arg0.time;// 昇順
	}
}

Measured memory_bytes: 107024
import scala.io.StdIn.{readInt,readLine}

object Main {
  def bubbleSort(a:Array[Int]):Int = {
    var cnt = 0
    for(i <- 0 until a.length) {
      for(j <- a.length-1 to i+1 by -1) {
        if(a(j) < a(j-1)) {
          val t = a(j)
          a(j) = a(j-1)
          a(j-1) = t
          cnt += 1
        }
      }
    }
    cnt
  }

  def main(args:Array[String]) = {
    val n = readInt
    val a = readLine.split(" ").map(_.toInt)
    val cnt = bubbleSort(a)

    println(a.mkString(" "))
    println(cnt)
  }
}

Measured memory_bytes: 43852
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
	int N,ans,x=1,i;
	scanf("%d",&N);
	for(i=1;i<N;i++){
		ans = i*i;
		if(ans>N) break;
		x = ans;
	}
	printf("%d",x);
	return 0;
}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    S=ii()
    if S<=2:
        print(0)
        return
    a = deque()
    an = deque()
    for _ in range(3, S+1):
        a.append(1)
    ans = 0
    try:
        while True:
            ans += a.pop()
            a.pop()
            a.pop()
            an.append(a.popleft())
            while a:
                an.append(an[-1] + a.popleft())
            a, an = an, a
            an.clear()
    except:
        pass

    print(ans % N1097)






main()



Measured memory_bytes: 71508
#include<stdio.h>
#define LL unsigned long long
#define DIVSUM(a, b, c) ((a)/(b) + (a)/(c) - (a)/((c)*(d)) )

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

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

LL lcm(LL a, LL b) {
    return (a / gcd(a, b) )* b;
}

LL divsum(LL a, LL c, LL d) {
    return a/c + a/d - a/lcm(c, d);
}

int main()
{
    LL a, b, c, d;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    LL a_count, b_count;
    a_count = divsum(a-1, c, d);
    b_count = divsum(b, c, d);
    printf("%lld\n", (b-a+1) - (b_count - a_count));
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> bomb(h+2,(vector<char>(w+2)));
  rep(i,0,h) {
    rep(j,0,w){
      cin >> bomb[i+1][j+1];
    }
  }
  int count = 0;
  rep(i,0,h) {
    rep(j,0,w){
      count = 0;
      if (bomb[i+1][j+1]=='#') continue;
      if (bomb[i][j]=='#') count++;
      if (bomb[i][j+1]=='#') count++;
      if (bomb[i][j+2]=='#') count++;
      if (bomb[i+1][j]=='#') count++;
      if (bomb[i+1][j+2]=='#') count++;
      if (bomb[i+2][j]=='#') count++;
      if (bomb[i+2][j+1]=='#') count++;
      if (bomb[i+2][j+2]=='#') count++;
      bomb[i+1][j+1] = '0' + count;
    }
  }
  
  rep(i,0,h) {
    rep(j,0,w){
      cout << bomb[i+1][j+1];
    }
    cout << endl;
  }
}


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

char swt(char c){
  if(c=='R')return 'L';
  else return 'R';
}

int main(){
  string s;
  cin >> s;
  int n=s.length();
  vector<int>ret(n, 0);
  int cnt=0;
  for(int i=0; i<n; i++){
    if(s[i]=='R')cnt++;
    else{
      ret[i]+=cnt/2;
      ret[i-1]+=cnt-(cnt/2);
      cnt=0;
    }
  }
  cnt=0;
  for(int i=n-1; i>=0; i--){
    if(s[i]=='L')cnt++;
    else{
      ret[i]+=cnt/2;
      ret[i+1]+=cnt-(cnt/2);
      cnt=0;
    }
  }
  for(int i: ret)cout << i << ' ';
  return 0;
}
  

Measured memory_bytes: 1088
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	
	public static void main(String [] args) {
		
		Scanner scan = new Scanner(System.in);
		final int ALPHABET = 26;
		int count;
		char c, lca = 97, ucl = 65;
		String ch;
		ArrayList<String> data = new ArrayList<String>();
		
		while (scan.hasNext()) {
			ch = scan.next();
			data.add(ch);
		} 
		
		
		for (int i = 0; i < ALPHABET; i++) {
			count = 0;
			for ( int j = 0; j < data.size(); j ++) {
				for (int k = 0; k < data.get(j).length(); k++) {
					c = data.get(j).charAt(k);
					if ( lca == c || ucl == c) {
						count++;
					}
				}				
			}
			
			System.out.println (lca + " : " + count);
			lca++;
			ucl++;
		}
		
		scan.close();
		
	}
}



Measured memory_bytes: 26228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a, b, ans = 0;
    cin >> a >> b;
    if (a > b) {
        cout << a - 1 << endl;
        return 0;
    }
    else
        cout << a << endl;
    return 0;
    
}


Measured memory_bytes: 256
def main():
    s = (input())
    # d,t,s = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    t = (input())

    mn = 10**5
    for i in range(len(s)-len(t)+1):
        result = 0
        for j in range(len(t)):
            if s[i+j] != t[j]:
                result += 1
        mn = min(result, mn)

    print(mn)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73288
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll div_ceil(ll, ll);

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

int main() {
  ll N;
  std::cin >> N;
  ll a[N][3];
  REP(i, N) {
    REP(j, 3) { std::cin >> a[i][j]; }
  }
  ll dp[N][3] = {0};
  REP(i, 3) { dp[0][i] = a[0][i]; }
  REP(i, N) {
    if (i > 0) {
      REP(j, 3) {
        REP(k, 3) {
          if (j != k) {
            dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
          }
        }
      }
    }
  }
  ll ans = 0;
  REP(i, 3) { ans = max(ans, dp[N - 1][i]); }
  std::cout << ans << '\n';
}

ll div_ceil(ll a, ll b) {
  ll quotient = a / b;
  ll remainder = a % b;
  if (remainder == 0) {
    return quotient;
  } else {
    return quotient + 1;
  }
}


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



int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll a,b;
    cin>>a>>b;
    ll ans = (a*b)/__gcd(a,b);
    cout<<ans<<"\n";
    return 0;
}


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

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

    bool ans = false;
    for(int i = 0; i < s.size(); i++){
        if(s == t){
            ans = true;
            break;
        }
        s = s.back() + s.substr(0, s.size()-1);
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#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>
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 EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#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)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);

int main() {
	int W, H;
	while(cin >> W >> H, W) {
		vs field(H);
		REP(i, H) {
			cin >> field[i];
		}

		vector<vs> dp(H+2, vs(W+2, "0"));
		string ans = "0";
		FOR(i, 1, H) {
			FOR(j, 1, W) {
				char c = field[i-1][j-1];
				if('0' <= c && c <= '9') {
					string s1 = dp[i-1][j];
					string s2 = dp[i][j-1];
					string tmp;
					if(s1.size() > s2.size()) {
						tmp = s1;
					} else if(s1.size() < s2.size()) {
						tmp = s2;
					} else {
						tmp = max(s1, s2);
					}

					if(tmp == "0") {
						dp[i][j] = c;
					} else {
						dp[i][j] = tmp + c;
					}

					if(dp[i][j].length() > ans.length()) {
						ans = dp[i][j];
					} else if(dp[i][j].length() == ans.length()) {
						ans = max(ans, dp[i][j]);
					}
				} else {

				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s; cin >> s;
  int sizeofs = s.size();
  set<char> sat;
  for(int i = 0; i < sizeofs; i++) {
    sat.insert(s.at(i));
  }
  int sizeofsat = sat.size();
  if(sizeofsat == sizeofs) {
    cout << "yes" << endl;
  }
  else {
    cout << "no" << endl;
  }
}

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

int main() {
  int N, Q; cin >> N >> Q;
  int s, t, x, D[Q]; pair<pair<int, int>, int> W[N];
  for (int i = 0; i < N; i++) {
    cin >> s >> t >> x;
    W[i] = make_pair(make_pair(s, t), x);
  }
  sort(W, W+N, [](auto &a, auto &b) {
    return a.second < b.second;
  });
  for (int i = 0; i < Q; i++) cin >> D[i];
  int dist[Q], index[Q+1];
  for (int i = 0; i < Q; i++) {
    dist[i] = -1; index[i] = i;
  }
  index[Q] = Q;
  for (int i = 0; i < N; i++) {
    s = W[i].first.first; t = W[i].first.second; x = W[i].second;
    int s0 = distance(D, lower_bound(D, D+Q, s-x));
    int t0 = distance(D, lower_bound(D, D+Q, t-x));
    int j = index[s0];
    while (index[j] != j) j = index[j];
    index[s0] = j;
    while (j < t0) {
      if (dist[j] == -1 || x < dist[j]) dist[j] = x;
      index[j] = t0;
      int next_j = index[j+1];
      while (index[next_j] != next_j) next_j = index[next_j];
      j = index[j+1] = next_j;
    }
  }
  for (int i = 0; i < Q; i++) cout << dist[i] << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll mod=1e9+7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll>v;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        v.push_back(a);
    }
    vector<ll>v1=v;
    sort(v1.begin(),v1.end());
    int cnt=0;
    for(int i=0;i<n;i++){
        if(v1[i]!=v[i]){cnt++;}
    }
    if(cnt>2)cout<<"NO"<<endl;
    else{cout<<"YES"<<endl;}
    return 0;
    }


Measured memory_bytes: 256
DREAM = "dream"
ER = "er"
ERASE = "erase"
R = "r"

def judge(str)
  s = str
  while s.length > 0
    if s.start_with?(DREAM)
      s.slice!(0..4)
      if !s.start_with?(ERASE) && s.start_with?(ER)
        s.slice!(0..1)
      end
    elsif s.start_with?(ERASE)
      s.slice!(0..4)
      if s.start_with?(R)
        s.slice!(0)
      end
    else
      break
    end
  end
  puts s.length > 0 ? "NO" : "YES"
end

s = gets.chomp
judge(s)


Measured memory_bytes: 81272
class SegmentTree():
    """
    update, get を提供するSegmentTree

    Attributes
    ----------
    __n : int
        葉の数。2 ^ i - 1
    __dot :
        Segment function
    __e: int
        単位元
    __node: list
        Segment Tree
    """
    def __init__(self, A, dot, e):
        """
        Parameters
        ----------
        A : list
            対象の配列
        dot :
            Segment function
        e : int
            単位元
        """
        n = 2 ** (len(A) - 1).bit_length()
        self.__n = n
        self.__dot = dot
        self.__e = e
        self.__node = [e] * (2 * n)
        for i in range(len(A)):
            self.__node[i + n] = A[i]
        for i in range(n - 1, 0, -1):
            self.__node[i] = self.__dot(self.__node[2 * i], self.__node[2 * i + 1])
    
    def update(self, i, c):
        i += self.__n
        node = self.__node
        node[i] = c
        while i > 1:
            i //= 2
            node[i] = self.__dot(node[2 * i], node[2 * i + 1])

    def get(self, l, r):
        vl, vr = self.__e, self.__e
        l += self.__n
        r += self.__n
        while (l < r):
            if l & 1:
                vl = self.__dot(vl, self.__node[l])
                l += 1
            l //= 2
            if r & 1:
                r -= 1
                vr = self.__dot(vr, self.__node[r])
            r //= 2
        return self.__dot(vl, vr)


def main():
    import sys
    readline = sys.stdin.readline
    # readlines = sys.stdin.readlines
    N, T = map(int, input().split())
    A = list(map(int, readline().split()))

    if N == 2:
        print(1)
        return
    
    L = SegmentTree(A, min, float('inf'))
    R = SegmentTree(A, max, 0)

    profit = 0
    for i in range(1, N + 1):
        l = L.get(0, i + 1)
        r = R.get(i, N + 1)
        profit = max(profit, r - l)
    
    cnt = 0
    for i in range(N):
        l = L.get(0, i + 1)
        r = R.get(i, N + 1)
        if r - l == profit:
            if l == A[i]:
                L.update(i, l - 1)
            else:
                R.update(i, r + 1)
            cnt += 1
    
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 78596
#include <stdio.h>

int main(void){
	int n,i,x,odd1=0,odd2=0,even1=0,even2=0;
	int j;
	int odd[100001]={0},even[100001]={0};

	scanf("%d",&n);
	for(i=0;i<n/2;i++){
		scanf("%d",&x);
		odd[x] = odd[x] +1;
		scanf("%d",&x);
		even[x] = even[x] +1;
	}

	for(i=0;i<100001;i++){
		if(odd[odd1] < odd[i]){
			odd2 = odd1;
			odd1 = i;
		}else if(odd[odd2] < odd[i]){
			odd2 = i;
		}
		if(even[even1] < even[i]){
			even2 = even1;
			even1 = i;
		}else if(even[even2] < even[i]){
			even2 = i;
		}
	}
	if(odd1 == even1){
		j = (odd[odd1] + even[even2]) > (odd[odd2] + even[even1]) ? (odd[odd1] + even[even2]) : (odd[odd2] + even[even1]);
	}else{
		j = odd[odd1] + even[even1];
	}
	printf("%d\n",n-j);
}

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

long long N;

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  int ans = 0;
  for(int i = 2; i * i <= N; i++) {
    int cnt = 0;
    while(N % i == 0) {
      N /= i;
      cnt++;
    }
    for(int num = 1; cnt > 0; num++) {
      if(cnt >= num) ans++;
      cnt -= num;
    }
  }
  if(N > 1) ans++;
  cout << ans << "\n";
}

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

const int MAX_N = 10000000;

bool sieve[MAX_N + 1];
int main()
{
    rep(i, MAX_N + 1) sieve[i] = true;
    for (int i = 2; i * i <= MAX_N; i++){
        for (int j = i * i; j <= MAX_N; j += i){
            sieve[j] = false;
        }
    }
    vector<int> quad_prime;
    for (int i = 13; i <= MAX_N; i += 2){
        if (sieve[i] && sieve[i - 2] && sieve[i - 6] && sieve[i - 8]){
            quad_prime.push_back(i);
        }
    }

    int n;
    while (n = in()){
        printf("%d\n", quad_prime[upper_bound(quad_prime.begin(), quad_prime.end(), n) - quad_prime.begin() - 1]);
    }

    return (0);
}

Measured memory_bytes: 10976
a,b,c,x,y = map(int,input().split())
ans = 0
if 2*c >= a+b:
    print(a*x+b*y)
else:
    while x >= 1 and y >= 1:
        ans += 2*c
        x -= 1
        y -= 1
    print(min(ans + a*x+b*y,ans + 2*c*(x+y)))


Measured memory_bytes: 9104
n,k=map(int,input().split());m=2*k;a=[(m+1)*[0]for _ in[0]*(m+1)];z=lambda i,j:(a[i][j]-a[i-k][j]-a[i][j-k]+a[i-k][j-k])*2+a[m][m]-a[i][m]-a[m][j]+a[i-k][m]+a[m][j-k]
for _ in[0]*n:x,y,c=input().split();x=int(x);y=int(y)+k*(c=="B");a[x%m+1][y%m+1]+=1
for i in range(m):
  for j in range(m):a[i+1][j+1]+=a[i][j+1]+a[i+1][j]-a[i][j]
print(max(max(max(z(i,j),n-z(i,j))for j in range(k,m+1))for i in range(k,m+1)))

Measured memory_bytes: 108088
#include <stdio.h>
#include <math.h>

int main( void ) {
	int i, e, y, z, min;

	while ( scanf( "%d", &e ), e ) {
		min = e;
		for ( z = 0; z * z * z <= e; z++ ) {
			y = sqrt( e - z * z * z );

			if ( e - y * y - z * z * z + y + z < min )
				min = e - y * y - z * z * z + y + z;
		}

		printf( "%d\n", min );
	}

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
  int S, h, e, m, s;
  scanf("%d", &S);
  h = S / 3600;
  e = S % 3600;
  m = e / 60;
  s = e % 60;
  printf("%d:%d:%d\n", h , m ,s);
  return 0;
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int N;
  scanf("%d", &N);
  bool w = 0;
  while (N) {
    w |= (N%10 == 7);
    N /= 10;
  }
  if (w) printf("Yes\n");
  else printf("No\n");
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  solve();
	return 0;
}



Measured memory_bytes: 3732
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


int main() {
	int N; cin >> N;
	vector<int>x, y, h;
	vector<int>master;
	REP(i, N) {
		int a, b, c; cin >> a >> b >> c;
		x.push_back(a);
		y.push_back(b);
		h.push_back(c);
		if (master.size() == 0 && c > 0) {
			master.push_back(a);
			master.push_back(b);
			master.push_back(c);
		}
	}

	REP(i, 101) {
		REP(j, 101) {
			int localH = master[2] + abs(i - master[0]) + abs(j - master[1]);
			bool flag = true;
			REP(k, N) {
				if (h[k] != max(0, localH - abs(x[k] - i) - abs(y[k] - j))) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cout << i << " " << j << " " << localH << endl;
				return 0;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		for(int i = 0; i < adjList.size(); i++) {
			for(int j = 0; j < totalVertex; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		for(int i = 0; i < adjList.size(); i++) {
			for(int j = 0; j < adjList.get(i).size(); j++) {
				adjMatrix[i][adjList.get(i).get(j)] = 1;
				
			}
		}
		
		for(int i = 0; i < adjList.size(); i++) {
			for(int j = 0; j < totalVertex; j++) {
				if(j == totalVertex - 1) {
					System.out.print(adjMatrix[i][j]);
				}
				else {
					System.out.print(adjMatrix[i][j] + " ");
				}
				
			}
			System.out.println();
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


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

using namespace std;
typedef pair<int,int> pii;
const int N = 100010;
int _w;

int n, m, deg[N];

namespace G {
	int head[N], nxt[N*2], to[N*2], w[N*2], eid;
	void init() {
		eid = 0;
		memset(head, -1, sizeof head);
	}
	void link( int u, int v ) {
		to[eid] = v, nxt[eid] = head[u], head[u] = eid++;
		to[eid] = u, nxt[eid] = head[v], head[v] = eid++;
	}
}

vector<int> con;
bool vis[N];

void bfs( int s ) {
	int cnt = 0, maxd = 0;
	queue<int> q;
	q.push(s), vis[s] = 1;
	while( !q.empty() ) {
		int u = q.front(); q.pop();
		++cnt, maxd = max(maxd, deg[u]);
		using namespace G;
		for( int i = head[u]; ~i; i = nxt[i] ) {
			int v = to[i];
			if( !vis[v] ) {
				vis[v] = 1;
				q.push(v);
			}
		}
	}
	if( cnt > 1 ) {
		con.push_back(maxd/2);
	}
}

vector<int> eq;
int cur[N];

void euler( int u ) {
	using namespace G;
	for( int &i = cur[u]; ~i; ) {
		int nowi = i;
		i = nxt[i];
		int v = to[nowi];
		if( w[nowi] ) continue;
		w[nowi] = w[nowi^1] = 1;
		euler(v);
	}
	eq.push_back(u);
}

stack<int> stk;

int main() {
	cin >> n >> m;
	G::init();
	for( int i = 0; i < m; ++i ) {
		int u, v;
		_w = scanf( "%d%d", &u, &v );
		G::link(u, v);
		++deg[u], ++deg[v];
	}
	for( int i = 1; i <= n; ++i )
		if( deg[i] & 1 ) {
			puts("No");
			return 0;
		}
	for( int i = 1; i <= n; ++i )
		if( !vis[i] )
			bfs(i);
	if( con.size() > 3 ) {
		puts("No");
		return 0;
	}
	int sum = 0;
	for( int tmp : con )
		sum += tmp;
	if( sum >= 3 ) puts("Yes");
	else {
		int cnt4 = 0;
		for( int i = 1; i <= n; ++i )
			if( deg[i] == 4 )
				++cnt4;
		if( cnt4 >= 3 ) {
			puts("Yes");
			return 0;
		}
		for( int i = 1; i <= n; ++i )
			cur[i] = G::head[i];
		euler(1);
		int ans = 0;
		memset(vis, 0, sizeof vis);
		for( auto it = eq.rbegin(); it != eq.rend(); ++it ) {
			int u = *it;
			if( vis[u] == 0 ) {
				vis[u] = 1;
				stk.push(u);
			} else {
				++ans;
				while(1) {
					int v = stk.top();
					stk.pop();
					vis[v] = 0;
					if( v == u ) break;
				}
				stk.push(u);
				vis[u] = 1;
			}
		}
		puts( ans >= 3 ? "Yes" : "No" );
	}
	return 0;
}


Measured memory_bytes: 13880
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
   
   int N;
   string S;
   cin >> N >> S;
  
   int ans = 0;
   for (int i = 1; i < N; i++) {
      int count = 0;
      for (char c = 'a'; c <= 'z'; c++) {
         bool flg1 = false;
         for (int j = 0; j < i; j++) {
            if (S[j] == c) {
               flg1 = true;
               break;
            }
         }
         bool flg2 = false;
         for (int j = 0; j < N - i; j++) {
            if (S[N - j - 1] == c) {
               flg2 = true;
               break;
            }
         }
         if (flg1 && flg2) count++;
      }
      if (ans < count) ans = count;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
//typedef long long int;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int mini = INF;
int a[1500001];

void dfs(int n, int k, int K)
{
    if(k == n+K) return;
    
    for(int i=0;i < n;i++){
        for(int j=i+1;j < k;j++)
            mini = min(mini, a[i]-a[j]);
    }
    dfs(n-1,k+1,K);
}

int main()
{
    int n,k;
    cin >> n >> k;
    
    for(int i=0;i < n;i++){
        cin >> a[i];
    }
    sort(a,a+n,greater<int>());
    
    for(int i=0;i <= n-k;i++){
        mini = min(mini, a[i]-a[i+k-1]);
    }

    cout << mini << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
      ll N, A,B;
	cin >> N >> A >> B;
	if (A%2==B%2) {
		ce(B-(A+B)/2)
	}
	else {
		ce(min({ N - A,B - 1,N-B+1+N-(A+N-B+1+N)/2,A+(B-A+1)/2 -1 }))
	}
	

    return 0;
}



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

using namespace std;

typedef long long ll;

#define MOD 1000000007

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

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

int main() {
    int r, d, x;
    int tmp;
    cin >> r >> d >> x;
    rep(i, 10) {
        int tmp = x;
        x = r * x - d;
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 3564
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Path
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int N = 4;

/* typedef */

/* global variables */

int es[N], cs[N];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    es[a]++, es[b]++;
  }

  for (int i = 0; i < N; i++) cs[es[i]]++;

  if (cs[1] == 2 && cs[2] == 2) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static long Mod = (long)1e9 + 7;
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }
        static void Solve()
        {
            var x = Sarray()[0];
            var ans = x / 11 * 2;
            if (x % 11 != 0) ++ans;
            if (6 < x % 11) ++ans;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 28144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC152_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var min = Math.Min(ab[0], ab[1]);
            var max = Math.Max(ab[0], ab[1]);
            Console.WriteLine(new string(min.ToString()[0], max));
        }
    }
}


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

typedef unsigned long long int ll; 
#define MOD 1000000007
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ff first
#define ss second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define mk make_pair
#define pb push_back
#define po pop_back




int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int arr[n][n-1];
  rep(i,n)
  	rep(j,n-1)
  		cin >> arr[i][j];

  vector <int> v;
  rep(i,n){
  	v.push_back(0);
  }
  ll c = 0;
  ll m = (n*(n-1))/2;
  ll nm = 0;
  while(nm!=m){
  	int tc = 0;
  	vector <int> kela;
  	for(int i=0;i<n;i++){
  		if(v[i]!=n-1){
  			int against = arr[i][v[i]]-1;
  			if(against<=i)
  				continue;
  			int opp = arr[against][v[against]];
	  		if(arr[against][v[against]] == i+1 ){
	  			// cout << i+1 << against+1 << endl;
	  			tc++;
	  			kela.push_back(i);
	  			kela.push_back(against);
	  		}
  		}
  	}

  	if(tc==0){
  		cout << -1 << endl;
  		return 0;
  	}
  	for(int k=0;k<kela.size();k++){
  		v[kela[k]]++;
  	}
  	nm+=tc;
  	c++;
  	
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int bf[3] = { 1,2,4 };

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int dp[1005][8] = { 0 };
	for (int i = 0; i < 8; i++) {
		dp[1][i] = 1;
		if (!(i&(1<<0))) {
			dp[1][i] = 0;
		}
		//cout << dp[1][i] << endl;
		if (s[0] == 'J') {
			if (!(i&(1 << 0))) {
				dp[1][i] = 0;
			}
		}
		if (s[0] == 'O') {
			if (!(i&(1 << 1))) {
				dp[1][i] = 0;
			}
		}
		if (s[0] == 'I') {
			if (!(i&(1 << 2))) {
				dp[1][i] = 0;
			}
		}
		//cout << dp[1][i] << endl;
	}
	//cout << endl;
	for (int i = 2; i <= n; i++) {
		for (int j = 0; j < 8; j++) {
			for (int k = 0; k < 8; k++) {
				for (int m = 0; m < 3; m++) {
					if ((j&(1<<m)) && (k&(1<<m))) {
						dp[i][j] += dp[i - 1][k];
						break;
					}
				}
			}
			//cout << dp[i][j] << endl;
			if (s[i-1] == 'J') {
				if (!(j&(1 << 0))) {
					dp[i][j] = 0;
				}
			}
			if (s[i-1] == 'O') {
				if (!(j&(1 << 1))) {
					dp[i][j] = 0;
				}
			}
			if (s[i-1] == 'I') {
				if (!(j&(1 << 2))) {
					dp[i][j] = 0;
				}
			}
			dp[i][j] %= 10007;
		}
	}
	int res = 0;
	for (int i = 0; i < 8; i++) {
		res += dp[n][i];
		res %= 10007;
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin >> n;
  int64_t ans=0;
  for(int i=1;i<=n;i++){
    if(i%3==0&&i&5==0) continue;
    else if(i%3==0) continue;
    else if(i%5==0) continue;
    else ans+=i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;

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

int a[100][100],wf[20][100][100],p[20],q[50],r[51],sum[51];
int n,m,c,s,g,x,y,d,id,tmp;
const int INF = (1<<28);

int main(){
  while(scanf("%d%d%d%d%d",&n,&m,&c,&s,&g),n){
    REP(i,n)REP(j,n){
      a[i][j] = INF;
      REP(k,c)wf[k][i][j] = INF;
    }
    
    REP(i,m){
      scanf("%d%d%d%d",&x,&y,&d,&id);
      x--; y--; id--;
      wf[id][x][y] = min(wf[id][x][y],d);
      wf[id][y][x] = min(wf[id][y][x],d);
    }
    
    REP(l,c){
      scanf("%d",&p[l]);
      REP(k,n)REP(i,n)for(int j=i;j<n;j++){
	wf[l][i][j] = wf[l][j][i] = min(wf[l][i][j],wf[l][i][k] + wf[l][k][j]);
      }
    }

    REP(k,c){
      q[0] = 0;
      REP(i,p[k]-1)scanf("%d",&q[i+1]);
      q[p[k]] = INF;
      REP(i,p[k])scanf("%d",&r[i]);
      sum[0] = 0;
      REP(i,p[k])sum[i+1] = sum[i] + r[i]*(q[i+1]-q[i]);

      REP(i,n)for(int j=i;j<n;j++){
	if(wf[k][i][j] < INF){
	  tmp = upper_bound(q,q+p[k]+1,wf[k][i][j])-q-1;
	  a[i][j] = a[j][i] = min(a[i][j],sum[tmp] + r[tmp]*(wf[k][i][j]-q[tmp]));
	}
      }
    }

    REP(k,n)REP(i,n)for(int j=i;j<n;j++)a[i][j] = a[j][i] = min(a[i][j],a[i][k] + a[k][j]);

    printf("%d\n",(a[s-1][g-1]>=INF)?-1:a[s-1][g-1]);
  }
}

Measured memory_bytes: 1848
import copy

N, M, Q = [int(_) for _ in input().split()]
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q

for i in range(Q):
    xs = [int(_) for _ in input().split()]
    a[i] = xs[0] - 1
    b[i] = xs[1] - 1
    c[i] = xs[2]
    d[i] = xs[3]


def calc_score(A):
    acc = 0
    for i in range(Q):
        if c[i] == A[b[i]] - A[a[i]]:
            acc += d[i]
    return acc


max_score = -1


def dfs(A):
    if len(A) == N:
        global max_score
        max_score = max(calc_score(A), max_score)
    else:
        if len(A) == 0:
            A.append(1)
        else:
            A.append(A[-1])
        while (A[-1] <= M):
            dfs(copy.deepcopy(A))
            A[-1] += 1


dfs([])
print(max_score)


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

int GCD(int x, int y){
  int r;
  while(y){
    r=x%y;
    x=y;
    y=r;
  }
  return x;
}

int main(){
    int H,W,C;
    cin >> H >> W >> C;
    cout << H*W/GCD(H,W)/GCD(H,W)*C << endl;
    return 0;
}



Measured memory_bytes: 3136
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7


N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
Ka = sum(B)-sum(A)
Kb = Ka
for a,b in zip(A,B):
    if a < b:
        Ka -= (b-a+1)//2
print('Yes' if Ka >= 0 and Kb >= 0 else 'No')




Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int, int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int, int>
#define umii            unordered_map<int, int>
#define pqmax           priority_queue<int>
#define pqmin           priority_queue<int, vi, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y) / gcd(x, y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x

void __print(int x) {cout<<x;}
void __print(float x){cout<<x;}
void __print(double x){cout<<x;}
void __print(ld x) {cout<<x;}
void __print(char x){cout <<'\''<<x<<'\'';}
void __print(const char *x){cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
void __print(bool x) {cout<<(x?"true":"false");}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}void _print() {cout << "]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif

int power(int x, int y, int p = mod){
    int res = 1;
    x %= p;
    while(y > 0){
        if(y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res; 
}

int inv(int x, int p = mod){
    return power(x, p - 2) % p;
}

const int N = 1e6 + 6;

struct quantity{
    int a, b, c;
};
 
int32_t main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--){
       
        int n; cin>>n;
        mk(arr, n+1, quantity);
        for(int i=1; i<=n; i++)
            cin>>arr[i].a>>arr[i].b>>arr[i].c;

        int dp[n+1][3];
        dp[1][0] = arr[1].a;
        dp[1][1] = arr[1].b;
        dp[1][2] = arr[1].c;

        for(int i=2; i<=n; i++){
            dp[i][0] = arr[i].a + max(dp[i-1][1], dp[i-1][2]);
            dp[i][1] = arr[i].b + max(dp[i-1][0], dp[i-1][2]);
            dp[i][2] = arr[i].c + max(dp[i-1][0], dp[i-1][1]);
        }

        int ans = max({dp[n][0], dp[n][1], dp[n][2]});
        cout<<ans;
    }

    return 0;

}

Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
using ll = long long;

using namespace std;

int main() {
	ll N;
	cin >> N;
	ll sum = 1, x;

	int flag = 0;

	for (ll i = 0; i < N; i++) {
		cin >> x;
		if (x == 0) {
			flag = 2;
			break;
		}
		if ((double)x > 1000000000000000000.0 / (double)sum) {
			flag = 1;
		}
		sum *= x;
		
	}
	if (flag == 0) {
		if (sum <= 1000000000000000000) {
			cout << fixed << setprecision(0) << sum << endl;
		}
		else {
			cout << -1 << endl;
		}
	}
	else if (flag == 1) {
		cout << -1 << endl;
	}
	else {
		cout << 0 << endl;
	}

	return 0;
}


Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main() {
    int N, x;
    cin >> N >> x;

    int a[N];

    long long ans = 0;

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

    if (a[0] > x) {
        ans += a[0] - x;
        a[0] = x;
    }

    for (int i = 1; i < N; ++i) {
        int sum = a[i] + a[i-1];
        if (sum > x) {
            ans += sum - x;
            a[i] = x - a[i - 1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;

string s;

int main()
{
	cin >> s;
	for (int i=0; i<4; i++) cout << s[i];
	cout << " ";
	for (int i=4; i<12; i++) cout << s[i];
	cout << endl;
	return 0;
}


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

    int N;
    cin >> N;
    vector<int> X(N), L(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i) >> L.at(i);
    }

    vector<pair<int, int>> p(N);
    for (int i = 0; i < N; i++) {
        p[i].first = X[i] + L[i]; // 終端を先に入れておく
        p[i].second = X[i] - L[i];
    }

    sort(p.begin(), p.end()); // 終端を優先にソート

    int ans = 1;
    int t = p[0].first; // t:=現在までに選択した区間の中で一番後ろの点
    for (int i = 1; i < N; i++) {
        if (t <= p[i].second) {
            ans++;
            t = p[i].first;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2300
# Contest: DISCO Presents Discovery Channel Code Contest 2020 Qual (https://atcoder.jp/contests/ddcc2020-qual)
# Problem: A: DDCC Finals (https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_a)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


M = {
    1: 300000,
    2: 200000,
    3: 100000,
}
x, y = rints()
print(M.get(x, 0) + M.get(y, 0) + (400000 if x == y == 1 else 0))


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

int main() {
  int x, y, i = 0, o = 0;
  cin >> y >> x;
  while (x != 0 || y != 0) {
    while (i != y) {
      for (o = 0; o < x; o++) {
        cout << "#";
        }
      cout << endl;
      i++;
    }
    cout << endl;
    i = 0, o = 0;
    cin >> y >> x;
  }
}


Measured memory_bytes: 3088
from copy import deepcopy
from sys import stdin

def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())
def LI(): return list(map(int,stdin.readline().rstrip().split()))
def R(x):
    r = round(x)
    if r+0.5 <= x:
        r += 1
    return r

n = I() + 1

l = list(range(n))

i = 3
j = 5
while i < n:
    if 0<l.count(i):
        l.remove(i)
    i *= 3
    if j < n:
        if 0<l.count(j):
            l.remove(j)
        j*=5

ans = 0
for i in range(len(l)):
    if l[i]%3 != 0 and l[i]%5 != 0:
            ans += l[i]

print(ans)


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

int main() {
 long long x;
  cin >> x;
  long long ans=0;
  long long z=10;
  if(x%2){
    cout << 0 << endl;
    return 0;
  }
  while(z<=x){
    ans+=x/z;
    z*=5;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);

        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int c = stdIn.nextInt();
        //int x = stdIn.nextInt();
        //int num[] = new int[];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        //for(int i = 0; i < s.length(); i++){
        //}

        if(a + b + c >= 22) {
        	System.out.println("bust");
        }else {
        	System.out.println("win");
        }


        //System.out.println();
        //System.out.print();

        stdIn.close();
    }
}


Measured memory_bytes: 21588
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

k, n = LI()
a = LI()

# 一周kメートルの円形湖があり、n軒の家がある。
# i番目のいえは北端から時計回りにAメートルのところにある。
# いずれかの家から出発してn件すべての家に尋ねるための最短移動距離を求めよ

# 円形で考えるからややこしい
# 一番距離が長い家と家の区間を除外した直線状と考えればよいのでは。

far = []

for i in range(0,n):
    if i == 0:
        d = a[0] + k - a[-1]        
    else:
        d = a[i] - a[i-1]

    far.append(d)

longest = 0

for i in range(n):
    if far[i] > longest:
        longest = far[i]
        longest_i = i
del far[longest_i]
print(sum(far))

Measured memory_bytes: 99540