akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    using namespace std;
     
    const int MAX = 2005;
    int N, memo[MAX][MAX], cost[2][MAX][2*MAX], f[2][MAX];
    pair<int, int> A[2*MAX];
     
    int Solve(int a, int b) {
            if (a == N && b == N) return 0;
     
            int &ret = memo[a][b];
            if (ret != -1) return ret;
     
            ret = 1e8;
            if (a != N) ret = min(ret, Solve(a+1, b) + cost[0][a+1][f[0][a]] + cost[1][b][f[0][a]]);
            if (b != N) ret = min(ret, Solve(a, b+1) + cost[0][a][f[1][b]] + cost[1][b+1][f[1][b]]);
            return ret;
    }
     
    int main() {
            scanf("%d", &N);
     
            for (int i=0; i<2*N; ++i) {
                    char c;
                    scanf(" %c%d", &c, &A[i].second);
                    A[i].first = c == 'B';
                    A[i].second -= 1;
                    f[A[i].first][A[i].second] = i;
            }
     
            for (int t=0; t<2; ++t) for (int num=0; num<N; ++num) {
                    int x = 0;
                    for (int i=0; i<2*N; ++i) {
                            if (A[i].first == t && A[i].second >= num)
                                    ++x;
                            cost[t][num][i] = x;
                    }
            }
     
            memset(memo, -1, sizeof(memo));
            printf("%d\n", Solve(0, 0));
            return 0;
    }

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main(){
 int cnt,n;
 string s;
 cin >> s;
 cnt=0;
 n=s.size();
  for (int i=0;i<n-1;i++){
      if(s[i]==s[i+1] && s[i+1]=='1'){
          s[i+1]='0';
          cnt++;
      }
      if(s[i]==s[i+1] && s[i+1]=='0'){
          s[i+1]='1';
          cnt++;
      }
  }
  cout << cnt << endl;

}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if( (a*b) % 2 == 0){
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b){
	return *(int *)b-*(int *)a;
}
int main(void){
	int  w[10],k[10],i;
	for(i=0;i<10;i++){
		scanf("%d",&w[i]);
    }
    for(i=0;i<10;i++){
    	scanf("%d",&k[i]);
    }
    qsort(w,10,sizeof(int),cmp);
    qsort(k,10,sizeof(int),cmp);
    int sw=w[0]+w[1]+w[2];
    int sk=k[0]+k[1]+k[2];
    printf("%d %d\n",sw,sk);
    return 0;
}
	

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

