akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(){

  int i,j,k=0,dir,a,b;
  char ch;
  string str,direction,p;

  cin>>str;
  cin>>dir;

  for(i=0; i<dir; i++){

    j=k=0;    
    cin>>direction;
    cin>>a>>b;
    
    if(direction=="print"){
 
      cout<<str.substr(a,b-a+1)<<endl;

    }else if(direction=="reverse"){

      for(j=a; j<=(b-a)/2+a; j++){
        ch=str[j];
        str[j]=str[b+a-j];
        str[b+a-j]=ch;

      }
    }else if(direction=="replace"){

      cin>>p;
      for(j=a; j<=b; j++){
        str[j]=p[k];
        k++;
      }
      
    }

  }
  
}

Measured memory_bytes: 1220
S = input()
keyence = 'keyence'
n = False
for i in range(len(S) + 1):
    for j in range(i, len(S) + 1):
        rest_str = S[:i] + S[j:]
        if rest_str == keyence:
            n = True
            break
    if n:
        break
if n:
	print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    /* code */
    long long H;
    scanf("%lld", &H);
    long long L = 0;
    long long dummy = H;
    while(dummy > 0.5)
    {
        L += 1;
        dummy = dummy / 2;
    }
    long long result = pow(2, L) - 1;
    printf("%lld", result);
    return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MOD = 1e9+7;
const ll LINF = 1e18;
const int INF = 1e9;
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    while(N>=0)
    {
        if(N%4==0)
        {
            cout << "Yes";
            return 0;
        }
        N-=7;
    }

    cout << "No";
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>

#define INT unsigned long long int
#define FORN(n) for(int i=0;i<n;i++)
#define PINT(d) printf("%d\n", d);
#define PDOUBLE(lf) printf("%lf\n", lf);
#define PSTR(s) printf("%s\n", s);
#define N 1000000007
#define MAX_N 500000

using namespace std;

