akhauriyash/Code-Regression huggingface dataset:
from bisect import bisect_left, bisect_right
from collections import deque
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
infi = 10 ** 20

# 長さがi+1のときの最長部分増加列の末尾の最小値。
n, *A = map(int, read().split())
LIS = deque([10 ** 10])
for a in A:
    a *= -1
    pos1 = bisect_left(LIS, a)
    pos2 = bisect_right(LIS, a)
    if LIS[-1] <= a:
        LIS.append(a)
    else:
        if LIS[pos1] == a:
            LIS[pos2] = a
        else:
            LIS[pos1] = a

print(len(LIS))


Measured memory_bytes: 12836
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] nums = sc.nextLine().split(" ");
		int a = Integer.parseInt(nums[0]);
		int b = Integer.parseInt(nums[1]);
		if(a < b){
			System.out.println("a < b");
		} else if(a == b){
			System.out.println("a == b");
		} else {
			System.out.println("a > b");
		}
	}
}

Measured memory_bytes: 17120
// Single_Sorce_Shotest_Path_1


#include <stdio.h>
#include <stdlib.h>


typedef struct{
	int distance;
	int vertex_n;
	int *box;
	int *omomi;
} DATA_T;


void Bfs(DATA_T *box, int n)
{
	int vertex, sub_vertex;
	int omomi;
	int *ring_queue;
	int front, rear;
	int size = 500000;
	int i;

	ring_queue = (int *)malloc(sizeof(int) * size);

	box[0].distance = 0;
	front = rear = 0;
	ring_queue[rear++] = 0;
	while(front != rear){
		vertex = ring_queue[(front++) % size];

		for(i = 0; i < box[vertex].vertex_n; i++){
			sub_vertex = box[vertex].box[i];
			omomi = box[vertex].omomi[i];
			if(box[sub_vertex].distance == -1 ||  box[vertex].distance + omomi < box[sub_vertex].distance){
				box[sub_vertex].distance = box[vertex].distance + omomi;
				ring_queue[(rear++) % size] = sub_vertex;
			}
		}
	}
}


int main()
{
	DATA_T *box;
	int n, vertex, k;
	int sub_vertex, omomi;
	int i, j;

	scanf("%d", &n);

	box = (DATA_T *)malloc(sizeof(DATA_T) * n);

	for(i = 0; i < n; i++){
		scanf("%d %d", &vertex, &k);
		box[vertex].distance = -1;
		box[vertex].vertex_n = k;

		if(k){
			box[vertex].box = (int *)malloc(sizeof(int) * k);
			box[vertex].omomi = (int *)malloc(sizeof(int) * k);
			for(j = 0; j < k; j++){
				scanf("%d %d", &sub_vertex, &omomi);
				box[vertex].box[j] = sub_vertex;
				box[vertex].omomi[j] = omomi;
			}
		}
	}


	// 幅優先探索で最短経路を求める
	Bfs(box, n);


	// 表示
	for(i = 0; i < n; i++)
		printf("%d %d\n", i, box[i].distance);

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N, M;
    cin >> N >> M;
    ll sum = 0;
    vector<ll> A(N);
    REP(i,N){
        ll a;
        cin >> a;
        sum += a;
        A[i] = a;
    }

    ll ans = 0;
    REP(i,N){
        if(A[i]*(4*M) >= sum)
            ans++;
    }

    if(ans >= M)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
//ALDS1_12_C:Single_Source_Shortest Path II
//C++
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX=10000;
static const int INFTY=(1<<20);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
int n;
vector<pair<int,int> >adj[MAX];//加?有向?的?接表表示法
void dijkstra(){
    priority_queue<pair<int,int> > PQ;
    int color[MAX];
    int d[MAX];
    for(int i=0;i<n;i++){
        d[i]=INFTY;
        color[i]=WHITE;
    }
    d[0]=0;
    PQ.push(make_pair(0,0));
    color[0]=GRAY;
    while(!PQ.empty()){
        pair<int,int> f=PQ.top();PQ.pop();
        int u=f.second;
        color[u]=BLACK;
        //取出最小?，如果不是最短路径?忽略
        if(d[u]<f.first*(-1))continue;
        for(int j=0;j<adj[u].size();j++){
            int v=adj[u][j].first;
            if(color[v]==BLACK)continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                //priority_queue priority_queue 默??先最大?，因此要乘以-1.
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY; 
            }
        } 
    }
    for(int i=0;i<n;i++){
        cout<<i<<" "<<(d[i]==INFTY?-1:d[i])<<endl;
    }
}
int main(){
    int k,u,v,c;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v>>c;//1 此?写成cin>>v>>v; ?了会 
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
} 

Measured memory_bytes: 8024
#include <iostream>
#include <vector>
#include <set>
 #include <iomanip>
using namespace std;


