akhauriyash/Code-Regression huggingface dataset:
/*
* @Author Silviase(@silviasetitech)
* For ProCon
*/

import java.util.*;
import java.lang.*;
import java.math.*;

class Main{

    static int n;
    static long[] times;
    static int m;
    static long ans;
    static int[] rate;
    static int var;
    static int ansmin;
    static int ansmax;
    static int[] w;
    static int[] ww;
    static boolean[] visit;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        n = sc.nextInt();
        ans = 1;
        times = new long[n];
        for (int i = 0; i < n; i++) {
            times[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            ans = lcm(ans , times[i]);
        }
        System.out.println(ans);

        sc.close();
    }

    public static long gcd(long a, long b) {
        
        if (a < b) {
            long tmpp = a;
            a = b;
            b = tmpp;
        }
        if (b == 0) {
            return a;
        }else{
            return gcd(b, a%b);
        }
    }

    public static long lcm(long a, long b) {
        long gcd = gcd(a,b);
        return a/gcd*b;
    }

    public static void dfs(int placenow) {
        // if went all -> success! 
        // if not went all -> fail...
        
        /*
         dfs
         Go All Place that there is way to and not having been yet. 

         if island 1 is start point, dfs(1);
         if there is way to island 2 and island 3,
         - island 2 changes non-visited -> visited, and dfs(2).
         - island 3 changes non-visited -> visited, and dfs(3).
         

        */

        visit[placenow] = true;
        boolean success = true;
        for (int i = 0; i < n; i++) {
            if (visit[i] == false) { // not go all place
                success = false;
                break;
            }
        }
        if (success) {
            ans++;
            visit[placenow] = false;
            return;
        }

        for (int i = 0; i < m; i++) {
            if (w[i] == placenow && visit[ww[i]] == false ) {
                dfs(ww[i]);
            }else if(ww[i] == placenow && visit[w[i]] == false){
                dfs(w[i]);
            }else{
                continue;
            }
        }
        visit[placenow] = false;
        return;
    }

}



Measured memory_bytes: 21972
#include <iostream>

using namespace std;

typedef long long ll;

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

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

ll f(ll x, int c, int d)
{
	ll res = x;
	res -= x / c;
	res -= x / d;
	res += x / lcm(c,d);
	return res;
}

int main(void)
{
	ll a, b;
	int c, d;
	cin >> a >> b >> c >> d;
	ll ans = f(b, c, d) - f(a - 1, c, d);
	cout << ans << endl;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int a,b,c,n=0;
    cin >> a >> b >> c;
    for (int i=a; i<=b; i++) {
        if(c%i==0) n++;
    }
    cout << n << endl;
    return 0;
}



Measured memory_bytes: 3104
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
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)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        a,b = LI()
        a -= 1
        b -= 1
        v[a].append(b)
        v[b].append(a)
    d = [0]*n
    d[0] = 1
    q = deque([0])
    p = [None]*n
    while q:
        x = q.popleft()
        nd = d[x]+1
        for y in v[x]:
            if not d[y]:
                d[y] = nd
                p[y] = x
                q.append(y)
    V = list(range(n))
    V.sort(key = lambda x:-d[x])
    t = [1]*n
    for x in V[:-1]:
        t[p[x]] += t[x]
    ans = 0
    p = pow(2,n-1,mod)
    for x in range(n):
        tx = t[x]
        if len(v[x]) < 2:
            continue
        s = p-1
        for y in v[x]:
            ty = t[y]
            if tx < ty:
                s -= pow(2,t[0]-tx,mod)-1
            else:
                s -= pow(2,ty,mod)-1
            s %= mod
        ans += s
        ans %= mod
    print(ans*pow(2,(mod-2)*n%(mod-1),mod)%mod)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 98808
#include <stdio.h>

int main(void)
{
	int N,v,i,j,k;
	
		scanf("%d",&N);
	
		int A[N];
	
		for( i = 0; i<N; i++)
		{
			scanf("%d",&A[i]);
		}
	
		for( i = 0; i < N; i++)
		{
			v = A[i];
			j = i - 1;
			while( j>=0 && A[j] > v)
			{
				A[j+1] = A[j];
				j--;
				
			}
			
		    A[j+1] = v;
			
			for(k = 0; k< N; k++)
			{
				printf("%d",A[k]);
			
				if(k<N-1)
				{
					printf(" ");
				}
			}
			printf("\n");
		}
	return 0;
}
	


Measured memory_bytes: 2092
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {
	long res = 0;
	long X, A; cin >> X >> A;

		if (X >= A) res = 10;

	cout << res << endl;
}

Measured memory_bytes: 256
numbers = input().split(" ")
enemy_num = int(numbers[0])
kill_num = int(numbers[1])

enemy_hp_list = input().split(" ")
for i, hp in enumerate(enemy_hp_list):
  enemy_hp_list[i] = int(hp)

