akhauriyash/Code-Regression huggingface dataset:
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> line = {a, b, c};

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

    if (line.at(2) == line.at(0) + line.at(1)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
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;
}
ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

int main(){
    ll N;cin>>N;
    ll X,M;cin>>X>>M;
    vector<ll>ans;
    set<ll>ANS;
    ll sum=X;
    ans.push_back(X);
    ANS.insert(X);
    bool flag=false;
    for(ll i=1;i<N;i++){
        ll Z=ans[ans.size()-1];
        ll T=(Z*Z)%M;
        ans.push_back(T);
        if(ANS.count(T)){
            flag=true;
            break;
        }
        ANS.insert(T);
        sum+=T;
    }
    if(flag==true){
        ll TT=ans[ans.size()-1];
        ll subsum=0;
        ll C=0;
        rep(i,ans.size()){
            if(ans[i]==TT){
                C=i;
                break;
            }
        }
        ll cntcnt=0;
        for(int i=C;i<ans.size()-1;i++){
            subsum+=ans[i];
            cntcnt++;
        }
        sum+=subsum*((N+1-ans.size())/cntcnt);
        for(int i=C;i<C+(N+1-ans.size())%cntcnt;i++){
            sum+=ans[i];
        }
    }
    cout<<sum<<endl;
}

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

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

