akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<string> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	map<string,bool> m;
	m[v[0]] = 1;
	bool d = 1;
	for (int i = 1; i < n; ++i) {
		if (v[i][0] != v[i - 1][(int)v[i - 1].size() - 1] || m[v[i]]) {
			d = 0;
		}
		m[v[i]] = 1;
	}
	if (d) {
		cout << "Yes";
	}else {
		cout << "No";
	}
}


Measured memory_bytes: 256
//
// Created by Myabu on 2020/01/25.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    int X;
    cin>>X;

    if(X==3 || X==7 || X==5){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    return 0;
}

Measured memory_bytes: 888
from collections import Counter
num = int(input())
value = [input() for i in range(num)]
votes = Counter(value)
dict = {}

for value in votes.values():
    dict[value] = []

for (key, value) in votes.items():
    dict[value].append(key)
maxVote = sorted(dict.keys(), reverse=True)[0]
list_data = dict[maxVote]
list_data.sort()
for i in list_data:
    print(i)

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

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			for (string inp; (inp = Console.ReadLine()) != "0 0";)
			{
				var inp_arr = inp.Split(' ').Select(int.Parse).ToArray();
				Console.WriteLine(inp_arr[0] < inp_arr[1] ? inp_arr[0]+" "+inp_arr[1] : inp_arr[1]+" "+ inp_arr[0]);
			}
		}
	}
}



Measured memory_bytes: 16392
D = int(input())
C = list(map(int, input().split()))
S = []
for _ in range(D):
    ver = list(map(int,input().split()))
    S.append(ver)
d = 0
last = [0 for _ in range(26)]

t = []
for d in range(1, D+1):
    dc = [C[i]*(d-last[i]) for i in range(26)]
    best = []
    for i in range(26):
        if_i = S[d-1][i] + dc[i]
        best.append(if_i)
    t.append(best.index(max(best))+1)
    #indexの要素の重複を考えない
    last_i = best.index(max(best))
    last[last_i] += 1
for t_i in t:
    print(t_i)

Measured memory_bytes: 9536
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto t = reads!long;
    long a = t[0], b = t[1], c = t[2], k = t[3];

    writeln(k % 2 == 0 ? a - b : b - a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<double> v;
    for(int i = 0;i < n;i++)
    {
        double x;
        cin >> x;
        v.push_back(x);
    }
    while(v.size() > 1)
    {
        sort(v.begin(),v.end(),greater<double>());
        v.at(v.size() - 2) = (v.at(v.size() - 1) + v.at(v.size() - 2)) / 2.0;
        v.pop_back();
    }
    cout << v.at(0);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;


void solve()
{
    ll n;
    cin>>n;
    ll i;
    ll res=1e18;
    for(i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ll no=n/i;
            ll tans=i+no-2;
            res=min(res,tans);
        }
    }   
    cout<<res<<"\n";
}



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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

int div_ceil(int n, int w)
{
	return (n + (w - 1)) / w;
}

int main()
{
    int N, D;
    cin >> N >> D;
    cout << div_ceil(N, D * 2 + 1) << endl;
    return 0;
}


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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> v(n);
    for(int i=0;i<n;i++){
        std::cin >> v[i];
    }
    for(int j=0;j<n;j++){
        std::cout << v[j];
        if(j<(n-1)) std::cout << " ";
        else std::cout << "\n";
     }
    for(int i=1;i<n;i++){
        int comp = v[i];
        int j = i-1;
        while(j>=0 && v[j] > comp){
            v[j+1] = v[j];
            j--;
        }
        v[j+1] = comp;
        for(int j=0;j<n;j++){
            std::cout << v[j];
            if(j<(n-1)) std::cout << " ";
            else std::cout << "\n";
        }
    }
    return 0;
}


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

public class Main {
    static int n,m;
    static int[][]vals;
    static long[][][]memo;