int main(){
	int N,M;
	cin >> N>> M;
	vector<int>X(M,0);
	for(int i=0;i<M;i++)cin >> X[i];
	
	sort(X.begin(),X.end());

	vector<int>sa(M-1);
	for(int i=0;i<M-1;i++)sa[i]=X[i+1]-X[i];
	int ans=0;
	
	sort(sa.begin(),sa.end());
	for(int i=0;i<M-N;i++)ans+=sa[i];
	
	cout << ans <<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    ll S, W;
    cin >> S >> W;
    if(W >= S){
        cout << "unsafe" << endl;
    }
    else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

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

template <typename T>
T gcd(T a, T b) {
  if(b == 0) return a;
  else return gcd(b,a%b);
}


int main(){
  int K;
  int ans = 0;
  cin >> K;
  for(int i=1; i<=K; i++) {
    for(int j=1; j<=K; j++) {
      int tmp = gcd(i,j);
      for(int k=1; k<=K; k++) {
	ans += gcd(tmp,k);
      }
    }
  }
  cout << ans << endl;
}















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

enum {
    B10 = 10000, B5 = 5000, B1 = 1000
};

inline int maxNumber(long yen, int bill){
    return int(yen / bill);
}

inline bool isCorrect(int x10, int x5, int x1, int n, long y){
    bool isPositive = ((x10 >= 0) && (x5 >= 0) && (x1 >=0));
    bool isCorrectN = (n == x10 + x5 + x1);
    bool isCorrectY = (y - B10*x10 - B5*x5 - B1*x1 == 0);

    return isPositive && isCorrectN && isCorrectY;
}

void ans(int& x10, int& x5, int& x1, int n, long y){
    x10 = min(n, maxNumber(y, B10));
    for(; x10 >= 0; x10--){
        x5 = min(n - x10, maxNumber(y - B10*x10, B5));
        for(; x5 >= 0; x5--){
            x1 = min(n - x10 - x5, maxNumber(y - B10*x10 - B5*x5, B1));

            if(isCorrect(x10, x5, x1, n, y)) return;
        }
    }
}

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

    int x10 = -1, x5 = -1, x1 = -1;
    ans(x10, x5, x1, n, y);

    if(isCorrect(x10, x5, x1, n, y)){
        cout << x10 << " " << x5 << " " << x1 << endl; 
    } else {
        cout << "-1 -1 -1" << endl;
    }
}

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