enemy_hp_list.sort(reverse=True)
target = enemy_hp_list[kill_num:]
count = 0
for i in target:
  count += i
print(count)

Measured memory_bytes: 20176
#ifdef __GNUG__
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
#endif

//#pragma optimize GCC("O3")
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int r, c, k;
	cin >> r >> c >> k;
	vector<vector<vector<ll> > > dp(r + 1, vector<vector<ll> >(c + 1, vector<ll>(4, 0))); // kolko uz zobral
	vector<vector<ll> > v(r + 1, vector<ll>(c + 1, 0));
	for (int i = 0; i < k; i++)
	{
		int ri, ci;
		ll vi;
		cin >> ri >> ci >> vi;
		v[ri][ci] = vi;
	}
	ll ans = 0;
	for (int i = 1; i <= r; i++)
	{
		for (int j = 1; j <= c; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				dp[i][j][k] = max({ dp[i][j][k], dp[i - 1][j][0], dp[i - 1][j][1], dp[i - 1][j][2], dp[i - 1][j][3], dp[i][j - 1][k] });
				ans = max(ans, dp[i][j][k]);
			}
			for (int k = 3; k >= 0; k--)
			{
				if (k)
				{
					dp[i][j][k] = max({ dp[i][j][k], dp[i][j][k - 1] + v[i][j] });
				}
				ans = max(ans, dp[i][j][k]);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int n,m;
int dp[4096];

void solve(){
    int i,j,k;
    cin >> n >> m;
    vector<int> a(m),b(m),c(m,0);
    for(i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        for(j = 0;j < b[i];j++){
            cin >> k;
            k--;
            c[i] |= 1<<k;
        }
    }
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;
    for(i = 0;i < m;i++){
        for(j = 0;j < (1<<n);j++){
            if(dp[j] > -1){
                k = j|c[i];
                if(dp[k] == -1) dp[k] = dp[j] + a[i];
                else dp[k] = min(dp[k],dp[j]+a[i]);
            }
        }
    }
    cout << dp[(1<<n)-1] << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;

int n, ar[1000001], l, r, ans, c, k;

int main()
{
    cin >> n >> c >> k;
    for(int i = 0; i < n; i++)
        scanf("%d", &ar[i]);
    sort(ar, ar + n);

    while(l < n)
    {
        while(ar[r + 1] - k <= ar[l] && r < n - 1 && r - l + 1 < c)
            r++;
        ans++;
        l = r + 1;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
# 素数の数を数える
# n
# i1
# i2
# ...
# in
import math

def is_prime(x):
    if x == 1:
        return False

    for j in range(2, int(math.sqrt(x))+1):
        if x % j == 0: return False

    return True

n = int(input())
print(sum([(1 if is_prime(int(input())) else 0) for _ in range(n)]))


Measured memory_bytes: 5760
N=int(input())
v=[[0,None] for _ in range(N)]
for i in range(N):
  v[i][0],v[i][1]=input().split()            
ans=0
for i in range(N):
  if v[i][1]=='JPY':
    ans+=int(v[i][0])
  else:
    ans+=float((v[i][0]))*380000
print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    vector<bool> v(1e9, false);
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        a--;
        if (v[a] == false)
        {
            ans++;
            v[a] = true;
        }
        else
        {
            ans--;
            v[a] = false;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 122368
#include <stdio.h>
#define abs(a) ((a)<0 ? -(a) : (a))
#define min(a, b) ((a)<(b) ? (a) : (b))

int main(){
  int n, h[100001], dp[100001] = {0};
  scanf("%d", &n);
  for(int i=0; i<n; i++) scanf("%d", &h[i]);

  dp[0] = 0, dp[1] = abs(h[1]-h[0]);
  for(int i=2; i<n; i++){
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
  }

  printf("%d\n", dp[n-1]);
  return 0;
}


Measured memory_bytes: 896
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

constexpr auto INF = numeric_limits<ll>::max();

int main() {
  ll N;
  cin >> N;

  const ll mid = N / 1.08;
  ll answer = INF;
  for (ll i = -1; i <= 1; i++) {
    ll X = mid + i;
    const ll R = X * 1.08;
    if (R == N) {
      answer = X;
    }
  }
  if (answer == INF) {
    cout << ":(" << endl;
  } else {
    cout << answer << endl;
  }
  return 0;
}


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

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

constexpr int MOD = 10000;

void decr(std::string& s) {
    std::reverse(s.begin(), s.end());
    for (auto& c : s) {
        if (c != '0') {
            --c;
            break;
        } else {
            c = '9';
        }
    }
    std::reverse(s.begin(), s.end());
}

int calc(std::string s, int m) {
    std::reverse(s.begin(), s.end());

    auto dp = vec(2, vec(2, vec(10, vec(m, 0))));
    {
        char c = s.front();
        int dmax = c - '0';

        for (int ch = 0; ch <= 1; ++ch) {
            for (int d = 0; d <= 9; ++d) {
                dp[0][ch][d][d % m] = 1;
                if (d <= dmax) {
                    dp[1][ch][d][d % m] = 1;
                }
            }
        }

        s.erase(s.begin());
    }

    int ret = 0, ten = 10 % m;
    bool first = true;
    for (char c : s) {
        for (int ch = 0; ch <= 1; ++ch) {
            if (first && ch == 1) continue;
            for (int d = 1; d <= 9; ++d) {
                (ret += dp[0][ch][d][0]) %= MOD;
            }
        }
        first = false;

        int dmax = c - '0';
        auto ndp = vec(2, vec(2, vec(10, vec(m, 0))));

        for (int ch = 0; ch <= 1; ++ch) {
            for (int pd = 0; pd <= 9; ++pd) {
                for (int r = 0; r < m; ++r) {
                    int lpval = dp[0][ch][pd][r],
                        tpval = dp[1][ch][pd][r];

                    for (int d = 0; d <= 9; ++d) {
                        if ((ch == 0 && pd >= d) || (ch == 1 && pd <= d)) continue;

                        int nr = (r + ten * d) % m;

                        // loose -> loose
                        (ndp[0][1 - ch][d][nr] += lpval) %= MOD;

                        // loose -> tight
                        if (d < dmax) {
                            (ndp[1][1 - ch][d][nr] += lpval) %= MOD;
                        }

                        // tight -> tight
                        if (d == dmax) {
                            (ndp[1][1 - ch][d][nr] += tpval) %= MOD;
                        }
                    }
                }
            }
        }
        dp = ndp;

        (ten *= 10) %= m;
    }

    for (int ch = 0; ch <= 1; ++ch) {
        if (first && ch == 1) continue;
        for (int d = 1; d <= 9; ++d) {
            (ret += dp[1][ch][d][0]) %= MOD;
        }
    }

    return ret;
}

void solve() {
    std::string a, b;
    int m;
    std::cin >> a >> b >> m;
    decr(a);
    std::cout << (calc(b, m) - calc(a, m) + MOD) % MOD << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3380
#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 INF (1e9)

using namespace std;
int N;
int A[3][100001];
int dp[3][100001];
int main(void){
    cin >> N;
    rep(i,N) scanf("%d %d %d",&A[0][i+1], &A[1][i+1], &A[2][i+1]);
    dp[0][1] = A[0][1];
    dp[1][1] = A[1][1];
    dp[2][1] = A[2][1];

    for(int i = 2;i<=N;i++) rep(j,3) dp[j][i] = max(dp[(j+1)%3][i-1], dp[(j+2)%3][i-1]) + A[j][i];
    cout << max(max(dp[0][N],dp[1][N]),dp[2][N]) << endl;
    return 0;
}



Measured memory_bytes: 2560
// AUTHOR - SANDEEP PRADHAN
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include<limits.h>


#define eps 1e-8
#define PI 3.141592653589793
#define bsize 512

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define bs 1000000007

using namespace std;

int longestCommonSubsequence(string s1, string s2, vector<vector<int>>& dp) 
{
    for (int i = 1; i <= s1.size(); i++) 
    {
        for (int j = 1; j <= s2.size(); j++) 
        {
            if (s1[i-1] == s2[j-1]) 
                dp[i][j] = dp[i-1][j-1] + 1;

            dp[i][j] = max({dp[i][j], dp[i][j-1], dp[i-1][j]});
        }
    }
    return dp[s1.size()][s2.size()];
}

int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    string s1, s2; 
    cin >> s1 >> s2;

    vector<vector<int>> dp(s1.size()+1, vector<int>(s2.size()+1, 0));
    int count = longestCommonSubsequence(s1, s2, dp);   // This will give count of lcs and change the dp vector

    string s = "";
    int i = s1.size(), j = s2.size();
    while (i > 0 && j > 0) 
    {
        if (dp[i-1][j-1] + 1 == dp[i][j] && dp[i-1][j] + 1 == dp[i][j] && dp[i][j-1] + 1 == dp[i][j]) 
        {
            i--; 
            j--; 
            s = s1[i] + s; //As we are travelling backward reverse the string
        }
        else if (dp[i][j-1] > dp[i-1][j]) 
            j--;
        else
            i--;
    }
    cout << s << endl;

    return 0;
}


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

using namespace std;

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

  vector<int> v(n);

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

  sort(v.begin(), v.end());
  for(int i=1; i<n; i++){
    if(v[i] == v[i-1]){
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
  return 0;
}


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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define inf (0x3f3f3f3f)

using namespace std;

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

template<class T>inline T read(T &_) {
	T __ = getchar(), ___ = 1; _ = 0;
	for (; !isdigit(__); __ = getchar()) if (__ == '-') ___ = -1;
	for (; isdigit(__); __ = getchar()) _ = (_ << 3) + (_ << 1) + (__ ^ 48);
	return _ *= ___;
}

template<class T>inline bool chkmax(T &_, T __) { return _ < __ ? _ = __, 1 : 0; }
template<class T>inline bool chkmin(T &_, T __) { return _ > __ ? _ = __, 1 : 0; }

inline void proStatus() {
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>());
}

const int N = 2e5 + 9;

ll n, L, ans, a[N], b[N], Sa[N], Sb[N];

ll Qa(int l, int r) { return Sa[r] - Sa[l - 1]; }
ll Qb(int l, int r) { return Sb[r] - Sb[l - 1]; }

void Solve() { 
	for (int i = n; i; -- i) { 
		int blen = (n - i) >> 1, alen = n - i - blen;
		chkmax(ans, ((n - i) & 1 ? b[n - blen] : a[n - alen]) + (Qb(n - blen + 1, n) + Qa(i, i + alen - 1)) * 2);
	}
}

int main() {

	read(L), read(n);

	for (int i = 1; i <= n; ++ i) { 
		b[i] = L - read(a[i]);
		Sa[i] = Sa[i - 1] + a[i];
		Sb[i] = Sb[i - 1] + b[i];
	}
	Solve();

	for (int i = 1; i <= n; ++ i) 
		a[i] = b[n - i + 1];

	for (int i = 1; i <= n; ++ i) {
		b[i] = L - a[i];
		Sa[i] = Sa[i - 1] + a[i];
		Sb[i] = Sb[i - 1] + b[i];
	}
	Solve();

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int d = in.nextInt();
        int[] ci = new int[26];
        int[][] sdi = new int[d][26];
        for(int i=0; i<26; i++) {
            ci[i] = in.nextInt();
        }
        for(int day=0; day<d; day++) {
            for(int i=1; i<26; i++) {
                sdi[day][i] = in.nextInt();
            }
        }
        
        // TODO : calc!
        
        for(int i=0; i<d; i++) {
            System.out.println((i%26) + 1);
        }
    }
}


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

int main() {
  string S;
  int cnt=0;
  cin >> S;
  rep(i, S.size()/2){
    if(S.at(i)!=S.at(S.size()-i-1)) cnt++;
  }
 cout << cnt << endl;
}

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

int main(){
	int sum = 0, minx = 10;
	for (int i=0;i<5;i++){
		int temp;
		cin >> temp;
		sum += (temp-1)/10*10 + 10;
		if (temp%10 != 0) minx = min(minx,temp%10);
	}
	sum += minx-10;
	cout << sum;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;
 
int main() {
    int n,c;
    cin >> n >> c;
    vector<vector<int>> d(c,vector<int>(c)),t(3,vector<int>(c));
    rep(i,c) {
        rep(j,c) cin >> d[i][j];
    }
    int tin;
    rep(i,n) {
        rep(j,n) {
            cin >> tin;
            ++t[(i+j)%3][tin-1];
        }
    }
    int ans=1000000000;
    rep(i,c) {
        rep(j,c) {
            rep(k,c) {
                if (i==j || j==k || k==i) continue;
                int tans=0;
                rep(l,c) {
                    tans+=t[0][l]*(d[l][i]);
                    tans+=t[1][l]*(d[l][j]);
                    tans+=t[2][l]*(d[l][k]);
                }
                ans=min(ans,tans);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8


yes = 'Heisei'
no = 'TBD'

def main():
    y, m, d = map(int, input().split('/'))
    if y < 2019:
        print(yes)
        return
    if y == 2019:
        if m <= 4:
            print(yes)
            return
    print(no)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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


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

  int n,m;
	cin >> n >> m;

	vector<int> num(n,-1);
	rep(i, m) {
	  int s, c;
		cin >> s >> c;
		if (num[n-s] == -1 || num[n-s] == c) num[n-s] = c;
		else {
			cout << -1 << endl;
			return 0;
		}
	}

	rep(i, 1000) {
		if(!(pow(10,n-1) <= i && i < pow(10,n)) && !(i == 0 && n == 1)) continue;
		bool e = true;
		rep(d,n) {
		  e = e && (num[d] == (i / (int) pow(10,d) % 10) || num[d] == -1);
		}
		if (e) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		int k=Integer.valueOf(s);
		s=br.readLine();
		int n=s.length();
		if(n<=k)
			System.out.println(s);
		else
		{
			String t=s.substring(0,k);
			t=t+"...";
			System.out.println(t);
		}
	}

}


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

long long lcm(long long x,long long y){
  return x / __gcd(x,y) * y;
}
int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  long long l = lcm(c, d);
  long long all=b-a+1, cs=(a+c-1)/c, ce=b/c, ds=(a+d-1)/d, de=b/d, ls=(a+l-1)/l, le=b/l;
  cout << all-(ce-cs+1)-(de-ds+1)+(le-ls+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

/*----------------------------------------------*/
int check[30][52];

signed main(){
  int n;
  cin>>n;
  string s[50];
  rep(i,n) cin>>s[i];
  rep(i,n){
    rep(j,s[i].size()){
      int k=s[i][j]-'a';
      check[k][i]++;
    }
  }
  string ans;
  rep(i,26){
    int t=50;
    rep(j,n) chmin(t,check[i][j]);
    rep(_,t) ans.push_back('a'+i);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import collections


def prime_decomp(j):
    if j == 1:
        return [1]

    num = j
    s = 0
    R = int(num)
    L = []
    while s == 0:
        for i in range(2, R+1):
            if num % i == 0:
                num = num/i
                if num == 1:
                    s = 1
                L.append(i)
                break

    return L


if __name__ == '__main__':
    x = int(input())

    for t in range(x):
        y = x - t
        nums = prime_decomp(y)
        counter = collections.Counter(nums)

        if y == 1000:
            print(1000)
            exit()

        if len(counter) == 1:
            for key, val in counter.items():
                if val == 1:
                    continue

                else:
                    print(y)
                    exit()

        ans = True
        for key, val in counter.items():
            if val % 2 != 0:
                ans = False

        if ans:
            print(y)
            exit()

    print(1)


Measured memory_bytes: 3444
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

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

int bfs(int x, int y, vector<vector<char>> S,  vector<vector<int>> & mp) {
	queue<P> q;
	int ret = 0;
	q.push(make_pair(y, x));
	mp[y][x] = 0;

	while (!q.empty())
	{
		P c_pos = q.front(); q.pop();
		ret = max(ret, mp[c_pos.first][c_pos.second]);

		int nx, ny;
		for (int i = 0; i < 4; ++i) {
			ny = c_pos.first + dy[i];
			nx = c_pos.second + dx[i];
			if (0 <= nx && nx < W && 0 <= ny && ny < H &&
				S[ny][nx] != '#' && mp[ny][nx] == -1) {
				mp[ny][nx] = mp[c_pos.first][c_pos.second] + 1;
				q.push(make_pair(ny, nx));
			}
		}
	}

	return ret;
}

int main()
{
	cin >> H >> W;
	vector<vector<char>> S(H, vector<char>(W, '0'));
	rep(i, H) {
		rep(j, W) {
			cin >> S[i][j];
		}
	}

	int ans = 0;
	rep(i, H) {
		rep(j, W) {
			if (S[i][j] != '#') {
				vector<vector<int>> mp(H, vector<int>(W, -1));
				int t = bfs(j, i, S, mp);
				ans = max(ans, t);
			}

		}
	}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, q, k, a, b, c, x, y;
vector<P> es[100001];
ll d[100001];

void dfs(int v, int pa, ll t) {
	d[v] = t;
	REP(i, es[v].size()) if (es[v][i].F != pa) dfs(es[v][i].F, v, t + es[v][i].S);
}

int main(int argc, char **argv) {
	cin >> n;
	REP(i, n - 1) {
		cin >> a >> b >> c;
		es[a].push_back(MP(b, c));
		es[b].push_back(MP(a, c));
	}
	cin >> q >> k;
	dfs(k, 0, 0);
	REP(i, q) {
		cin >> x >> y;
		cout << (d[x] + d[y]) << endl;
	}
	return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(){
  ll n; cin >> n;
  cout << n/500*1000 + n%500/5*5 << endl;
}

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

using namespace std;

#define LL long long

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

int main() {
	int n, a;
	bool flag = true;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (a % 2 == 0) {
			if ((a % 3) && (a % 5)) {
				flag = false;
			}
		}
	}
	if (flag) {
		cout << "APPROVED" << endl;
	}
	else {
		cout << "DENIED" << endl;
	}
	return 0;
}

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

int main() {
  ll r,l;
  cin >> l >> r;
  if(r-l>=673){
    cout << 0 << endl;
    return 0;
  }
  int MIN=2019;
  bool s=false;
  rep2(i,l,r){
    rep2(j,i+1,r+1){
      MIN=min(MIN,((i%2019)*(j%2019))%2019);
     /* if(MIN==758&&!s){
        cout << i << ' ' << j << endl;
        s=true;
      }*/
    }
  }
  cout << MIN << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define COUNT_RESET 0
#define LOOP_RESET 0
int serch_word(unsigned char * str1, unsigned char * str2);
unsigned short s_scan_word(unsigned char * str, unsigned short length_max);

int main(){
	unsigned char str1[10], str2[1000];
	unsigned int long1, long2;
	unsigned int count = 0;
	unsigned char end_sentence[] = {"END_OF_TEXT\n"};
	unsigned int i;
	
	for(i = 0;i < 10;i++){
		str1[i] = 0;
	}
	for(i = 0;i < 1000;i++){
		str2[i] = 0;
	}
	
	long1 = s_scan_word(str1, 1000);
	
	while(1){
		long2 = s_scan_word(str2, 1000);
		if(serch_word(end_sentence, str2) == 1){
			break;
		}
		
		for(i = 0;i < long1;i++){
			str1[i] |= 0x60;
		}
		for(i = 0;i < long2;i++){
			str2[i] |= 0x60;
		}
		if(long1 == long2){
			count += serch_word(str1, str2);
		}
		for(i = 0;i <= long2;i++){
			str2[i] = 0;
		}
	}
	
	printf("%d\n", count);
	return 0;
}

/* 関数名：文字列入力 */
/* 概要：文字列を入力する。入力された文字列の長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_word(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if((*(str + usW_C_i) == ' ') || (*(str + usW_C_i) == '\n')){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

int serch_word(unsigned char * str1, unsigned char * str2)
{
	unsigned char * word = str1, * sent = str2;
	unsigned int frg = 0;
	unsigned int i = 0;
	while(1){
		if(*(word + i) == '\n'){
			frg =1;
		}
		if(*(word + i) != *(sent + i)){
			break;
		}
		i++;
	}
	
	return frg;
}


Measured memory_bytes: 2036
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) throws IOException {
		/**
		 * ?????°?????£?¨?
		 */
		int n = 0;
		int temp = 0;
		/**
		 * ???????????£?¨?
		 */
		ArrayList<Integer> reverse = new ArrayList<Integer>();
		/**
		 * ??\?????¨?????????????´?
		 */
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine()); //??\???????????????????????\???
		String box[] = new String[n];
		String str = br.readLine();
		box = str.split(" ");
		/**
		 * int???????????¨????????????????´?
		 */
		for(int i = 0; i < n; ++i){
			temp = Integer.parseInt(box[i]);
			reverse.add(temp);
		}
		for (int j = n-1; j >= 0; --j) {
			System.out.print(reverse.get(j));
			if (j != 0) {
				System.out.printf(" ");
			}
			else{
				System.out.println("");
			}
		}
	}
}

Measured memory_bytes: 24504
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,cnt=0;
	cin>>n;
	string s;
	cin>>s;
	for (int i = 3; i <=n; ++i)
		{
			if(s[i-3]=='A'&&s[i-2]=='B'&&s[i-1]=='C'){
				cnt++;
			}
		}	
		cout<<cnt;
   return 0;
}


Measured memory_bytes: 3608
A = []
for i in range(3):
    for j in input().split():
        A.append(int(j))

bingo = False
for n in range(int(input())):
    num = int(input())
    if num in A:
        A[A.index(num)] = 0
    if A[0] == A[1] == A[2] == 0: bingo = True
    if A[3] == A[4] == A[5] == 0: bingo = True
    if A[6] == A[7] == A[8] == 0: bingo = True
    if A[0] == A[3] == A[6] == 0: bingo = True
    if A[1] == A[4] == A[7] == 0: bingo = True
    if A[2] == A[5] == A[8] == 0: bingo = True
    if A[0] == A[4] == A[8] == 0: bingo = True
    if A[2] == A[4] == A[6] == 0: bingo = True

if bingo:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

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

    int N, M; cin >> N >> M;
    Yes(N == M);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	double x1, y1, x2, y2, d;
	cin >> x1 >> y1 >> x2 >> y2;
	d = sqrt(pow((x2-x1), 2)+pow((y2-y1), 2));
	cout << fixed << setprecision(12) << d << endl;
	return 0;
}

Measured memory_bytes: 1288
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
inline int maxn(int a, int b){
    return a > b ? a : b;
}
char s[110], t[110];
inline bool cmp(char a, char b){
    return a > b;
}
int main(){
    gets(s);
    gets(t);
    int x = strlen(s), y = strlen(t);
    sort(s, s + x);
    sort(t, t + y, cmp);
    int n = maxn(x, y);
    for(int i = 0; i < n; ++i){
        if(s[i] < t[i]){
            cout << (char)89 << (char)101 << (char)115;
            return 0;
        }
        if(s[i] > t[i]) break;
    }
    cout << (char)78 << (char)111;
    return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> s = nextCharArray();
      String output = "";
      for(int i = 0; i < s.size(); i += 2){
        output += s.get(i);
      }
      myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 61368
#include <iostream>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

int main(){
    int N; cin >> N;
    ll ans = 0;
    rep(i, N) ans += i;
    cout << ans << endl; 
    return 0;
}

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

int main(void)
{
    bool judge = true;
    string s;
    int count[150];
    cin >> s;
    for(int i = 0;i < 150;i++){count[i] = 0;}
    for(int i = 0;i < s.size();i++)
    {
        if(count[s[i]] == 0){count[s[i]] += 1;}
        else{judge = false; break;}
    }
    if(judge){cout << "yes" << endl;}
    else{cout << "no" << endl;}
    return 0;
}

Measured memory_bytes: 256
import fractions


def func(n, c, d):
    x = n // c
    y = n // d
    z = n // (c * d // fractions.gcd(c, d))

    return n - x - y + z


a, b, c, d = map(int, input().split())

print(func(b, c, d) - func(a - 1, c, d))


Measured memory_bytes: 5048
#include<bits/stdc++.h>
int L,M,N,r,c;
int main(){
  scanf("%d",&L);
  N=floor(log2(L))+1;
  r=L-(1<<(N-1));
  M=(N-1)*2+__builtin_popcount(r);
  c=1<<(N-1);
  printf("%d %d\n",N,M);
  for(int i=1;i<N;i++)printf("%d %d %d\n%d %d %d\n",i,i+1,0,i,i+1,1<<(i-1));
  for(int i=N-2;i>=0;i--)if(L&(1<<i))printf("%d %d %d\n",i+1,N,c),c+=1<<i;
}


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

int main(){
    ll a, b, k;
    cin>>a>>b>>k;
    if(k<=a){
        a -= k;
    }else if(k<=a+b){
        b -= k-a;
        a = 0;
    }else{
        a = 0;
        b = 0;
    }
    cout<<a<<' '<<b<<endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
a_ = set(a)
x = Counter(a)
y = {i:x[i]*(x[i]-1)//2 for i in a_}

res = sum(y.values())
for i in a:
    t = x[i]
    t_ = y[i]
    print(res-t_+(t-1)*(t-2)//2)

Measured memory_bytes: 36252
n, m = gets.split.map(&:to_i)
xs = gets.split.map(&:to_i).sort!

dists = (m - 1).times.with_object(Array.new(m - 1, 0)) do |i, a|
  a[i] = xs[i + 1] - xs[i]
end.max(n - 1)

puts xs.last - xs.first - (dists.inject(:+) || 0)


Measured memory_bytes: 10480
N, M = map(int, input().split())
a = [tuple(map(int, input().split())) for i in range(M)]
a.sort(key=lambda x:x[1])
divided = [0 for i in range(N-1)]

p = 0
for i in a:
    # 分断済みなら次の関係へ
    if p >= i[0]:
        continue
    
    # 分断
    p = i[1]-1
    divided[p -2]=1
    
print(sum(divided))

Measured memory_bytes: 18244
#include <iostream>
using namespace std;
int main(void){
    int N,M,a=1;
    cin>>N>>M;
    for(int i=1;i*i<=M&&i<=M/N;i++){
        if(M%i==0){
            a=max(a,i);
             if(M/i<=M/N){
                a=max(a,M/i);
             }
        }
    }
    cout<<a<<endl;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
p = [int(i)-1 for i in input().split()]
c = [int(i) for i in input().split()]
INF = float("INF")
ans = -INF
for i in range(n):
    flag = [False]*n
    now = i
    cnt = 0
    j = 0
    mlst = [-INF]*n
    m = -INF
    while not flag[now]:
        flag[now] = True
        now = p[now]
        cnt += c[now]
        m = max(cnt,m)
        mlst[j] = m
        j += 1
    # print(mlst)
    q,r = divmod(k,j)
    if q == 0: res = mlst[r-1]
    elif cnt >= 0 and r == 0: res = cnt*(q-1)+mlst[j-1]
    elif cnt >= 0: res = max(cnt*q+mlst[r-1],cnt*(q-1)+mlst[j-1])
    else: res = mlst[j-1]
    # print("res",res)
    ans = max(ans,res)
print(ans)

Measured memory_bytes: 98104
$n=<>;$h[$|--]{$_}--for glob<>;
($u,$x,$v,$y)=map$h[$i++/2]{$_},@a=map{(sort{$$_{$a}-$$_{$b}}keys%$_)[0,1]}@h;
print$n+("@a"-$a[2]?$u+$v:$u+$y<$v+$x?$u+$y:$v+$x)

Measured memory_bytes: 30208
#include<stdio.h>
int main(){
    int i, r, z, n, m, l;
long  x[101][101] = {}, y[101][101] = {}, c[101][101] = {};
 
    scanf("%d %d %d", &n, &m, &l);
    for( i = 0; i < n; i++ ){
        for( r = 0; r < m; r++ ){
            scanf("%d", &x[i][r]);
        }
    }
    for( i = 0; i < m; i++ ){
        for( r = 0; r < l; r++ ){
            scanf("%d", &y[i][r]);
        }
    }
    for( i = 0; i < n; i++ ){
        for( r = 0; r < l; r++ ){
            for( z = 0; z < m; z++ ){
                c[i][r] += x[i][z] * y[z][r];
            }
            if( r == l - 1 ){
                printf("%ld", c[i][r]);
            }else{
            printf("%ld ", c[i][r]);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 852
s = input()
l = len(s)

ans = 0
for i in range(2 ** (l -1)):
    ans_sub = 0
    subst = s[0]
    for j in range(l-1):
        if(i>>j)&1:
            ans_sub += int(subst)
            subst = s[j+1]
        else:
            subst += s[j+1]
        if j ==l-2:
            ans_sub += int(subst)
    ans += ans_sub
if l == 1:
    print(int(s))
else:
    print(ans)

Measured memory_bytes: 9212
import sys
input=sys.stdin.readline
n,m=map(int,input().split())
INF=10**9
w=[[INF]*n for i in range(n)]
for i in range(n):
    w[i][i]=0
V=[]
for i in range(m):
    a,b,c=map(int,input().split())
    V.append((a-1,b-1,c))
    w[a-1][b-1]=c
    w[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):
            w[i][j]=min(w[i][j],w[i][k]+w[k][j])
count=0
for v in V:
    short=False
    for i in range(n):
        for j in range(i+1,n):
            if w[i][j]==w[i][v[0]]+v[2]+w[v[1]][j] or w[i][j]==w[i][v[1]]+v[2]+w[v[0]][j]:
                short=True
    if not short:
        count+=1
print(count)



Measured memory_bytes: 44380
#include <iostream>
#include <list>
#include <algorithm>

int main() {
	std::list<int> mountain;
	int height;

	for(int i=1; i<=10; ++i){
		std::cin >> height;
		mountain.push_back(height);
	}

	for(int i=1; i<=3; ++i){
		std::list<int>::iterator max_it = std::max_element(mountain.begin(), mountain.end());
		std::cout << *max_it << std::endl;
		mountain.erase(max_it);
	}

	return 0;
}

Measured memory_bytes: 1192
import java.io.*;
import java.util.*;
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int count=0;
        int n;
        while(true){
            count++;
            n=Integer.parseInt(br.readLine());
            if(n==0) break;
            System.out.println("Case "+count+": "+n);
        }
    }
}

Measured memory_bytes: 31916
from sys import stdin
import numpy as np
N = int(stdin.readline().rstrip())
L = np.array([int(x) for x in stdin.readline().rstrip().split()])
LS = np.sort(L)[::-1]
if LS[0] < np.sum(LS[1:]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 18380
N,M = map(int,input().split())
L = map(int,input().split())

L = sorted(L)

total = 0
for i in range(N):
    if M - int(L[0]) >= 0:
        M -= int(L[0])
        total += 1
        L.pop(0)

if total == N and not M == 0:
    total = N - 1
        
print(total)

Measured memory_bytes: 3064
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=(f,F),(f,-F),;H=(F,f),(-F,f),
for i in r(n):*a,c=I();R+=(a,c),;Y+=c,;X+=a
for i in r(m):a,*b=I();H+=(a,b),;X+=a,;Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)
h,s,K=g(X);w,t,L=g(Y);V,U,v=[[[0]*-~K for i in r(L+1)]for _ in r(3)]
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]-=1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]-=1
for i in r(L):
 for j in r(K):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];a=0
while q:
 x,y=q.pop();v[y][x]=1;a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in(-1,0),(1,0),(0,1),(0,-1),:
  c=x+e;d=y+f
  if 1-v[d][c]and U[(f>0)+y][x]*f+V[y][(e>0)+x]*e==0:q+=[(c,d)];v[d][c]=1
print([a,'INF'][a>F])

Measured memory_bytes: 551336
<?php
$n = trim(fgets(STDIN));
$s1 = trim(fgets(STDIN));
$s2 = trim(fgets(STDIN));

$max = 0;
for($i = 1; $i <= $n; $i++){
    if(substr($s1,-$i) == substr($s2,0,$i)){
        $max = max($max, $i);
    }
}
echo $n * 2 - $max;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int res=0;

int main(){
	int m=0;
	for(int i=0;i<5;i++){
		int x;
		cin>>x;
		int y=(x+9)/10*10;
		res+=y;
		m=max(m,y-x);
	}
	cout<<res-m<<endl;
}

Measured memory_bytes: 256
while True:
  H, W = map(int, input().split())
  if H == 0 and W == 0:
    break
  print('#' * W)
  for i in range(1, H-1):
    print('#', end = '')
    for j in range(1, W-1):
      print('.', end ='')
    print('#')
  print('#' * W)
  print()


Measured memory_bytes: 6992
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    var vals = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
    int N=vals[0];
    int M=vals[1];
    int mod=1000000007;
    long[] d=new long[N+1];
    for(int i=0;i<M;i++){
        int a=int.Parse(Console.ReadLine());
        d[a]=-1;
    }
    d[0]=1;
    for(int i=0;i<N;i++){
        if(d[i+1]==-1) d[i+1]=0;
        else {
            if(i==0) d[i+1]=d[i];
            else d[i+1]=(d[i]+d[i-1])%mod;
        }
    }
    Console.Write(d[N]);
    }
}


Measured memory_bytes: 13372