int main(){
int n;
cin>>n;
map<int,int> m;
int a[n];
rep(i,n){
cin>>a[i];
m[a[i]-1]++;
m[a[i]]++;
m[a[i]+1]++;
}
int M=0;
rep(i,100001)
M=max(M,m[i]);

cout<<M<<endl;


  return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <math.h>

void dfs(const std::vector<std::vector<long long>> &g, long long v, std::vector<bool> *used, std::vector<long long> *available_colors, long long k, long long depth) {
    (*used)[v] = true;
    bool subtract_parent = false;
    for (auto i = g[v].begin(); i != g[v].end(); ++i) {
        if (!(*used)[*i]) {
            (*available_colors)[*i] = k - 1 - (i - g[v].begin());
            if (subtract_parent) {
                (*available_colors)[*i] += 1;
            }
            if (depth >= 1) {
                (*available_colors)[*i] -= 1;
            }
            dfs(g, *i, used, available_colors, k, depth+1);
        } else {
            subtract_parent = true;
        }
    }
}

int main() {
    long long n, k;
    std::cin >> n >> k;

    if (n == 1) {
        std::cout << k << "\n";
        return 0;
    }

    std::vector<std::vector<long long>> g(n);
    for (int i = 0; i < n; ++i) {
        g[i] = std::vector<long long>();
    }

    long long v = -1;

    for (int i = 0; i < n - 1; ++i) {
        long long a, b;
        std::cin >> a >> b;
        --a;
        --b;
        if (v == -1) {
            v = a;
        }
        g[a].push_back(b);
        g[b].push_back(a);
    }

    std::vector<bool> used(n);
    std::vector<long long> available_colors(n);
    for (int i = 0; i < n; ++i) {
        used[i] = false;
        available_colors[i] = 0;
    }

    available_colors[v] = k;
    dfs(g, v, &used, &available_colors, k, 0);

    long long ans = available_colors[v];
    for (int i = 0; i < n; ++i) {
        if (i == v) {
            continue;
        }
        if (!used[v]) {
            continue;
        }
        if (available_colors[i] <= 0) {
            std::cout << 0 << "\n";
            return 0;
        }
        ans = (ans * available_colors[i]) % 1000000007;
    }

    std::cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 12800
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[a-x:]
q=sorted(list(map(int,input().split())))[b-y:]
r=sorted(list(map(int,input().split())))[::-1]
s=sum(p)+sum(q)
p=p+[10**10]
q=q+[10**10]
pp=0
qq=0
for i in range(c):
  t=r[i]
  if p[pp]<t:
    if q[qq]<p[pp]:
      s=s+t-q[qq]
      qq+=1
    else:
      s=s+t-p[pp]
      pp+=1
  elif q[qq]<t:
    s=s+t-q[qq]
    qq+=1
print(s)

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

int main() {
    int N;
    long long X, D;
    cin >> N >> X >> D;
    if(D == 0) {
        cout << (X == 0 ? 1 : N + 1) << endl;
        return 0;
    } else if(D < 0) {
        X *= -1; D *= -1;
    }

    using pp = pair<long long, long long>;
    map<long long, vector<pp>> B;
    for(long long k=0; k<=N; ++k) {
        long long tl = (k * X - (X < 0 ? D : 0)) / D + k * (k - 1) / 2;
        long long tr = (k * X - (X < 0 ? D : 0)) / D + k * (2 * N - k - 1) / 2 + 1;
        B[(k * X % D + D) % D].emplace_back(tl, tr);
    }

    long long res = 0;
    for(auto i : B) {
        auto I = i.second;
        sort(begin(I), end(I));
        long long l = I[0].first, r = I[0].second;
        for(int k=1; k<I.size(); ++k) {
            long long tl = I[k].first, tr = I[k].second;
            if(tr < r) continue;
            else if(tl < r) r = tr;
            else {
                res += r - l;
                l = tl; r = tr;
            }
        }
        res += r - l;
    }
    cout << res << endl;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 long long int N;
 cin >> N;
 int i=0;
 int j;
 if(N==2)cout << N << endl;
 else{
 while(i==0){
     for(j=2;j<N;++j){
      if(N%j==0){
          break;
      }
      if(j==N-1)i++;}
      if(i==0)N++;
     }
    cout << N << endl;}
  return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

const int MAX_N = 405;
const ll INF = 1ll << 60;


ll slim[405][405];
ll cost[405][405];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  ll a;
  rep(i, 0, 405) {
    rep(j, 0, 405) {
      slim[i][j] = INF;
      cost[i][j] = INF;
    }
  }

  rep(i, 0, N) {
    cin >> a;
    slim[i][i+1] = a;
    cost[i][i+1] = 0ll;
  }

  rep(w, 2, N+1) {
    rep(l, 0, N+1-w) {
      int r = l + w;
      rep(i, 1, r) {
        if (cost[l][i]+cost[i][r]+slim[l][i]+slim[i][r] < cost[l][r]) {
          cost[l][r] = cost[l][i]+cost[i][r]+slim[l][i]+slim[i][r];
          slim[l][r] = slim[l][i]+slim[i][r];
        }
      }
    }
  }

  cout << cost[0][N] << endl;

  return 0;
};


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

fn primes(n: usize) -> Vec<usize> {
    let mut ret = Vec::new();
    for i in 2..n {
        let mut is_prime = true;
        for j in 2..i {
            if i % j == 0 {
                is_prime = false;
                break;
            }
        }
        if is_prime {
            ret.push(i);
        }
    }
    ret
}

fn factor_num(n: usize, p: usize) -> usize {
    let mut ret: usize = 0;
    let mut x = p;
    while x <= n {
        ret += n / x;
        x *= p;
    }
    ret
}

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();

    let prime = primes(100);

    let mut dp = [0i64; 100];
    dp[1] = 1;

    for i in 0..prime.len() {
        let p = prime[i];
        let f = factor_num(n, p);
        if f == 0 {
            continue;
        }
        for j in (0..76).rev() {
            for k in 1..f + 1 {
                let t = j * (k + 1);
                if t < dp.len() {
                    dp[t] += dp[j];
                }
            }
        }
    }

    println!("{}", dp[75]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;

int main(void){
	string s;
	cin>>s;
	if(s[0] == 'A')cout<<'T'<<endl;
	else if(s[0] == 'T')cout<<'A'<<endl;
	else if(s[0] == 'C')cout<<'G'<<endl;
	else if(s[0] == 'G')cout<<'C'<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    int N;
    string S;
    cin >> N;
    cin >> S;
    if(N%2) {cout << "No" << endl; return 0;}
    REP(i, 0, N/2) if(S[i] != S[i+N/2]) { cout << "No" << endl; return 0;}
    cout << "Yes" << endl;
    return 0;
}

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

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

  if (s=="SUN")
  cout << 7 << endl;
  else if (s=="MON")
  cout << 6 << endl;
  else if (s=="TUE")
  cout << 5 << endl;
  else if (s=="WED")
  cout << 4 << endl;
  else if (s=="THU")
  cout << 3 << endl;
  else if (s=="FRI")
  cout << 2 << endl;
  else if (s=="SAT")
  cout << 1 << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		while(n != 1)
		{
			count++;
			if(n % 2)
			{
				n = 3 * n + 1;
			}
			else
			{
				n /= 2;
			}
		}
		cout << count << endl;
	}
}

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

Measured memory_bytes: 0
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        var t = new int[n];
        var x = new int[n];
        var y = new int[n];
        for (int i = 0; i < n; i++)
        {
            t[i] = sc.NextInt();
            x[i] = sc.NextInt();
            y[i] = sc.NextInt();
        }

        int time = 0;
        int px = 0;
        int py = 0;
        for (int i = 0; i < n; i++)
        {
            int dist = Math.Abs(px - x[i]) + Math.Abs(py - y[i]);
            if (dist > t[i] - time || (t[i] - time - dist) % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }

            px = x[i];
            py = y[i];
            time = t[i];
        }

        Console.WriteLine("Yes");
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(std::string s){
    vector<char> x;
    REP(i, s.size()) {
        if(s[i] == '0' || s[i] == '1') {
            x.PB(s[i]);
        } else if (!x.empty()){
            x.pop_back();
        }
    }

    REP(i, x.size()) {
        cout << x[i];
    }
    cout << endl;
}

int main(){
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int A, B, C, D, P, X, Y;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);
    scanf("%d",&P);
    X = A*P;
    if(C >= P){
        Y = B;
    }
    else {
        Y = B + D * (P - C);
    }
    printf("%d\n",(X <= Y) ? X : Y);

    return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 2.01e14;
const double eps = 1e-8;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;
    vector<long double> x(N),y(N);
    vector<char> d(N);
    rep(i,0,N) cin >> x[i] >> y[i] >> d[i];

    auto f=[&](long double t){
        long double xmin=inf64,xmax=-inf64,ymin=inf64,ymax=-inf64;
        rep(i,0,N){
            long double xx=x[i],yy=y[i];
            if(d[i]=='R') xx+=t;
            else if(d[i]=='L') xx-=t;
            else if(d[i]=='U') yy+=t;
            else yy-=t;
            chmin(xmin,xx);
            chmax(xmax,xx);
            chmin(ymin,yy);
            chmax(ymax,yy);
        }
        return (xmax-xmin)*(ymax-ymin);
    };

    long double lb=0,ub=inf64;
    rep(i,0,200){
        auto a=(lb+lb+ub)/3;
        auto b=(lb+ub+ub)/3;
        if(f(a)>f(b)){
            lb=a;
        }else{
            ub=b;
        }
    }

    long double ans=min(f(lb),f(0));

    i64 loop=1000;
    rep(i,-loop,loop){
        if(max((long double)0,(long double)(i64(lb)+0.5*i)) == 0){
            ++loop;
            continue;
        }
        chmin(ans,f(i64(lb)+0.5*i));
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

#ifdef LOCAL
clock_t timer = clock();
#endif

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	int h[n];
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	for(int i = 0; i < n; i++){
		dp[i] = 1e9;
        }
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j <= i + k; j++) if(j < n){
			dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
		}
	}
	cout << dp[n - 1] << endl;
