akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] c = new Integer[n - 1];
        Integer[] s = new Integer[n - 1];
        Integer[] f = new Integer[n - 1];
        for (int i = 0; i < n - 1; i++) {
            c[i] = Integer.parseInt(sc.next());
            s[i] = Integer.parseInt(sc.next());
            f[i] = Integer.parseInt(sc.next());
        }
        sc.close();

        // 主処理
        List<String> list = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            int time = s[i];
            time += c[i];
            for (int j = i + 1; j < n - 1; j++) {
                time = Math.max(time, s[j]);
                int mod = (time - s[j]) % f[j];
                if (mod != 0) {
                    time += f[j] - mod;
                }
                time += c[j];
            }
            list.add(Integer.toString(time));
        }
        list.add("0");
        String result = String.join("\r\n", list);

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 38744
x1,y1,x2,y2 = map(int,input().split())
x3 = x2 - (y2-y1)
y3 = y2 + (x2-x1)
x4 = x3 - (x2-x1)
y4 = y3 - (y2-y1)
print(x3,y3,x4,y4)

Measured memory_bytes: 9024
D,G = map(int, input().split(' '))
prb = []
for i in range(D):
    prb.append(list(map(int, input().split(' '))))
p_cmp = []
for i in range(D):
    p_cmp.append((i+1)*100*prb[i][0]+prb[i][1])
ans = 10**18

for b in range(2**D):
    Gtmp = G
    pslv = 0
    binstr = format(b,'b')
    binstr = binstr.zfill(D)
    for i, x in enumerate(binstr):
        if x == "1":
            Gtmp -= p_cmp[i]
            pslv += prb[i][0]
        if x == '0':
            continue
    if Gtmp > 0:
        for i, x in enumerate(binstr[::-1]):
            if x == "1":
                continue
            if x == '0':
                j = D-i-1
                if Gtmp < prb[j][0] * (j+1) * 100:
                    pslv += (Gtmp + (j+1)*100-1)//((j+1)*100)
                    Gtmp = 0
                    ans = min(ans, pslv)
                    break
                else:
                    break
                break
    if Gtmp <= 0:
        ans = min(ans, pslv)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mx=2e5+7;

//#define int long long
set<int>adj[mx];
vector<bool>vis;
int nodes;

void dfs(int u){
    vis[u]=1;
    nodes+=1;
    for(auto i:adj[u]){
        if(!vis[i])
            dfs(i);
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<=n;i++)
        vis.push_back(0);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        if(adj[u].find(v)==adj[u].end())
        adj[u].insert(v);
        if(adj[v].find(u)==adj[v].end())
        adj[v].insert(u);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i]) {
            nodes=0;
            dfs(i);
            ans=max(ans,nodes);
        }
    }
    cout<<ans<<endl;
}


signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t;
    solve();
}

Measured memory_bytes: 37940
#include <iostream>
#define LINF (1LL << 60)
using namespace std;
typedef long long Int;

