akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

int N,X;

int main(){
    scanf("%d%d",&N,&X);
    if(X==1||X==2*N-1)
        return !puts("No");
    puts("Yes");
    if(N==2)
        return !puts("1\n2\n3");
    if(X==2){
        for(int i=1;i<=N-2;i++)
            printf("%d\n",4+i);
        printf("3\n2\n1\n4\n");
        for(int i=1;i<=N-3;i++)
            printf("%d\n",N+2+i);
        return 0;
    }
    int cnt=1;
    for(int i=1;i<=N-2;i++){
        if(cnt==X-2)
            cnt=X+2;
        printf("%d\n",cnt++);
    }
    printf("%d\n%d\n%d\n%d\n",X-1,X,X+1,X-2);
    for(int i=1;i<=N-3;i++){
        if(cnt==X-2)
            cnt=X+2;
        printf("%d\n",cnt++);
    }
}

Measured memory_bytes: 1408
#define scanf_s scanf
#define sscanf_s sscanf
#define gets_s gets
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 1001
#define HO 6
int main(void)
{
	int n;
	char str[MAX], no[] = { "Hoshino" }, na[] = { "Hoshina" };
	gets_s(str);
	sscanf_s(str, "%d", &n);
	for (int i = 0; i < n; ++i) {
		gets_s(str);
		for (int j = 0; str[j] != '\0'; ++j) {
			if (no[HO] == str[j] && j >= HO) {
				for (int k = 0; k <= HO; ++k) {
					if (str[j - k] != no[HO - k]) break;
					else if (k == HO) {
						str[j] = na[HO];
					}
				}
			}
			printf("%c", str[j]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

// TLE
// 'RL'で最終的に子どもたちが集まる。RLの間隔の単体RとLの数を数え上げて、RとLの箇所にそれぞれ行く場所に足してあげる。

int main(void)
{
    string S;
    cin >> S;

    int N = S.size();
    int R = 0;
    int L = 0;
    vector<int> ans(N, 1);

    // Rの部分を反映
    for (int i = 0; i < N - 1; i++)
    {
        if (S[i] == 'R' && S[i + 1] != 'L')
        {
            R++;
            ans[i] -= 1;
        }

        if (S[i] == 'R' && S[i + 1] == 'L')
        {
            int add = R / 2;
            if (R % 2 == 0)
            {
                ans[i] += add;
                ans[i + 1] += add;
            }
            else
            {
                ans[i] += add;
                ans[i + 1] += add + 1;
            }
            // init R
            R = 0;
        }
    }

    // Lの部分を反映
    reverse(S.begin(), S.end());
    reverse(ans.begin(), ans.end());
    for (int i = 0; i < N - 1; i++)
    {
        if (S[i] == 'L' && S[i + 1] != 'R')
        {
            L++;
            ans[i] -= 1;
        }

        if (S[i] == 'L' && S[i + 1] == 'R')
        {
            int add = L / 2;
            if (L % 2 == 0)
            {
                ans[i] += add;
                ans[i + 1] += add;
            }
            else
            {
                ans[i] += add;
                ans[i + 1] += add + 1;
            }
            // init L
            L = 0;
        }
    }
    reverse(ans.begin(), ans.end());

    //debug
    for (int i = 0; i < N; i++)
    {
        printf("%d", ans[i]);
        if (i != N - 1)
        {
            printf(" ");
        }
    }
    printf("\n");
    return (0);
}

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    string s;
    cin >> s;
    ll n=s.size(), ans=INF;
    
    string a, b;
    ll tmp1=0,tmp2=0;
    rep(i,n){
        a += "10";
        b += "01";
    }
    rep(i,n){
        if(s[i] != a[i]) tmp1++;
        if(s[i] != b[i]) tmp2++;
    }
    ans = min(tmp1, tmp2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

map<char, int> num;

int formula(string &s, int &i){
    if(num.find(s[i]) != num.end()){
        ++i;
        return num[s[i-1]];
    }
    else if(s[i] == '-'){
        ++i;
        int ret = 2 - formula(s, i);
        return ret;
    }
    else{
        ++i;
        int lhs = formula(s, i);
        int ret;
        if(s[i] == '*'){
            ++i;
            int rhs = formula(s, i);
            ret = min(lhs, rhs);
        }
        else{
            ++i;
            int rhs = formula(s, i);
            ret = max(lhs, rhs);
        }
        ++i;
        return ret;
    }
}

void solve(string &s){
    rep(i, 3) num['0'+i] = i;
    int ans = 0;
    rep(S, 27){
        int t = S;
        rep(i, 3){
            num['P'+i] = t % 3;
            t /= 3;
        }
        int idx = 0;
        ans += (formula(s, idx) == 2);
    }
    printf("%d\n", ans);
}

int main(){
    string s;
    while(cin >> s && s != "."){
        solve(s);
    }
}


Measured memory_bytes: 3272
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cstring>
#include<algorithm>
#define ll long long
#define Max(x,y) ((x) > (y) ? (x) : (y))
#define Min(x,y) ((x) < (y) ? (x) : (y))
#define mod 1000000007
#define N 200010
using namespace std;
inline int read(){
	int x = 0,f = 1;char ch = getchar();
	while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}

int n,m;
int nxt[N*2],to[N*2],head[N],cnt;

void add(int x,int y){
	to[++cnt] = y; nxt[cnt] = head[x]; head[x] = cnt;
	to[++cnt] = x; nxt[cnt] = head[y]; head[y] = cnt;
}

int main(){
	n = read(); m = read();
	for(int i = 1;i <= m;i++){
		int x = read(),y = read();
		add(x,y);
	}
	for(int i = head[1];i;i = nxt[i]){
		if(to[i] == n){
			puts("POSSIBLE");
			return 0;
		}
		for(int j = head[to[i]];j;j = nxt[j]){
			if(to[j] == n){
				puts("POSSIBLE");
				return 0;
			}
		}
	}
	puts("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 4096
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (n, m) = (it.next().unwrap(), it.next().unwrap());

    // println!("N: {}, M: {}", n ,m);
    let ans = (n * 3 + m) / 2;
    println!("{}", ans);
}

Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<char> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

const int MXN=200001;
vl G[MXN];
vl D0(MXN,-1),D1(MXN,-1);

void dfs0(int v,int p=-1){
    int sz=G[v].size();
    if(p==-1) D0[v]=0;
    else D0[v]=D0[p]+1;
    rep(i,sz){
        if(G[v][i]!=p)dfs0(G[v][i],v);
    }
}

void dfs1(int v,int p=-1){
    int sz=G[v].size();
    if(p==-1) D1[v]=0;
    else D1[v]=D1[p]+1;
    rep(i,sz){
        if(G[v][i]!=p) dfs1(G[v][i],v);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs0(0);
    ll MX=0,u=0;
    rep(i,N){
        if(chmax(MX,D0[i])){
            u=i;
        }
    }
    dfs1(u);
    rep(i,N){
        chmax(MX,D1[i]);
    }
    cout << ( MX%3!=1 ? "First" : "Second" ) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

Measured memory_bytes: 26596
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int x;
	cin>>x;
	if(x>=-40&&x<=40)
	{
		if (x>=30)
		{
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
	return 0;
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    ll X,A,B;
    cin>>X>>A>>B;
    if(X<(B-A))cout<<"dangerous";
    else if(0<(B-A)&&(B-A)<=X)cout<<"safe";
    else cout<<"delicious";
    return 0;
}

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

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

  if((a*b)%2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<stdio.h>
#define MIN 1e13
typedef long long ll;
using namespace std;

double
euc_dis(int n, int arr[][2], int *permutation){
  double x;
  double y;
  double sum = 0;
  for (int i = 0; i < n - 1; ++i){
    x = arr[permutation[i]][0] - arr[permutation[i+1]][0];
    y = arr[permutation[i]][1] - arr[permutation[i+1]][1];
    sum += sqrt((x * x) + (y * y));
  }
  return sum;
}

int
main(void)
{
  int n; cin >> n;
  int arr[n][2]; for(int i = 0; i < n; i++){
    cin >> arr[i][0];
    cin >> arr[i][1];
  }
  double factorial = 1;
  double tmpfac = n;
  while(tmpfac){
    factorial *= tmpfac;
    --tmpfac;
  }
  int tmp[] = {0,1,2,3,4,5,6,7};
  int permutaion[n];
  int count = 0;
  for(int i = 0; i < n; ++i){
    permutaion[i] = tmp[i];
  }

  double sum = 0;
  do{
    sum += euc_dis(n, arr, permutaion) ;
  }while (next_permutation(permutaion, permutaion + n));
  printf("%.10f\n",sum / factorial);
  
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ll longlongint
using namespace std;
int main(){
     SPEED;
     string  a ,b ;
     cin>>a>>b;
     a=a+b;
     int n=stoi(a);
     int sq=sqrt(n);
    string ans="No";
    if(sq*sq==n)ans="Yes";
    cout<<ans;
     ed;
     return 0;
}


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

int main(void) {
	int a,b,c;
	cin >> a >> b >> c;
	cout << (a + b + c == 17 && (a == 5 || a == 7) && (b == 5 || b == 7) && (c == 5 || c == 7) ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    
  	cout << (a * b) / 2 << endl;
  
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

struct Date
{
	int year, month, day;
	Date(int y, int m, int d) : year(y), month(m), day(d) {}
	Date() {}

	bool operator<(const Date& d)const
	{
		if(year != d.year)
			return year < d.year;
		if(month != d.month)
			return month < d.month;
		return day < d.day;
	}
};

int main()
{
	const Date begin[] = { Date(1868, 9, 8), Date(1912, 7, 30), Date(1926, 12, 25), Date(1989, 1, 8) };
	const char* name[] = { "pre-meiji", "meiji", "taisho", "showa", "heisei" };

	Date d;
	while(scanf("%d%d%d", &d.year, &d.month, &d.day) != EOF){
		int id = distance(begin, upper_bound(begin, begin+4, d));
		if(id)
			printf("%s %d %d %d\n", name[id], d.year-begin[id-1].year+1, d.month, d.day);
		else
			puts(name[id]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool tr[15];
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
  ll a=0,n,b,A,B,t,T,sa,sb,ans=0;
  string worda,wordb,answord;
  bool flag;
  cin>>a>>b;
  A=a*b;
  if(a<b){sa=a;a=b;b=sa;}
  t = a % b;
  while(t!=0){
    a = b;
    b = t;
    t = a % b;
  }
 
 
 
  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  
  cout<<ll(A/b)<<endl;
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	vector<vector<int>> c(3, vector<int>(3));
	rep(i, 3) rep(j, 3) cin >> c[i][j];
	bool flg = false;
	rep(a1, c[0][0] + 1) {
		int a2, a3;
		rep(i, 3) {
			int b = c[0][i] - a1;
			if (i == 0) {
				a2 = c[1][0] - b, a3 = c[2][0] - b;
			} else {
				if (c[1][i] - b != a2 || c[2][i] - b != a3) break;
			}
			if (i == 2) flg = true;
		}
		if (flg) break;
	}
	cout << (flg ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)cout<<1;
    else if(b==0)cout<<2;
    else if(c==0)cout<<3;
    else if(d==0)cout<<4;
    else cout<<5;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
string st,st1;
int main()
{
	cin>>st>>st1;
	if(st[0]==st1[2]&&st[2]==st1[0]&&st[1]==st1[1])
	cout<<"YES"<<endl;else
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << x << endl;
#else 
    #define dbg(x)
#endif

#define int long long
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int dp[MX][2][2]; // done, delta + 1, last
int a[MX];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    fi(0, n) 
        cin >> a[i];
    dp[0][1][1] = a[0];
    dp[0][1][0] = dp[0][0][1] = -BIG;
    fi(1, n) {
        dbg(i);
        dp[i][1][1] = a[i] + ((i + 1) % 2 ? dp[i - 1][1][0] : dp[i - 1][0][0]);
        dp[i][0][1] = a[i] + ((i + 1) % 2 ? dp[i - 1][0][0] : -BIG - a[i]);
        dp[i][1][0] = ((i + 1) % 2 ? -BIG : dp[i - 1][1][1]);
        dp[i][0][0] = ((i + 1) % 2 ? max(dp[i - 1][1][1], dp[i - 1][1][0]) : max(dp[i - 1][0][1], dp[i - 1][0][0]));
        dbg(dp[i][0][0]);
        dbg(dp[i][0][1]);
        dbg(dp[i][1][0]);
        dbg(dp[i][1][1]);
    }
    if (n % 2)
        cout << max(dp[n - 1][0][0], dp[n - 1][0][1]);
    else
        cout << max(dp[n - 1][1][0], dp[n - 1][1][1]);
    cout << '\n';
}

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

 int main() {
   int N, K, mx_pk = 0;
   cin >> N >> K;
   vector<int> p(N + 1, 0), p_sum(N + 1, 0);
   rep(i, N) cin >> p.at(i + 1);
   rep(i, N) p_sum.at(i + 1) = p_sum.at(i) + p.at(i + 1);

   for (int i = N; i - K >= 0; i--) mx_pk = max(mx_pk, p_sum.at(i) - p_sum.at(i - K));
   cout << fixed << setprecision(10) << (mx_pk + K) / 2.0 << endl;
 }


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<cstring>
#include<set>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#include<string>
#include<bitset>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
typedef long long ll;
using namespace std;
const int N = 1e5;
const int INF = 1e9;
ll MOD = 998244353;
struct point
{
    int x , y , num;
};
vector <int> g[N];
bool used[N];
int cl[N];
bool ok = 1;
void dfs(int v, int c = 0)
{
    used[v] = true;
    cl[v] = c;
    for (auto u : g[v])
    {
        if (!used[u])
        {
             dfs(u , c ^ 1);
        }
        else
        {
            if (cl[u] != (c ^ 1)) ok = 0;
        }
    }
}

int main()
{
    ll n , m;
    ll l = 0 , r = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int u , v;
        cin >> u >> v;
        u--; v--;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(0 , 0);
    for (int i = 0; i < n; i++)
    {
        if(cl[i])
            l++;
        else
            r++;
    }
    ll ans = 0LL;
    if (!ok) ans = (ll)((1LL * (n * (n - 1)) / 2) - m );
    else ans = (ll)(1LL * l * r - m);
    cout << ans << "\n";
    return 0;
}

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

int main(){
  int n,k,ans=1e9;cin>>n>>k;
  vector<int> x(n,0);
  REP(i,n) cin>>x.at(i);
  sort(x.begin(),x.end());
  REP(i,n-k+1) ans=min(ans,x.at(i+k-1)-x.at(i));
  cout<<ans;
}

Measured memory_bytes: 640
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

n, m = map(int, input().split())
if n == m == 1:
    print(1)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))


Measured memory_bytes: 5068
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>

using namespace std;


int main() {
    string s; cin >>s;
    int cnt1(0),cnt2(0);
    
    for(int i=0;i<s.size();i++){
        if(s[i]=='0'){
            cnt1++;
        }
        else{
            cnt2++;
        }
    }
    if(s.size()==1) {
        cout<<0<<endl;
        return 0;
        
    }
    cout<<2*min(cnt1,cnt2)<<endl;
    
    
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int n,m;
    cin >> n >> m;
    int ans = 1;
    if(m % n == 0) {cout << m / n  <<endl; return 0;}
    for(int i = 2; i * n <= m; ++i){if((m - n * i) % i == 0) ans = i;}
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        System.out.println(((a * b) % 2 == 0) ? "Even" : "Odd");
    }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vii vector<pair<int, int> >
#define fi first
#define se second
#define ii pair<int , int> 
#define eb emplace_back
int a[5][205], dp[5][105];
vii G[200005]; bool vs[200005]; int dist[200005];
vector<pair<ii, int> > q;
void dfs(int u)
{
	vs[u]=1;
//	mx=max()
	for(auto v: G[u])
	{
		if(!vs[v.fi]) 
		{
			dist[v.fi]=dist[u]+v.se;
			dfs(v.fi);
		}
	}
}
signed main()
{
	int n, m;
	cin>>n>>m;
	for(int i=1; i<=m; i++)
	{
		int u, v, w;
		cin>>u>>v>>w;
		G[u].eb(v, w);
		G[v].eb(u, -w);
		q.push_back({{u, v}, w});
	}
	for(int i=1; i<=n; i++)
	{
		if(!vs[i]) 
		{
			dfs(i);
		}
	}
	for(auto temp: q)
	{
		if(dist[temp.fi.se]!=dist[temp.fi.fi]+temp.se) 
		{
			return cout<<"No", 0;
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 26372
#include <stdio.h>
int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>

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

const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<ll> l(n);
    vector<ll> r(n);

    r[n-1] = -1;
    ll cnt = 0;
    REP(i, n) {
        if (s[i] == 'L') {
            REP2(j, i-cnt, i) {
                r[j] = cnt;
                cnt--;
            }
        } else {
            cnt++;
        }
    }
    l[0] = -1;
    RREP(i, n-1, 0) {
        if (s[i] == 'R') {
            RREP(j, i+cnt, i+1) {
                l[j] = cnt;
                cnt--;
            }
        } else {
            cnt++;
        }
    }

    vector<ll> ch(n, 0);
    REP(i, n) {
        if (s[i] == 'R') {
            if (r[i]%2 == 0) {
                ch[i+r[i]]++;
            } else {
                ch[i+r[i]-1]++;
            }
        } else {
            if (l[i]%2 == 0) {
                ch[i-l[i]]++;
            } else {
                ch[i-l[i]+1]++;
            }
        }
    }

    REP(i, n) {
        std::cout << ch[i] << ' ';
    }
    std::cout << '\n';

    return 0;
}


Measured memory_bytes: 3072
#include <cstdio>

typedef long long i64;

const int N = 2000 + 10, MOD = 1000000007;

inline void add(int &lhs, i64 rhs) { lhs = (lhs + rhs) % MOD; }

int fact[N * N], ifact[N * N];

inline int binom(int n, int m) {
  return m > n ? 0 : ((i64)fact[n] * ifact[m] % MOD * ifact[n - m] % MOD);
}

int n, m, f[N][N];

int main() {
  fact[0] = 1;
  for (int i = 1; i < N * N; ++i) fact[i] = (i64)fact[i - 1] * i % MOD;
  ifact[1] = 1;
  for (int i = 2; i < N * N; ++i) ifact[i] = ((i64)MOD - MOD / i) * ifact[MOD % i] % MOD;
  ifact[0] = 1;
  for (int i = 1; i < N * N; ++i) ifact[i] = (i64)ifact[i - 1] * ifact[i] % MOD;
  scanf("%d%d", &n, &m);
  if (--m == 0) return puts("1"), 0;
  f[0][0] = 1;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      if (i < j) add(f[i + 1][j], f[i][j]);
      add(f[i][j + 1], (i64)binom(i + (j + 1) * m - 1, m - 1) * f[i][j] % MOD);
    }
  }
  printf("%d\n", (i64)f[n][n] * fact[n] % MOD);
  return 0;
}


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

public class Program
{
	public static int N, A, B, C;
	public static string[] s;
	public static int[] l;
	public static int INF;
	public static void Main(string[] args)
	{
		s = Console.ReadLine().Split(' ');
		N = int.Parse(s[0]);
		A = int.Parse(s[1]);
		B = int.Parse(s[2]);
		C = int.Parse(s[3]);
		l = new int[N];
		INF = (int) (Math.Pow(10.0, 9.0));
		for (int i = 0; i < N; i++)
		{
			l[i] = int.Parse(Console.ReadLine());
		}
		Console.WriteLine("{0}", Dfs(0, 0, 0, 0));
	}

	public static int Min(params int[] nums)
	{
		if (nums.Length == 0) { return 0; }
		return nums.OrderBy(x => x).ToArray()[0];
	}

	public static int Dfs(int cur, int a, int b, int c)
	{
		if (cur == N) { return (Min(a, b, c) > 0) ? Math.Abs(a - A) + Math.Abs(b - B) + Math.Abs(c - C) - 30 : INF; }
		int ret0 = Dfs(cur + 1, a, b, c);
		int ret1 = Dfs(cur + 1, a + l[cur], b, c) + 10;
		int ret2 = Dfs(cur + 1, a, b + l[cur], c) + 10;
		int ret3 = Dfs(cur + 1, a, b, c + l[cur]) + 10;
		return Min(ret0, ret1, ret2, ret3);
	}
}


Measured memory_bytes: 17456
#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int main()
{	
	fast
	int n,i;
	set<int> s;
	cin>>n;
	for(i=0;i<n;i++)
	{
		int ele;
		cin>>ele;
		s.insert(ele);
	}
	if(s.size()==n)
		cout<<"YES\n";
	else cout<<"NO\n";
	
}

Measured memory_bytes: 9600
num_500 = int(input())
num_100 = int(input())
num_050 = int(input())
price = int(input())

i_500 = 0
pattern = 0
while i_500 <= num_500:
    remaining_price = price - 500 * i_500
    if remaining_price < 0:
        i_500 += 1
        continue
    i_100 = 0
    while i_100 <= num_100:
        price_500 = remaining_price - 100 * i_100
        if price_500 < 0:
            i_100 += 1
            continue
        number = price_500 / 50
        if number <= num_050:
            pattern += 1
        i_100 += 1
    i_500 += 1
print(pattern)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H, W, m;
	cin >> H >> W >> m;
	map<int, ll> y, x;
	int my = -1, mx = -1;
	set<P> st;
	rep(i,m){
		int h, w;
		cin >> h >> w;
		st.insert(P(h, w));
		++y[h];
		++x[w];
		if(y[my] < y[h]) my = h;
		if(x[mx] < x[w]) mx = w;
	}
	vector<int> hh, ww;
	for(auto p : y){
		if(p.second == y[my]) hh.push_back(p.first);
	}
	for(auto q : x){
		if(q.second == x[mx]) ww.push_back(q.first);
	}
	ll ans = y[my] + x[mx];
	for(auto p : hh){
		for(auto q : ww){
			if(st.find(P(p, q)) == st.end()){
				cout << ans << endl;
				return 0;
			}
		}
	}
	--ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 58948
#include<iostream>
using namespace std;
int gcd(int a,int b) {
  if(a<b) {
    int tmp=a;
    a=b;
    b=tmp;
  }
  if(a%b==0) return b;
  return gcd(b,a%b);
}

int main() {
  int a=0;
  int b=0;
  while(cin>>a>>b) {
    int n=gcd(a,b);
    cout<<n<<" "<<a/n*b<<endl;
  }
  return 0;
}



Measured memory_bytes: 3080
fun main(args:Array<String>) {
    var (a, b) = readLine()!!.split(" ").map { it.toInt() }
    var sum=0
    for (i in 0..1){
        if(a>=b) {
            sum+=a
            a--
        }
        else {
            sum+=b
            b--
        }
    }
    println(sum)
}


Measured memory_bytes: 37900
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;



void solve(){
	
	int n, k;
	scanf("%d %d", &n, &k);
	bool *a = new bool[n];
	for (int i =0; i < n; ++i) a[i] = false;
	int ans = 0;
	for (int tc = 0, d; tc < k; ++tc){
		cin >> d;
		for (int j = 0, x; j < d; ++j){
			cin >> x ,--x;
			if (!a[x]) {
				++ans;
				a[x] = true;
			}
		}
	}
	delete[] a;
	
	
	printf("%d", n-ans);
	
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	//int t; scanf("%d", &t);
	//while(t--){
	solve();
	//}
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k ; 
  cin >> n >> k ;
  vector<int> p(n) ; 
  rep(i,n) cin >> p.at(i) ;
  
  sort(all(p)) ;
  
  int ans = 0 ;
  rep(i,k){
    ans += p.at(i) ;
  }
  
  cout << ans ;
}


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

int main(void) {
    ll x; cin >> x;
    ll y;
    for(int a=-120; a<=120; a++) {
        for(int b=-120; b<=120; b++) {
            ll ans = pow(a,5) - pow(b,5);
            if(x == ans) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4048
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,k = inpm()
    l = inpl()
    l.sort()
    l.reverse()
    ans = 0
    for i in range(k):
        ans += l[i]
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 4080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  ll a,b;
  ll min = N+1;
  for(ll a=1;a<=(ll)sqrt(N)+1;a++){
    if(N%a==0){
      b = N / a;
      if(min > a+b){
        min = a + b;
      }
    }
  }
  ll ans = min -2;
  cout << ans << endl;
}

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

int main()
{
  string s; cin >> s;
  ll ans = 0;
  ll blk = 0;
  for (auto c:s) {
    if (c == 'B') blk++;
    else ans += blk;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#define MAX_V  1000000
int prime[MAX_V+1];
int a[MAX_V];
int data[30];
int n,count=0,k=0;

int main(void)
{
  int i, k, v;
  for(i = 2; i <= MAX_V; i++)
    prime[i] = 1;

  for(i = 2; i*i <= MAX_V; i++)
    if(prime[i])
      for(k = 2 * i; k <= MAX_V; k += i)
        prime[k] = 0;

  while(scanf("%d",&n)!=EOF)
    for(i=n;i>=2;i--)
      if(prime[i]==1 && prime[i-2] == 1){
          printf("%d %d\n",i-2,i);  break;
        }
}

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

const int MAXN = 444;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
int n;
ll a[MAXN];
ll pre[MAXN];

ll mem[MAXN][MAXN];

ll dp(int l, int r) {
  ll & ans = mem[l][r];
  if (ans<INF) return ans;
  if (l==r) return 0;
  for(int i=l;i<r;i++) {
    ans = min(ans, dp(l,i) + dp(i+1, r) + pre[r]-pre[l-1]);
  }
  return ans;
}

int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n;
  memset(mem, 0x3f,sizeof mem);
  for(int i=1;i<=n;i++) cin >> a[i];
  for(int i=1;i<=n;i++) pre[i] = pre[i-1]+a[i];
  cout << dp(1,n) <<endl;
}


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

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define INF 1000000000
#define MOD 1000000007
#define endl '\n'

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

char mp[111][111];

int main()
{
	int a,b;cin >> a >> b;
	
	REP(i,100){
		REP(j,100){
			if(i < 50)mp[i][j] = '#';
			else mp[i][j] = '.';
		}
	}
	
	REP(i,a - 1){
		mp[(i/50)*2][(i%50)*2] = '.';
	}
			
	REP(i,b - 1){
		mp[(i/50)*2+51][(i%50)*2] = '#';
	}	
	
	cout << 100 << ' ' << 100 << endl;
	REP(i,100){
		REP(j,100){
			cout << mp[i][j];
		}cout << endl;
	}
	
	return 0;
}

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

int main(void) {
  int a = 700;
  std::string str1;
  std::cin >> str1;

if (str1[0] == 'o') {
  a = a + 100;
}
if (str1[1] == 'o') {
  a = a + 100;
}
if (str1[2] == 'o') {
  a = a + 100;
}
  std::cout << a << '\n';

return 0;
}

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

#define llong long long
#define inf 999999999
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<PP, int> PPP;
typedef struct data{
	int now;
	int cost;
}data;
int nh[4] = {1, 0, -1, 0};
int nw[4] = {0, 1, 0, -1};





int main(){
	int a,b,c,d,e;
	int A[100], B[100], C[100][100];
	cin >> a >> b >> c >>d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 764
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#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>
using namespace std;

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

    if(a.back() == b.front() && b.back() == c.front())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
x,y=map(int,input().split())
money=0
if x==3:
  money+=100000
elif x==2:
  money+=200000
elif x==1:
  money+=300000
if y==3:
  money+=100000
elif y==2:
  money+=200000
elif y==1:
  money+=300000
if x==1 and y==1:
  money+=400000
print(money)


Measured memory_bytes: 3060
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///====code start here====///

ll dp[3005][3005];

signed main() {
	fastio;
	int n; cin >> n;
	ll a[n];
	rep(i, 0, n) cin >> a[i];
	Rep(l, n - 1, -1) {
		rep(r, l, n) {
			if(l == r) dp[l][r] = a[l];
			else {
				dp[l][r] = max(a[l] - dp[l + 1][r], a[r] - dp[l][r - 1]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}


Measured memory_bytes: 49764
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = 0;
        int res = 0;
        if (a % 2 == 1 && b % 2 == 1 && a > b) {

            for (int i = b + 1; i <= a; i++) {
                if (i % 2 == 1) {
                    c = i;
                    res = a * b * c;
                    //   System.out.println(res);

                    break;
                }

            }

            if (res % 2 == 1) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else if (a % 2 == 1 && b % 2 == 1 && a <= b) {
            if (a < b) {
                for (int i = a + 1; i <= b; i++) {
                    if (i % 2 == 1) {
                        c = i;
                        res = a * b * c;
                        // System.out.println(res);

                        break;
                    }

                }
                if (res % 2 == 1) {
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
            } else {
                //System.out.println(a * b * (c+1));
                System.out.println("Yes");
            }
        } else {
            System.out.println("No");
        }
    }

}


Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProconTemplate
{
    class Doing
    {
        public static void Main(string[] args)
        {
            var loots = new List<Tuple<int, int>>();
            for(int i = 0; i < 3; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                loots.Add(Tuple.Create(input[0], input[1]));
            }

            var use = loots.ToArray();
            for(int i=1;i <= 4; i++)
            {
                if(CheckRoot(i, use))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

        public static bool CheckRoot(int nowPos, Tuple<int,int>[] loots)
        {
            if (!loots.Any()) { return true; }

            foreach(var useLoot in loots)
            {
                if(useLoot.Item1 == nowPos)
                {
                    var next = useLoot.Item2;
                    var lt = new List<Tuple<int, int>>(loots);
                    lt.Remove(useLoot);
                    if(CheckRoot(next,lt.ToArray())) { return true; }
                }else if (useLoot.Item2 == nowPos)
                {
                    var next = useLoot.Item1;
                    var lt = new List<Tuple<int, int>>(loots);
                    lt.Remove(useLoot);
                    if (CheckRoot(next, lt.ToArray())) { return true; }
                }
            }

            return false;
        }
    }
}


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

int N, temp;

int main() {
    cin >> N;
    int a[N];
    for (int i=0; i<N; i++) cin >> a[i];
    for (int i=0; i<N; i++) {
        for (int j=i; j>0; j--) {
            if (a[j] < a[j-1]) {
                temp = a[j]; a[j] = a[j-1]; a[j-1] = temp;
            }
        }
        cout << a[0];
        for (int k=1; k<N; k++) cout << " " << a[k];
        cout << endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


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


int main(){
    ll N;
    cin >> N;

    cout << (N) * (N-1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};

typedef long long ll;

int ans,ans2;

signed main(){

	int n,d;
	cin>>n>>d;
	ans=n/(1+d*2);
	if(n%(1+d*2))ans++;
	cout<<ans<<endl;
	
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
using namespace std;

int main() {
    map<int, vector<int>> route;
    map<int, int> sign;
    set<int> done;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> next;
    int n, m;
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        route[a].push_back(b);
        route[b].push_back(a);
    }
    next.push(make_pair(0, 1));
    done.insert(1);
    while (done.size() < n) {
        pair<int, int> state = next.top();
        next.pop();
        int current = state.second;
        int cnt = state.first+1;

        for (auto i: route[current]) {
            if (sign[i] != 0) {
                continue;
            }
            sign[i] = current;
            next.push(make_pair(cnt, i));
            done.insert(i);
        }
        cnt++;
    }

    cout << "Yes" << endl;
    for (int i=2; i<=n; i++) {
        cout << sign[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 25104
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;


int main() {
	string n;
	cin >> n;
	for (int i = 0; i < 3;i++) {
		if (n[i]=='1') {
			n[i] = '9';
		}
		else {
			n[i] = '1';
		}
	}
	cout << n << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 int a,b;
 cin>>a>>b;
 if((a+b)%2==0)
 cout<<(a+b)/2;
 else
 cout<<(a+b)/2+1;
 return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(;;){
			int max = 0;
			int min = 1000;
			int answer = 0;
			int n = sc.nextInt();
			if(n == 0){
				break;
			}
			int [] array = new int[n];
			for(int i = 0; i < n; i++){
				array[i] = sc.nextInt();
			}
			for(int i = 0; i < n; i++){
				if(array[i] >= max){
					max = array[i];
				}
			}
			for(int i = 0; i < n; i++){
				if(array[i] <= min){
					min = array[i];
				}
			}
			for(int i = 0; i < n; i++){
				if(min == array[i]){
					array[i] = 0;
					break;
				}
			}
			for(int i = 0; i < n; i++){
				if(max == array[i]){
					array[i] = 0;
					break;
				}
			}
			for(int i = 0; i < n; i++){
				answer += array[i];
			}
			answer = answer / (n - 2);
			System.out.println(answer);
		}
	}

}

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

int main() {
    int n, ans;
    cin >> n;
    if(n%2 == 0) {
        ans = n;
    }
    else {
        ans = 2*n;
    }

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

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1<<25;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;





int main() {

	ll n, s;
	cin >> n >> s;

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

	if (s == n) {
		cout << n + 1 << endl;
		return 0;
	}


	for (ll i = 2; i*i <= n; i++) {
		ll m = n;
		int res = 0;
		while (m) {
			res += m % i;
			m /= i;
		}
		if (res == s) {
			cout << i << endl;
			return 0;
		}
	}

	ll ans = INFL;

	for (ll i = 1; i*i <= n; i++) {
		ll a = (n - s) / i + 1;
		if (a == 1)continue;
		ll m = n;
		ll res = 0;
		while (m) {
			res += m % a;
			m /= a;
		}
		if (res == s) {
			ans = min(ans, a);
		}
	}

	if (ans == INFL)cout << -1 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N=int(input())
ans = N
for i in range(N+1):
    t=i
    cnt=0
    while t>0:
        cnt += t%6
        t //= 6
    k=N-i
    while k>0:
        cnt += k%9
        k //= 9
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;

int main() {
	int n, k, a[50];
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());

	int ans = 0;
	for (int i = 0; i < k; ++i) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
a,b,w,n,i,t[31];
main(){
    for(i=0;i<=30;i++){
        t[i]=i;
    }
    scanf("%d%d",&w,&n);
    for(;~scanf("%d,%d",&a,&b);t[a]^=t[b]^=t[a]^=t[b]);
    for(i=1;i<=w;i++){
        printf("%d\n",t[i]);
    }
}

Measured memory_bytes: 1748