int main() {
	string S;
	cin >> S;
	if (S.find('A') == 0 && 2 <= S.find('C') && S.find('C') <= S.size() - 2) {
		sort(S.begin(), S.end());
		if ('a' <= S.at(2) && S.at(2) <= 'z') {
			puts("AC");
		}
		else {
			puts("WA");
		}
	}
	else {
		puts("WA");
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << endl)

using namespace std;
using ll = unsigned long long;

int main() {
	int N;
	IN(N);
	vector<string> W(N);
	REP(i, N) IN(W[i]);
	
	map<string, int> memo;
	
	memo[W[0]]++;
	
	FOR(i, 1, N) {
		if(W[i-1][W[i-1].size() - 1] != W[i][0]) {
			OUT("No");
			return 0;
		}
		if(memo[W[i]] != 0) {
			OUT("No");
			return 0;
		}
		memo[W[i]]++;
	}
	OUT("Yes");
}

Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long X;
    cin >> X;
    long long money=100;
    long long year=0;
    while(money<X){
        money=money*1.01;
        year +=1;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <cstring>
#include <ctime>
#include <cassert>


#define pb emplace_back
#define re return
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using namespace std;
using namespace __gnu_cxx;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265359;

int n;
int a[200000];
int main()
{
    //freopen("distance.in", "r", stdin);
    //freopen("distance.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int ans = 0;
    int mx = 1e9;
    for (int i = 0; i < n; i++)
    {
        if (a[i] < mx || mx == 1e9)
            ans++;
        mx = min(mx, a[i]);
    }
    cout << ans;
}
/// ACTUAL CODE STARTS HERE:
//  I'm red in soul
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <ios>
#include <sstream>
#include <cstdio>

#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <regex>
#include <utility>
#include <random>

#include <cstddef>
#include <cstdint>
#include <cfloat>
#include <limits>

#include <array>
#include <bitset>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <valarray>
#include <vector>
#include <deque>
#include <forward_list>

#define FOR(i, a, b) for(auto i{a}; i < (b); ++i)
#define RFOR(i, a, b) for(auto i{(b)-1};i >= (a); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) std::begin(a), std::end(a)
#define EACH(x, xs) for (auto &x : xs)
#define CAST static_cast

template<typename T>
constexpr bool in_range(T const &l, T const &a, T const &u){ return l < a && a < u; };
constexpr double inf {std::numeric_limits<double>::infinity()};

#define FAST_TYPE
#ifdef FAST_TYPE
using i32 = std::int_fast32_t;  using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t; using u64 = std::uint_fast64_t;
#else
using i32 = std::int_least32_t;  using i64 = std::int_least64_t;
using u32 = std::uint_least32_t; using u64 = std::uint_least64_t;
#endif

using imx = std::intmax_t;
using umx = std::uintmax_t;

using namespace std;

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

  i32 n, x, t;
  cin >> n >> x >> t;

  cout << (static_cast<i32>(ceil(n / static_cast<double>(x)))) * t << endl;

  return 0;
}

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

/*
最小公倍数を求めればよい
primeかどうかチェックしながら因数を求めていく？
*/

int calc_min_factor(int X) {
    if (X <= 2) {
        return X;
    }

    if (X % 2 == 0) {
        return 2;
    }

    for (int i = 3; i <= X; i+=2)
    {
        if (X % i == 0) {
            return i;
        }
    }
    return X;
}

int main() {
    int A, B;
    cin >> A >> B;

    map<int, int> F_A, F_B;
    set<int> Fs;

    do {
        int f = calc_min_factor(A);
        // cout << f << endl;
        Fs.insert(f);
        F_A[f]++;
        A /= f;
    } while (A != 1);

    // cout << "A" << endl;
    // for (auto x : F_A) {
    //     cout << x.first << " " << x.second << endl;
    // }

    do
    {
        int f = calc_min_factor(B);
        // cout << f << endl;
        Fs.insert(f);
        F_B[f]++;
        B /= f;
    } while (B != 1);

    // cout << "B" << endl;
    // for (auto x : F_B) {
    //     cout << x.first << " " << x.second << endl;
    // }

    // // cout << "calc" << endl;

    long ans = 1;
    for (auto x : Fs)
    {
        // cout << x << endl;
        ans *= pow(x, max(F_A[x], F_B[x]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

void matrixChainOrder(int *);

int n,m[N][N];
int main(){
  int i,r[N];
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d%d",&r[i],&r[i+1]);
  }
  matrixChainOrder(r);
  return 0;
}

void matrixChainOrder(int *p){
  int i,l,j,k,q;
  for(i=0 ; i<n+1 ; i++){
    for(j=0 ; j<n+1 ; j++){
      m[i][j]=10000000;
    }
  }
  for(i=0 ; i<n+1 ; i++){
    m[i][i]=0;
  }
  for(l=2 ; l<n+1 ; l++){
    for(i=1 ; i<(n+1)-l+1 ; i++){
      j=i+l-1;
      for(k=i ; k<=j-1 ; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	
	if(m[i][j]>q) m[i][j] = q;
      }
    }
  }
	printf("%d\n",m[1][n]);
}




Measured memory_bytes: 2112
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    if (n % 2 == 0 || n % 5 == 0) {
        cout << -1 << endl;
        return; 
    }
    LL v = 7;
    int cnt = 0;
    while (v < n) {
        v = v * 10 + 7;
        ++cnt;
    }
    while (v > 0) {
        v %= n;
        ++cnt;
        if (v > 0) v = v * 10 + 7;
    }
    cout << cnt << endl;
}


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

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

using namespace std;

typedef long long ll;

int main(){
    string S;
    int ans = 0;
    cin >> S;

    int left = 0;
    int right = S.length() - 1;
    for (int i = 0; i < S.length() / 2; i++){
        if(S[left] != S[right]) ans++;
        left++;
        right--;
    }

    cout << ans << endl;

    return 0;
}


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

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	map<string, int>cnt;
	vector<string>a;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string x;
		cin >> x;
		sort(x.begin(), x.end());
		ans += cnt[x];
		cnt[x]++;
		a.push_back(x);
	}
	cout << ans;
	return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  cout << ((in() * in()) & 1 ? "Odd" : "Even") << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;
 
class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
  public static void Main()
  {
    var tmp = ReadIntArray();
    int n = tmp[0], ma = tmp[1], mb = tmp[2];
    int[] a = new int[n];
    int[] b = new int[n];
    int[] c = new int[n];
    
    for (int i = 0; i < n; i++)
    {
      tmp = ReadIntArray();
      a[i] = tmp[0]; b[i] = tmp[1]; c[i] = tmp[2];
    }
    
    int nMax = 40, aMax = 10, bMax = 10, cMax = 100;
    int [,,] d = new int[n+1, (nMax+1)*aMax, (nMax+1)*bMax];
    
    int inf = 1000000;
    
    for (int i = 0; i <= n; i++){
      for (int j = 0; j < (nMax+1)*aMax; j++){
    	for (int k = 0; k < (nMax+1)*bMax; k++){
          d[i,j,k] = inf;
        }
      }
    }

    d[0,0,0] = 0;
    for (int i = 0; i < n; i++){
      for (int j = 0; j <= nMax*aMax; j++){
    	for (int k = 0; k <= nMax*bMax; k++){
          if(d[i,j,k] == inf) continue;
          d[i+1,j,k] = Math.Min(d[i+1,j,k], d[i,j,k]);
          d[i+1,j+a[i],k+b[i]] = Math.Min(d[i+1,j+a[i],k+b[i]], d[i,j,k]+c[i]);
        }
      }
    }

    int ans = inf;
    for (int i = 1; i <= nMax*aMax; i++){
      for (int j = 1; j <= nMax*bMax; j++){
        if(i*mb == j*ma) ans = Math.Min(ans, d[n,i,j]);
      }
    }
    
    WriteLine(ans < inf ? ans : -1);
  }
}

Measured memory_bytes: 37984
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int N, M;
int state[11][10001];

int func(int sembe[11][10001], int nct){
	int sum = 0;
	if(nct == N){
		for(int i = 0; i < M; i++){
			int lcnt = 0;
			int mcnt = 0;
			for(int j = 0; j < N; j++){
				if(sembe[j][i] == 1)lcnt++;
				if(sembe[j][i] == 0)mcnt++;
			}
			sum+=max(lcnt, mcnt);
		}
	}else{
		sum = max(sum, func(sembe, nct+1));
		rep(i, M){
			if(state[nct][i] == 0){
				sembe[nct][i] = 1;
			}else{
				sembe[nct][i] = 0;
			}
		}
		sum = max(sum, func(sembe, nct+1));
	}
	return sum;
}

int main(void){
	while(cin >> N >> M){
		if(N == M && N == 0)break;
		fill_n(*state, 11*10001, 0);
		rep(i, N){
			rep(j, M){
				cin >> state[i][j];
			}
		}
		cout << func(state, 0) << endl;
	}


	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1592
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("O3") 
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
#define __USE_MINGW_ANSI_STDIO 0
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#include<string>
#include<map>
#include <math.h>
#include<queue>
#include<complex>
#include<ctime>
#include<list>
#include<stack>
#define ll  long long
#define lll __int128
#define fi first
#define ld long double
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<vector<int>>
using namespace std;
ll a,b,c;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
    char z;
    cin >> a >> b >> z >> c ;
    ll ans = (a*b*100+c*a)/100;
    cout << ans;
  return  0;    
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> P;
typedef map<int,int> mp;

const int MOD = 1e9 + 7;


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

    int n, k;
    cin >> n >> k;
    vi p(n);
    vector<double> ret(n);
    rep(i, n){
        cin >> p[i];
        ret[i] = (p[i]+1) / 2.0;
    }

    double ans = 0.0;
    double tmp = 0.0;
    rep(i, k-1){
        tmp += ret[i];
    }
    FOR(i, k-1, n){
        tmp += ret[i];
        ans = max(tmp, ans);
        tmp-=ret[i-k+1];
    }

    cout << fixed;
    cout <<setprecision(7) <<  ans << endl;

    return 0;
}



Measured memory_bytes: 2560
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
S = []
for _ in range(N):
    S.append(list(map(int, input())))

pt = [[] for _ in range(N)]
for i in range(N):
    for j in range(N):
        if S[i][j]==1:
            pt[i].append(j)

def bfs(pt,v):
    used = [[False]*N for _ in range(N)]
    d = [-1]*N
    d[v] = 0
    q = [v]
    c = 1
    while q:
        flag = False
        q1 = []
        for i in q:
            for j in pt[i]:
                if d[j]==-1:
                    used[i][j] = True
                    used[j][i] = True
                    flag = True
                    d[j] = c
                    q1.append(j)
                else:
                    if used[i][j]==False and d[j]!=c:
                        return -float('inf')
                    else:
                        if used[i][j]==False and d[j]==c:
                            used[i][j] = True
                            used[j][i] = True
        q = q1
        if flag:
            c += 1
    return c

ans = -1
for i in range(N):
    x = bfs(pt,i)
    if x>ans:
        ans = x

print(ans)

Measured memory_bytes: 48604
n = int(input())
lows, highs = [], []
for i in range(n):
    a, b = map(int, input().split())
    lows.append(a)
    highs.append(b)
lows.sort()
highs.sort()

if n % 2 == 0:
    low = lows[n // 2 - 1] + lows[n // 2]
    high = highs[n // 2 - 1] + highs[n // 2]
    print(high - low + 1)
else:
    low = lows[(n - 1) // 2]
    high = highs[(n - 1) // 2]
    print(high - low + 1)


Measured memory_bytes: 99100
#include<stdio.h>
int main() {

	int n, x, t;

	scanf("%d%d%d", &n, &x, &t);


	if (n % x != 0)
		printf("%d", (n / x + 1) * t);
	else
		printf("%d", n / x * t);

	return 0;
}

Measured memory_bytes: 2148
#include<stdio.h>
int main()
{
	static const int mday[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
	static const char *youbi[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
	int m, d, i, days;
	while (scanf("%d%d", &m, &d)>0, m) {
		days = d-1;
		for (i = 0; i < m-1; i ++)
			days += mday[i];
		puts(youbi[(3+days)%7]);
	}
	return 0;
}

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

public class Main {
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        int n=sc.nextInt();
        long sum=0;
        for (int i=1;i<=n;i++){
            if (i%3==0 || i%5==0)continue;
            sum+=i;
        }
        System.out.println(sum);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 32780
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define N 100010
int n,m,c[N],d[N],k[N];char vis[N];
int fa[N];
int find(int x) {
	return ~fa[x]?fa[x]=find(fa[x]):x;
}
inline void join(int a,int b) {
	int x=find(a),y=find(b);
	if(x!=y) {
		fa[x]=y;
		if(d[k[y]]>d[k[x]]) k[y]=k[x];
	}
}
int main() {
	int a,b;long long ans=0;
	scanf("%d%d",&n,&m);
	if(n-2*m>2) {
		puts("Impossible");
		return 0;
	}
	if(n-1==m) {
		puts("0");
		return 0;
	}
	memset(fa,-1,sizeof(fa));
	for(int i=0;i<n;++i) scanf("%d",d+i),k[i]=i;
	for(int i=0;i<m;++i) {
		scanf("%d%d",&a,&b);
		join(a,b);
	}
	for(int i=0;i<n;++i) if(!~fa[i]) vis[k[i]]=1,ans+=d[k[i]];
	a=0;
	for(int i=0;i<n;++i) if(!vis[i]) c[a++]=d[i];
	std::sort(c,c+a);
	b=n-m-2;
	for(int i=0;i<b;++i) ans+=c[i];
	printf("%lld",ans);
	return 0;
}

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

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
    Node *cur = nil->next; //番兵の次の要素から辿る
    while (cur != nil && cur->key != key) {
        cur = cur->next;
    }
    return cur;
}

void init() {
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList() {
    Node *cur = nil->next;
    int isf = 0;
    while (1) {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

void deleteNode(Node *t) {
    if (t == nil) return; //t が番兵の場合は処理しない
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst() {
    deleteNode(nil->next);
}

void deleteLast() {
    deleteNode(nil->prev);
}

void deleteKey(int key) {
    //検索したノードを削除
    deleteNode(listSearch(key));
}

void insert(int key) {
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    //番兵の直後に要素を追加
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main() {
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++) {
        scanf("%s%d", com, &key); //より高速な入力関数を使用
        if (com[0] == 'i') {insert(key); np++; size++;}
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') deleteFirst();
                else if (com[6] == 'L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}


Measured memory_bytes: 34460
S=input()
if 1 <= int(S[0:2]) <= 12:
  if 1 <= int(S[2:4]) <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= int(S[2:4]) <= 12:
    print("YYMM")
  else:
    print("NA")

Measured memory_bytes: 9152
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   
   boolean glay = false;
   boolean blown = false;
   boolean green = false;
   boolean sky = false;
   boolean blue = false;
   boolean yellow = false;
   boolean orange = false;
   boolean red = false;
   
   int tmp = 0;
   int allcount=0;
   for(int i = 0;i<N;i++) 
   {
     tmp = sc.nextInt();
     if(!glay&&tmp<400) glay = true;
     else if(!blown&&tmp>=400&&tmp<800) blown = true;
     else if(!green&&tmp>=800&&tmp<1200) green = true;
     else if(!sky&&tmp>=1200&&tmp<1600) sky = true;
     else if(!blue&&tmp>=1600&&tmp<2000) blue = true;
     else if(!yellow&&tmp>=2000&&tmp<2400) yellow = true;
     else if(!orange&&tmp>=2400&&tmp<2800) orange = true;
     else if(!red&&tmp>=2800&&tmp<3200) red = true;
     else if(tmp>=3200) allcount++;
   }
   int anslow =0;
   if(glay) anslow++;
   if(blown) anslow++;
   if(green) anslow++;
   if(sky) anslow++;
   if(blue) anslow++;
   if(yellow) anslow++;
   if(orange) anslow++;
   if(red) anslow++;
   
   int  anshigh = anslow+allcount;
   if(anslow==0) anslow++;
   System.out.println(anslow+" "+anshigh);
 }
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

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

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    priority_queue< int, vector< int >, greater< int > > pq;
    for( int i = 0; i < n; ++i ) {
        int a;
        cin >> a;
        pq.push(a);

    }

    vector< P > v;
    for( int i = 0; i < m; ++i ) {
        int a, b;
        cin >> a >> b;
        v.pb(MP(b, a));

    }
    sort(all(v), greater< P >());

    for( int i = 0; i < m; ++i ) {
        while( v[i].S > 0 ) {
            int p = pq.top();
            if( p >= v[i].F ) break;
            pq.pop();
            pq.push(v[i].F);
            v[i].S--;

        }
    }

    LL sum = 0;
    while( !pq.empty() ) {
        sum += pq.top(); pq.pop();

    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i < (int)n; i++)
#define Loopr(i, n) for(int i= (int)n - 1; i >= 0; i--)
using namespace std;
typedef long long int ll;

struct node {
	int parent, left, right;
};

int n;
vector<node> nodes(25, { -1,-1,-1 });

int sib_of(int a) {
	if (nodes[a].parent == -1) return -1;
	else {
		int x = nodes[nodes[a].parent].left;
		int y = nodes[nodes[a].parent].right;
		if (x == a) return y;
		else return x;
	}
}

int deg_of(int a) {
	int ret = 0;
	if (nodes[a].left != -1) ret++;
	if (nodes[a].right != -1) ret++;
	return ret;
}

int depth_of(int a) {
	if (nodes[a].parent == -1) return 0;
	else return depth_of(nodes[a].parent) + 1;
}

int height_of(int a) {
	if (a == -1) return -1;
	else if (deg_of(a) == 0) return 0;
	else return max(height_of(nodes[a].left) + 1, height_of(nodes[a].right) + 1);
}

string type_of(int a) {
	if (nodes[a].parent == -1) return "root";
	else if (deg_of(a) == 0) return "leaf";
	else return "internal node";
}

void print(int a) {
	cout << "node " << a << ": parent = " << nodes[a].parent;
	cout << ", sibling = " << sib_of(a);
	cout << ", degree = " << deg_of(a);
	cout << ", depth = " << depth_of(a);
	cout << ", height = " << height_of(a);
	cout << ", " << type_of(a) << endl;
}

int main() {
	cin >> n;
	Loop(i, n) {
		int id;
		cin >> id;
		int l, r;
		cin >> l >> r;
		nodes[id].left = l;
		nodes[id].right = r;
		if (l != -1)nodes[l].parent = id;
		if (r != -1)nodes[r].parent = id;
	}
	Loop(i, n) {
		print(i);
	}
	return 0;
}

Measured memory_bytes: 3132
def make_lun(lun):
  temp_lun=[]
  i=0
  while(i<len(lun)):
    if(lun[i][0]=="0"):
      temp_lun.append("1"+lun[i])
    elif(lun[i][0]=="1"):
      temp_lun.append("1"+lun[i])
      temp_lun.append("2"+lun[i])
    elif(lun[i][0]=="9"):
      temp_lun.append("9"+lun[i])
      temp_lun.append("8"+lun[i])
    else:
      temp_lun.append(str(int(lun[i][0])+1)+lun[i])
      temp_lun.append(str(int(lun[i][0]))+lun[i])
      temp_lun.append(str(int(lun[i][0])-1)+lun[i])

    if(lun[i][-1]=="0"):
      temp_lun.append(lun[i]+"0")
      temp_lun.append(lun[i]+"1")
    elif(lun[i][-1]=="9"):
      temp_lun.append(lun[i]+"9")
      temp_lun.append(lun[i]+"8")
    else:
      temp_lun.append(lun[i]+str(int(lun[i][-1])+1))
      temp_lun.append(lun[i]+str(int(lun[i][-1])))
      temp_lun.append(lun[i]+str(int(lun[i][-1])-1))
    i+=1
  temp2_lun=list(set(temp_lun))
  temp3_lun=temp2_lun.sort()
  return temp2_lun

K=int(input())

lun=[str(n) for n in range(1,10)]
while(len(lun)<K):
  K-=len(lun)
  lun=make_lun(lun)
ans = lun[K-1]
print(ans)

Measured memory_bytes: 37332
n = int(input())
x = 0
for i in range(1, n+1):
    if i%64 == 0 and 64 > x:
        ans = i
        x = 64
    elif i%32 == 0 and 32 > x:
        ans = i
        x = 32
    elif i%16 == 0 and 16 > x:
        ans = i
        x = 16
    elif i%8 == 0 and 8 > x:
        ans = i
        x = 8
    elif i%4 == 0 and 4 > x:
        ans = i
        x = 4
    elif i%2 == 0 and 2 > x:
        ans = i
        x = 2
    elif i == 1:
        ans = 1
        x = 1
print(ans)

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

#include <iostream>


#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;
auto f=[]()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
};


int main()
{
	f();
	int n,l;cin>>n>>l;
	vector<int> arr(n,0);
	bool neg=false;
	for(auto i=0;i<n;++i)
	{
		arr[i]=l+i;
		//cout<<arr[i]<<' ';
		if(arr[i]<0 && !neg)
			neg=true;
	}
	//cout<<'\n';
	int ans=0;
	if(neg)
	{
		
		if(arr[arr.size()-1]<0)
		{
			for(auto i=0;i<n-1;++i)
				ans+=arr[i];
		}
		else{
			for(auto i=0;i<n;++i)
				ans+=arr[i];
		}
	}
	else{
		//cout<<"No negative\n";
		//accumulate(arr.begin()+1,arr.end(),ans);
		for(auto i=1;i<n;++i)
			ans+=arr[i];
	}
	cout<<ans<<'\n';
	
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void){
  int p;
  scanf("%d", &p);
  int a[p];
  int k= 0;
  for(int i = 1;i<=p;i++){
    scanf("%d", &a[i-1]);
    if(i%2==1 && a[i-1]%2==1){
      k++;
    }
  }
  printf("%d\n", k);

  return 0;
}


Measured memory_bytes: 1680
h,w = map(int,input().split())
s = [list("."+input()+".") for _ in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flg = 0
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
        flg = 1
print("Yes" if flg == 0 else "No")
    

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdint>

using namespace std;

int64_t solve_slow(int w, int h, const vector<int64_t>& p, const vector<int64_t>& q) {
    // consider x * y rectanble
    // first column should be constructed
    int64_t ans = 0;
    for (auto qq : q) {
        ans += qq;
    }
    for (int x = 1; x <= w; ++x) {
        // first row in each column should be constructed
        ans += p[x - 1];
        for (int y = 1; y <= h; ++y) {
            if (p[x - 1] > q[y - 1]) {
                ans += q[y - 1];
            } else {
                ans += p[x - 1];
            }
        }
    }

    return ans;
}

int64_t solve(int w, int h, vector<int64_t>& p, vector<int64_t>& q) {
    // add each q (N + 1) times where N = #{p; p > q}
    // add each p (M + 1) times where N = #{q; p <= q}

    int64_t ans = 0;
    for (auto pp : p) {
        ans += pp;
    }
    for (auto qq : q) {
        ans += qq;
    }

    sort(p.begin(), p.end());
    sort(q.begin(), q.end());

    int64_t curp = 0, curq = 0, sump = 0, sumq = 0;
    for (curp = 0; curp < p.size(); ++curp) {
        while (curq < q.size() && p[curp] > q[curq]) {
            sumq += q[curq];
            ++curq;
        }
        ans += sumq;
        ans += p[curp] * (q.size() - curq);
    }

    return ans;
}

int main() {
    int w, h;
    cin >> w >> h;

    vector<int64_t> p(w);
    for (auto&& pp : p) {
        cin >> pp;
    }

    vector<int64_t> q(h);
    for (auto&& qq : q) {
        cin >> qq;
    }

    cout << solve(w, h, p, q) << endl;

    return 0;
}

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

int main()
{
    int K, S;

    cin >> K >> S;

    int count = 0;
    for (int i = 0; i <= K; i++) {
        for (int j = 0; j <= K; j++) {
            if ((S - i - j >= 0) && (S - i - j) <= K) {
                count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	if h == 1 || w == 1 {
		fmt.Println(1)
	} else if h%2 == 0 {
		fmt.Println(h / 2 * w)
	} else if w%2 == 0 {
		fmt.Println(int(math.Ceil(float64(h)/2))*w/2 + int(math.Floor(float64(h)/2))*w/2)
	} else {
		fmt.Println(int(math.Ceil(float64(h)/2))*int(math.Ceil(float64(w)/2)) + int(math.Floor(float64(h)/2))*int(math.Floor(float64(w)/2)))
	}

}


Measured memory_bytes: 512
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
inline void print() { cout << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

void solve(int num, int val) {
    FOR(i, 1, 5) {
        int s1, s2; cin >> s1 >> s2;
        if (chmax(val, s1 + s2))num = i;
    }
    cout << char('A' + num) << " " << val << "\n";
}

int main() {
    init();

    for (int s1, s2; cin >> s1 >> s2 && s1 != 0;)solve(0, s1 + s2);

    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mod 1000000007
using namespace std;

void fast(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
}

int main(){
    fast();
    ll t=1;
//    cin>>t;
    while(t--){
    	ll n,ans=0;
    	cin>>n;
    	ll a[n],pre[n];
    	for(ll i=0;i<n;i++)cin>>a[i],pre[i]=a[i]%mod,a[i]=a[i]%mod;
    	for(ll i=1;i<n;i++){
    		pre[i]=(pre[i]%mod+pre[i-1]%mod)%mod;
		}
		for(ll i=0;i<n-2;i++){
			ans=(ans%mod+((a[i])%mod*((pre[n-1]-pre[i]+mod)%mod))%mod)%mod;
//			cout<<ans<<" ";
		}
		ans=(ans%mod+(a[n-1]%mod*a[n-2]%mod)%mod)%mod;
		cout<<ans%mod;
	}
}

Measured memory_bytes: 6772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int main(){
    int n, k;
    cin >> n >> k;
    int mx = (n - 2) * (n - 1) / 2;
    if(mx < k)
        return cout << -1, 0;
    vector <ii> v;
    for(int i = 2; i <= n; i++){
        v.emplace_back(1, i);
    }
    for(int i = 2; i <= n; i++){
        if(mx == k)
            break;
        for(int j = i + 1; j <= n; j++){
            if(mx == k)
                break;
            v.emplace_back(i, j);
            mx--;
        }
    }
    cout << v.size() << "\n";
    for(int i = 0; i < v.size(); i++){
        cout << v[i].first << " " << v[i].second << "\n";
    }
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >>c;
	if (a+b==c||b+c==a||c+a==b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;  
    vector<int>arr(3,0);
    for(int i=0;i<n;i++){
      
    
     
          vector<int>c(3);
       for(int q=0;q<3;q++){
           
           cin>>c[q];
          
       }  
       
       vector<int>v(3,0);
       
      for(int j=0;j<3;j++){
          for(int k=0;k<3;k++){
              if(j!=k){
                  v[k]=max(v[k],arr[j]+c[k]);
              }
          }
           
           
           
           
      }
    //   for(int j=0;j<3;j++)cout<<v[j]<<" ";
      
      for(int j=0;j<3;j++)
      cout<<endl;
        arr=v;
        
    }
    cout<<max(arr[0],max(arr[1],arr[2]))<<endl;;
        
        
        
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 512
N = int(input())
li_p = list(map(int, input().split()))
count = 0
flag = True
for i in range(N):
    if li_p[i] != i+1:
        count += 1
        if count > 2:
            flag = False
            break
if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
from collections import Counter
mod = 998244353

N = int(input())
d = [int(i) for i in input().split()]
if d[0] != 0:
    print(0)
    exit()

else:
    D = Counter(d)
    if D[0] >= 2:
        print(0)
        exit()
    else:

        ans = 1
        c = 1
        for i in range(max(D.keys())+1):
            ans *= c ** D[i]
            ans %= mod
            c = D[i]

        print(ans)


Measured memory_bytes: 19936
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int memo[50][50][2];
int dfs(int a, int b, int turn, const vector< vector<int> >& G){
  if(memo[a][b][turn] != -1) return memo[a][b][turn];
  if(a == b) return memo[a][b][turn] = 0;
  memo[a][b][turn] = INF;
  if(turn == 0){
    // Aaron - escape
    int res = dfs(a, b, turn ^ 1, G);
    FORIT(u, G[a]){
      int next = dfs(*u, b, turn ^ 1, G);
      res = max(res, next);
    }
    return memo[a][b][turn] = res;
  }else{
    // Bruce - chase
    int res = 1 + dfs(a, b, turn ^ 1, G);
    FORIT(u, G[b]){
      int next = dfs(a, *u, turn ^ 1, G);
      res = min(res, 1 + next);
    }
    return memo[a][b][turn] = res;
  }
}

int main(){
  int T; cin >> T;
  while(T--){
    int N; cin >> N;
    vector< vector<int> > G(N);
    REP(i, N)REP(j, N){
      int t; cin >> t;
      if(t) G[i].push_back(j);
    }
    REP(i, N) G[i].push_back(i);
    int sa, sb;
    cin >> sa >> sb;
    //memset(memo, -1, sizeof(memo));
    //int ans = dfs(a, b, 0, G);
    int dp[50][50][2] = {};
    memset(dp, -1, sizeof(dp));
    REP(i, N) dp[i][i][0] = 0;
    REP(iter, 1000){
      for(int a = 0; a < N; a++){
        for(int b = 0; b < N; b++){
          if(a == b) continue;
          dp[a][b][0] = -1;
          REP(i, G[a].size()){
            int u = G[a][i];
            if(dp[u][b][1] != -1){
              if(dp[a][b][0] == -1 || dp[a][b][0] < dp[u][b][1]) dp[a][b][0] = dp[u][b][1];
            }
          }
          dp[a][b][1] = -1;
          REP(i, G[b].size()){
            int u = G[b][i];
            if(dp[a][u][0] != -1){
              if(dp[a][b][1] == -1 || dp[a][b][1] > 1 + dp[a][u][0]){
                dp[a][b][1] = 1 + dp[a][u][0];
              }
            }
          }
        }
      }
    }
    //REP(a, N) REP(b, N) REP(turn, 2) printf("(%d, %d, %d) = %d\n", a, b, turn, dp[a][b][turn]);
    int ans = dp[sa][sb][0];
    if(ans >= N || ans == -1) cout << "infinity" << endl;
    else cout << ans << endl;
  }
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    for (double x = 0; x <= 50000; x++) {
        if ((int)(x * 1.08) == n) {
            cout << (int)x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 3656
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,r = nm()

print(r if n >= 10 else r + 100*(10-n))


Measured memory_bytes: 3316