main(){
    char way;
    bool flag = true, direction[4] = {false, false, false, false};
    int i = 0;
    while(flag){
        scanf("%c", &way);
        switch(way){
            case 'S':
                direction[0] = true;
                break;
            case 'E':
                direction[1] = true;
                break;
            case 'N':
                direction[2] = true;
                break;
            case 'W':
                direction[3] = true;
                break;
            default:
                flag = false;
                true;
        }
    }
    if((direction[0] == direction[2]) && (direction[1] == direction[3])){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {

		HashSet<Integer> accepted = new HashSet<>();

		HashMap<Integer, Integer> penalty = new HashMap<>();

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		IntStream.rangeClosed(1, n).forEach(i -> penalty.put(i, 0));

		for (int i = 0; i < m; i++) {
			int problem = sc.nextInt();
			String result = sc.next();
			if (!accepted.contains(problem)) {
				// まだ正解していない
				if (result.equals("AC")) {
					accepted.add(problem);
				} else {
					int prev = penalty.get(problem);
					penalty.put(problem, prev + 1);
				}
			}
		}
		int penaltyNum = 0;
		for (int acceptedProblem : accepted) {
			penaltyNum = penaltyNum + penalty.get(acceptedProblem);
		}
		print(accepted.size() + " " + penaltyNum);
		sc.close();
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


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

int a,b,c;
ll solve(){
   ll ans=0;
   int sum=a+b+c;
   int mx=max(max(a,b),c);
   while(sum<mx*3||sum%3!=0){
       ans++;
       sum+=2;
   }

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

    cin>>a>>b>>c;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = scan.nextInt();
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int m = scan.nextInt();
			x -= m;
			min = Math.min(min, m);
		}
		System.out.println(n + (x / min));
	}
	public static void main(String[] args) {
		new Main().run();
	}
}


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

//ねこのあな
int main() {
    int l;
    cin >> l;
    stack<int> c;
    bool can = true;
    int error = 0;
    vector<int> data(l,0);
    rep(i,l){
        cin >> data[i];
    }
    vector<bool> now(l+1,false);
    rep(i,l){
        if(data[i] > 0){//はいる時
            if(now[data[i]] == false){
                now[data[i]] = true;
                c.push(data[i]);
            }
            else{
                cout << i+1 << endl;
                return 0;
            }
        }else{//出る時
            if(i == 0 && data[i] < 0){
                cout << 1 << endl;
                return 0;
            }
            if(c.top() == 0-data[i] && now[0-data[i]] == true){
                now[0-data[i]] = false;
                c.pop();
            }else{
                cout << i+1 << endl;
                return 0;
            }
        }
    }
    cout << "OK\n";
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3120
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
p = []
for i, a in enumerate(A):
    idx = i+1
    if a>idx:
        a,idx = idx, a
    p.append((a, idx))
c = Counter(p)
ans = 0
for k,v in c.items():
    if v==2:
        ans += 1
print(ans)

Measured memory_bytes: 28504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
  int A;
  cin >>A;
  cout << 3*A*A<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  int l[n];
  int i;
  i = 0;
  while (i < n)
  {
    scanf("%d",&l[i]);
    i++;
  }
  if (n < 3)
  {
    printf("0");
    return (0);
  }
  int j = 0;
  i = 0;
  int k = 0;
  int cnt = 0;
  while (i < n)
  {
    j = i + 1;
    while (j < n)
    {
      k = j + 1;
      while (k < n)
      {
      	if ((l[i] + l[k] > l[j] && l[i] + l[j] > l[k] && l[k] + l[j] > l[i]) && l[i] != l[k] && l[i] != l[j] && l[k] != l[j])
      	{
          //printf("%d:%d:%d\n",l[i],l[j],l[k]);
          cnt++;
        }
        k++;
      }
      j++;
    }
    i++;
  }
  printf("%d",cnt);
}

Measured memory_bytes: 1680
S=input()
A=[int(S[i]) for i in range(0,len(S))]
s1=0
for i in range(0,len(S)):
    if i%2==0:
        s1+=0^A[i]
    else:
        s1+=1^A[i]
s2=0
for i in range(0,len(S)):
    if i%2==0:
        s2+=1^A[i]
    else:
        s2+=0^A[i]
print(min(s1,s2))


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n, kk;
  int x[50], y[50];
  cin >> n >> kk;
  rep(i, 0, n) cin >> x[i] >> y[i];
  ll ans = 1e19;
  rep(i, 0, n) rep(j, 0, n) rep(k, 0, n) rep(l, 0, n) {
    int c = 0;
    ll mtx = max(x[i], max(x[j], max(x[k], x[l])));
    ll mox = min(x[i], min(x[j], min(x[k], x[l])));
    ll mty = max(y[i], max(y[j], max(y[k], y[l])));
    ll moy = min(y[i], min(y[j], min(y[k], y[l])));
    rep(m, 0, n) {
      if(x[m] <= mtx && x[m] >= mox && y[m] <= mty && y[m] >= moy) {
        c++;
      }

    }
    if(c >= kk) {
      ans = min(ans, (mtx - mox) * (mty - moy));
    }
  }
  cout << ans << endl;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int n;
  cin >> n;
  int di = n%10;
  if (di == 0 || di == 1 || di == 6 || di == 8) {
    cout << "pon\n";
  } else if (di == 3) {
    cout << "bon\n";
  } else {
    cout << "hon\n";
  }
}


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};
int main(void) {
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind fr(N);
  map<int, int> mfr, mbl;
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    mfr[A]++;
    mfr[B]++;
    fr.unite(A, B);
  }
  for (int i = 0; i < K; i++) {
    int C, D;
    cin >> C >> D;
    C--;
    D--;
    if (fr.find(C) == fr.find(D)) {
      mbl[C]++;
      mbl[D]++;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << max(0, fr.size(i) - mfr[i] - mbl[i] - 1) << " ";
  }
  return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
    int n, i, a[100000], m=1000000000, k=0;
    long long sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]<0)
        {
            a[i]=-a[i];
            k++;
        }
        sum=sum+a[i];
        if(a[i]<m)
            m=a[i];

    }
    if(k%2==1)
    {
        sum=sum-2*m;
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 640
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let n = input
        .split_whitespace()
        .nth(0)
        .unwrap()
        .parse::<usize>()
        .unwrap();
    let list = input
        .split_whitespace()
        .skip(1)
        .map(|x| x.parse::<i64>().unwrap())
        .collect::<Vec<_>>();

    //i-1からiまでの料金
    let ens = {
        let mut now = 0;
        let mut v = Vec::new();
        for &x in &list {
            v.push((x - now).abs());
            now = x;
        }

        v
    };

    //全部行った時の料金
    let ens_sum = {
        let mut now = 0;
        let mut sum = 0;
        for &x in &list {
            sum += (x - now).abs();
            now = x;
        }

        sum + now.abs()
    };

    let mut out = Vec::new();
    for i in 0..list.len() {
        out.push(
            if i == n - 1 {
                ens_sum - ens[i] - list[i].abs() + list[i - 1].abs()
            } else if i == 0 {
                ens_sum - ens[i] - ens[i + 1] + list[i + 1].abs()
            } else {
                //iに行かない
                ens_sum - ens[i] - ens[i + 1] + (list[i - 1] - list[i + 1]).abs()
            }.to_string(),
        );
    }
    out.join("\n").to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "3\n3 5 -1" => "12\n8\n10",
    test2: "5\n1 1 1 2 0" => "4\n4\n4\n2\n4",
    test3: "6\n-679 -2409 -3258 3095 -3291 -4462" => "21630\n21630\n19932\n8924\n21630\n19288",
}