int main(){
  int x;
  cin >> x;
  int up = x / 100;
  int down = x % 100;
  down = (down + 4) / 5;
  if(up >= down) cout << 1 << endl;
  else cout << 0 << endl;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

//! [品物iまでみたとき][重さがwになるときの]=最大価値
ll dp[105][100005];

int main()
{
    ll N, W;
    cin >> N >> W;
    REP(i, W + 1)
    {
        dp[0][i] = 0;
    }

    REP(i, N)
    {
        ll w, v;
        cin >> w >> v;
        REP(j, W + 1)
        {
            dp[i + 1][j] = dp[i][j];
            if (j - w < 0)
                continue;
            dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j - w] + v);
        }
    }

    ll max = 0;
    REP(i, W + 1)
    {
        max = std::max(max, dp[N][i]);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 80128
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

#  = input()
#  = int(input())
X, Y, Z = map(int, input().split())
print(Z, X, Y)
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()


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

using namespace std;

struct px {
	int p;
	int x;

};

bool operator<(const px& left, const px& right) {
	return left.p > right.p;
}


int main() {

	int n, q;
	cin >> n >> q;
	vector<vector<int>> G(n + 1);
	vector<int> res(n + 1);
	int a, b;
	for (int i = 1; i <= n-1; i++) {
		cin >> a >> b;
//		if (a > b) { swap(a, b); }
		G[a].push_back(b);
		G[b].push_back(a);
	}

	vector<px> ppxx;
	int pp, xx;
	for (int i = 1; i <= q; i++) {
		cin >> pp >> xx;
		ppxx.push_back({ pp,xx });
	}

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

	for (int i = 0; i < q; i++) {
		res[ppxx[i].p] += ppxx[i].x;
	}

	//幅優先探索処理
	vector<bool> seen(n + 1, false);	//発見したらtrue
	deque<int> todo;					//行く所のスタック

	int s = 1;							//今いる場所
	int j = 1; //この問題ではjから到達できるところを調べる

	if (seen[j] == false) {			//訪れてなかったら処理すすめる
		seen[j] = true;
		//while (ppxx.empty()==false && ppxx.back().p==s) {
		//	res[j] += ppxx.back().x;
		//	ppxx.pop_back();
		//}
		todo.push_back(j);

		while (todo.empty() != true) {				//スタックが空になるまで処理	
			s = todo.front();						//処理番号を指定
			int tugiflg = false;					//次があったらtrueにするフラグ
			for (int k = 0; k < G[s].size(); k++) {
				if (seen[G[s][k]] != true) {
					seen[G[s][k]] = true;
					res[G[s][k]] += res[s];
					//if (ppxx.empty() == false) {
					//	while (ppxx.empty() == false && ppxx.back().p == G[s][k]) {
					//		res[G[s][k]] += ppxx.back().x;
					//		ppxx.pop_back();
					//	}
					//}
					todo.push_back(G[s][k]);
					tugiflg = true;
				}
			}
			todo.pop_front(); //次を全部探したので削除する
		}
	}


	for (int i = 1; i <= n; i++) {
		if (i != 1) {
			cout << " " << res[i];
		}
		else {
			cout << res[i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 17136
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i;
    cin>>a>>b;
    if(a==b)
    {
        for(i=1;i<=b;i++)
        {
            cout<<a;
        }
    }
   else if(a>b)
    {
        for(i=1;i<=a;i++)
            cout<<b;
    }
    else
    {
        for(i=1;i<=b;i++)
            cout<<a;
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, W int
  	fmt.Scanf("%d%d", &n, &W)


	ws := make([]int, n)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d%d", &ws[i], &vs[i])
	}

	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, W+1)
	}

	for i := 1; i < n+1; i++ {
		for j := range dp[i-1] {
			if j-ws[i-1] >= 0 {
				dp[i][j] = max(dp[i][j], dp[i-1][j-ws[i-1]]+vs[i-1])
			}
			dp[i][j] = max(dp[i][j], dp[i-1][j])
		}
	}

	fmt.Println(dp[n][W])
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// -----------------------------------------


Measured memory_bytes: 81792
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h;
    for(int i=0;i<n;i++){
        ll e;
        cin >> e;
        h.push_back(e);
    }

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

    ll ans=M;
    for(int i=k-1;i<n;i++) ans=min(ans,h.at(i)-h.at(i-(k-1)));

    cout << ans << endl;
}

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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args) => B();

        static void B()
        {
            var s = Read();
            Console.WriteLine($"{s[0]}{s.Slice(1, s.Length-1).Count()}{s.Last()}");
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

const int MX=10000001;
bool p[MX];
int n;

int main()
{
	for(int i=2;i*i<MX;i++)if(!p[i])for(int j=i+i;j<MX;j+=i)p[j]=1;
	
	while(scanf("%d",&n),n)
	{
		int s=n;
		for(;s>13;s--)if(!p[s]&&!p[s-2]&&!p[s-6]&&!p[s-8])break;
		printf("%d\n",s);
	}
	return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    string s;
    cin >> s;

    bool state = true;
    for(int i=1; i<=s.length(); i++){
        if((i%2 == 0 && s[i-1] == 'R') || (i%2 != 0 && s[i-1] == 'L')){
            state = false;
            break;
        }
    }

    if(state)
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long K = sc.nextInt();
		long ans = 0;
		long nSum = (N+1)*N/2+1;

		for(long k = K; k<=N+1; k++) {
			ans+=((2*N+1-k)*k/2-(k-1)*k/2+1);
			ans%=Math.pow(10,9)+7;
//			System.out.println(ans);
		}

		ans%=Math.pow(10,9)+7;

		System.out.println(ans);


	}
	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}

}


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