#ifdef LOCAL
        cout << "Total Time: " << (double)(clock() - timer) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
n,k= list(map(int, input().split()))
z=[0]*n
ans=0
for j in range(k):
    q=int(input())
    i = list(map(int, input().split())) 
    for h in range(len(i)):
        z[i[h]-1]+=1
for u in range(n):
    if z[u]==0:
        ans+=1
print(ans)


Measured memory_bytes: 9192
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
using namespace std;
using lint = long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

const lint INF = 1ll << 60;
const int mod = 1000000007;
const int inf = INT_MAX;
void speed() {
	std::cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	return;
}



int main(void) {
	speed();
	string s; cin >> s;
	int k; cin >> k;
	vector<string> d;
	for (int i = 0; i < (int)s.length(); i++) {
		for (int j = 1; j <= k; j++) {
			if (i + j - 1 >= (int)s.length()) continue;
			d.emplace_back(s.substr(i, j));
		}
	}
	sort(d.begin(), d.end());
	d.erase(unique(d.begin(), d.end()), d.end());
	cout << d[k - 1] << endl;

	return 0;
}

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

using namespace std;

#define INF 10000000000000
#define LL long long int

struct edge{
    LL a;
    LL b;
    LL c;
};

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

    vector<edge> vec;

    for(int i = 0; i < m; i++){
        LL a,b,c;
        
        cin >> a >> b >> c;

        vec.push_back(edge{a,b,(-1)*c});
    }

    vector<LL> v(n+1);
    vector<bool> update(n+1);

    for(int i = 0; i < n+1; i++){
        v[i] = INF;
        update[i] = false;
    }

    v[1] = 0;


    for(int i = 1; i < n; i++){
        for(int j = 0; j < m; j++){
            if(v[vec[j].b] > v[vec[j].a] + vec[j].c){
                v[vec[j].b] = v[vec[j].a] + vec[j].c;
            }
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(v[vec[j].b] > v[vec[j].a] + vec[j].c){
                v[vec[j].b] = v[vec[j].a] + vec[j].c;
                update[vec[j].b] = update[vec[j].a] = true;
            }
        }
    }


    if(update[n]){
        cout << "inf" << endl;
    }else{
        cout << (-1)*v[n] << endl;
    }

    return 0;

}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
long long n;
main()
{
    cin>>n;
    cout<<50<<endl;
    for(int i=0;i<50;i++)
    {
        if(i)cout<<' ';
        cout<<49-i+(n+49-i)/50;
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    vector<int> p(n), q(n), a(n);
    for (int i = 0; i < n; i++)
        cin >> p[i];
    for (int i = 0; i < n; i++)
        cin >> q[i];
    for (int i = 0; i < n; i++)
        a[i] = i + 1;

    int count = 1;
    map<vector<int>, int> m;
    while (true)
    {
        m[a] = count;
        count++;
        if (!next_permutation(a.begin(), a.end()))
        {
            break;
        }
    }

    int ans = abs(m[p] - m[q]);
    cout << ans << endl;
    return 0;
}

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

int main(){
  int port=0,tobe=0,asis=1,result=0;
  cin >> port >> tobe;
  while(true){
    if(asis>=tobe) break;    
    asis--;
    asis+=port;
    result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

vector<vector<ll>> emp(2001, vector<ll>(2001, 0LL));

ll em(ll a, ll b) {
    if (b == 0 || a == 1) {
        return 1;
    }
    if (emp[a][b] > 0) {
        return emp[a][b];
    }
    emp[a][b] = (em(a-1, b) + em(a, b-1)) % 1000000007;
    return emp[a][b];
}

int main(int argc, const char * argv[]) {
    
    ll N, K;
    cin >> N >> K;
    
    for (ll i = 0; i < 2001; i++) {
        for (ll j = 0; j < 2001; j++) {
            emp[i][j] = 0;
        }
    }
    
    for (ll i = 0; i < K; i++) {
        if (i > N - K) {
            cout << 0 << endl;
        } else {
            cout << (em(i + 1, K - 1 - i) * em(2 + i, N - K - i)) % 1000000007 << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 31744
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <vector>
using namespace std;
#define ll long long
int gcd(int a, int b) {
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.size()/2; i++)
	{
		if (s[i] != s[s.size() - 1 - i]) ans++;

	}
	cout << ans;
	system("pause>0");
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, h, w;
  cin >> n >> h >> w;
  ll ans = 0;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    if(a >= h && b >= w) ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;

    cin >> n;
    map <string,int> m;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        m[s]++;
    }
    int mx = 0;
    for (auto &x : m) {
        int v = x.second;
        if(v > mx) {
            mx = v;
        }
    }
    for (auto i = m.begin(); i != m.end(); i++) {
        if(i->second == mx) {
            cout << i->first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

// #include "competitive_helper.cpp"

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n, x;

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    cin >> n;
    int cur = 0;
    for (int i = 0; i < n; ++i) {
        cin >> x;
        if (x == cur + 1) {
            ++cur;
        }
    }
    cout << (cur == 0 ? -1 : n - cur) << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * A.c
 *
 *  Created on: 2018/04/16
 *      Author: Haruyuk1
 */

#include <stdio.h>

int main(void){
	char string[4];
	int i, j, k, res;
	res = 0;

	scanf("%s", string);

	for (i = 0; i <= 2; i++){
		if (string[i] == 'a'){
			for (j = 0; j <= 2; j++){
				if (string[j] == 'b'){
					for (k = 0; k <= 2; k++){
						if (string[k] == 'c'){
							res = 1;
						}
					}
				}
			}
		}
	} if (res == 1){
		printf("Yes");
	} else {
		printf("No");
	}
	return 0;
}



Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        a: [usize; n],
        b: [usize; n]
    }
    let mut ad= vec![];
    let mut bd = vec![];
    for i in 0..n - 1 {
        ad.push(a[i] ^ a[i + 1]);
        bd.push(b[i] ^ b[i + 1]);
    }
    ad.push(a[0] ^ a[n - 1]);
    bd.push(b[0] ^ b[n - 1]);
    let mut ad = [ad.clone(), ad].concat();
    ad.pop();
    let ks = kmp_all(&ad, &bd);
    for &k in &ks {
        println!("{} {}", k, a[k] ^ b[0]);
    }
}

fn kmp_tab(s: &[usize]) -> Vec<usize> {
    let m = s.len();
    let mut tab: Vec<usize> = vec![0; m + 1];
    let mut i = 2;
    let mut j = 0;
    while i <= m {
        if s[i - 1] == s[j] {
            tab[i] = j + 1;
            i += 1;
            j += 1;
        } else if j > 0 {
            j = tab[j];
        } else {
            i += 1;
        }
    }
    tab
}

fn kmp_all(s: &[usize], sub: &[usize]) -> Vec<usize> {
    let m = sub.len();
    let tab = kmp_tab(sub);
    let mut ret = vec![];
    let mut i = 0;
    let mut j = 0;
    while i + j < s.len() {
        if sub[j] == s[i + j] {
            j += 1;
            if j == m {
                ret.push(i);
                i += j - tab[j];
                j = tab[j];
            }
        } else {
            if j == 0 {
                i += 1;
            } else {
                i += j - tab[j];
                j = tab[j];
            }
        }
    }
    ret
}


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

using namespace std;

#define FOR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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


    string s;
    cin >> s; 

    int ss = s.length();
    int a = 0, b = 0;
    FOR(i, 0, ss){
        if(s[i] == '0')
            a++;
        else 
            b++;
    }

    cout << 2*min(a,b);
    return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {
    var (x1, y1, x2, y2) = readLine()!!.split(" ").map(String::toDouble)
    val distance = Math.sqrt(Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0))
    println("$distance")
}



Measured memory_bytes: 33880
import numpy as np
INF = 10**15
def solve(n, k, h):
    dp = np.full((n+1, n+1), INF, dtype=int)
    dp[0, 0] = 0
    h = np.array([0] + h, dtype=int)
    for i, h_i in enumerate(h[1:], 1):
        t = np.maximum(h_i - h[:i], 0)
        dp[i,1:] = np.min(dp[:i,:-1]+t[:,None], axis=0)
    return np.min(dp[:, n-k])

n, k = map(int, input().split())
h = list(map(int, input().split()))
print(solve(n, k, h))

Measured memory_bytes: 14004
#include <iostream>
#include <limits.h>
#include <queue>
#include <algorithm>
#include <map>
#include <cstring>
#include <utility>
#include <stdio.h>


#define dprintf(s,...) printf("%s:%d" s,__func__,__LINE__,__VA_ARGS__)
using namespace std;

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

//Marked Ancestor
//AOJ 2170

int N,Q;

int par[100001],marked[100001],mpar[100001];

void init(){
  
  fill(par, par+N+1, -1);
  fill(marked, marked+N+1, 0);
  fill(mpar, mpar+N+1, 1);
  
  marked[1] = 1;
  par[1] = 1;
}

int ans(int v){

  //if(marked[par[v]] == 1) return mpar[v] = par[v];
  //return mpar[v] = ans(par[v]);

  while(marked[v]==0)
    v = par[v];
  
  return v;
  
}


int main(){
  
  while(1){

    ll res=0;
    
    scanf("%d %d",&N,&Q);
    if(N==0 && Q==0) break;

    init();
    
    
    for(int i=2;i<=N;i++)
      scanf("%d",&par[i]);

    for(int i=0;i<Q;i++){
      char op;
      int v;
      scanf("%s %d",&op,&v);

      if(op=='Q') res += ans(v);
      if(op=='M') marked[v]=1;
    }
    printf("%lld\n", res);
  }

  return 0;
}

Measured memory_bytes: 4412
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main{


	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		String string = scanner.next();
		String mae = string.substring(0,A);
		String naka = string.substring(A,A+1);
		String ushiro = string.substring(A+2);
		Pattern p = Pattern.compile("^[0-9]*$");
		Matcher m = p.matcher(mae);
		Matcher u = p.matcher(ushiro);




		if(m.find() && u.find() && naka.equals("-")){
			System.out.println("Yes");
		}else{
			System.out.println("No");


		}



	}
}
class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
 
public class Program
{
    public static void Main()
    {
        string s = Console.ReadLine();
        string s_ = new string(s.Reverse().ToArray());
        Console.WriteLine((s.Length - (s_.IndexOf("Z"))) - (s.IndexOf("A")));
    }
}

Measured memory_bytes: 15200
n = int(input())
str_l = []

for i in range(n):
    str_l.append("".join(sorted(input())))

str_l.sort()
ans = 0
num = 0
st = "a"

for j in range(n):
    if str_l[j] == st:
        num += 1
        ans += num
    else:
        num = 0
        st = str_l[j]

print(ans)

Measured memory_bytes: 10640
a,b,k = map(int,input().split())
l=[]
for i in range(k):
    if a+i not in l and a+i<=b:
        l.append(a+i)
for i in range(k):
    if b-k+1+i not in l and b-k+1+i>=a:
        l.append(b-k+1+i)
m=sorted(l)
for i in range(len(m)):
    print(m[i])

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		int start, goal, close;
		double a[][];
		int k;
		n = sc.nextInt();
		while (n != 0) {
			start = (int)(sc.next().charAt(0) - 'A' + 1);
			goal  = (int)(sc.next().charAt(0) - 'A' + 1);
			close = (int)(sc.next().charAt(0) - 'A' + 1);

			a = new double[n + 1][10];
			for (int i = 0; i <= n; i++) {
				for (int j = 1; j <= 9; j++) {
					k = 0;
					if (i == 0) {
						if (j == goal) {
							a[i][j] = 1.0;
						} else {
							a[i][j] = 0.0;
						}
					} else {
						if (j % 3 == 1 && j + 1 != close) {
							a[i][j] += a[i - 1][j + 1] / 4;
							k++;
						}
						if (j % 3 == 2) {
							if (j + 1 != close) {
								a[i][j] += a[i - 1][j + 1] / 4;
								k++;
							}
							if (j - 1 != close) {
								a[i][j] += a[i - 1][j - 1] / 4;
								k++;
							}
						}
						if (j % 3 == 0 && j - 1 != close) {
							a[i][j] += a[i - 1][j - 1] / 4;
							k++;
						}
						if (1 <= j && j <= 3 && j + 3 != close) {
							a[i][j] += a[i - 1][j + 3] / 4;
							k++;
						}
						if (4 <= j && j <= 6) {
							if (j - 3 != close) {
								a[i][j] += a[i - 1][j - 3] / 4;
								k++;
							}
							if (j + 3 != close) {
								a[i][j] += a[i - 1][j + 3] / 4;
								k++;
							}
						}
						if (7 <= j && j <= 9 && j - 3 != close) {
							a[i][j] += a[i - 1][j - 3] / 4;
							k++;
						}
						a[i][j] += a[i - 1][j] * (4 - k) / 4;
					}
				}
			}
			System.out.println(a[n][start]);
			n = sc.nextInt();
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int res=0;
  rep(i,n){
    repz(j,i+1,n){
      res += a[i]*a[j];
    }
  }
  cout << res <<endl;
  return 0;
}


Measured memory_bytes: 256
testCase = Array.new
i = 0
STDIN.each_line do |line|
  testCase[i], testCase[i+1] = line.split(" ").map(&:to_i)
  i += 2
end
i = 0
cases = testCase.length/2
cases.times do
  print testCase[i].gcd(testCase[i+1])
  print " "
  puts testCase[i].lcm(testCase[i+1])
  i += 2
end

Measured memory_bytes: 8564
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
#      .      '                    Udit Gupta @luctivud         ,              
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                            ##     ##  #######  # #  ######
                            ##     ##  ##   ##  ###    ##
                            ##     ##  ##    #  # #    ##
                            #########  #######  # #    ##
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import math
# sys.setrecursionlimit(10**6)

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args): return print(*args, end="")
def printsp(*args): return print(*args, end=" ")
def printchk(*args): return print(*args, end="tst, ")

MODPRIME = int(1e9+7); BABYMOD = 998244353;
# ################################ HELPER PROGRAMS USED ###################################
# ################################## MAIN STARTS HERE #####################################
# for _testcases_ in range(int(input())):
x, y, a, b, c = get_ints()
la = get_array()
lb = get_array()
lc = get_array()
la.sort(reverse = True)
lb.sort(reverse = True)
for i in range(x):
    lc.append(la[i])
for i in range(y):
    lc.append(lb[i])
lc.sort(reverse = True)
sum = 0
for i in range(x+y):
    sum += lc[i]
print(sum)


# #########################################################################################
'''
THE LOGIC AND APPROACH IS BY ME @luctivud.
SOME PARTS OF THE CODE HAS BEEN TAKEN FROM WEBSITES LIKE::
(I Own the code if no link is provided here or I may have missed mentioning it)
: DO NOT PLAGIARISE.
'''

Measured memory_bytes: 100904
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        
        if(a<b){
            System.out.println("a < b");
        }
        else if(a>b){
            System.out.println("a > b");
        }
        else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
typedef long long ll;
typedef pair<int, int> P;

int main() {
    ll a, b; cin >> a >> b;
    if ((a+b)%2 == 0) {
        cout << (a+b)/2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define loop(n)  for(int i=0;i<n;i++)
#define loop1(i,a,n)  for(int i=a;i<n;i++)
using namespace std;
int main()
{
    fastio;
    int n,k;
    cin>>n>>k;
  	if(n%k==0)
    {
      cout<<"0";
    }
  	else
    {
      cout<<"1";
    }
    return 0;
}

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

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            
            List<char> list1 = new List<char>();
            for(int i = 0 ; i < s1.Length ; i++) list1.Add(s1[i]);
            list1.Sort();
            
            List<char> list2 = new List<char>();
            for(int i = 0 ; i < s2.Length ; i++) list2.Add(s2[i]);
            list2.Sort();
            list2.Reverse();
            
            
        
            List<string> sss = new List<string>();
            sss.Add(string.Join("",list1));
            sss.Add(string.Join("",list2));
            sss.Sort();
            
            bool can = false;
            string ss = string.Join("",list1);
            
            
            if(sss[0] == ss) can = true;
            if(can && sss[0] != sss[1])
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 14432
# ==================================================-
# 二分探索
# functionを満たす,search_listの最大の要素を出力
# 【注意点】searchリストの初めの方はfunctionを満たし、後ろに行くにつれて満たさなくなるべき
import math
import sys

sys.setrecursionlimit(10 ** 9)


def binary_research(start, end,function):
    if start == end:
        return start
    middle = math.ceil((start + end) / 2)
    if function(middle, k, a_sum, b_sum):
        start = middle
    else:
        end = middle - 1
    return binary_research(start, end, function)


# ==================================================-

n, m, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a_sum = [0]
b_sum = [0]
for book in a:
    a_sum.append(a_sum[-1] + book)
for book in b:
    b_sum.append(b_sum[-1] + book)


def can_read(num, k, a_sum, b_sum):
    min_read_time = 1000000000000
    for i in range(max(0, num - m), min(num+1,n+1)):
        a_num = i
        b_num = num - i
        min_read_time = min(min_read_time, a_sum[a_num] + b_sum[b_num])
    if min_read_time <= k:
        return True
    return False


start = 0
end = n + m

print(binary_research(start, end, can_read))

Measured memory_bytes: 47416
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    vi t(N+1), x(N+1), y(N+1);
    t[0] = x[0] = y[0] = 0;
    rep(i, N) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }

    bool res = true;
    FOR(i, 1, N+1) {
        int pt=t[i-1], px=x[i-1], py=y[i-1];
        int d = abs(x[i]-px) + abs(y[i]-py);
        int td = t[i] - pt;

        if(td >= d && !((td-d)%2)) continue;
        else {
            res = false;
            break;
        }
    }

    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 2560
s = int(input())

def f(x):
    if x % 2 == 0:
        return int(x / 2)
    else:
        return x * 3 + 1

numlist = [s]
for i in range(1000000):
    if i+1 == 1:
        x = s
    else:
        x = x
    x = f(x)
    if numlist.count(x) == 1:
        print(i+2)
        break
    else:
        numlist.append(x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  string s;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << "\n";
  return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}

const int INF = 1e9;
int a[100], b[100], c[100];
int dp[500][500];

/*
dp[i][a][b]
iまでの薬品を買って Aaグラム Bbグラムとしたときの
必要な最小予算
*/

int main() {
    int N,MA,MB; cin >> N >> MA >> MB;
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }
    
    for (int i = 0; i < 500; i++) {
        for (int j = 0; j < 500; j++) {
            dp[i][j] = INF;
        }
    } 
    dp[0][0] = 0;
    
    
    for (int i = 0; i < N; i++) {
        for (int j = 499; j >= 0; j--) {
            for (int k = 499; k >= 0; k--) {
                if (j-a[i] >= 0 && k-b[i] >= 0) {
                    chmin(dp[j][k],dp[j-a[i]][k-b[i]]+c[i]);
                }
            }
        }
    }
    int res = INF;
    for (int i = 1; i*MA < 500 && i*MB < 500; i++) {
        chmin(res,dp[i*MA][i*MB]);
    }
    if (res == INF) {
        cout << "-1\n";
    } else cout << res << endl;
}

Measured memory_bytes: 1280