akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 80 + 5;
const int gap = 25600 + 5;
bool dp[maxn][maxn][4 * maxn * maxn];
int grid[maxn][maxn];
inline int v(int val) {
    return val >= 0? val: gap + val;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int h, w; cin >> h >> w;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
            cin >> grid[i][j];
    int a;
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
            cin >> a;
            grid[i][j] = abs(grid[i][j] - a);
        }
    dp[0][0][grid[0][0]] = dp[0][0][gap - grid[0][0]] = 1;
    for (int i = 1; i < h; ++i)
        for (int j = 0; j < 4 * maxn * maxn; ++j)
            if (dp[i - 1][0][j]) {
                int tmp = j;
                if (j > 12800)
                    tmp -= gap;
                dp[i][0][v(tmp + grid[i][0])] = dp[i][0][v(tmp - grid[i][0])] = 1;
            }
    for (int i = 1; i < w; ++i)
        for (int j = 0; j < 4 * maxn * maxn; ++j)
            if (dp[0][i - 1][j]) {
                int tmp = j;
                if (j > 12800)
                    tmp -= gap;
                dp[0][i][v(tmp + grid[0][i])] = dp[0][i][v(tmp - grid[0][i])] = 1;
            }
    for (int i = 1; i < h; ++i)
        for (int j = 1; j < w; ++j)
            for (int k = 0; k < 4 * maxn * maxn; ++k)
                if (dp[i - 1][j][k] || dp[i][j - 1][k]) {
                    int tmp = k;
                    if (k > 12800)
                        tmp -= gap;
                    dp[i][j][v(tmp + grid[i][j])] = dp[i][j][v(tmp - grid[i][j])] = 1;
                }
    for (int i = 0; i < 4 * maxn * maxn; ++i)
        if (dp[h - 1][w - 1][i]) {
            if (i > 12800)
                i = abs(i - gap);
            cout << i << '\n';
            break;
        }
    return 0;
}

Measured memory_bytes: 191744
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n:usize,
        mut a: [i64; n],
    }
    let mut c = 0;
    for i in 0..n {
        let mut cc = 0;
        loop {
            if a[i]%2==0 {
                a[i]/=2;
                cc+=1;  
            }else{
                break;
            }
        }
        c+=cc;
    }
    println!("{}", c);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
#define ce(a) cout << (a) << endl
int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[m];
    rp(i, 0, m) cin >> a[i];
    ll sum = 0;
    rp(i, 0, m) sum += a[i];
    if (sum > n)
    {
        cout << -1 << endl;
    }
    else
    {
        ce(n - sum);
    }
}

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