Measured memory_bytes: 15864
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define endl '\n'
//#define int long long


signed main() { //[J][O][L][S][K][E][Y]
        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int mas[3];
        cin >> mas[0] >> mas[1] >> mas[2];
        sort(mas, mas + 3);
        if ((mas[0] == mas[1] && mas[1] != mas[2]) || (mas[1] == mas[2] && mas[1] != mas[0]))
                cout << "Yes";
        else cout << "No";
        return 0;
}

/*

*/

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1
MOD = 10 ** 9 + 7


def nCr_mod(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % MOD
        q = q * (i + 1) % MOD
    return p * pow(q, MOD - 2, MOD) % MOD


N, K = map(int, input().split())
for i in range(1, K + 1):
    print(nCr_mod(K - 1, i - 1) * nCr_mod(N - K + 1, i) % MOD)


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

int main() {
    int X = 0;
    cin >> X;
    int a = X % 500;
    int b = X - a;
    int x1 = b / 500;
    int c = a % 5;
    int d = a - c;
    int x2 = d / 5;
    int sum = x1*1000 + x2*5;
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vb = vector<bool>;
using vs = vector<string>;
using pint = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

    cout << 3 * r * r << endl;
    
    return 0;
}

Measured memory_bytes: 256
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]

import math
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ck = 0
    for k in range(D):
      ck += (X[i][k] - X[j][k])**2
    if math.sqrt(ck).is_integer():
      ans += 1

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
    int  n;
    cin>>n;
    ll a;
    map<ll,int> bou;
    vector<ll> hen;
    for(int i=0;i<n;i++){
        cin>>a;
        bou[a]++;
        if(bou[a]%2 == 0 && bou[a]!=0){
            hen.push_back(a);
        }
    }
    sort(hen.begin(),hen.end(),greater<ll>());
    ll ans = 0;
    if(hen.size() < 2) cout<<ans<<endl;
    else{
        ans = hen[0]*hen[1];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,x,n) for(int i=x;i<n;i++)
#define WHITE 0
#define BLACK 1
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
string s;
int k;
int INFi=1000000000;
ll INFl=1000000000000000;

struct UnionFind{
    vector<int> par;//初期化
    vector<int> rank;//高さ
    UnionFind(int n=0):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);//経路圧縮
    }
    void unite(int x,int y){
        int rx=root(x);
        int ry=root(y);
        if(rx==ry) return;
        if(rank[rx]<rank[ry]) rank[rx]=ry;
        else rank[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};
struct edge{int from,to,cost;};
vector<edge> es(100); //辺の集合
vector<int> d(100,INFi);//最短距離
int V,E;//頂点数、辺数

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}




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

int main(){
    int N;
		cin >> N;
		vector<int> H(N);
		for(int i = 0; i < N; ++i) cin >> H[i];

		int cnt = 0;

		for(int i = 0; i < N; ++i) {
			bool flag = false;
			for(int k = 0; k < i; ++k) {
				if(H[k] <= H[i] && flag == false) {
				} else {
					flag = true;
				}
			}

			if(flag == false) {
				cnt++;
			}
		}

		cout << cnt << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_Rally
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = ReadLine();
            string[] array = input.Split(' ');
            int[] n = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                n[i] = int.Parse(array[i]);
            }
            int a = 0;
            a = n[0] * n[1] % 2;
            if (a == 0)
            {
                WriteLine("Even");
            }
            else {

                WriteLine("Odd");
            }

            

        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=200005;