int main() {
    long long N;
    cin >> N;
    long long ans = 1;

    for (long long i = 1; i <= N; i++) {
        ans *= i;
        ans %= 1000000007;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<N;i++)
int main(){
  string S; cin>>S;
  bool dir[4]={};
  rep(i,S.size()){
    if(S[i]=='N') dir[0]=true;
    else if(S[i]=='E') dir[1]=true;
    else if(S[i]=='S') dir[2]=true;
    else dir[3]=true;
  }
  int cnt = 0;
  rep(i,4) if(!dir[i]) cnt++;
  if(cnt==4) cout<<"Yes"<<endl;
  else if(cnt==1 || cnt==3) cout<<"No"<<endl;
  else{
    if(dir[0]&&dir[2]) cout<<"Yes"<<endl;
    else if(dir[1]&&dir[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<int>>;
#define MAX 1000000007

class Calc_Mod{//calculate mod
    public:
        unsigned int mod=1000000007;
        ll plus_mod(ll a,ll b){
            return (a+b)%mod;
        }
        ll minus_mod(ll a,ll b){
            return (a-b)%mod;
        }
        ll multi_mod(ll a,ll b){
            return a*b%mod;
        }
        ll LSM(ll a,int b){//a^b%mod
            queue<int> q;
            while(b>=1){
                q.push(b%2);
                b/=2;
            }
            ll ans=1;
            while(!q.empty()){
                if(q.front()==1){
                    ans=multi_mod(ans,a);
                }
                a=multi_mod(a,a);
                q.pop();
            }
            return ans;
        }
        ll div_mod(ll a,ll b){// a/b
            return multi_mod(a,LSM(b,mod-2));
        }
        ll combi(ll a,ll b){//aCb
            ll ans=1;
            ll kaijo=1;
            rep(i,b){
                ans=multi_mod(ans,a-i);
                kaijo=multi_mod(kaijo,b-i);
            }
            ans=div_mod(ans,kaijo);
            return ans;
        }
        
};

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

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

int main()
{
    int x;
    cin >> x;
    int num=lcm(x,360);
    cout << num/x << endl;
    
}

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

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

  int mini = t.size();
  int count = 0;
  for (int i = 0; i <= s.size() - t.size(); i++)
  {
    count = 0;
    for (int j = 0; j < t.size(); j++)
    {
      if (i + j < s.size() && s.at(i + j) != t.at(j))
      {
        count++;
      }
    }
    mini = min(mini, count);
  }
  cout << mini << endl;

  return 0;
}

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


int  main()
{


#ifndef ONLINE_JUDGE
freopen("i.txt", "r", stdin);
freopen("o.txt", "w", stdout);
#else
// online submission

#endif
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll maxi=max(a*c,b*d);
  maxi=max(max(maxi,a*d),b*c);
  cout<<maxi<<endl;



    }








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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int a;
  cin >> a;
  cout << a+a*a+a*a*a << endl;
  
  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
long long t,s=0,a,i;
  cin >> t;
int p[t]={0};

for(int i=1;i<t;i++){
  cin>>a;
  p[a-1]++;
}
for (int i = 0; i < t; i++)
{
  cout<<p[i]<<endl;

}
  return 0;
}

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

#define ll long long
const ll mod = 1e9+7;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,ans,cnt = 0,p = 0;
	cin >> N >> K;
	vector<int> A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<N;i++)for(int j=i+1;j<N;j++){
		if(A[i]>A[j])cnt++;
	}
	for(int i=0;i<N;i++)for(int j=0;j<N;j++){
		if(i==j)continue;
		if(A[i]<A[j])p++;
	}
	ll a = K*(K-1)/2;
	ll b = cnt*K;
	a%= mod;
	b%= mod;
	ans = b + p*a % mod;
	cout << ans%mod << endl;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include "cassert"
#endif
#include "cctype"
#include "cerrno"
#include "cfloat"
#include "ciso646"
#include "climits"
#include "clocale"
#include "cmath"
#include "csetjmp"
#include "csignal"
#include "cstdarg"
#include "cstddef"
#include "cstdio"
#include "cstdlib"
#include "cstring"
#include "ctime"


// C++
#include "algorithm"
#include "bitset"
#include "complex"
#include "deque"
#include "exception"
#include "fstream"
#include "functional"
#include "iomanip"
#include "ios"
#include "iosfwd"
#include "iostream"
#include "istream"
#include "iterator"
#include "limits"
#include "list"
#include "locale"
#include "map"
#include "memory"
#include "new"
#include "numeric"
#include "ostream"
#include "queue"
#include "set"
#include "sstream"
#include "stack"
#include "stdexcept"
#include "streambuf"
#include "string"
#include "typeinfo"
#include "utility"
#include "valarray"
#include "vector"

#if __cplusplus >= 201103L
#include "array"
#include "atomic"
#include "chrono"
#include "condition_variable"
#include "forward_list"
#include "future"
#include "initializer_list"
#include "mutex"
#include "random"
#include "ratio"
#include "regex"
#include "scoped_allocator"
#include "system_error"
#include "thread"
#include "tuple"
#include "typeindex"
#include "type_traits"
#include "unordered_map"
#include "unordered_set"
#endif   

using namespace std;
int main() {
	long long a, b;
	cin >> a >> b;
	double c = ceil((a+b)/2.0);
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.text.*;

public class Main {
    static long MOD = (long)1e9+7;
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] a = new long[n];
        for(int i = 0; i< n; i++)a[i] = in.nextLong();
        
        long[][] res = new long[n][n];
        for(int i = 0; i< n; i++)Arrays.fill(res[i], Long.MAX_VALUE);
        for(int i = 0; i< n; i++){
            if(n%2 == 1)res[i][i] = a[i];
            else res[i][i] = -a[i];
        }
        for(int sz = 2; sz<= n; sz++){
            int turn = (n-sz)%2;
            for(int l = 0, r = sz-1; r < n; l++, r++){
                if(turn == 0)res[l][r] = Math.max(a[l]+res[l+1][r], res[l][r-1]+a[r]);
                else res[l][r] = Math.min(-a[l]+res[l+1][r], res[l][r-1]-a[r]);
            }
        }
        System.out.println(res[0][n-1]);
    }
}

Measured memory_bytes: 129688
import numpy as np

N = int(input())
A = np.array( [0] + list(map(int, input().split())) + [0] )

difA = np.diff(A)
dis = abs(difA)
PM = difA//dis
S = sum(dis)

for i in range(N):
  if PM[i] == PM[i+1]:
    print(S)
  else:
    print(S - (dis[i] + dis[i+1]) + abs(difA[i] + difA[i+1]))

Measured memory_bytes: 38580
#include <cstdio>
#include <vector>

using namespace std;

const int MAXN=1e5+10;
int H[MAXN];
vector<int> graph[MAXN];

int N,M;

int main(){
    scanf("%d%d",&N,&M);
    for(int i=1;i<=N;i++) scanf("%d",H+i);

    for(int i=0;i<M;i++){
        int s,e;
        scanf("%d%d",&s,&e);
        graph[s].push_back(e);
        graph[e].push_back(s);
    }

    int ans=0;
    for(int vert=1;vert<=N;vert++){
        bool good=true;
        for(auto adj:graph[vert]){
            if (H[adj]>=H[vert]){
                good=false;
                break;
            }
        }

        if (good) ans++;
    }

    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 8736
n = gets.to_i
a = Array.new(2) { gets.chomp.split.map(&:to_i) }

(1...n).each do |i|
  a[0][i] += a[0][i - 1]
  a[1][n - 1 - i] += a[1][n - i]
end
puts (0...n).to_a.map {|i| a[0][i] + a[1][i] }.max

Measured memory_bytes: 1788
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
using namespace std;

int main(){
  
  int i,j;
  long int ans=0;
  int m=INT_MAX;
  int minus=0;
  int n; cin >> n;
  vector<int> a(n);
  for (i=0; i<n; i++){
    cin >> a[i];
  }
  
  for (i=0; i<n; i++){
    if (a[i]==0){
      for (j=0; j<n; j++){
        ans += abs(a[j]);
      }
      cout << ans << endl;
      return 0;
    }
  }
  
  for (i=0; i<n; i++){
    if (a[i]<0){
      minus++;
    }
  }
  
  if (minus % 2 == 0){
    for (j=0; j<n; j++){
      ans += abs(a[j]);
    }
  } else {
    for (j=0; j<n; j++){
      m = min(m, abs(a[j]));
    }
    
    for (j=0; j<n; j++){
      ans += abs(a[j]);
    }
    
    ans -= 2*m;
  }
  
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>
// #include <atcoder/all>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
// using namespace atcoder;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;
// using mint = modint1000000007;


#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ")
#define print1(v) cout << fixed << setprecision(10) << v << "\n"
#define print2(v1, v2) cout << fixed << setprecision(10) << v1 << " " << v2 << "\n"
#define print3(v1, v2, v3) cout << fixed << setprecision(10) << v1 << " " << v2 << " " << v3 << "\n"
#define printvi(v, n) REP(iiii, n) { cout << v[iiii]; delim(iiii, n); }
#define printvii(v, h, w) REP(iiiii, h) { printvi(v[iiiii], w); }

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 1e5+5;
int n, m, k;
vi v_even(maxn);
vi v_odd(maxn);

vi dx = {-1, 0, 0, 1};
vi dy = {0, -1, 1, 0};

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

    cin >> n;
    REP(i, n/2) {
        int v0, v1; cin >> v0 >> v1;
        v_even[v0]++;
        v_odd[v1]++;
    }

    int m1_even = 0;
    int m2_even = 0;
    int m1_odd = 0;
    int m2_odd = 0;
    int n1_even = 0;
    int n1_odd = 0;
    REP(i, maxn) {
        if (m1_even > v_even[i]) {
            chmax(m2_even, v_even[i]);
        } else {
            m2_even = m1_even;
            m1_even = v_even[i];
            n1_even = i;
        }
        if (m1_odd > v_odd[i]) {
            chmax(m2_odd, v_odd[i]);
        } else {
            m2_odd = m1_odd;
            m1_odd = v_odd[i];
            n1_odd = i;
        }
    }

    int ret = 0;
    if (n1_even == n1_odd) {
        ret = n - max(m1_even + m2_odd, m1_odd + m2_even);
    } else {
        ret = n - m1_even - m1_odd;
    }
    print1(ret);
}

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

//モジュラー逆数
long long modinv(long long n, long long p) {
  long long a = p, u = 1, v = 0;
  while (a) {
    long long t = n / a;
    n -= t * a;
    swap(n, a);
    u -= t * v;
    swap(u, v);
  }
  u %= p;
  if (u < 0) u += p;
  return u;
}

int main() {
  long long n, k, p = 1000000007;
  cin >> n >> k;
  long long ans = 1;
  for (long long i = 1; i <= k; i++) {
    for (long long j = 0; j < i - 1; j++) {
      ans *= k - 1 - j;
      ans %= p;
    }
    if (i >= 3) {
      for (long long j = 1; j < i - 1; j++) {
        ans *= modinv(j + 1, p);
        ans %= p;
      }
    }
    for (long long j = 0; j < i; j++) {
      ans *= n - k + 1 - j;
      ans %= p;
    }
    if (i >= 2) {
      for (long long j = 1; j < i; j++) {
        ans *= modinv(j + 1, p);
        ans %= p;
      }
    }
    cout << ans << endl;
    ans = 1;
  }
}


Measured memory_bytes: 384
#include<iostream>
using namespace std ;
 int main(){
int A,B,C;
cin>>A>>B>>C;
if(A==C &&B!=C && B!=A && C==A){
    cout<<B;
}
else if (A==B && B==A && C!=A && C!=B){
    cout<<C;
}
else if (A!=B && A!=C && B==C &&C==B){
    cout<<A;
}
 return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<double, int> pdi;
typedef long long ll;

int h, w;
int iy, ix, fy, fx;

int dijkstra(const vector<string>& a)
{
    vector<vector<int>> dist(h, vector<int>(w, INT_MAX));
    vector<vector<bool>> visit(h, vector<bool>(w, false));

    priority_queue<pipii, vector<pipii>, greater<pipii>> pq;
    pq.push({0, {iy, ix}});
    dist[iy][ix] = 0;

    while (!pq.empty())
    {
        auto [y, x] = pq.top().second; pq.pop();

        if (visit[y][x]) continue;
        if (fy == y && fx == x) return dist[y][x];
        visit[y][x] = true;

        for (int dy = -2; dy <= 2; dy++)
        {
            for (int dx = -2; dx <= 2; dx++)
            {
                auto [ny, nx] = make_pair(y+dy, x+dx);
                if (ny == y && nx == x) continue;
                if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
                if (a[ny][nx] == '#') continue;
                if (visit[ny][nx]) continue;

                int d = (abs(dy)+abs(dx) != 1);
                if (dist[ny][nx] > dist[y][x]+d)
                {
                    dist[ny][nx] = dist[y][x]+d;
                    pq.push({dist[ny][nx], {ny, nx}});
                }
            }
        }
    }
    return -1;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> h >> w;
    cin >> iy >> ix >> fy >> fx;
    iy--; ix--; fy--; fx--;

    vector<string> a(h); for (string& s : a) cin >> s;
    cout << dijkstra(a) << endl;

    return 0;
}


Measured memory_bytes: 8620
#include <bits/stdc++.h>
#define ll long long
#define FOR(i, start, stop) for (ll i = start; i < stop; i++)
using namespace std;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;cin>>N;
    vector<ll> dv = divisor(N);
    ll a,b,al,bl;string as,bs;
    ll ans=0,temp=10e10;
    FOR(i,0,dv.size()){
        a=dv[i];b=N/a;
        if(a>b)break;
        as=to_string(a);al=as.size();
        bs=to_string(b);bl=bs.size();
        if(temp>abs(al-bl)){
            temp=abs(al-bl);
            ans=max(al,bl);
        }
    }
    cout<<ans<<endl;
}

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

#define sync {ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
#define ll long long int
#define mod 1000000007

int n;

bool c(const pair<ll,ll>&a, const pair<ll,ll>&b)
{
    return (a.first+a.second)<(b.first+b.second);
}

bool c1(const pair<ll,ll>&a, const pair<ll,ll>&b)
{
    return (a.first-a.second)<(b.first-b.second);
}

void solve()
{
    cin>>n;
//    ll maxm = 0;
//    ll minm = 1e10;
//    pair<ll,ll> ans1,ans2;
//
    vector<pair<ll, ll>> points(n);
    for(int i=0;i<n;i++)
    {
        ll x,y;
        cin>>x>>y;
        
        points[i].first = x;
        
        points[i].second = y;
        
        
    }
    
    vector<pair<ll,ll>> pts = points;
    
    sort(pts.begin(),pts.end(),c1);
    
    sort(points.begin(),points.end(),c);

    cout<<max((points[n-1].first+points[n-1].second)-(points[0].first+points[0].second),((pts[n-1].first-pts[n-1].second)-(pts[0].first-pts[0].second)));
    
}

int main()
{
    sync;
    int t = 1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}







Measured memory_bytes: 9536
#include<iostream>
#include<functional>
#include<iomanip>
#include<algorithm>
#include<vector>

using namespace std;
using ll = long long;

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

int main(){
  int n; cin >> n;
  vector<int> l(n);  
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end(), greater<int>());
  ll max_l = l[0];
  ll sum_l = 0;
  rep(i,n) sum_l += l[i];
  sum_l -= max_l;
  
  if(sum_l > max_l)  cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;
#define eps 1e-7

map<string , int > m;

int dir[4]={-4,4,-1,1};
void bfs(){
	queue<string> q;
	m["01234567"]=1;
	q.push("01234567");
	while(!q.empty()){
		string t=q.front();
		q.pop();
		int pi;
		for(int i=0;i<8;i++){
			if(t[i]=='0'){
				pi=i;
				break;
			}
		}
		for(int i=0;i<4;i++){
			if(pi==4&&i==2)
				continue;
			if(pi==3&&i==3)
				continue;
			int np=pi+dir[i];
			if(np<0||np>=8)
				continue;
			string st=t;
			swap(st[pi],st[np]);
			if(m[st] == 0){
				m[st]=m[t]+1;
				q.push(st);
			}
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	bfs();
	string s;
	char te;
	while(cin>>te){
		s=s+te;
		for(int i=1;i<=7;i++){
			cin>>te;
			s=s+te;
		}
		
	//	cout<<s<<endl;
		cout<<m[s]-1<<endl;
		s.clear();
	}
	return 0;
}




Measured memory_bytes: 5352
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d",&n);
    int m[n];
    for(int i=0;i<n;i++) {
        scanf("%d",&m[i]);
    }
    int k;
    int min[10000];
    for(int i=0;i<n-1;i++) {
        int s1=0;
        int s2=0;
        for(k=0;k<=i;k++) {
            s1+=m[k];
        }
        for(int j=n-1;j>i;j--) {
            s2+=m[j];
            }
        min[i]=s1-s2;
    }
    
    for(int i=0;i<n-1;i++) {
        if(min[i]<0) {
            min[i]=0-min[i];
        }
    }
    
    int i_min=min[0];
    for(int i=0;i<n-1;i++) {
        if(min[i]<=i_min) {
            i_min=min[i];
        }
    }
    printf("%d\n",i_min);
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int ans=753;
  for(int i=0;i+3<=s.size();i++){
    string t=s.substr(i,3);
    int p=stoi(t);
    ans=min(ans,abs(p-753));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==7&&b==5&&c==5){
    cout <<"YES"<<endl;
  }
   else if(b==7&&a==5&&c==5){
    cout <<"YES"<<endl;
  }
  else if(c==7&&b==5&&a==5){
    cout <<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N, K;
  cin>>N>>K;
  Int ans = 0;
  for(Int i=0;i<N;i++){
    Int h;
    cin>>h;
    ans += h >= K;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
const int N = 2e5 + 55;
int arr[N];
vector<int> ans;
int n;
void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> arr[i];
	for (int i = n; i >= 1; --i) {
		for (int j = 2 * i; j <= n; j += i) {
			arr[i] -= arr[j];
			if (arr[i] < 0) {
				arr[i] += 1000;
				arr[i] %= 2;
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < arr[i]; ++j)
			ans.push_back(i);
	}
	cout << (int) ans.size() << endl;
	for (auto i: ans) {
		cout << i << ' ';
	}
}	

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S, T;
  cin >> S >> T;
  int l = S.length();
  
  bool match = true;
  REP(i, l){
    REP(j, l){
//      cout << i << "/" << j << endl;
      
      match = true;
      
      if(i+j > (l-1)) {
//        cout << i + j -l << endl;
//        cout <<S.at(i) << ":" <<  T.at(i + j -l) << endl;
        
        if(S.at(j) != T.at(i+j-l)){
          match = false;
          break;
        }
      }else{
//       cout << i + j << endl;
//       cout <<S.at(j) << ":" <<  T.at(i+j) << endl;
        
        if(S.at(j) != T.at(i+j)){
          match = false;
          break;
        }
      }
    }
    
    if(match){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
### constant

MDAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

### subroutines

def leap?(y)
  (y % 4 == 0) && (y % 100 != 0 || y % 400 == 0)
end

def ad2days(y, m, d)
  lp = leap?(y)
  ly = y - 1
  m -= 1

  (ly * 365 + ly / 4 - ly / 100 + ly / 400) +
    $msums[m] + ((lp && m >= 2) ? 1 : 0) +
    d
end

def days2ad(days)
  y = 1
  lp = false
  ydays = 365

  while days > ydays
    days -= ydays
    y += 1
    lp = leap?(y)
    ydays = lp ? 366 : 365
  end

  m = 0

  while true
    mdays = MDAYS[m]
    mdays += 1 if m == 1 && lp
    break if days <= mdays
    days -= mdays
    m += 1
  end

  [y, m + 1, days]
end

def maya2days(b, ka, t, w, ki)
  (((b * 20 + ka) * 20 + t) * 18 + w) * 20 + ki
end

def days2maya(days)
  ki = days % 20
  days /= 20
  w = days % 18
  days /= 18
  t = days % 20
  days /= 20
  ka = days % 20
  days /= 20
  b = days % 13

  [b, ka, t, w, ki]
end

### main

$msums = [0]
(1..12).each{|m| $msums[m] = $msums[m - 1] + MDAYS[m - 1]}
#p $msums

base = ad2days(2012, 12, 21)
#p base
#exit 0

while true
  line = gets.strip
  break if line == '#'

  nums = line.split('.').map{|s| s.to_i}

  if nums.length == 3
    days = ad2days(*nums) - base
    puts days2maya(days).join('.')
  else
    days = maya2days(*nums) + base
    puts days2ad(days).join('.')
  end
end

Measured memory_bytes: 6124
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n, cnt =0;
    cin >> n;
    vector <int> L(n, 0);
    for(int i=0; i<n; i++){
        cin >> L[i]; 
    }
    for(int i=1; i <n-1; i++){
        if(L[i-1] < L[i] and L[i] < L[i+1]){
            cnt+=1;
        }else if(L[i] < L[i-1] and L[i+1] < L[i]){
            cnt+=1;
            
        }
    }
    cout << cnt;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
int n, m;
vector<vector<pair<int, ll>>> p, inv;
vector<ll> cost;
vector<bool> used;

bool ok = true;
int d = 0;

void dfs(int i, ll c) {
  if (cost[i] >= c || !used[i]) {
    return;
  }
  d++;
  cost[i] = max(cost[i], c);
  if (d > 3 * n) {
    ok = false;
    return;
  }
  for (auto &pr: p[i]) {
    dfs(pr.first, c + pr.second);
  }
}

void dfs2(int i) {
  if (used[i]) return;
  used[i] = true;
  for (auto &j : inv[i]) {
    dfs2(j.first);
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  ll INF = 1LL << 50;
  cost.resize(n, -INF);
  inv.resize(n);
  used.resize(n);
  p.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--;
    b--;
    p[a].emplace_back(b, c);
    inv[b].emplace_back(a, c);
  }
  dfs2(n - 1);

  dfs(0, 0);
  if (ok) {
    cout << cost[n - 1] << endl;
  } else {
    cout << "inf" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		
		int bitsum = 0;
		
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
			bitsum ^= a[i];
		}

		System.out.print((bitsum^a[0]));
		for(int i=1; i<n; i++) {
			System.out.print(" " + (bitsum^a[i]));
		}

	}

}


Measured memory_bytes: 62588
import           Control.Monad
import           Data.Char

main :: IO ()
main = do
  [a, b, c] <- replicateM 3 getLine
  putChar $ solve 'a' a b c

solve :: Char -> String -> String -> String -> Char
solve 'a' ""       _        _        = 'A'
solve 'a' (x : xs) ys       zs       = solve x xs ys zs
solve 'b' _        ""       _        = 'B'
solve 'b' xs       (y : ys) zs       = solve y xs ys zs
solve 'c' _        _        ""       = 'C'
solve 'c' xs       ys       (z : zs) = solve z xs ys zs


Measured memory_bytes: 508
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a="0";
		while(true){
			String num=sc.next();
			if(num.equals(a)){
				break;
			}else{
				int sum=0;
				for(int i=0;i<num.length();i++){
					int k=num.charAt(i)-a.charAt(0);
					sum+=k;
				}
				System.out.println(sum);
			}
		}
	}
}

Measured memory_bytes: 26280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int A,B,C,D; cin>>A>>B>>C>>D;
	while(1){
		C-=B;
		if (C<=0) {
			cout<<"Yes";
			exit(0);
		}
		A-=D;
		if (A<=0){
			cout<<"No";
			exit(0);
		}
	}
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
     
int main() {
    
    int n, m;
    cin >> n >> m;
    
	int a[n][m];
	int b[m];
	int c[n] = {};
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
		    cin >> a[i][j];
		}
	}
	
	for(int i = 0; i < m; i++){
	    cin >> b[i];
	}

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
		    c[i] += a[i][j] * b [j];
		}
	}
	
	for(int i = 0; i < n; i++){
	    cout << c[i] << endl;
	}
	return 0;
}
	
	


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
using namespace std;
#define ll long long

int main() {
    int n, count = 0, f, i, j;
    cin >> n;
    vector<ll>a(n);
    for(int i = 0; i < n; i++) cin >> a.at(i);
    sort(a.begin(), a.end());
    
    for(i = 0; i < n; i++) {
        f = 1;
        for(j = i+1; a[i] == a[j]; j++) f++;
        count += f%2;
        i += j-i-1;
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pii;
#define endl '\n'
#define F first
#define S second
const int MAX_N=2e5+5;

int n;
ll c;
ll h[MAX_N];
ll dp[MAX_N];
deque<pii> dq;

ll calc(pii x, ll y)
{ return x.F*y+x.S; }
double getX(pii x, pii y)
{ return (x.F-y.F)*1.0/(y.S-x.S); }

int main()
{
	scanf("%d%lld",&n,&c);
	for(int i=0;i<n;i++) scanf("%lld",&h[i]);
	dq.emplace_back(-2*h[0],h[0]*h[0]);
	for(int i=1;i<n;i++)
	{
		while(dq.size()>=2&&calc(dq[0],h[i])>=calc(dq[1],h[i]))
			dq.pop_front();
		dp[i]=calc(dq[0],h[i])+h[i]*h[i]+c;
		pii tmp={-2*h[i],dp[i]+h[i]*h[i]};
		while(dq.size()>=2&&getX(tmp,dq[dq.size()-2])>=getX(dq.back(),dq[dq.size()-2]))
			dq.pop_back();
		dq.emplace_back(tmp);
	}
	printf("%lld\n",dp[n-1]);
	return 0;
}



Measured memory_bytes: 5632
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;
template<typename T>
T gcd(T a, T b){
    return b ? gcd(b, a % b) : a;
}    

int main(){ 
    int n,m;
    cin >> n >>m;
    VI l(m);
    VI r(m);
    rep(i,m){ cin >> l[i] >> r[i]; }

    int lmax=0;
    rep(i,m){   
        lmax = max(lmax,l[i]);
    }

    int rmin =10000000;
    rep(i,m){   
        rmin = min(rmin,r[i]);
    }
    if (lmax > rmin){
        cout << 0 << endl;
        return 0;
    }
    else{
        cout << rmin + 1 - lmax << endl;
    }
    return 0;
}


    
    

   


Measured memory_bytes: 1152