    static long dp(int c,int i,int j){
        if (i==n&&j==m)
            return 0;
        if (memo[c][i][j]!=-1)
            return memo[c][i][j];

        long ans=(long)-1e16;
        if (i<n){
            if (vals[i+1][j]!=0){
                ans=Math.max(ans,vals[i+1][j]+dp(2,i+1,j));
            }
            ans=Math.max(ans,dp(3,i+1,j));
        }
        if (j<m){
            if (vals[i][j+1]!=0){
                if (c>0)
                ans=Math.max(ans,vals[i][j+1]+dp(c-1,i,j+1));
            }
            ans=Math.max(ans,dp(c,i,j+1));
        }
        return memo[c][i][j]=ans;
    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = sc.nextInt();
        m = sc.nextInt();
        int k = sc.nextInt();
        vals= new int[n+1][m+1];
        memo= new long[4][n+1][m+1];
        while (k-->0)
            vals[sc.nextInt()][sc.nextInt()]=sc.nextInt();
        for (long[][]x:memo)for (long[]z:x)Arrays.fill(z,-1);

        pw.println(Math.max(vals[1][1]+dp(2,1,1),dp(3,1,1)));
        pw.close();

    }



    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

Measured memory_bytes: 409240
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int gcds(int a, int b){
    int c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << (a-c) / (b+c) << endl;
}

Measured memory_bytes: 3568
#include <cstdio>

const int MAXH = 105;
const int MAXW = 10;
const int MOD = 1000000007;

const int fib[] = {0, 1, 1, 2, 3, 5, 8, 13, 21};
int f[MAXH][MAXW];

int main() {
    int h, w, k;
    scanf("%d %d %d", &h, &w, &k);

    f[1][1] = fib[w];
    f[1][2] = fib[w - 1];
    for (int i = 2; i <= h; i++) for (int j = 1; j <= w; j++) {
        f[i][j] = 1ll * f[i - 1][j] * fib[j] % MOD * fib[w - j + 1] % MOD;

        if (j > 1) {
            f[i][j] += 1ll * f[i - 1][j - 1] * fib[j - 1] % MOD * fib[w - j + 1] % MOD;
            f[i][j] >= MOD ? f[i][j] -= MOD : 0;
        }
        if (j < w) {
            f[i][j] += 1ll * f[i - 1][j + 1] * fib[j] % MOD * fib[w - j] % MOD;
            f[i][j] >= MOD ? f[i][j] -= MOD : 0;
        }
    }

    printf("%d\n", f[h][k]);
    
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool ans = true;
    for(int i = 0;i < s.length();i++)    if(s[i] == 'x') ans = false;
    for(int i = 0;i+6 <= s.length();i++)     if(s.substr(i, 6) == "eraser")  s.replace(i, 6, "x");
    for(int i = 0;i+5 <= s.length();i++)    if(s.substr(i, 5) == "erase")   s.replace(i, 5, "x");
    for(int i = 0;i+7 <= s.length();i++)    if(s.substr(i, 7) == "dreamer") s.replace(i, 7, "x");
    for(int i = 0;i+5 <= s.length();i++)    if(s.substr(i, 5) == "dream")   s.replace(i, 5, "x");
    for(int i = 0;i < s.length();i++)   if(s[i] != 'x') ans = false;
    if(ans) cout << "YES" << endl;
    else    cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(a, b, c) for(ll c=a;c<b;c++)
#define re(b, c) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;
  std::vector<ll> v;
  for(ll i=0;i<=10000;i++) v.push_back((i*(i+1))/2);
  ll l = lower_bound(v.begin(), v.end(), n) - v.begin();
  if(v[l]!=n){
    std::cout << "No" << '\n';
    return 0;
  }
  vvl ans = vv(l+1, 0, 0, ll);
  vector<set<ll>> num(l+1);
  set<ll> t;
  for(int i=1;i<=n;i++) t.insert(i);

  for(int i=0;i<l+1;i++){
    for(int j=0;j<i;j++){
      ll tmp = *num[j].begin();
      ans[i].push_back(tmp);
      num[j].erase(tmp);
    }
    for(int j=0;j<l-i;j++){
      ll tmp = *t.begin();
      t.erase(tmp);
      ans[i].push_back(tmp);
      num[i].insert(tmp);
    }
  }
  std::cout << "Yes" << '\n';
  std::cout << l+1 << '\n';
  for(int i=0;i<l+1;i++){
    std::cout << ans[i].size() << " ";
    for(int j=0;j<ans[i].size();j++) std::cout << ans[i][j] << (j==ans[i].size()-1?"\n":" ");
  }
  return 0;
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  int r;
  cin >> r;
  double ans;
  ans = 2*r*3.1415926;
  cout << ans << endl;
  return 0;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    string S;
    cin >> S;
    const int N = S.size();
    int ans = N;
    REP(i, 0, N - 1) {
        if (S[i] != S[i + 1]) {
            ans = min(ans, max(i + 1, N - i - 1));
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, a, k=0;
  cin >> n;
  map<int, int> type;
  for (int i = 0; i < n; i++) {
    cin >> a;
    ++(type[a]);
  }
  k = type.size();
  if (k % 2 == 0) cout << k-1 << '\n';
  else cout << k << '\n';
}


Measured memory_bytes: 4992
/*
 */

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
    LL X,Y;
    while (cin >> X >> Y) {
        int ans = 1;
        while (X*2 <= Y) {
            X *= 2;
            ans ++;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int K_MAX = 1000;

int N, K;

int ans(int x, int y) {

  int pos = min(x-1, N-x);
  pos = min(pos, y-1);
  pos = min(pos, N-y);
  return pos % 3 + 1;
}

int main() {

  cin >> N;
  cin >> K;

  for (int i = 0; i < K; i++) {
    int x, y;
    cin >> x >> y;
    cout << ans(x, y) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(){
  char s[4];
  int i,abc[3] = {0,0,0};
  scanf("%s",s);
  
  for(i = 0;i < 3;i++){
    if(s[i] == 'a')
      abc[0] = 1;
    if(s[i] == 'b')
      abc[1] = 1;
    if(s[i] == 'c')
      abc[2] = 1;
  }
  if(abc[0] == 1 && abc[1] == 1 && abc[2] == 1)
    puts("Yes");
  else 
    puts("No");
  
  return 0;
}

Measured memory_bytes: 128
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline

N, *abc = map(int, read().split())
c = abc[2 * (N - 1):]
c.sort()
graph = [[] for _ in range(N + 1)]
cnt = [0] * (N + 1)
for a, b in zip(*[iter(abc[:2 * (N - 1)])] * 2):
    graph[a].append(b)
    graph[b].append(a)
    cnt[a] += 1
    cnt[b] += 1

m = max(cnt)
nodes = [0] * (N + 1)
score = sum(c) - c[-1]
start = cnt.index(max(cnt))
nodes[start] = c.pop()
queue = deque([start])
while queue:
    V = queue.popleft()
    for v in graph[V]:
        if nodes[v] == 0:
            nodes[v] = c.pop()
            queue.append(v)

print(score)
print(' '.join(map(str, nodes[1:])))


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
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; }

int main() {
    int N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return (0);
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class AWhiteCells {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int H, W, h, w;
	    in >> H >> W >> h >> w;

        out << H*W - h*W - H*w + h*w << endl;
	}
};


int main() {
	AWhiteCells solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
ans=[]

if N%2==0:
    N-=1

half=N//2

if half%2==0:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2):
        ans.append((half+1+j,N-j))
else:
    for i in range(half//2):
        ans.append((i+1,half-i))
    for j in range(half//2+1):
        ans.append((half+1+j,N-j))

#print(ans)
for i in range(M):
    print(*ans[i])

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll a, b, c; cin >> a >> b >> c;
  ll left = a*a + 2*a*b - 2*a*c + b*b - 2*b*c + c*c;
  ll right = 4*a*b;

  if (a + b - c < 0 && left > right) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3660
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end
require 'pp'
N,_=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d],_=gets.chomp.split(' ').map{|n| n.to_i}
}
Asort = A.sort
imax = N/2
dif = 0
dif += (Asort[N-1] - Asort[0]).abs
	# puts "#{Asort[0]} #{Asort[N-1]}"
	# puts dif
# pp Asort
# smaller start
for i in 1..(imax-1)
	dif += (Asort[N-1-i+1] - Asort[i]).abs
	dif += (Asort[N-1-i] - Asort[i]).abs
	# puts "#{Asort[N-1-i]} #{Asort[i]}"
	# puts "#{Asort[i]} #{Asort[N-1-i+1]}"
	# puts dif
end
if(N%2!=0)
	a = (Asort[N/2] - Asort[N/2+1]).abs
	b = (Asort[N/2] - Asort[0]).abs
	# puts "#{Asort[N/2]} #{Asort[N/2+1]}"
	# puts "vs"
	# puts "#{Asort[N/2]} #{Asort[0]}"
	if(a < b)
		dif += b
	else
		dif += a
	end
	# puts dif
else
	dif -= (Asort[N/2]-Asort[N/2-1]).abs
	dif += (Asort[N/2]-Asort[0]).abs
end
# puts dif
smallerdif = dif

imax = N/2
dif = 0
dif += (Asort[N-1] - Asort[0]).abs
	# puts "#{Asort[N-1]} #{Asort[0]}"
	# puts dif
# pp Asort
for i in 1..(imax-1)
	dif += (Asort[N-1-i] - Asort[i-1]).abs
	dif += (Asort[N-1-i] - Asort[i]).abs
	# puts "#{Asort[i-1]} #{Asort[N-1-i]}}"
	# puts "#{Asort[N-1-i]} #{Asort[i]}"
	# puts dif
end
if(N%2!=0)
	a = (Asort[N/2] - Asort[N-1]).abs
	b = (Asort[N/2] - Asort[N/2-1]).abs
	# puts "#{Asort[N/2]} #{Asort[N-1]}"
	# puts "vs"
	# puts "#{Asort[N/2]} #{Asort[N/2-1]}"
	if(a < b)
		dif += b
	else
		dif += a
	end
	# puts dif
else
	dif -= (Asort[N/2]-Asort[N/2-1]).abs
	dif += (Asort[N/2]-Asort[N-1]).abs
end

largerdif = dif

thedif = smallerdif > largerdif ? smallerdif : largerdif

puts thedif





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

using namespace std;

void solve()
{
    int n;
    cin >> n;
    vector<int> bs(n - 1), as(n);
    for (int &a : bs)
        cin >> a;
    long ans = bs.front() + bs.back();
    for (int i = 0; i < n - 2; i++)
    {
        ans += min(bs[i], bs[i + 1]);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("fibsubseq.in","r",stdin)
#define write()         freopen("fibsubseq.out","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long int
#define endll           printf("\n")
#define pf              printf
#define pi              acos(-1.0)
#define eps             1e-10
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())

bool Check(unsigned int  N,int pos){return (bool)(N & (1LL<<pos));}
ll  Set(unsigned int N,int pos){    return N=N | (1LL<<pos);}
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MX 100005
#define mod  1000000007
#define mod1 1000000009
#define var    int ii,i,j,k,z=0,c=0,t,x,y,l,r,mid
//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};

bool chk(int x,int pos){return (bool)(x&(1<<pos));}
int Set(int x,int pos){return x=x|(1<<pos);}
int clr(int x,int pos){return x=x&~(1<<pos);}

int n,m,a[25][25],dp[21][(1<<21)];

int fn(int pos,int mask)
{
    if(pos==n)return 1;
    int &z=dp[pos][mask];
    if(z!=-1)return z;
    z=0;
    for(int i=0;i<n;i++)
    {
        if(a[pos][i] && chk(mask,i)==0)
        {
            z+=fn(pos+1,Set(mask,i));
            if(z>mod)z%=mod;
        }
    }
    return z;
}

int main()
{
    var;
    sf(n);
    mem(dp,-1);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            sf(a[i][j]);
        }
    }
    z=fn(0,0);
    cout<<z<<endl;
}


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

namespace AtCoder_Cs
{
    class Program
    {
        public static void Main()
        {
            int N = int.Parse(Console.ReadLine().Trim());
            string[] S = Console.ReadLine().Split(' ');
            //string[] ans = new string[S.Length];
            //List<string> list = new List<string>();
            Queue<string> q = new Queue<string>();
            Stack<string> s = new Stack<string>();
            bool Is偶数 = S.Count() % 2 == 0;

            for (int i = 0;i < N; ++i)
            {
                //ans[i] = S[i];
                //Array.Reverse(ans);
                if ((i + Convert.ToInt32(Is偶数) + 2) % 2 == 1)
                {
                    q.Enqueue(S[i]);
                }
                else
                {
                    s.Push(S[i]);
                }
            }
            

            Console.WriteLine($"{string.Join(" ",s)} {string.Join(" ",q)}");

        }
    }
}


Measured memory_bytes: 48576
#include<stdio.h>
int main(){
  char a[3][111],win[4]="ABC";
  int aa[3]={0,-1,-1},t=0;
  scanf("%s%s%s",a[0],a[1],a[2]);
  while(1){
    if(a[t][aa[t]]=='\0'){
      printf("%c",win[t]);
      return 0;
    }
    else{
      t=a[t][aa[t]]-'a';
      aa[t]++;
    }
  }
}

Measured memory_bytes: 128
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){

    ll a, b, c;
    cin >> a >> b >> c;
    string ans = "No";
    if(a == b && b != c)ans = "Yes";
    if(a == c && b != c)ans = "Yes";
    if(b == c && a != c)ans = "Yes";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    flag = 0
    for i in range(1, 10):
        for j in range(1, 10):
            if n == i*j:
                print("Yes")
                flag += 1
                break
        else:
            continue
        break
    if not flag:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,dp[100005][3];
vector<int>gr[100005];
void dfs(int x,int p)
{
    dp[x][1]=dp[x][0]=1;
    for(int i=0;i<gr[x].size();i++)
    {
        int u=gr[x][i];
        if(u!=p)
        {
            dfs(u,x);
            dp[x][0]*=(dp[u][0]+dp[u][1])%mod;
            dp[x][1]*=dp[u][0]%mod;
            dp[x][0]%=mod;
            dp[x][1]%=mod;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int x,y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    dfs(1,0);
    cout<<(dp[1][0]+dp[1][1])%mod;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    int list[100010]={};
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]==0){
            list[a[i]]++;
            list[a[i]+1]++;
        }
        else{
            list[a[i]]++;
            list[a[i]+1]++;
            list[a[i]-1]++;
        }
    }
    int max1 = 0;
    for(int i=0;i<100005;i++){
        if(max1<list[i])max1 = list[i];
    }
    cout << max1 << endl;
}


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

#define infi            2e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define loop1(i,n)      for(register int i=1;i<=n;i++)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
// inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//

int cnt=0,n;
bool vis[10]={0};
vector<int>adj[10];

void DFS(int u, int p, int nod){
    if(nod==n)cnt++;
    vis[u]=1;
    for(auto v:adj[u]){
        if(v!=p && !vis[v]){
            DFS(v,u,nod+1);
        }
    }
    vis[u]=0;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle//freopen("in.txt", "r", stdin);//#endif
    //freopen("in.txt", "r", stdin);

    n=rr;
    int m=rr,x,y;
    loop(i,m){
        x=rr;y=rr;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    if(m<n-1){
        cout << 0 << endl;
        return 0;
    }

    DFS(1,0,1);

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;



int main() {
	string S;

	cin >> S;
	if (S[2] == S[3] && S[4] == S[5]) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)

Measured memory_bytes: 47496
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    ll n,m;
    cin>>n>>m;
    vector<ll> h(n);
    rep(i,n) cin>>h[i];
    bool path[100010]={};

    rep(i,m){
        ll a;
        ll b;
        cin>>a>>b;
        a-=1;
        b-=1;
        if(h[a]<h[b]){
            path[a]=true;
        }else if(h[a]>h[b]){
            path[b]=true;
        }else{
            path[a]=true;
            path[b]=true;
        }
    }
    ll ans=0;

    rep(i,n){
        if(!path[i]) ans++;
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3888
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MOD 1000000007
using namespace std;
int n,c[200005],last[200005],lastpos;
long long qzh[200005],all[200005];
int main()
{
	all[0]=1;
	scanf("%d",&n);for(int i=1;i<=n;++i) scanf("%d",&c[i]);for(int i=1;i<=n;++i) last[i]=200004;
	int loc=unique(c+1,c+1+n)-c-1;n=loc;
	for(int i=1;i<=n;++i) {
		all[i]=(all[i-1]+qzh[last[c[i]]])%MOD;
		qzh[i]=(qzh[last[c[i]]]+all[i-1])%MOD;
		last[c[i]]=i;
	}
	printf("%lld",all[n]);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int n, d; 
	while (cin >> n >> d, n)
	{
		vector<vi> v(n);
		vi p(n);
		REP(i, n)
		{
			int m; cin >> m;
			v[i].resize(m);
			REP(j, m)
			{
				cin >> v[i][j];
				p[i] += v[i][j];
			}
		}
		bool update = true;
		while (update)
		{
			update = false;
			REP(i, n)
			{
				int mx = -1, mn = INF;
				if (v[i].size() == 0) continue;
				p[i] -= v[i].back();
				REP(j, n)
				{
					chmax(mx, p[j]); chmin(mn, p[j]);
				}
				if (mx - mn > d)
				{
					p[i] += v[i].back();
				}
				else
				{
					v[i].pop_back();
					update = true;
				}
			}
		}
		if (*max_element(ALL(p)) == 0) puts("Yes");
		else puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 3104
x = list(map(int,input().split()))
ans = x.index(0)

if ans == 0:
    a = x[ans+2]-x[ans+1]
    print(x[ans+1]-a)
elif ans == 4:
    b = x[ans-2]-x[ans-3]
    print(x[ans-1]+b)
else:
    print((x[ans-1]+x[ans+1])//2)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    int n; cin>>n;
    string s,t; cin>>s>>t;
    int ans=-1;
    rep(i,0,n){
        if(s.substr(i,n-i) == t.substr(0,n-i)){
            ans=n+i;
            break;
        }
    }
    if(ans==-1) ans=2*n;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import Data.List

change [] n = []
change (d:dx) n = 
    if isInfixOf [d] "ATCG" then 
        [n] ++ change dx (n + 1)
    else 
        [0] ++ change dx 1

solve s = maximum (change s 1)

main::IO()
main=do
    s <- getLine
    print $ solve s


Measured memory_bytes: 380
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll n,k,v,w,dp[100001],ans;
const ll INF=1LL<<62;

int main()
{
	cin>>n>>k;
	for(int i=1;i<=100000;i++)
		dp[i]=INF;
	for(int i=0;i<n;i++)
	{
		cin>>w>>v;
		for(int j=100000;j>-1;j--)
			if(dp[j]!=INF)
				dp[j+v]=min(dp[j+v],dp[j]+w);
	}
	for(int i=100000;i>-1;i--)
		if(dp[i]<=k)
			return cout << i<<'\n',0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  rep(i, T) {
    int N;
    cin >> N;
    int64_t result = 0;

    using P = pair<int, int>;
    vector<P> diff;
    rep(i, N) {
      int K, L, R;
      cin >> K >> L >> R;
      result += R;

      diff.emplace_back(P(K - 1, L - R));
    }
    sort(diff.begin(), diff.end());

    priority_queue<int> q;
    int j = N - 1;
    int cnt = 0;
    rrep(i, N) {
      while (j >= 0 && diff[j].first >= i) {
        if (diff[j].second >= 0) {
          q.push(diff[j].second);
        }
        j--;
      }
      if (!q.empty()) {
        result += q.top();
        q.pop();
        cnt++;
      }
    }

    rep(i, N) {
      if (diff[i].second < 0) {
        result += diff[i].second;
      }
    }

    q = priority_queue<int>();
    j = 0;
    for (int i = cnt; i < N; i++) {
      while (j < N && diff[j].first + 1 <= i) {
        if (diff[j].second < 0) {
          q.push(-diff[j].second);
        }
        j++;
      }
      if (!q.empty()) {
        result += q.top();
        q.pop();
      }
    }
    cout << result << "\n";
  }
  return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}

const int n_max = 100050;
vector<vector<int>> root(n_max);

vector<int> color(n_max, 0);
vector<bool> visited(n_max, false);

bool fds(int v, int c){
    color[v] = c;  
    visited[v] = true;
    for (auto next: root[v]){
        if (color[next] == c) return false;
        if (color[next] == -c) continue; 
        if (!fds(next, -c)) return false;
    }
    return true;
}


int main()
{
    ll n, m;
    cin >> n >> m;
    
    rep(i, m){
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        tmp1--; tmp2--;
        root[tmp1].push_back(tmp2);
        root[tmp2].push_back(tmp1);
    }

    ll ans = 0;
    if (fds(0, 1)){
        //二部グラフ
        ll one = 0;
        rep(i, n){
            //cout << color[i] << endl;
            if (color[i]==1) one++; 
        }
        ans = one*(n-one);
    } else {
        ans = n*(n-1)/2;
    }

    cout << ans-m << endl;

}



Measured memory_bytes: 7800
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define PI (3.141592653589793)
using namespace std;

struct edge { int from, to, cost; };
vector<edge> G[100010];
int dist[100010]={INF};

void dijkstra(int s){
    fill(dist,dist+100010,INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p=que.top(); que.pop();
        int v=p.S;
        if(dist[v]<p.F) continue;
        rep(i,G[v].size()){
            edge e=G[v].at(i);
            if(dist[e.to]>dist[v]+e.cost){
                dist[e.to]=dist[v]+e.cost;
                que.push(P(dist[e.to],e.to));
            }
        }
    }
}

signed main(){
    int V; cin>>V;
    rep(i,V-1){
        edge e,f;
        cin>>e.from>>e.to>>e.cost;
        e.from--; e.to--;
        f.from=e.to; f.to=e.from; f.cost=e.cost;
        G[e.from].push_back(e);
        G[f.from].push_back(f);
    }
    int Q,K; cin>>Q>>K;
    K--;
    dijkstra(K);
    rep(i,Q){
        int x,y; cin>>x>>y;
        cout<<dist[x-1]+dist[y-1]<<endl;
    }
}

Measured memory_bytes: 12720
#include <bits/stdc++.h>
//debug
#define vecprint(v) rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};



int main() {
  //input
  int k, a, b;
  cin >> k >> a >> b;
  
  int tmp = a / k;
  if(k*tmp == a) w1("OK");
  else if(k*(tmp+1) >= a && k*(tmp+1) <= b) w1("OK");
  else w1("NG");

}

Measured memory_bytes: 3600
s = input()
n = len(s) - 1

opl = []

for i in range(2 ** n):
  op = ["-"] * n
  for j in range(n):
    if (i >> j) & 1:
      op[2-j] = "+"
  opl.append(op)

fl = []

for i in opl:
  f = s[0]
  for j in range(n):
    f += i[j]
    f += s[j+1]
  fl.append(f)

for f in fl:
  if eval(f) == 7:
    print(f+"=7")
    exit()

Measured memory_bytes: 3064
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    ll X, N; cin >> X >> N;
    set<ll> s;
    rep(i, N){
        ll x; cin >> x;
        s.insert(x);
    }
    pair<ll, ll> ans = make_pair(-100, INF);
    for(ll i = -10; i <= 105; i++){
        if(!s.count(i) && abs(i - X) < ans.second){
            ans.first = i;
            ans.second = abs(i - X);
        }
    }
    pt(ans.first);
}

Measured memory_bytes: 3632
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 1000000 + 5;

int n;
int a[N];

void solve()
{
    cin >> n;
    int pos = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] > a[pos]) {
            pos = i;
        }
    }
    if (a[pos] <= 0) {
        cout << a[pos] << endl;
        cout << n - 1 << endl;
        for (int i = 0; i < pos; i++) {
            cout << 1 << endl;
        }
        for (int i = n - pos; i >= 2; i--) {
            cout << i << endl;
        }
        return;
    }

    int rec = 0;
    long long best = 0;
    for (int st = 0; st < 2; st++) {
        long long value = 0;
        for (int i = st; i < n; i += 2) {
            if (a[i] >= 0) {
                value += a[i];
            }
        }
        if (value > best) {
            best = value;
            rec = st;
        }
    }

    cout << best << endl;
    vector<int> ops;
    int lst = -1;
    for (int i = rec; i < n; i += 2) {
        if (a[i] >= 0) {
            if (lst == -1) {
                for (int j = 0; j < i; j++) {
                    ops.push_back(1);
                }
            } else {
                for (int j = 0; j < (i - lst) / 2 - 1; j++) {
                    ops.push_back(3);
                }
                ops.push_back(2);
            }
            lst = i;
        }
    }
    for (int i = n - lst; i >= 2; i--) {
        ops.push_back(i);
    }
    cout << ops.size() << endl;
    for (auto u : ops) {
        cout << u << endl;
    }
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int h[n];
  int max = 0;
  int counter = 0;
  for (int i = 0; i<n; i++) {
    scanf("%d", &h[i]);
    if(max <= h[i]) {
      max = h[i];
      counter += 1;
    }
  }
  printf("%d\n", counter);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}

int main()
{
fast();
int n=D(),a=D(),b=D();
cout<<min(n*a,b)<<endl;
}


Measured memory_bytes: 256