vector<int> ea[maxn],eb[maxn];
int st[maxn],ed[maxn],n,S,rt,ans,vis[maxn],fa[maxn];
int dep[maxn];
const int inf=1e9;
inline void dfs(int x,int f){
	for(int w:eb[x]){
		if(w==f)continue;
		dep[w]=dep[x]+1;
		fa[w]=x;
		dfs(w,x);
	}
}
inline void calc(int x,int f,int cur){
	if(ans==inf)return;
	if(dep[x]<cur)return;
	if(dep[x]==cur){
		ans=max(ans,cur<<1);
		return;
	}
	if(vis[x]){
		ans=inf;return;
	}
	for(int w:ea[x]){
		if(w==f)continue;
		calc(w,x,cur+1);
	}
	ans=max(ans,dep[x]<<1);
}
inline bool get(int x,int y){
	if(dep[x]<dep[y])swap(x,y);
	if(fa[x]==y)return 0;
	if(fa[fa[x]]==y)return 0;
	if(fa[x]==fa[y])return 0;
	return 1;
}
int main(){
	read(n);read(S);read(rt);
	rep(i,1,n-1){
		read(st[i]);read(ed[i]);
		ea[st[i]].pb(ed[i]);
		ea[ed[i]].pb(st[i]);
	}
	rep(i,1,n-1){
		int x,y;read(x);read(y);
		eb[x].pb(y);eb[y].pb(x);
	}
	dfs(rt,0);
	rep(i,1,n-1)if(get(st[i],ed[i]))vis[st[i]]=vis[ed[i]]=1;
	calc(S,0,0);
	if(ans==inf)
		puts("-1");
	else
		printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 31740
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define gc getchar()
#define mp make_pair
#define P pair<int,int>
#define ri register int
#define rb register bool
#define rc register char
#define t(i) edge[i].to
#define w(i) edge[i].wei
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
#define e(i,x) for(ri i=head[x];i;i=edge[i].nxt)

const int N=2e5+10;
int n,x,a[N],tmp;
bool vis[N];

il int read()
{
	rc ch=gc;ri x=0;rb y=1;
	while(ch!='-' && (ch<'0' || ch>'9'))ch=gc;
	if(ch=='-')ch=gc,y=0;
	while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
	return y?x:-x;
}

int main()
{
	n=read();x=read();if(x==1 || x==n*2-1)return printf("No\n"),0;printf("Yes\n");
	if(x==2){a[n]=2;a[n+1]=1;tmp=2;n=n*2-1;rp(i,1,n)if(!a[i])a[i]=++tmp;rp(i,1,n)printf("%d\n",a[i]);return 0;}
	a[n]=x;a[n+1]=x+1;a[n-1]=x-1;a[n+2]=x-2;vis[x]=vis[x+1]=vis[x-1]=vis[x-2]=1;
	tmp=1;n=n*2-1;rp(i,1,n)if(!a[i]){while(vis[tmp])++tmp;a[i]=tmp;vis[tmp]=1;}rp(i,1,n)printf("%d\n",a[i]);
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
//#ifndef ONLINE_JUDGE
//#  define LOG(x) (cerr << #x << " = " << (x) << endl)
//#else
//#  define LOG(x) 0
//#endif
#define pb push_back
#define mod 1000000007
#define endl '\n'
typedef int integer;
#define int long long
using namespace std;

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

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

const integer NN = 200005;
int ar[NN];
int n, m, k;
vector<int> adj[NN];


integer main() {
    ios_base::sync_with_stdio(false);

    int t = 1;
//    cin >> t;
    while (t--) {
        double r;
        cin >> r;
        cout << fixed << setprecision(10) << 2 * 2 * acos(0.0) * r << endl;

    }

}



Measured memory_bytes: 8492
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
void solve(){
  string s,t;
  cin>>s>>t;
  s+=s;
  cout<<(s.find(t)==string::npos?"No":"Yes")<<endl;	
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

int main( void )
{
    int x, a, b;
    cin >> x >> a >> b;
    if ( abs( a - x ) < abs( b - x ) )
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "B" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
double a, b, c, d, e, f;

int main(){
    while(cin >> a >> b >> c >> d >> e >> f){
        double y = (a * f - c * d) / (a * e - b * d);
        double x = (c - b * y) / a;
        cout << fixed << setprecision(3) << x << " " << y << endl;
    }
}

Measured memory_bytes: 3200
#include <algorithm>
#include <cstdio>

using namespace std;

const int MAXN = 100000;
int t[MAXN], n, c, k;

int main() {
	scanf("%d%d%d", &n, &c, &k);
	for(int i = 0; i < n; i++)
		scanf("%d", &t[i]);
	sort(t, t + n);
	int p = c, d, sol = 0;
	for(int i = 0; i < n; i++) {
		if(p == c || t[i] > d) {
			sol++;
			p = 0;
			d = t[i] + k;
		}
		p++;
	}
	printf("%d\n", sol);
	return 0;
}


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

int main(){
  	int n,k,l[50],memo = 0;
  	cin >> n >> k;
  	
  	rep(i,0,n) cin >> l[i];
  
  	sort(l,l+n,greater<int>());
  	
  	rep(i,0,k){
      memo += l[i];
    }
  
  	cout << memo << endl;
    
  	return 0;
}

Measured memory_bytes: 256
fun main(){
    val num = readLine()!!.toLong()

    var x = num
    var tempX = num
    var count = 0
    val sosuuList = decom(num)
    sosuuList.forEach {
        x = num
        var kisuu = 1L
        while (x % (it * kisuu) == 0L){
            val keisango = it * kisuu
            x /= keisango
            count++
            kisuu = keisango
        }
        while (tempX % it == 0L){
            tempX /= it
        }
    }
    if (isPrime(tempX)) count++

    if (num < 2) println(0)
    else println(count)
}



// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from : Long, to : Long = from) : List<Long> {
    return (from..to).filter { i -> isPrime(i) }
}

// 素因数分解
fun decom(value : Long) : List<Long>{
//    if (value == 1L) return listOf(1)
    if (value == 1L) return emptyList()
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

fun isPrime(num: Long): Boolean {
    if (num < 2)
        return false
    else if (num == 2L)
        return true
    else if (num % 2 == 0L) return false // 偶数はあらかじめ除く

    val sqrtNum = Math.sqrt(num.toDouble())
    var i = 3
    while (i <= sqrtNum) {
        if (num % i == 0L) {
            // 素数ではない
            return false
        }
        i += 2
    }

    // 素数である
    return true
}

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

int main(){
  int n,k;
  cin>>n>>k;
  int x[n];
  REP(i,n){
    cin>>x[i];
  }
  int ans=0;
  for (int i = 0; i < n; i++)
  {
    /* code */
    ans+=min(abs(x[i]-k)*2,x[i]*2);
  }
  cout<<ans<<endl;
  
  }

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		int m;
		cin>>m;
		vector<vector<int> >cost(n,vector<int>(n));
		rep(i,n)rep(j,n)cost[i][j]=inf;
		vector<int>used(n);
		rep(i,m){
			int a,b,c;
			char d;
			cin>>a>>d>>b>>d>>c;
			c=(c-100)/100;
			cost[a][b]=cost[b][a]=c;
		}
		vector<int>d(n);
		rep(i,n)d[i]=inf;
		d[0]=0;
		int out=0;
		while(1){
			int v=-1;
			rep(i,n)if(!used[i]&&(v==-1||d[v]>d[i]))v=i;
			if(v==-1)break;
			used[v]=true;
			out+=d[v];
			rep(i,n)d[i]=min(d[i],cost[v][i]);
		}
		cout<<out<<endl;
	}
}

Measured memory_bytes: 1264
use std::io::Read;

fn main(){
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let n: i32 = iter.next().unwrap().parse().unwrap();
    let p: Vec<i32> = (0..n)
        .map(|_| { iter.next().unwrap().parse().unwrap() })
        .collect();
    let mut cnt = 0 ;
    for j in 1..n-1 {
        let i = j as usize;
        if (p[i-1] < p[i] && p[i] < p[i+1]) ||
           (p[i-1] > p[i] && p[i] > p[i+1]) { cnt+=1; };
    }
    println!("{}", cnt);
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int DP[100100];
int H[100100];
int main()
{
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
  {
    cin>>H[i];
    DP[i]=999999999;
  }
  DP[0]=0;
  for(int i=1;i<N;i++)
    for(int j=i-1;j>=0&&i-j<=K;j--)
      DP[i]=min(DP[i],DP[j]+abs(H[i]-H[j]));
  cout<<DP[N-1];
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define foreach(c,itr) for(__typeof(c)::iterator itr=c.begin();itr!=c.end();itr++)
typedef long long ll;
typedef long double ld;
int i,j;

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

    int k;
    cin>>k;
    rep(i,k) cout<<"ACL";
	return 0;
}


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

int main() {
  ll n, tmp;
  cin >> n;
  vector<ll> a(n + 1, 0);
  for(int i = 2; i <= n; i++)
  {
    cin >> tmp;
    if(tmp <= 0 || tmp >= i) continue;
    a[tmp]++;
  };
  for(int i = 1; i <= n; i++) {
    cout << a[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i=1; i < (int)(n); i++)
#define rrep(i, n) for (int i=((int)(n)-1); i>=0; i--)
#define rreps(i, n) for (int i=((int)(n)-1); i>0; i--)
#define ALL(x) (X).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using lint = long long;
using p = pair<int, int>;
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; }

int main() {
  lint N; cin >> N;
  lint sqN = sqrt(N);
  lint ans = 1e13;
  for (lint i = 1; i <= sqN; i++) {
    lint j = N / i;
    lint cnt = i + j - 2;
    if (i * j == N) {
      chmin (ans, cnt);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



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

	vector<int> a(n);

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

	int ans = 1;
	int index = k;
	while (index < n) {
		index += k - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>

int main() {
    char s[101], p[101], t[201];
    scanf("%s %s", s, p);
    strcpy(t, s);
    strcat(t, s);
    if (strstr(t, p) == NULL) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2760
n, a, b = map(int, input().split())
ans = 0

def calculate_digit_sum(n):
    digit_sum = 0
    for digit in str(n):
        digit_sum += int(digit)
    return digit_sum

for num in range(1, n + 1):
    
    if a <= calculate_digit_sum(num) and calculate_digit_sum(num) <= b:
        ans += num
print(ans)




Measured memory_bytes: 2940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long
const lint PN = 1e9+7;
using namespace std;

lint powmod(lint k,lint n)
{
  if(n==0){
    return 1;
  }
  if(n%2==0){
    return ((powmod(k,n/2)%PN)*(powmod(k,n/2)%PN))%PN;
  }else{
    return (k*powmod(k,n-1))%PN;
  }
}

lint fact2(lint n,lint a)
{
  lint ans=1;
  for(int i=0;i<a;i++){
    ans = (ans*(n-i))%PN;
  }
  return ans;
}

int main()
{
  lint n,a,b;
  cin >> n >> a >> b;

  lint a_fact=(fact2(a,a))%PN;
  lint b_fact=(fact2(b,b))%PN;
  lint nca = fact2(n,a)*(powmod(a_fact,PN-2))%PN;
  lint ncb = fact2(n,b)*(powmod(b_fact,PN-2))%PN;

  lint answer = powmod(2,n)-1-nca-ncb;
  if(answer<0){
    while(answer<0){
      answer += PN;
    }
  }else{
    answer %= PN;
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
import heapq

input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    heapq.heapify(A)
    while True:
        m1 = heapq.heappop(A)
        try:
            m2 = heapq.heappop(A)
        except IndexError:
            print(m1)
            break
        m2 %= m1
        heapq.heappush(A, m1)
        if m2 > 0:
            heapq.heappush(A, m2)


if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

void solve() {
    ll N, M, R;
    cin >> N >> M >> R;
    vector<ll> r(R);
    rep(i, R) cin >> r[i];
    Graph graph(N, vector<ll>(N, INF));
    rep(i, N) {
        graph[i][i] = 0;
    }
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a][b] = c;
        graph[b][a] = c;
    }
    warshall_floyd(graph);
    sort(r.begin(), r.end());
    ll ans = INF;
    do {
        ll start = r[0] - 1;
        ll cost = 0;
        rep2(i, 1, R) {
            ll next = r[i] - 1;
            cost += graph[start][next];
            start = next;
        }
        ans = min(ans, cost);
    } while (next_permutation(r.begin(), r.end()));
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3752
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

//よくわかんないけど通った？

ll dp[302][301];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N, K;
	scanf("%d", &N);
	scanf("%d", &K);
	int H[302] = {};
	rep1(i, N) scanf("%d", H + i);
	ll hutuu = 0;
	rep(i, N + 1) {
		if (H[i + 1] > H[i]) hutuu += H[i + 1] - H[i];
	}

	if (N == K) {
		printf("0");
		return 0;
	}

	rep(i, N + 1) {
		auto dpi = dp[i];
		ll tmp1 = max(0, H[i + 1] - H[i]);
		ll tmp2 = max(0, H[i] - H[i + 1]);
		ll tmp3 = min(tmp1, tmp2);
		int mae = H[i + 1];
		ll maetmp = tmp3;
		for (int j = i + 2; j <= min(N + 1, K + i + 1); j++) {
			if (mae < H[j]) tmp1 += H[j] - mae;
			if (mae > H[j]) tmp2 += mae - H[j];
			tmp3 = min(tmp1, tmp2);
			if (maetmp < tmp3) {
				int k = j - i - 1;
				auto dpj = dp[j] + k;
				rep(p, K - k + 1) if (dpj[p] < dpi[p] + tmp3) dpj[p] = dpi[p] + tmp3;
			}
			mae = H[j];
			maetmp = tmp3;
		}
		auto dpi2 = dp[i + 1];
		rep(p, K + 1) chmax(dpi2[p], dpi[p]);
	}
	printf("%lld", hutuu - dp[N + 1][K]);


	Would you please return 0;
}

Measured memory_bytes: 896
//             بسم الثالوث الاقدس
#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<set>
#include<fstream>
using namespace std;
//********************************************************************************************
//******************************************************************************************** 
/*
jesus help me.......
*/
typedef long long lld;
typedef char c;



/*
jesus help me.......
jesus help me.......
jesus help me.......
*/



int binarySearch(int arr[], int l, int r, int x)
{
	while (l <= r)
	{
		int m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;

}





bool sortbysec(const pair<int, char> &a, const pair<int , char> &b)
{
	return (a.first > b.first);
}	
////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
long long sum1(int n,long long a)
{
	if (n == 0)
		return 1;
	return 	a*sum1(n - 1, a + 1);
	

}
////////////////////////////////////////////////////////////////////

vector<vector<int>>vis(100, vector<int>(100, 0));
void fun(int i, int j,int a, int n, int m, vector<vector<int>>v, vector<string>&v2)
{
	if (a< 0||i<0||j<0||i==n||j==m||v2[i][j]=='B'||vis[i][j]==1)
		return;

	vis[i][j] = 1;
	v2[i][j] = 'Y';
		fun(i - 1, j, a - 1, n, m, v, v2);
		fun(i , j-1, a - 1, n, m, v, v2);
		fun(i +1, j, a - 1, n, m, v, v2);
		fun(i , j+1, a - 1, n, m, v, v2);
		vis[i][j] = 0;

}
////////////////////////////////////////////////////////////////////

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);


	//freopen("keys.in", "r", stdin);
	
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int r=0;
	for (int i = 0; i <= a; i++)
	{
		for (int j = 0; j <= b; j++)
		{
			for (int h = 0; h <= c; h++)
			{
				if (i * 500 + j * 100 + h * 50 == x)
					r++;
			}
		}
	}
	cout << r << endl;
	/////////system("pause");			


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n, m;
vector<vector<ll>> g;
vector<vector<ll>> dist;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    cin >> n >> m;
    g.resize(n);
    rep(i, m) {
        ll u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
    }
    ll s, t;
    cin >> s >> t;
    s--; t--;
    dist.resize(n, vector<ll>(3, inf));
    queue<pair<ll, ll>> q;
    q.push(make_pair(s, 0));
    dist[s][0] = 0;
    while(!q.empty()) {
        auto p = q.front(); q.pop();
        ll u = p.first, d = p.second;
        for(auto v : g[u]) {
            ll par = (d + 1) % 3;
            if (dist[v][par] <= (d + 1)) continue;
            dist[v][par] = d + 1;
            q.push(make_pair(v, d + 1));
        }
    }
    if (dist[t][0] == inf) cout << -1 << endl;
    else cout << (dist[t][0] / 3) << endl;
    return 0;
}


Measured memory_bytes: 11264
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

l, r = map(int, input().split())
ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        if ans > (i * j)%2019:
            ans = (i * j)%2019
        if ans == 0:
            print('0')
            sys.exit()
print(ans)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


ll hamburger(int N, ll X, ll layer){
  // レベルNバーガーの下からX層にパティは何枚存在するか
  // 但しレベルNバーガーの層の合計はlayerとする
  if (N == 0) return X;
  if (X == 0) return 0;
  
  ll res = 0;
  if (X == layer / 2 + 1) res = hamburger(N-1, X-2, (layer-3)/2) + 1;
  else if (X == layer) res = hamburger(N-1, (X-3)/2, (layer-3)/2) * 2 + 1;
  else if (X <= layer / 2) res = hamburger(N-1, X-1, (layer-3)/2);
  else res = hamburger(N-1, (layer-3)/2, (layer-3)/2) + 1 + hamburger(N-1, X - 2 - (layer-3)/2, (layer-3)/2);
  return res;
}

int main() {
  int N; cin >>N;
  ll X; cin >>X;
  ll layer = 1;
  rep(i, N) layer = 2 * layer + 3;
  ll res = hamburger(N, X, layer);
  cout <<res <<endl;
}

Measured memory_bytes: 256
from collections import deque
import math

def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

x, y = NextInts()

if x*2 <= y <= x*4 and y%2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9472
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int dm = 1 << 18;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N, M;
	scanf("%d", &N);
	scanf("%d", &M);
	char S[100001];
	scanf("%s", S);

	int kotae[100001];
	int k = 0;
	for (int i = N; i > 0;) {
		int atta = 0;
		for (int j = max(0, i - M); j < i; j++) {
			if (S[j] == '0') {
				kotae[k++] = i - j;
				i = j;
				atta = 1;
				break;
			}
		}
		if (atta == 0) {
			printf("-1\n");
			return 0;
		}
	}

	if (M == 1) {
		rep(i, N) {
			*di++ = '1';
			*di++ = ' ';
		}
	}
	else {
		for (int i = k - 1; i >= 0; i--) {
			putint(kotae[i]);
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1024
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for a,b in zip(A,B):
   if a>b:count -=a-b
   elif b>a:count +=(b-a)//2

print("Yes" if count>=0 else "No")

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

class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        int w = scan.nextInt(), n = scan.nextInt();
        int[] a = new int[n], b = new int[n];
        int[] ans = new int[w];

        scan.useDelimiter(",|\n");

        for (int j = 0; j < n; j++)
        {
            a[j] = scan.nextInt();
            b[j] = scan.nextInt();
        }

        for (int i = 1; i <= w; i++)
        {
            int now = i;

            for (int j = 0; j < n; j++){
                if (a[j] == now)
                {
                    now = b[j];
                }
                else if (b[j] == now)
                {
                    now = a[j];
                }
            }
            ans[now - 1] = i;
        }

        for (int i = 0; i < w; i++) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 26168
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9 + 7;

class matrix{
public:
  int n;
  vector<vector<int>> a;

  matrix(){}
  
  matrix(int n, int value){
    this->n = n;
    a = vector<vector<int>>(n, vector<int>(n, value));
  }

  matrix operator* (const matrix& mat){
    matrix ret(this->n, 0);

    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
	for(int k = 0; k < n; k++){
	  ret.a[i][j] = (ret.a[i][j] + (long long)this->a[i][k] * mat.a[k][j] % MOD) % MOD;
	}
      }
    }
    
    return ret;
  }
};

int main(){

  int N;
  long long K;
  cin >> N >> K;

  matrix a(N, 0);

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

  vector<matrix> mat2(60);
  mat2[0] = a;
  for(int i = 1; i < 60; i++){
    mat2[i] = mat2[i - 1] * mat2[i - 1];
  }

  matrix matAns(N, 0);
  for(int i = 0; i < N; i++){
    matAns.a[i][i] = 1;
  }
  
  for(int i = 0; i < 60; i++){
    if(K & (1LL << i)){
      matAns = matAns * mat2[i];
    }
  }

  long long ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      ans = (ans + matAns.a[i][j]) % MOD;
    }
  }

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


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
int main(){
    int N, D;
    cin >> N >> D;
    int ans;
    if(N % (D * 2 + 1) > 0)ans = N / (D * 2 + 1) + 1;
    else ans = N / (D * 2 + 1);
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(long long ,long long);
int main(){
  long long x,y,a;
  while(cin>>x>>y){
    a=gcd(x,y);
  cout<<a<<endl;
  }
  return 0;
}

int gcd(long long x,long long y){
  while(x!=y){
    if(x>y){
      x=x%y;
      if(x==0) return y;
    }
    else{
      y=y%x;
      if(y==0) return x;
    }
  }
  return x;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
 
using namespace std;
 
main()
{
    fast;
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[1]-a[0]+a[2]-a[1]<<endl;
}

Measured memory_bytes: 256