int32_t main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    int ans = 0;
    rep(i, 0, n){
        rep(j, i + 1, n){
            rep(k, j + 1, n){
                if(a[i] != a[j] and a[j] != a[k] and a[k] != a[i] and a[i] + a[j] > a[k] and a[i] + a[k] > a[j] and a[j] + a[k] > a[i]){
                    //cout << a[i] << " " << a[j] << " " << a[k] << '\n';
                    ans++;
                }
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3628
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#ifndef debug_on
#define debug_on 0
#endif

#define dbg \
    if(debug_on) cerr << "DEBUG:"
#define ast(cond)           \
    do {                    \
        if((cond) == false) \
        {                   \
            if(debug_on)    \
            cerr << "ASSERT" << #cond " failed at line:" << __LINE__ << endl;   \
            exit(1);        \
        }                   \
    }while(0)

template<typename T>
void InvMod(T *inv_mod, T n, T r)
{
    inv_mod[0] = 1;
    if(1 <= n)
        inv_mod[1] = 1;
    for(T i = 2; i <= n; ++i)
    {
        inv_mod[i] = r - ((r / i) * inv_mod[r % i] % r);
        ast(((inv_mod[i] * i) % r) == 1);
    }
}

template<typename T>
void InvFactMod(T * inv_fact_mod, const T *inv_mod, T n, T r)
{
    inv_fact_mod[0] = 1;
    if(1 <= n)
        inv_fact_mod[1] = 1;
    for(T i = 2; i <= n; ++i)
    {
        inv_fact_mod[i] = inv_fact_mod[i - 1] * inv_mod[i] % r;
    }
}

template<typename T>
void FactMod(T * fact_mod, T n, T r)
{
    fact_mod[0] = 1;
    if(1 <= n)
        fact_mod[1] = 1;
    for(T i = 2; i <= n; ++i)
    {
        fact_mod[i] = fact_mod[i-1] * i % r;
    }
}


int main(int, char *[])
{
    uint64_t N;
    const uint64_t R = 1000000000 + 7;
    cin >> N;

    const int min_step = (1+N) / 2;
    const int max_step = N - 1;
    dbg << "MinStep:" << min_step << " max_step:" << max_step << endl;
    vector<uint64_t> inv_mod(N+1);
    InvMod(inv_mod.data(), N, R);
    vector<uint64_t> inv_fact_mod(N+1);
    InvFactMod(inv_fact_mod.data(), inv_mod.data(), N, R);
    vector<uint64_t> fact_mod(N+1);
    FactMod(fact_mod.data(), N, R);
    auto comb = [&](uint64_t n, uint64_t i)->uint64_t
    {
        uint64_t mul = fact_mod[n];
        mul *= inv_fact_mod[i];
        mul %= R;
        mul *= inv_fact_mod[n - i];
        mul %= R;
        dbg << "Comb(" << n << "," << i << "):" << mul << endl;
        return mul;
    };
    uint64_t sum = 0;
    uint64_t prev_pats = 0;
    for(int i = 1; i <= max_step; ++i)
    {
        if(i-1 < N - 1 - i) continue;
        uint64_t mul = comb(i-1, N - 1 - i);
        mul *= fact_mod[i];
        mul %= R;
        mul *= fact_mod[N - 1 - i];
        mul %= R;

        const uint64_t cur_total = mul;

        mul += R;
        mul -= prev_pats;
        mul %= R;

        prev_pats  = cur_total;

        mul *= i;
        mul %= R;
        sum += mul;
        sum %= R;
    }
    cout << sum << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a+n);
    for (int i = 0; i < n-1; i++)
    {
        if (a[i] == a[i+1])
        {
            cout << "NO" << endl;
            return 0;
        }
        
    }
    cout << "YES" << endl;
    return 0;
    
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) {
		cin >> a[i];
	}
	sort(all(a));
	vector<int> cnt(100005, 0);
	rep(i, N) {
		cnt[a[i]]++;
	}
	int mx = 0;
	rep1(i, 100000) {
		if (mx < cnt[i - 1] + cnt[i] + cnt[i + 1]) {
			mx = cnt[i - 1] + cnt[i] + cnt[i + 1];
		}
	}
	cout << mx << endl;
	return 0;
}

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

int main(){
  int h,w; cin >>h >>w;
  int cnt = 0;
  rep(i,h){
    string s; cin >>s;
    rep(j,w) if(s[j]=='#') cnt++;
  }
  if(cnt==h+w-1) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#define FILE_NAME "a"


int n;
vi a;

bool read() {
	if  (scanf("%d", &n) < 1) {
		return 0;
	}
	a.resize(n);
	forn(i, n) {
		scanf("%d", &a[i]);
	}
	return 1;
}



bool solve(vi a) {
	assert(sz(a) >= 2);
	
	sort(all(a));
	if  (a.front() == 0 || a.front() + 1 < a.back()) {
		return 0;
	}
	if  (a.front() == a.back()) {
		if  (a.back() == sz(a) - 1) {
			return 1;
		}
		const int mx = sz(a) / 2;
		if  (a.back() > mx) {
			return 0;
		}
		return 1;
	}

	int cnt_small = 0;
	for (int x : a) {
		cnt_small += (x == a.front());
	}

	vi na;
	for (int x : a) {
		if  (x != a.back()) {
			continue;
		}
		x -= cnt_small;
		if  (x < 0) {
			return 0;
		}
		na.pb(x);
	}
	sort(all(na));

	{
		if  (sz(na) <= 1) {
			return 0;
		}
		const int mx = sz(na) / 2;
		if  (na.back() > mx) {
			return 0;
		}
		if  (na.back() == 0) {
			return 0;
		}
		return 1;
	}
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		puts(solve(a) ? "Yes" : "No");
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 1660
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

I, O, T, J, L, S, Z = map(int, read().split())

x = O
y = 3 + 2 * ((L - 1) // 2 + (I - 1) // 2 + (J - 1) // 2)  # LIJ あり
if L == 0 or I == 0 or J == 0:
    y = 0
z = 2 * (L // 2 + I // 2 + J // 2)  # LIJ なし
x += max(y, z)
print(x)

Measured memory_bytes: 9196
#include<stdio.h>                                                                                                                      
                                                                                                                                       
int main(){                                                                                                                        
   int A,B,C;                                                                                                                          
   scanf("%d %d %d",&A,&B,&C);                                                                                                         
                                                                                                                                       
   if((A == B && A != C) || (A == C && A != B)||(B == C && B != A)){                                                                   
      printf("Yes");                                                                                                                   
   }else{                                                                                                                              
      printf("No");                                                                                                                    
   }                                                                                                                                   
   return 0;                                                                                                                           
}  


Measured memory_bytes: 1732
#include<stdio.h>


#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N],d[N],f[N],tt;
/* id ha chouten bangou */
/* d ha sono chouten no hakken jikoku */
/* f ha sono chouten no kanryou jikoku */

/* saiki kannsuu ni yoru fukasa_yuusen_tansaku */
/* u ha chouten no bangou*/
void dfs_visit(int u)
{
  int v;
  color[u] = GRAY; /* houmon siita node GRAY ni suru */
  d[u] = ++tt; /* saisho no houmon */   /* jikoku wo 1 tuika */
  for (v = 0; v < n; v++)
    {
      if (M[u][v] == 0) continue; /* u gyou j retsu ni chouten ga nakattara for loop wo nukekru */
      if (color[v] == WHITE)
        {
          dfs_visit(v);/* saiki kannsuu wo yobu */
        }
    }
  color[u] = BLACK; /* u no rinestsu ni mihoumon(WHITE)ga nai node houmon_kanryou(BLACK)to suru */
  f[u] = ++tt;
}

  /* iro wo shokika tumari chouten wo white ni suru */
  /* mihoumon no u wo siten tosite fukasa yuusen tansaku */
  /* chouten_bangou , hakkenn_jikoku f, kannryou jikoku d, wo print */
void dfs()
{
 int u;
  /* syokika */
  for (u = 0; u < n; u++) color[u] = WHITE;
  tt = 0;

  /* u ha chouten no bangou*/
  for (u = 0; u < n;u++)
    {
      /* mihoumon no u wo shiten tosite fukasa yuusen tansaku */
      if (color[u] == WHITE) dfs_visit(u);
   }
  /* WHITE mihoumon */
  /* GRAY genzai houmon chuu mataha houmonsita chouten */
  /* BLACK houmon ga kanryou sita chouten */


  /* chouten no bangou, hakkenn_jikoku , kanryou_jikoku wo printout */
  for ( u = 0; u < n; u++)
    {
      printf("%d %d %d\n", u +1, d[u],f[u]);
    }
}


  
  int main ()
{
int u,v,k,i,j;
  scanf("%d",&n);/* chouten no kazu wo toru */
  /* rinsetsu gyouretsu wo shokika */
  for(i = 0; i < n; i++)
      {
        for (j = 0; j < n; j++)
          {
            M[i][j] = 0;
          }
      }
  /* rinsetsu gyouretsu ni atai wo ireru */
  for ( i = 0; i < n; i++)
    {
      scanf("%d %d",&u,&k);
        /* u ha chouten no bangou*/
        /* k ha syutu_ji_suu. tumamri rinsetsu suru chouten no kazu */
        u--; /* 0 orign no tame 1 hiku */
      for (j = 0; j < k; j++)
        {
          scanf("%d",&v);
          v--;/* 0 orign no tame 1 hiku */
          M[u][v] = 1;
        }
    }

  dfs();
  /* kansuu wo yobu*/
  /* iro wo shokika tumari chouten wo white ni suru */
  /* mihoumon no u wo siten tosite fukasa yuusen tansaku */
  /* chouten_bangou , hakkenn_jikoku f, kannryou jikoku d, wo print */
return 0;
}

Measured memory_bytes: 632
import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();
type NumberOrBigintOrElse<T> = T extends number
  ? number
  : T extends bigint
  ? bigint
  : undefined;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isNumber = (x: unknown): x is number => typeof x === "number";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const isBigint = (x: unknown): x is bigint => typeof x === "bigint";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const max = <T>(...ts: T[]): NumberOrBigintOrElse<T> => {
  if (ts.length === 0) return undefined as NumberOrBigintOrElse<T>;
  const t = ts[0];
  return (typeof t === "number"
    ? Math.max(...((ts as unknown) as number[]))
    : ((ts as unknown) as bigint[]).reduce((acc, t) =>
        acc >= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const min = <T>(...ts: T[]): NumberOrBigintOrElse<T> => {
  if (ts.length === 0) return undefined as NumberOrBigintOrElse<T>;
  const t = ts[0];
  return (typeof t === "number"
    ? Math.min(...((ts as unknown) as number[]))
    : ((ts as unknown) as bigint[]).reduce((acc, t) =>
        acc <= t ? acc : t
      )) as NumberOrBigintOrElse<T>;
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const abs = <T>(t: T): NumberOrBigintOrElse<T> =>
  (typeof t === "number"
    ? t >= 0
      ? t
      : -t
    : typeof t === "bigint"
    ? t > 0n
      ? t
      : -t
    : undefined) as NumberOrBigintOrElse<T>;

type Color = "R" | "W";

const getAnswer = (N: number, cs: Color[]): number => {
  const rNum = cs.filter((c) => c === "R").length;
  return min(rNum, N - rNum, cs.slice(0, rNum).filter((c) => c === "W").length);
};

{
  const N = nCin();
  const cs = cin()
    .split("")
    .map((c) => c as Color);
  const ans = getAnswer(N, cs);
  console.log(ans);
}


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

int main()
{
    int m, n, o, i, j;
    char ch;
    cin >> m;
    cin >> n;
    cin >> o;
    if (m>o && n<o){
        cout << "Yes";
    }
    else if (n>o && m<o){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <istream>
#include <string.h>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <math.h>
#include <vector>
using namespace std;
#define mod 1000000007
#define ttt 200005
#define inf 0x3f3f3f3f
#define ll long long
#define pi 3.1415926
int main()
{
    ll n;
    ll sum=0;
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++)
    {
       sum+=(i+n-n%i)*(n/i)/2; 
    }
    printf("%lld\n",sum);
    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  int M;
  i64 K;
  cin >> M >> K;
  if(M == 1) {
    if(K == 0) {
      cout << "0 0 1 1" << endl;
    }
    else {
      cout << -1 << endl;
    }
    return 0;
  }
  if(K >= (1 << M)) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  for(int i = (1 << M) - 1;i >= 0;i--) {
    if(i == K) continue;
    ans.push_back(i);
  }
  for(auto x: ans) {
    cout << x << " ";
  }
  cout << K << " ";
  reverse(all(ans));
  for(auto x: ans) {
    cout << x << " ";
  }
  cout << K << endl;
}


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

typedef long long ll;

/*
x-> floor((x-1)/2)
2 is zero
in reverse
x-> x*2 + 2
*/

int main(){
	cout.precision(13);
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	ll ans = 2;
	while(n--){
		ans = 2 * ans + 2;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
int read() {
    char ch = getchar();
    int x = 0, flag = 1;
    for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
    for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x * flag;
}
void write(int x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) write(x / 10);
    putchar(x % 10 + 48);
}

const int Maxn = 200009;
int fa[Maxn];
int find(int u) { 
	return fa[u] != u ? fa[u] = find(fa[u]) : u; 
}

struct edge {
	int u, v;
	LL w;
	int operator < (const edge b) const {
		return w < b.w;
	}
};
vector <edge> s;
int n, q;
LL val[Maxn];

void init() {
	n = read(), q = read();
	rep (i, 1, n) fa[i] = i;
	rep (i, 0, n) val[i] = INT_MAX - n;
	rep (i, 1, q) {
		int u = read(), v = read(), w = read();
		s.push_back((edge){u % n, v % n, w});
		val[(u + 1) % n] = min(val[(u + 1) % n], w + 1ll);
		val[(v + 1) % n] = min(val[(v + 1) % n], w + 2ll);
	}
}

void solve() {
	rep (i, 1, n - 1) val[i] = min(val[i - 1] + 2, val[i]);
	val[0] = min(val[n - 1] + 2, val[0]);
	rep (i, 1, n - 1) val[i] = min(val[i - 1] + 2, val[i]);

	rep (i, 1, n - 1) s.push_back((edge){i - 1, i, val[i]});
	s.push_back((edge){n - 1, 0, val[0]});
	
	LL ans = 0;
	sort(s.begin(), s.end());
	rep (i, 0, s.size() - 1) {
		int x = find(s[i].u), y = find(s[i].v);
		if (x != y) {
			ans += s[i].w;
			fa[x] = y;
		}
	}
	cout << ans << endl;
}

int main() {
///	freopen("G.in", "r", stdin);
///	freopen("G.out", "w", stdout);

	init();
	solve();

#ifdef Qrsikno
    debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
    return 0;
}



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

using namespace std;

const int64_t INF = INT64_C(1) << 60;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<pair<int, pair<int, int>>> E(M);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    E[i] = make_pair(a, make_pair(b, c));
  }
  vector<int64_t> D(N, -INF);
  D[0] = 0;
  for (int i = 0; i < N; i++) {
    for (auto e : E) {
      int u = e.first, v = e.second.first, d = e.second.second;
      if (D[u] != -INF) chmax(D[v], D[u] + d);
    }
  }
  for (int i = 0; i < N; i++) {
    for (auto e : E) {
      int u = e.first, v = e.second.first, d = e.second.second;
      if (D[u] != -INF && chmax(D[v], D[u] + d)) D[v] = INF;
    }
  }
  if (D[N - 1] == INF) {
    cout << "inf" << '\n';
  } else {
    cout << D[N - 1] << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int N;
  int ichi;
  scanf("%d",&N);
  ichi = N % 10;
  if(ichi == 3){
    printf("bon\n");
  }
  else if(ichi == 0 || ichi == 1 || ichi == 6 || ichi == 8){
    printf("pon\n");
  }
  else{
    printf("hon\n");
  }
  return 0;
}

Measured memory_bytes: 1612
from sys import stdin

N, W = map(int, stdin.readline().split())
dp = [0] * (W + 1)
for i in range(N):
    w, v = [int(k) for k in stdin.readline().split()]
    for j in range(W, w - 1, -1):
        dp[j] = max(dp[j], dp[j - w] + v)
print(dp[W])

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

#define int long long
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) otp(v[i]) cte
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

string s;

main() {
    cin >> s;
    rep(i,2) s.pop_back();
    while(s.size()) {
        int n=s.size()/2;
        rep(i,n) {
            if (s[i] != s[i+n]) break;
            if (i == n-1) {
                ct(s.size())
                return 0;
            }
        }
        rep(i,2) s.pop_back();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  int n, m;
  cin >> n;
  vector<int> t(n);
  for (int i = 0; i < n; i++) { cin >> t[i]; }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int pi, xi;
    cin >> pi >> xi;

    int total = 0;
    for (int k = 0; k < n; k++) {
      int tt = (k == pi - 1 ? xi : t[k]);
      // cout << "   " << k << ":" << tt << endl;
      total += tt;
    }
    cout << total << endl;
  }
}


Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

cost_all = 0
for i in range(n+1):
    cost_all += abs(a[i+1] - a[i])

for i in range(1,n+1):
    tmp_cost = cost_all
    tmp_cost -= abs(a[i]-a[i-1]) + abs(a[i+1] - a[i])
    tmp_cost += abs(a[i+1] - a[i-1])
    print(tmp_cost)

Measured memory_bytes: 20560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
    int h,w,n;
    cin>>h>>w>>n;
    int ans=10000;
    for(int i=0;i<=h;i++){
        for(int j=0;j<=w;j++){
            int x =h*i+w*j-i*j;
            if(x>=n)ans=min(ans,i+j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int, input().split()))
dp=[10**10]*n
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2, n):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])


Measured memory_bytes: 52464
#include<cstdio>
#include<cstring>
const int N = 1e5+5;
char s[N];
//一个区间的左右端点
//记录最近的一个不同的即可
int l[N], r[N];
int ans[N];

int min(int a,int b){ return a>b?b:a; }

int max(int a,int b){ return a>b?a:b; }

void pre(int n){
    //记录最近的L和R
    int L = -1, R = -1;
    for(int i = 1; i <= n; i++){
        if(s[i]=='L'){ 
            L = i;
            if(R==-1) l[i] = 1;
            else l[i] = R+1;
        }
        else{ 
            R = i;
            if(L==-1) l[i] = 1;
            else l[i] = L+1;
        }
    }
    L = -1, R = -1;
    for(int i = n; i >= 1; i--){
        if(s[i]=='L'){ 
            L = i;
            if(R==-1) r[i] = n;
            else r[i] = R-1;
        }
        else{ 
            R = i;
            if(L==-1) r[i] = n;
            else r[i] = L-1;
        }
    }
}

int main(){
    scanf("%s",s+1);
    int n = strlen(s+1);
    pre(n);
    for(int i = 1; i <= n; i++) ans[i] = 0;
    for(int i = 1; i <= n; i++){
        if(s[i]=='R'){
            int d = r[i]-i;
            if(d%2) ans[r[i]+1]++;
            else ans[r[i]]++;
        }
        else{
            int d = i-l[i];
            if(d%2) ans[l[i]-1]++;
            else ans[l[i]]++;
        }
    }
    for(int i = 1; i <= n; i++) printf("%d%c",ans[i],i==n?'\n':' ');
    return 0;
}

Measured memory_bytes: 1664
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(n>2) cout << s[0] << n-2 << s[n-1] << endl;
    else cout << s << endl;
	return 0;
}

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

int main()
{
 int n; cin >> n;
 int num_of_sub[200001]={0};
 for(int i=0;i<n-1;i++)
 {
  int temp; cin>> temp;  num_of_sub[temp]++;
 }
 for(int i=1;i<n+1;i++)
 {
   cout<<num_of_sub[i]<<"\n";
 }
}


Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
    int t,n,k,a,b;
    cin>>k>>a>>b;
    t=1;
    for(int i=a;i<=b;i++){
        if(i%k==0){cout<<"OK"<<"\n";t=0;break;}
    }
    if(t)cout<<"NG"<<"\n";
}


Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	m := intScanner()
	as := intSliceScanner(n)
	for i := 0; i < n; i++ {
		as[i] /= 2
	}
	x := as[0]
	for i := 1; i < n; i++ {
		x = x / gcd(x, as[i])
		if x*as[i]/as[i] != x {
			x = 0
			break
		} else {
			x *= as[i]
		}
	}
	for i := 0; i < n; i++ {
		if x/as[i]%2 == 0 {
			x = 0
			break
		}
	}
	if m < x {
		x = 0
	}
	if x == 0 {
		fmt.Println(0)
	} else {
		fmt.Println((m/x-1)/2 + 1)
	}
}
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}


Measured memory_bytes: 4208
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


int main(){
  string s;
  cin>>s;
  int l;
  int count;
  count=0;
  l=s.size();
  if(l%2==0){
    REP(i,l/2){
      if(s[i]!=s[l-i-1]){
        count=count+1;
      }
    }
    cout<<count<<endl;
    return 0;
  }
  else{
    REP(i,(l-1)/2){
      if(s[i]!=s[l-i-1]){
        count=count+1;
      }
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];

    let s = read::<String>();
    for (i, c) in s.chars().enumerate() {
        if i as u32 == a {
            if c != '-' {
                yn(false);
                return;
            }
        } else if ((i as u32) < a) || ((i as u32) < a + b + 1) {
            if !(c >= '0' && c <= '9') {
                yn(false);
                return;
            }
        } else {
            yn(false);
            return;
        }
    }
    yn(true);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define mod  1073741824
#pragma GCC optimization ("O3")
using namespace std;
const int N = 100*1000+5;
#define all(x) begin(x),end(x)
int main()
{
   
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    int n,c =0;
    cin >> n;
    string s,s1="ABC";
    cin >> s;
   	for (int i = 0; i < (int)s.size(); ++i)
   	{
   		string k = s.substr(i,(int)s1.size());
   		if(k == s1)
   			c++;
   	}
   	cout << c;
   	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<deque>
#include<set>
#include<vector>
#include<map>
#define ll long long
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    int n,a,b;
	int ans;
	cin>>n>>a>>b;
	ans=min(a*n,b); 
	cout<<ans<<endl;
	
		return 0;
 } 


Measured memory_bytes: 3184
#include <stdio.h>
#include <string.h>

#define N 200001

int main(void)
{
	int i,length,count=0;
	char str_s[N],str_t[N];

	scanf("%s",str_s);
	scanf("%s",str_t);

	length = strlen(str_s);

	for(i=0;i<length;i++){
		if(str_s[i]!=str_t[i]){
			count++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
  int x; cin >> x;
  int rtn;
  if (x >= 400 && x <= 599) rtn = 8;
  if (x >= 600 && x <= 799) rtn = 7;
  if (x >= 800 && x <= 999) rtn = 6;
  if (x >= 1000 && x <= 1199) rtn = 5;
  if (x >= 1200 && x <= 1399) rtn = 4;
  if (x >= 1400 && x <= 1599) rtn = 3;
  if (x >= 1600 && x <= 1799) rtn = 2;
  if (x >= 1800 && x <= 1999) rtn = 1;

  cout << rtn << endl;
}


Measured memory_bytes: 3632
import sys
import copy
import math
import itertools
import numpy as np
l = [int(c) for c in input().split()]
N=l[0]
K=l[1]
Q=l[2]
A=[int(input()) for c in range(Q)]

S = [K]*N

for i in range(Q):
    S[A[i]-1]+=1

for i in range(N):
    if S[i]-Q>0:
        print("Yes")
    else:
        print("No")

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

int main(){
    int r,c;
    
    while(cin >> r >> c , r+c){
        int seat_num = r*c;
        
        if(seat_num%2==0) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    
    return 0;
}

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

int n,ans;
string s;
map<string,int> m;

int main()
{
	cin>>n;
	while(n--)
	{
		cin>>s;
		m[s]++;
		if(m[s]==1) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 19256
N = gets.to_i
a = N.times.map{gets.to_i}
a<<0
ans = 0
N.times.map{|i|
  x = (a[i]+a[i+1])/2
  ans+=x
  y = [x*2-a[i],0].max
  a[i+1]-=y
  #p x,y,a 
}
puts ans

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

int main() {
    int h, w, m = 1e9 + 7;
    cin>>h>>w;
    vector<string> grid(h);
    for(int i=0; i<h; i++) cin>>grid[i];
    // dp[i][j] - #ways to reach (i, j) from starting from (0, 0)
    vector<vector<int>> dp(h, vector<int> (w, 0));
    dp[0][0] = 1;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w ; j++) {
            if(j+1 < w) dp[i][j+1] = (dp[i][j+1] + (grid[i][j+1] == '#' ? 0 : dp[i][j])) % m;
            if(i+1 < h) dp[i+1][j] = (dp[i+1][j] + (grid[i+1][j] == '#' ? 0 : dp[i][j])) % m;
        }
    }
    cout<< dp[h-1][w-1] <<endl;
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}


void ssolve(std::istream& in, std::ostream& out){
    int x, k, d; s3(x, k, d);
    x = abs(x);
    if(x/d < k){
        int n = x/d;
        if(n%2==k%2){
            p(x - n * d);
        }else{
            p(abs(x - n * d - d));
        }
    }else{
        p(x - k * d);
    }

}

class CWalkingTakahashi {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CWalkingTakahashi solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

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

using namespace std;

int main()
{
    int a, b;

    while (true)
    {
        cin >> a >> b;

        if (a == b && a == 0)
        {
            break;
        }
        else if (a < b)
        {
            cout << a << " " << b << endl;
        }
        else
        {
            cout << b << " " << a << endl;
        }
    }
}


Measured memory_bytes: 3092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np

N = int(input())
ABC = np.array([np.array(list(map(int, input().split()))) for _ in range(N)])

dp = np.ones((N, 3))*-float("inf")

dp[0] = ABC[0]

for i in range(1, N):
    dp[i, 0] = max(dp[i-1, 1], dp[i-1, 2]) + ABC[i, 0]
    dp[i, 1] = max(dp[i-1, 0], dp[i-1, 2]) + ABC[i, 1]
    dp[i, 2] = max(dp[i-1, 0], dp[i-1, 1]) + ABC[i, 2]

print(int(max(dp[-1])))

Measured memory_bytes: 31896
package main
import "fmt"

func main() {
  var (
    A int
    B int
    X int
  )
  fmt.Scan(&A)
  fmt.Scan(&B)
  fmt.Scan(&X)
  if (A > X) {
    fmt.Println("NO")
  } else if (A + B < X) {
    fmt.Println("NO")
  } else {
    fmt.Println("YES")
  }
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

bool used[2005][2005];
char ca[2005];
int num[2005][2005];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>ca;
		for(j=0,b=0;j<m;j++){
			if(ca[j]=='#'){
				used[i][j]=true;
				for(k=j-b;k<j;k++)num[i][k]=b;
				b=0;
			}else b++;
		}
		for(k=j-b;k<j;k++)num[i][k]=b;
		#ifdef MORIRIN
		array_show(num[i],m);
		#endif
	}
	for(i=0,a=0;i<m;i++){
		for(j=0,b=0;j<n;j++){
			if(used[j][i]){
				for(k=j-b,c=0;k<j;k++)c=max(c,num[k][i]);
				a=max(a,b+c),b=0;
			}else b++;
		}
		for(k=j-b,c=0;k<j;k++)c=max(c,num[k][i]);
		a=max(a,b+c),b=0;
	}
	cout<<a-1<<endl;
}


Measured memory_bytes: 19840
import sys
input = sys.stdin.readline
import collections

N, X, Y = map(int, input().split())

def dist(i,j):
    return min(abs(j-i), abs(X-i)+1+abs(j-Y))

ans = [0]*N
for i in range(N):
    for j in range(i+1, N):
        d = dist(i+1,j+1)
        ans[d] += 1
for i in range(N):
    if i == 0:
        continue
    print(ans[i])

Measured memory_bytes: 48220
#include<stdio.h>

int main(){
	int x, y, i, v, a;

	scanf("%d%d", &x, &y);

	if(x < y){
		v = x;
		x = y;
		y = v;
	}

	while(1){
		a = x % y;
		if(a == 0){
			printf("%d\n", y) ;
			break;
		}
		x = y;
		y = a;
	}
return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<cstring>

using namespace std;

const int N(3009);

int n, m, cnt;
char a[N], b[N], c[N];
int f[N][N];

void print(int i, int j)
{
	while (i >= 1 && j>= 1)
	{
		if (a[i] == b[j])
		{
			c[++cnt] = a[i];
			i--;j--;
		}
		else if (f[i][j] == f[i][j - 1])
		{
			j--;
		}
		else
		{
			i--;
		}
	}
}
int main()
{
	cin>>(a+1)>>(b+1);
	n = strlen(a + 1);
	m = strlen(b + 1);
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (a[i] == b[j])
			{
				f[i][j] = f[i - 1][j - 1] + 1;
			}
			else
			{
				f[i][j] = max(f[i - 1][j], f[i][j - 1]);
			}
		}
	}
	print(n, m);
	if (cnt == 0) cout<<' ';
	else
	{
		for (int i=cnt;i>=1;i--)
		{
			cout<<c[i];
		}
	}
	return 0;
}

Measured memory_bytes: 35584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int p0 = 0, p1 = 0, p2 = 0;
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();

                int p = 0;
                while (k != 0 && k % 2 == 0) {
                    p++;
                    k /= 2;
                }

                if (p == 0)
                    p0++;
                else if (p == 1)
                    p1++;
                else if (p >= 2)
                    p2++;
            }
            if (p2 == 0 && p0 > 0)
                out.println("No");
            else if (p2 < p0 && p1 > 0)
                out.println("No");
            else if (p2 + 1 >= p0)
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

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

    }
}
 

Measured memory_bytes: 37716
n=int(input())
ans=[0]*10000

for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            temp=x**2+y**2+z**2+x*y+y*z+z*x
            if temp <=10000:
                ans[temp-1]+=1

for i in range(n):
    print(ans[i])

Measured memory_bytes: 69576