Int n, k, h[110000], dp[110000];

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> h[i];

  for (int i = 1; i < n; i++) dp[i] = LINF;
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; in(N);
  out((N%4 == 0 || N%7 == 0 || N == 11 || N == 15 || N >= 18 ? "Yes" : "No"));

  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int n = s.size()-1;
    int flag = 0;

    for (int i=0; i< n/2; i++){
        if (s.at(i) != s.at(n-i)){
            flag += 1;
            break;
        }
    }

    for (int i=0; i<n/4; i++){
        if(s.at(i) != s.at(n/2-i-1) || s.at(i+n/2+1) != s.at(n-i)){
            flag++;
            break;
        }
    }

    if (flag > 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long A,B,N,a,b;
    cin>>N>>A>>B;
    a = N / (A+B);
    b = N - (A+B) * a;
    if(a==0){
        if(A>=N){
            cout<<N<<endl;
        }
        else{
            cout<<A<<endl;
        }
        return 0;
    }
    if(b>=A){
        cout<<(a+1)*A<<endl;
    }
    else{
        cout<<a*A+b<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define ff first
#define ss second
#define rev(a) reverse(a.begin(),a.end())
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define ins insert
#define pb emplace_back
#define sz(x) (int)(x).size()
#define MOD 1000000007  //1e9 + 7
#define INF 2000000000 //2e9
#define DESPACITO 1000000000000000000 //1e18
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> T chmin(T &a, T b) { a = min(a, b); return a; }
template<class T> T chmax(T &a, T b) { a = max(a, b); return a; }
using pii = pair<int, int>;
using ll = long long;
const int N = 2e5 + 5;

int32_t main() {
    IOS;
    int i; string n;
    cin >> n;
    for(i = 0; i < sz(n); i++) 
        if(n[i] == '7') return cout << ("Yes"), 0;
    cout << ("No");
    return 0;
}


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

int main(){
    int M, T, P, R;
    cin >> M >> T >> P >> R;
    while(M > 0){
        vector<pair<pair<int, int>, int>> ans(T);
        for(int i=0; i<T; i++){
            ans[i].first = make_pair(P, 0);
            ans[i].second = -i;
        }
        vector<vector<int>> pen(T, vector<int>(P, 0));
        for(int i=0; i<R; i++){
            int m, t, p, j;
            cin >> m >> t >> p >> j;
            t--; p--;
            if(j == 0){
                ans[t].first.first--;
                ans[t].first.second += m + pen[t][p];
            }else{
                pen[t][p] += 20;
            }
        }
        sort(ans.begin(), ans.end());
        for(int i=0; i<T; i++){
            cout << -ans[i].second+1;
            if(i<T-1) cout << (ans[i].first == ans[i+1].first ? "=":",");
        }
        cout << endl;

        cin >> M >> T >> P >> R;
    }
}



Measured memory_bytes: 3140
import java.text.ParseException;
import java.util.Scanner;

public class Main {

	public static void main(String[] arges) throws ParseException {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();

		int v1 = Integer.parseInt(line);
		int[] vs = new int[v1];
		for (int i = 0; i < v1; i++) {
			String line2 = sc.nextLine();
			vs[i] = Integer.parseInt(line2);
		}
		int sosuuc = 0;
		for (int i = 0; i < v1; i++) {
			int count = 0;
			if (vs[i] <= 10) {

				for (int j = 2; j <= vs[i] /2; j++) {
					if (vs[i] % j == 0) {
						count++;
						if (count == 1) {
							break;
						}
					}
				}

			} else {
				for (int j = 2; j <= Math.sqrt(vs[i]); j++) {
					if (vs[i] % j == 0) {
						count++;
						if (count == 1) {
							break;
						}
					}
				}

			}
			if (count == 0) {
				sosuuc++;
			}
		}
		System.out.println(sosuuc);
	}
}

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

def is_sorted(li):
  for i in range(len(li)-1):
    if li[i] > li[i+1]:
      return False
  return True

ans = is_sorted(p)

def check():
  for i in range(N-1):
    for j in range(i+1, N):
      new = p[:]
      new[j] = p[i]
      new[i] = p[j]
      if is_sorted(new):
        return True
  return False

if ans:
  print("YES")
else:
  if check():
    print("YES")
  else:
    print("NO")

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

using namespace std;
using ll = long long int;

bool Satisfies(const string &t, string &s, size_t index)
{
    if (index + t.size() - 1 >= s.length())
    {
        return false;
    }

    for (size_t i = 0; i < t.size(); i++)
    {
        if (s[index + i] != '?' && s[index + i] != t[i])
        {
            return false;
        }
    }

    for (size_t i = 0; i < t.size(); i++)
    {
        s[index + i] = t[i];
    }

    return true;
}

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

    for (int i = s.length() - 1; i >= 0; i--)
    {
        if (Satisfies(t, s, i))
        {
            for (auto &c : s)
            {
                if (c == '?')
                {
                    c = 'a';
                }
            }

            cout << s << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b = readmi()
if (a + b) % 2 == 0:
    print((a + b) // 2)
else:
    print("IMPOSSIBLE")


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

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#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=1e10,EPS=1e-9;

int n,m,t[50000],s[50000];
int so[256];

int tonum(char *buf)
{
	return so[buf[0]]+(buf[1]=='#');
}

bool bfs()
{
	queue<pi> Q;
	Q.push(mp(0,0));
	while(!Q.empty())
	{
		int cur=Q.front().first,step=Q.front().second;
		Q.pop();
		
		if(n+1-cur>2*(m-step+1))continue;
		
		if(step==m)
		{
			if(cur+1==n+1||cur+2==n+1)return 1;
			continue;
		}
		
		if(cur+1<=n&&t[cur]==s[step])Q.push(mp(cur+1,step+1));
		if(cur+2<=n&&(t[cur+1]+1)%12==s[step])Q.push(mp(cur+2,step+1));
		if(cur-1>0&&(t[cur-2]+11)%12==s[step])Q.push(mp(cur-1,step+1));
	}
	return 0;
}

int main()
{
	so['C']=0; so['D']=2; so['E']=4;
	so['F']=5; so['G']=7; so['A']=9;
	so['B']=11;
	
	int cs; scanf("%d",&cs);
	while(cs--)
	{
		scanf("%d%d",&n,&m);
		
		char buf[3];
		rep(i,n)scanf("%s",buf),t[i]=tonum(buf);
		rep(i,m)scanf("%s",buf),s[i]=tonum(buf);
		
		cout<<(bfs()?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1520
#include <iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> it(3, 1);
	vector<int> zer(3, 0);
	vector<vector<int> > tek(n, it);
	for (int i = 0; i < k; i++) {
		int x, y;
		cin >> x >> y;
		tek[x - 1][(y + 1) % 3] = 0;
		tek[x - 1][(y + 2) % 3] = 0;
	}
	vector<vector<int> > ku(2, zer);
	ku[0] = tek[0];
	for (int i = 1; i < n; i++) {
		vector<vector<int> > yob(2, zer);
		yob = ku;
		ku[0] = zer;
		for (int j = 0; j < 3; j++) {
			ku[1][j] = tek[i][j]*yob[0][j];
			for (int k = (j + 1) % 3; k != j; k = (k + 1) % 3) {
				ku[0][j] =( ku[0][j]+(tek[i][j] * (yob[0][k]+yob[1][k])))%10000;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 3; j++) {
			ans = (ku[i][j] + ans) % 10000;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
    int yy,mm,dd;
    char c1,c2;
	cin >> yy>>c1>>mm>>c2>>dd;
	if (yy < 2019)cout << "Heisei";
	else if (yy == 2019 && mm < 4)cout << "Heisei";
	else if (yy == 2019 && mm == 4 && dd <= 30)cout << "Heisei";
	else cout << "TBD";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repR(i, n) for(int i = n; i >= 0; ++i)
#define FDS(i, n) for(int i = 0; i < n; ++i)
#define FDSR(i, n) for(int i = n; i >= 0; ++i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main(){
	int a,b;
	cin>>a>>b;
	if(a<=b){
		cout<<a<<endl;
	}
	else{
		cout<<a-1<<endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			char ch[]=in.next().toCharArray();
			String ans="";
			for(int i=0;i<ch.length;i+=2)
			{
				if(ch[i]=='1')
				{
					if(ch[i+1]=='T')
						ans+="a";
					else if(ch[i+1]=='L')
						ans+="i";
					else if(ch[i+1]=='U')
						ans+="u";
					else if(ch[i+1]=='R')
						ans+="e";
					else if(ch[i+1]=='D')
						ans+="o";
				}
				else if(ch[i]=='2')
				{
					if(ch[i+1]=='T')
						ans+="ka";
					else if(ch[i+1]=='L')
						ans+="ki";
					else if(ch[i+1]=='U')
						ans+="ku";
					else if(ch[i+1]=='R')
						ans+="ke";
					else if(ch[i+1]=='D')
						ans+="ko";
				}
				else if(ch[i]=='3')
				{
					if(ch[i+1]=='T')
						ans+="sa";
					else if(ch[i+1]=='L')
						ans+="si";
					else if(ch[i+1]=='U')
						ans+="su";
					else if(ch[i+1]=='R')
						ans+="se";
					else if(ch[i+1]=='D')
						ans+="so";
				}
				else if(ch[i]=='4')
				{
					if(ch[i+1]=='T')
						ans+="ta";
					else if(ch[i+1]=='L')
						ans+="ti";
					else if(ch[i+1]=='U')
						ans+="tu";
					else if(ch[i+1]=='R')
						ans+="te";
					else if(ch[i+1]=='D')
						ans+="to";
				}
				else  if(ch[i]=='5')
				{
					if(ch[i+1]=='T')
						ans+="na";
					else if(ch[i+1]=='L')
						ans+="ni";
					else if(ch[i+1]=='U')
						ans+="nu";
					else if(ch[i+1]=='R')
						ans+="ne";
					else if(ch[i+1]=='D')
						ans+="no";
				}
				else if(ch[i]=='6')
				{
					if(ch[i+1]=='T')
						ans+="ha";
					else if(ch[i+1]=='L')
						ans+="hi";
					else if(ch[i+1]=='U')
						ans+="hu";
					else if(ch[i+1]=='R')
						ans+="he";
					else if(ch[i+1]=='D')
						ans+="ho";
				}
				else if(ch[i]=='7')
				{
					if(ch[i+1]=='T')
						ans+="ma";
					else if(ch[i+1]=='L')
						ans+="mi";
					else if(ch[i+1]=='U')
						ans+="mu";
					else if(ch[i+1]=='R')
						ans+="me";
					else if(ch[i+1]=='D')
						ans+="mo";
				}
				else if(ch[i]=='8')
				{
					if(ch[i+1]=='T')
						ans+="ya";
					else if(ch[i+1]=='U')
						ans+="yu";
					else if(ch[i+1]=='D')
						ans+="yo";
				}
				else if(ch[i]=='9')
				{
					if(ch[i+1]=='T')
						ans+="ra";
					else if(ch[i+1]=='L')
						ans+="ri";
					else if(ch[i+1]=='U')
						ans+="ru";
					else if(ch[i+1]=='R')
						ans+="re";
					else if(ch[i+1]=='D')
						ans+="ro";
				}
				else if(ch[i]=='0')
				{
					if(ch[i+1]=='T')
						ans+="wa";
					else if(ch[i+1]=='U')
						ans+="nn";
					else if(ch[i+1]=='D')
						ans+="wo";
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 12000
package main

import (
  "fmt"
)

func main(){
  var b string
  fmt.Scan(&b)
  
  switch b{
    case "A":
    fmt.Println("T")
    case "T":
    fmt.Println("A")
    case "C":
    fmt.Println("G")
    case "G":
    fmt.Println("C")
  }
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = listOf(0)
        .plus(readLine()!!.split(' ').map { it.toInt() })
        .plus(0)
    val sum = (0 until a.size - 1).map { Math.abs(a[it] - a[it + 1]) }.sum()
    for (i in 1..n) {
        val left = Math.abs(a[i] - a[i - 1])
        val right = Math.abs(a[i] - a[i + 1])
        val jump = Math.abs(a[i - 1] - a[i + 1])
        println(sum - left - right + jump)
    }
}

Measured memory_bytes: 59228
#include "bits/stdc++.h"
#define readInt(x) scanf_s("%d", &x)
#define readStr(x) scanf("%s", x)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmax(x, y) (x > (y) ? x : x = (y))
#define chmin(x, y) (x < (y) ? x : x = (y))
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = INT32_MAX / 2;
const int MAX = 1e5 + 10;

int N;
int A[MAX];
set<int> s;

int main()
{
    cin >> N;
    rep(i, N) cin >> A[i];
    rep(i, N) {
        auto it = s.find(A[i]);
        if (it == s.end()) s.insert(A[i]);
        else s.erase(it);
    }
    write(s.size());
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int n = s.size() + t.size();
    string ans = "";
    rep(i, n) {
        if (i%2 == 0) {
            ans += s[i/2];
        } else {
            ans += t[i/2];
        }
    }
    cout << ans << endl;
}

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


int main() {

ll n;
cin>>n;
ll a[n+1],b[n+1],c[n+1];
for (int i = 1; i <= n; ++i)
{
	cin>>a[i]>>b[i]>>c[i];
}

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

}

Measured memory_bytes: 8252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;

    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x1 - dy;
    int y4 = y1 + dx;

    printf("%lld %lld %lld %lld\n", x3, y3, x4, y4);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(998244353)
#define PI 3.14159265358979323846264338327950L
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "[ " << *it << " = " << a << " ] ";
    err(++it, args...);
}

signed main(){

    fastIO

    int t = 1;
    // cin >> t;
    while (t--){
   		int n, x;
   		cin >> x >> n;
   		int smal = 1e9, diff = 1e9;
   		set<int> s;
   		for (int i = 0,a; i < n; i++) {
   			cin >> a;
   			s.insert(a);
   		}
   		for (int i = 0; i < 1000; i++) {
   			if (s.find(i) == s.end()) {
	   			int tmp = abs(x - i);
	   			if (tmp < diff) {
	   				diff = tmp;
	   				smal = i;
	   			}
	   		}
   		}
   		cout << smal << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
int main(){
    int a;
    scanf("%4d",&a);
    if (0<=a && a<1200) printf("%s","ABC");
    else if (1200<=a && a<2800) printf("%s","ARC");
    else printf("%s","AGC");

    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
const long long oo=1ll<<40;
struct edge{int v,w;};
int n;
long long best[2200001];
vector<edge> w[220001];
vector<pair<long long,long long>> f[220001];
bool cmpinv(const pair<int,int> &a,const pair<int,int> &b){return a.second<b.second;}
void dfs(int u,long long lim)
{
	f[u].clear();
	if(w[u].empty()){f[u].push_back({0,0});return;}
	for(edge e:w[u])
	{
		dfs(e.v,lim);
		for(auto &x:f[e.v])x.first+=e.w,x.second+=e.w;
	}
	auto &a=f[w[u][0].v],&b=f[w[u][1].v];
	int p=a.size(),q=b.size();
	if(!p&&!q)return;
	if(p>q)swap(p,q),swap(a,b);
	sort(a.begin(),a.end(),cmpinv);
	sort(b.begin(),b.end());
	for(int i=0;i<q;i++)best[i]=min(!i?oo:best[i-1],b[i].second);
	for(int i=0,j=q-1;i<p;i++)
	{
		while(j>=0&&a[i].second+b[j].first>lim)j--;
		if(j<0)break;
		f[u].push_back({a[i].first,best[j]});
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end(),cmpinv);
	for(int i=0;i<q;i++)best[i]=min(!i?oo:best[i-1],b[i].first);
	for(int i=0,j=q-1;i<p;i++)
	{
		while(j>=0&&a[i].first+b[j].second>lim)j--;
		if(j<0)break;
		f[u].push_back({best[j],a[i].second});
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=2,a,b;i<=n;i++)scanf("%d%d",&a,&b),w[a].push_back({i,b});
	long long l=0,r=oo,ans=r;
	while(l<=r)
	{
		long long m=(l+r)/2;
		dfs(1,m);
		if(f[1].empty())l=m+1;
		else ans=m,r=m-1;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 34676
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

class BIT():
    def __init__(self, n, data=None):
        self.n = n
        self.bit = [0] * (self.n + 1)
        self.data = [0] * (self.n + 1)
        if data:
            self.build(data)

    def build(self, data):
        for i in range(self.n):
            self.bit[i + 1] = self.data[i + 1] = data[i]
        for i in range(1, self.n):
            j = i + (i & (-i))
            if j <= self.n:
                self.bit[j] += self.bit[i]

    def add(self, idx, x):
        self.data[idx] += x
        while idx <= self.n:
            self.bit[idx] += x
            idx += (idx & (-idx))

    def sum(self, idx):
        s = 0
        while idx:
            s += self.bit[idx]
            idx -= (idx & (-idx))
        return s


#n,q=map(int,input().split())
#a=list(map(int,input().split()))
n,q=nii()
a=lnii()
bit=BIT(n,a)
for i in range(q):
#    t,x,y=map(int,input().split())
    t,x,y=nii()
    if t==0:
        bit.add(x+1,y)
    else:
        print(bit.sum(y)-bit.sum(x))

Measured memory_bytes: 65056
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
L=[]
for i in range (N):
	L.append(T-H[i]*0.006)
tmp=float("inf")
ans=0
for i in range (N):
	if tmp>abs(L[i]-A):
		tmp=abs(L[i]-A)
		ans=i+1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b,c;
  	ci(a>>b>>c);
  ll x,y;
  	ci(x>>y);
  ll n=x*a+y*b;//単純
  ll m;
  if(x<y){
    m=2*x*c+(y-x)*b;
  }
  else{
    m=2*y*c+(x-y)*a;
  }
  ll l;
  if(x<y){
	l=y*c*2;
  }
  else{
    l=x*2*c;
  }
  
  co(min({n,m,l}))
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x,s=0;
	cin>>n>>m;
	for(int i=1;i<=m;i++) 
	{
		cin>>x;
		s+=x;
	}
	if(s>n)
		cout<<"-1"<<endl;
	else
		cout<<n-s<<endl;
    return 0;
}
	

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

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);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t 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);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

int main(void){
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  REP(i, n) cin >> h[i];
  int ans = 0;
  REP(i, n){
    if (h[i] >= k) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

// 最小全域木（kruskal）
template< typename T >
struct edge {
  int from, to;
  T cost;

  edge(int to, T cost) : from(-1), to(to), cost(cost) {}

  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


template< typename T >
struct MinimumSpanningTree {
  T cost;
  Edges< T > edges;
};

template< typename T >
MinimumSpanningTree< T > kruskal(Edges< T > &edges, int V) {
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
    return a.cost < b.cost;
  });
  UnionFind tree(V);
  T total = T();
  Edges< T > es;
  for(auto &e : edges) {
    if(tree.unite(e.from, e.to)) {
      es.emplace_back(e);
      total += e.cost;
    }
  }
  return {total, es};
}

int main() {
    ll N;
    cin >> N;
    vpll vx, vy;
    rep(i, N) {
        ll x, y;
        cin >> x >> y;
        vx.emplace_back(x, i);
        vy.emplace_back(y, i);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());

    Edges<ll> es;
    rep(i, N-1) {
        es.emplace_back(vx[i].second, vx[i+1].second, vx[i+1].first - vx[i].first);
        es.emplace_back(vy[i].second, vy[i+1].second, vy[i+1].first - vy[i].first);
    }

    ll ans = kruskal(es, N).cost;
    cout << ans << endl;
}


Measured memory_bytes: 11488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

int main()
{
  ll N,L_0,L_1,L;
  cin >> N;
  L_0 = 2;
  L_1 = 1;

  if(N>=2)
  rep(i,N-1)
  {
    L = L_0 + L_1;
    L_0 = L_1;
    L_1 = L;
  }
  else if(N==1)
    L = L_1;
  cout << L << endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define FOR(n) for(int i=0;i<n;i++)
#define MOD 1e9+7
#define INF 1e9
#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
int main(void){
  int n;
  cin>>n;
  int ans=n/2-15;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3120
#include<iostream>
#include<stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n,M[N][N];
int color[N],d[N],f[N],tt;
int nt[N];

int next(int u)
{
    for (int v = nt[u]; v < n; v++)
    {
        nt[u]=v+1;
        if(M[u][v])return v;
    }
    
    return -1;
}

void dfs_visit(int r)
{
    for (int i = 0; i < n; i++)nt[i]=0;
    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    d[r]=++tt;

    while (!S.empty())
    {
        int u=S.top();
        int v=next(u);
        if(v!=-1)
        {
            if(color[v]==WHITE)//未訪問なら訪問
            {
                color[v]=GRAY;
                d[v]=++tt;
                S.push(v);
            }
        }
        else
        {
            S.pop();//もどる
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs()
{
    for (int i = 0; i < n; i++)
    {
        color[i]=WHITE;
        nt[i]=0;
    }
    tt=0;
    for (int u = 0; u < n; u++)
    {
        if(color[u]==WHITE)dfs_visit(u);
    }
    for (int i = 0; i < n; i++)
    {
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
    }
}

int main()
{
    int u,k,v;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            M[i][j]=0;
        }
    }
    for (int i = 0; i < n; i++)
    {
        cin>>u>>k;
        u--;
        for (int j = 0; j < k; j++)
        {
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }
    
    dfs();

    return 0;
}



Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
const int maxn=1011111;
int fa[maxn],d[maxn];//relative distance
int n,m;
int find_father(int x)
{
    if(fa[x]==x)
        return x;
    int f=find_father(fa[x]);
    d[x]=d[fa[x]]+d[x];
    return fa[x]=f; 
}
bool union_point(int x,int y,int dis)//Dy-Dx=dis
{
    int fx=find_father(x);
    int fy=find_father(y);
    if(fx==fy)
        return dis==d[y]-d[x];
    fa[fy]=fx;
    d[fy]=d[x]+dis-d[y];
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie();
    cin>>n>>m;
    for(int i=1;i<=n;++i)
        fa[i]=i;
    bool flag=true;
    while(m--)
    {
        int x,y,d;
        cin>>x>>y>>d;
        flag&=union_point(x,y,d);
    }
    if(flag)
        puts("Yes");
    else
        puts("No");
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
        cin>>N;
        A.resize(N);
        
        for(auto &x:A) cin>>x;
        
        vector<Int> dp(N);
        
        dp[0]=0; dp[1]=abs(A[1]-A[0]);
        
        for(int i=2;i<N;++i){
            dp[i]=min(dp[i-1]+abs(A[i]-A[i-1]),dp[i-2]+abs(A[i]-A[i-2]));
        }
       
        cout<<dp[N-1]<<"\n";
}


Measured memory_bytes: 28324
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat
int dp[20][2019];

int main(int argc, char const *argv[])
{
	sync;
	//1,3,673,2019
	string s;
	cin >> s;
	int n = s.size();
	memset(dp,0,sizeof(dp));
	// for(int i=1; i<=n; i++){
	// 	dp[i][s[i-1]-'0']++;
	// 	for(int j=0; j<2019; j++){
	// 		if(dp[i-1][j]!=0){
	// 			dp[i][(j*10 + s[i-1]-'0')%2019] += dp[i-1][j];
	// 		}
	// 	}
	// }
	// for(int i=0; i<=n; i++){
	// 	for(int j=0; j<2019; j++){
	// 		if(dp[i][j]!=0){
	// 		cout << dp[i][j] sp i sp j << " ";
	// 		}
	// 	}
	// 	cout<< endl;
	// }
	// int ans =0;
	// for(int i=1; i<=n; i++){
	// 	ans += dp[i][0];
	// }
	//cout << dp[n][0] << endl;
	int row=1, ans=0;
	for(int i=1; i<=n; i++){
		dp[row][s[i-1]-'0']++;
		for(int j=0; j<2019; j++){
			if(dp[row^1][j]!=0){
				dp[row][(j*10 + s[i-1]-'0')%2019] += dp[row^1][j];
			}
		}
		ans += dp[row][0];
		row=row^1;
		for(int j=0; j<2019; j++){
			dp[row][j] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3932
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s,t;
  cin >> s >> t;
  int ls = s.size(),lt = t.size();
  vector<vector<int>> v(ls+1,vector<int>(lt+1));
  for(int i = 0; i < ls; ++i){
    for(int j = 0; j < lt; ++j){
      if(s[i] == t[j]) v[i+1][j+1] = 1+v[i][j];
      else v[i+1][j+1] = max(v[i][j+1],v[i+1][j]);
    }
  }
  int ans = v[ls][lt],row = ls,col = lt;
  string ret;
  while(ans > 0){
    while(v[row-1][col] == ans) --row;
    while(v[row][col-1] == ans) --col;
    ret.push_back(s[row-1]);
    --row;
    --col;
    --ans;
  }
  reverse(begin(ret),end(ret));
  cout << ret;
  return 0;
}

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define re return
#define ull unsigned long long
#define ll long long
#define ld long double
#define f first
//#define s second
#define oo 1e9
#define pi acos(-1)
#define OO 4e18
#define EPS 1e-12
#define FX(n) fixed<<setprecision(n)
#define mm(o,k) memset(o,k,sizeof o)
#define Hossam_Yehia ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
string s;
int main(){
    Hossam_Yehia;
    cin >> s;
    if(s.find('9')!=-1)cout<<"Yes";
    else cout<<"No";
    re 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,M;

int V;
struct edge{int to,cost;};
vector<edge> G[SIZE*5];
int d[SIZE*5];
map<int,int> S[SIZE];
void dijkstra(int s);
int t;

void add_edge(int p,int q,int c){
	if(S[p].find(c) == S[p].end()){
		S[p][c] = ++t;
		G[p].push_back((edge){t,0});
		G[t].push_back((edge){p,1});
	}
	if(S[q].find(c) == S[q].end()){
		S[q][c] = ++t;
		G[q].push_back((edge){t,0});
		G[t].push_back((edge){q,1});
	}
	int t1 = S[p][c];
	int t2 = S[q][c];
	G[t1].push_back((edge){t2,0});
	G[t2].push_back((edge){t1,0});
}


int main()
{
	cin >> N >> M;
	t = N;
	rep(i,0,M){
		int p,q,c;
		cin >> p >> q >> c;
		add_edge(p,q,c);
	}
	V = t+1;
	dijkstra(1);
	if(d[N]>=INF)d[N]=-1;
	cout << d[N] << endl;

	return 0;
}

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P>> que;
	fill(d,d+V,INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p = que.top();que.pop();
		int v = p.second;
		if(d[v] < p.first)continue;
		for(int i=0;i<G[v].size();i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}


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

using namespace std;
char a[22],b[22];
int main(){
  cin>>a>>b;
  int len=strlen(a);
  for(int i=0;i<len;i++){
    if(a[i]!=b[i]){
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 100100;
int a[N], b[N], c[N];
int n;
ll ans;

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &b[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &c[i]);
	sort(a, a + n);
	sort(b, b + n);
	sort(c, c + n);
	int it1 = 0, it3 = 0;
	for (int i = 0; i < n; i++) {
		while(it1 < n && a[it1] < b[i]) it1++;
		while(it3 < n && c[it3] <= b[i]) it3++;
		ans += (ll)it1 * (n - it3);
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  in6 a,b;
  cin >> a >> b;
  in6 s = max(a,b);
  in6 t = min(a,b);
  in6 gcd;
  while(true) {
    s = s % t;
    if(s == 0) {
      gcd = t;
      break;
    }
    t = t % s;
    if(t == 0) {
      gcd = s;
      break;
    }
  }
  cout << a * b / gcd << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;
 
ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
 
ll mod(ll a, ll b) {return (a % b + b) % b;}
 
ll powerm(ll base,ll exp,ll mod) 
{ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}

using namespace std;

int main()
{
	fast;
	ll n; cin>>n; 
	ll arr[n];
	for(ll i = 0; i < n; i++)
	{
		cin >> arr[i];
		if(arr[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	ld L = 0;
    for(ll i = 0 ; i < n; i++) 
	{
        L += log10(arr[i]);
    }
    if (L > 18.1) 
	{
        cout << -1 << endl; 
		return 0;
    }
    ll ans = 1;
    for(ll i = 0; i < n; i++) ans *= arr[i];
    if (ans > 1000000000000000000) 
	{
        cout << -1 << endl; 
		return 0;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

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

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

ll a[100010];


int main() {
  ll n,m;cin>>n>>m;
  rep(i,n) {
    cin>>a[i];
    a[i]/=2;
  }
  ll cnt=0,a_0=a[0];
  while(1) {
    if(a_0%2==0) {
      cnt++;
      a_0/=2;
    }else {
      break;
    }
  }
  rep(i,n){
    if((a[i]%(1<<cnt)!=0) || (a[i]%(1<<(cnt+1))==0)) {
      cout<<0<<endl;
      return 0;
    }
  }
  
  ll lcm=1;
  rep(i,n) {
    lcm = LCM(lcm,a[i]);
  }
  cout<<(m/lcm+1)/2<<endl;
}

Measured memory_bytes: 4272
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    for i:=0;i<len(s);i+=2{
        fmt.Printf("%c",s[i])
    }
    fmt.Println("")
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

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

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

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define in(x) cin >> x
#define debug(x) cerr << (x) << " "
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
string s;
int y, m, d;

void input() {
  in(s);
}

void solve() {
  y = stoi(s.substr(0, 4));
  m = stoi(s.substr(5, 2));
  d = stoi(s.substr(8, 2));
  if(y<2019){
    return;
  } else if(y>2019){
    ret = 1;
    return;
  }
  if(m<=4){
    return;
  }else if(m>4){
    ret = 1;
    return;
  }
}

int main(void){
  input();
  solve();
  PRINT(((ret==0)?"Heisei":"TBD"));
}


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

const int MAXN = 100000;

int x[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++)
        cin >> x[i];
    sort(x, x + n);
    ll ans = 0;
    for(int i = 1; i < n; i++) {
        ans += min((x[i] - x[i - 1]) * (ll)a, (ll)b);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768