akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <set>

//#define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define vec(x) vector< x >
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define sqr(x) 1LL*(x)*(x)
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define debug
#endif

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    ll K; cin >> K;
    int N = 50;
    vector<int> ans(N,N-1);
    for0(i,N)
        ans[i] += K/N;
    for0(i,K%N) {
        ans[i] = ans[i] + N - K%N+1;
    }
    for (int i=K%N; i<N; i++)
        ans[i] -= K%N;
    
    cout<<N<<endl;
    for0(i,N) {
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, k, a[MAX_N], f0, kmax=0;

ll f(ll x){
    ll res = 0;
    REP(i,n) res += a[i]^x;
    return res;
}

int main() {
    cin >> n >> k;
    REP(i,n) cin >> a[i];
    f0 = f(0);
    REPR(i,45){
        if(k<1LL<<i)continue;
        if(f(1LL<<i)>f0){
            kmax += 1LL<<i;
            k -= 1LL<<i;
        }
    }
    cout << f(kmax) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    double X, x = 100;
    cin >> X;
    int ans = 0;
    while(x < X) {
        x = floor(x*101.0/100);
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3732
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                             in(T &p){cin>>p;}
template<class T1,class T2>inline void                   in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void          in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T>inline void                             ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
template<class T>inline void                             outs(T p){for_each(all(p),out<decltype(p[0])>);}
string s;
inline void solve(void){
  in(s);
  out(s.substr(0,4)=="YAKI"?"Yes":"No");
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  int cnt = 0;
  set<int> st;
  rep (i, n) {
    int a;
    cin >> a;
    if (a >= 3200) {
      cnt++;
    }
    else {
      st.insert(a / 400);
    }
  }
  cout << max(1, (int)st.size()) << " " << st.size() + cnt << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#define int long long
//#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int x[101], y[101], h[101];

int a[100001], b[2001][2001], sum[100001];

int G[1001][1001];

int f(int b, int n) {
	//if (n < b) return n;
	//else return f(b, floor((double)n / (double)b)) + n%b;
	int ret=0;
	while (n >= b) {
		ret += n % b;
		n = floor((double)n / (double)b);
	}
	ret += n;
	return ret;
}

signed main() {
	int n,s;
	cin >> n>>s;
	if (s == n) {
		cout << n + 1 << "\n";
	}
	else {
		int ans = -1;
		for (int b = 2; b*b <= n; b++) {
			if (f(b, n) == s) { 
				ans = b;
				break;
			}
		}
		if (ans != -1) {
			cout << ans << "\n";
			return 0;
		}
		for (int p = 1; p*p <= n; p++) {
			if ((n - s) / p + 1 <= 1) continue;
			if (f((n - s) / p + 1, n) == s && (ans == -1 || (n - s) / p + 1 < ans)) {
				ans = (n - s) / p + 1;
				
			}
		}
		cout << ans << "\n";
	}



	return 0;
}

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

const int INF = 1001001001;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;
    vector<int> ans (n);
    rep(sv, n) {
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d) {
            if (dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while (!q.empty()) {
            int v = q.front(); q.pop();
            int d = dist[v];
            if (v-1 >= 0) push(v-1, d+1);
            if (v+1 < n) push(v+1, d+1);
            if (v == x) push(y, d+1);
            if (v == y) push(x, d+1);
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i, n) ans[i] /= 2;
    for (int i = 1; i <= n-1; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <assert.h>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <bitset>
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

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

  ll N, A, B;
  cin >> N >> A >> B;

  ll H[100010] = {};
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  A -= B;

  ll left = 0;
  ll right = *max_element(H, H + N);

  while (right - left > 1) {
    ll trial = (left + right) / 2;
    ll remains = trial;
    for (int i = 0; i < N; i++) {
      if (H[i] > trial * B) {
        remains -= (H[i] - trial * B + A - 1) / A;
      }
    }
    if (remains >= 0) {
      right = trial;
    } else {
      left = trial;
    }
  }

  cout << right << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

map<string, int> mp;

int main(){
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    mp[s] = a;
    mp[t] = b;
    string u;
    cin >> u;
    mp[u]--;

    cout << mp[s] << " " << mp[t] << endl;
    return 0;
}


Measured memory_bytes: 3504
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    set<int> st;
    REP(i,3){int a; cin >> a; st.insert(a);}
    out(st.size());

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int main(void){
    int m1, m2, d1, d2;
    int ans = 0;
    scanf("%d%d%d%d",&m1, &d1, &m2, &d2);
    if(m1==1||m1==3||m1==5||m1==7||m1==8||m1==10||m1==12){
        if(d1==31){
            if(m1==12){
                if(m2==1&&d2==1)  ans++;
            }else{
                if(m2==m1+1&&d2==1) ans++;
            }
        }
    }else if(m1==2){
        if(d1==28&&m2==3&&d2==1) ans++;
    }else{
        if(m2==m1+1&&d1==30&&d2==1) ans++;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
 
        Scanner sc = new Scanner(System.in);
 
        int a = sc.nextInt();
        int b = sc.nextInt();
 
        String relation;
 
        if(a > b){
            relation = ">";
        }else if(a < b){
            relation = "<";
        }else{
            relation = "==";
        }
 
        System.out.printf("a %s b\n", relation);
    }
}


Measured memory_bytes: 26292
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;
long long f(long long a) {
     long long res[] = {a,1,a+1,0};
     return res[a%4];
}

long long getXor(long long a, long long b) {
     return f(b)^f(max(0LL,a-1));
}

int32_t main(){
	ios::sync_with_stdio(false);

    int a,b;
    cin>>a>>b;
    cout<<getXor(a,b)<<"\n";


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,k,x3,y3,x2,y2;
int dx[4]={1,-1,0,0};int dy[4]={0,0,1,-1};
int main()
{ cin>>n>>m>>k>>x3>>y3>>x2>>y2;x3--;y3--;x2--;y2--;
string s[n];
for(int i=0;i<n;i++)
cin>>s[i];
vector<vector<int> > g(n,vector<int> (m,1e9));
queue<pair<int,int> > q;
q.push({x3,y3});
g[x3][y3]=0;
while(!q.empty()){
	int x=q.front().first;int y=q.front().second;
	q.pop();
	int val=g[x][y]+1;
	 for(int dir=0;dir<4;dir++){int xx=x;int yy=y;
	 	for(int i=1;i<=k;i++){
	 	  xx +=dx[dir]; yy+=dy[dir];
	 	if(xx<0||yy<0||xx>=n||yy>=m||s[xx][yy]=='@'||g[xx][yy]<val)
	 	break;
	 	if(g[xx][yy]>val){
	 	g[xx][yy]=val;
	 	q.push({xx,yy});}}
	 }
}
if(g[x2][y2]==1e9){
	cout<<-1;
}
else{
	cout<<g[x2][y2];
}
}

Measured memory_bytes: 12056
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;

int n,m,l,cnt,mx,my;
char a[1009][1009];
int vis[1009][1009];
pair<int,int> p[10],st;
int mov[4][2] = {1,0,0,-1,-1,0,0,1};
struct status
{
    int x,y;
    int ord;
    status(int a,int b,int c)
    {
        x = a, y = b, ord = c;
    }
};

void bfs(int x,int y,int color)
{
    queue <struct status> q;
    struct status temp(x,y,0);
    q.push(temp);
    int flag = 0;
    while(!q.empty())
    {
        struct status nw = q.front();
        q.pop();
        if(nw.x == p[color].first && nw.y == p[color].second)
        {
            cnt += nw.ord;
            break;
        }
        vis[nw.x][nw.y] = 1;
        for(int i=0;i<4;i++)
        {
            int tx = mov[i][0] + nw.x, ty = nw.y + mov[i][1];
            if(tx>=0 && tx< n && ty>=0 && ty< m && !vis[tx][ty] && a[tx][ty] != 'X')
            {
                struct status tmp(tx,ty,nw.ord+1);
                q.push(tmp);
                vis[tx][ty] = 1;
            }
        }
    }
}

int main()
{
    while(~scanf("%d%d%d",&n,&m,&l))
    {
        getchar();
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                scanf("%c",&a[i][j]);
                if(a[i][j]>='0' && a[i][j]<='9')
                    p[a[i][j]-'0'].first = i, p[a[i][j]-'0'].second = j;
                if(a[i][j] == 'S') st.first = i, st.second = j;
            }
            getchar();
        }

        int sx = st.first, sy = st.second;
        cnt = 0;
        for(int i=1;i<=l;i++)
        {
            memset(vis,0,sizeof(vis));
            bfs(sx,sy,i);
            sx = p[i].first, sy = p[i].second;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

Measured memory_bytes: 6024
#include <iostream>

void funcC() {
  long long int n, k, temp;
  std::cin >> n >> k;
  temp = n % k;
  if ((temp - k)*(-1) < temp)temp = (temp - k)*(-1);
  std::cout << temp;
}

int main(void) {
  funcC();
  return 0;
}

Measured memory_bytes: 256
#import<iostream>
int main(){int K,n,i=-1,j,k;std::cin>>K;std::cout<<(n=(K+3)/4*2);while(++i<n){std::cout<<'\n';j=-1;while(++j<n)std::cout<<((k=i%2*n+(i+j)%n)>=K?(k-n)%K:k)+1<<' ';}return 0;}

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

const int INF = 2147483647;

typedef long long ll;

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

template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}

int main(){

    int N, W; cin >> N >> W;
    ll w[N], v[N]; for(int i = 0; i < N; i++){cin >> w[i] >> v[i];}
    ll dp[N][W+1]; for(int i = 0; i < N; i++){for(int j = 0; j <= W; j++){dp[i][j]=0;}}

    for(int i = 0; i < N; i++){
        for(int j = 1; j <= W; j++){

            if(i == 0){if(j >= w[i]){dp[i][j] = v[i];}}
            else if(i > 0 && j >= w[i]){dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]] + v[i]);}
            else{dp[i][j] = max(dp[i][j-1],dp[i-1][j]);}

            //cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << " "; 
        }
        //cout << endl;
    }

    cout << dp[N-1][W] << endl;
}

Measured memory_bytes: 78336
#include <stdio.h>

int i,c=0;

void LinearSearch(int *A,int key){
  int j=0;
  A[i]=key;
  while(A[j]!=key){
    j++;
  }
    if(j==i){
      return;
    }
    c++;
    return;
}

main(){
  int S[10000];
  int t,j,q,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);
    for(j=0;j<q;j++){
      scanf("%d",&t);
      LinearSearch(S,t);
    }

    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const ll NN = 2e5 + 5;
ll n, has;
string s;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> s;
    n = s.length();
    for(ll i = 0; i < n; i++)
        if(s[i] != s[n - i - 1])
            has++;
    has /=2;
    cout << has << "\n";

}

Measured memory_bytes: 256
//#define USE_CPP11
// #define USE_PRINTF

#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <complex>
#include <memory>
#include <sstream>

#ifdef USE_CPP11
#include <unordered_map>
#include <unordered_set>
#include <functional>
#endif

#define PRINT(obj) cout << obj << endl
#define REP(i, n) for(int (i) = 0; (i) < (n); i++)
#define SPACE " "

typedef long long ll;

const int INF = 1e9 + 10;

using namespace std;

namespace Scanner {
#ifdef USE_PRINTF
  int    nextInt()    { int    d; scanf("%d" , &d); return d; }
  float  nextFloat()  { float  f; scanf("%f" , &f); return f; }
  double nextDouble() { double f; scanf("%lf", &f); return f; }  
  string nextString() { string s; scanf("%s" , &s); return s; }
  ll     nextll()     { ll     l; scanf("%ll", &l); return l; }
#else
  int    nextInt()    { int    d; cin >> d; return d; }
  float  nextFloat()  { float  f; cin >> f; return f; }
  double nextDouble() { double f; cin >> f; return f; }  
  string nextString() { string s; cin >> s; return s; }
  ll     nextll()     { ll     l; cin >> l; return l; }
#endif

  string getLine() { 
    string input;
    getline(cin, input);
    return input;
  }
};

namespace myLibrary {
  vector<string> split(const string& str, char delim) {
    vector<string> ret;
    size_t current = 0, found;
    while ((found = str.find_first_of(delim, current)) != string::npos) {
      ret.push_back(string(str, current, found - current));
      current = found + 1;
    }
    ret.push_back(string(str, current, str.size() - current));
    return ret;
  }
  
#ifdef USE_CPP11
  ///
  /// higher-order functional
  /// This is something like map in haskell, python, etc.
  /// Sample usage:
  ///   vector<int> a = {1, 2, 3, 4, 5};
  ///   vector<int> b = myLibrary::_Map<int, int>(a, [](int n){
  ///     return n * n;
  ///   });
  /// Result:
  ///   b = 1, 4, 9, 16, 25
  ///
  template<typename T_IN, typename T_OUT, class Functor>
  vector<T_OUT> _Map(vector<T_IN> src, Functor func) {
    vector<T_OUT> ret;
    for (int i = 0; i < src.size(); i++) {
      ret.push_back(func(src[i]));
    }
    return ret;
  }
#endif

};

/// BEGIN //////////////////////////////////////////////////////////

int main() {
  while (true) {
    int m    = Scanner::nextInt();
    int nmin = Scanner::nextInt();
    int nmax = Scanner::nextInt();

    if (m + nmin + nmax == 0) {
      break;
    }

    vector<int> Ps(m);
    REP(i, m) {
      int p = Scanner::nextInt();
      Ps[i] = p;
    }

    int ans, ans_diff = -1;
    for (int i = nmin - 1; i <= nmax - 1; i++) {
      int diff = Ps[i] - Ps[i + 1];
      if (diff >= ans_diff) {
        ans_diff = diff;
        ans = i;
      }
    }
    PRINT(ans + 1);
  }

  return 0;
}
/// END   //////////////////////////////////////////////////////////

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

void solve() {
    int N;
    cin >> N;
    vector<double> T(N), V(N);
    double tmax = 0;
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        tmax += T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    map<double, double> ma;
    for(double t = 0.0; t <= tmax; t += 0.5) {
        ma[t] = t;
    }

    for(double t = tmax; t >= 0; t -= 0.5) {
        ma[t] = min(ma[t], tmax - t);
    }

    double s = 0;
    for (int i = 0; i < N; i++) {
        double t = s + T[i];
        for(double x = s; x >= 0; x -= 0.5) {
            ma[x] = min(ma[x], V[i] + s - x);
        }
        for(double x = t; x <= tmax; x += 0.5) {
            ma[x] = min(ma[x], V[i] + x - t);
        }
        for(double x = s; x <= t; x += 0.5) {
            ma[x] = min(ma[x], V[i]);
        }
        s = t;
    }
    vector<double> A;
    for(auto m : ma) {
        A.push_back(m.second);
    }
    double ans = 0;
    for (int i = 0; i + 1 < A.size(); i++) {
        ans += (A[i] + A[i + 1]) / 4.0;
    }
    cout << ans << endl;
}

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
    int n;
    cin>>n;
    vector<int> vi(n);
    REP(i, n)
    {
        cin >> vi[i];
    }
    int ans = 1e9;
    FOR(i, 1, 101)
    {
        int a = 0;
        REP(j, n)
        {
            a += (vi[j] - i) * (vi[j] - i);
        }
        ans = min(ans, a);
    }
    cout<<ans<<endl;
}

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

#define  ll         long long
#define  llu        unsigned long long
#define  mod        1000000007
#define  pi         ((2.0)*acos(0.0))
#define  pb         push_back
#define  pf         push_front
#define  eb         emplace_back
#define  mp         make_pair
#define  all(x)     (x).begin(),(x).end()
#define  X          first
#define  Y          second

/*loop*/
#define  fr(i,m,n)   for(ll i=m;i<n;++i)

/*output shortcuts*/
#define  nl         "\n"
#define  Yes        cout<<"Yes\n"
#define  yes        cout<<"yes\n"
#define  YES        cout<<"YES\n"
#define  No         cout<<"No\n"
#define  no         cout<<"no\n"
#define  NO         cout<<"NO\n"

using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll h,w,k=1,p=1;
    cin>>h>>w;
    char a[h][w];

    fr(i,0,h)
    fr(j,0,w)
    cin>>a[i][j];

    ll dp[h][w];
    dp[0][0]=0;

    fr(i,1,h) //1st column
    {
        if(a[i][0]=='#') k=0;
        dp[i][0]=k;
    }
    fr(i,1,w) //1st row
    {
        if(a[0][i]=='#') p=0;
        dp[0][i]=p;
    }

    fr(i,1,h)
    {
        fr(j,1,w)
        {
            if(a[i][j]=='#')
            {
                dp[i][j]=0; continue;
            }
            dp[i][j] = (dp[i-1][j]%mod) + (dp[i][j-1]%mod) ;
        }
    }
/*
    fr(i,0,h)
    { fr(j,0,w)
        cout<<dp[i][j]<<" ";
      cout<<nl;
    }
*/
    cout<<dp[h-1][w-1] % mod<<nl;
return 0;
}



Measured memory_bytes: 12372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll arr[100100],n,ans,temp,a,b,num,count1,count2;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        if(!(num%4))
            count1++;
        else if(!(num%2))
            count2++;
    }
    count1+=count2/2;
    count1*=2;
    if(count1>=(n-1))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
return 0;
}


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

using namespace std;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, result = 0, pre = -2;
    scanf("%d", &N);

    queue<int> q;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        scanf("%d", &A[i]);
        if(A[i] == pre + 1)
            q.push(A[i]);
        pre = A[i];
    }

    vector<int> B(N);
    for(int i = 0; i < N; i++){
        scanf("%d", &B[i]);
        result += B[i];
    }

    vector<int> C(N);
    for(int i = 0; i < N - 1; i++){
        scanf("%d", &C[i]);
    }

    while(!q.empty()){
        result += C[q.front() - 2];
        q.pop();
    }

    cout << result << "\n";
    return 0;
}

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

int main(void) {
  int N, A, B, sum = 0;
  cin >> N >> A >> B;
  for (int i = 1; i <= N; i++) {
    int s = 0, tmp = i;
    while (tmp > 0) {
      s += tmp % 10;
      tmp /= 10;
    }
    if (A <= s && s <= B) sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back



ll gcd(ll a , ll b){
    ll bigger=max(a,b);
    ll smaller=min(a,b);
    if (bigger%smaller==0){
        return smaller;
    }
    else {
        return gcd(smaller, bigger%smaller);
    }

}






int main(){

    int a;
    cin>>a;

    cout<<(a+a*a+a*a*a)<<endl;

    











}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	A := make([][]byte, N)
	B := make([][]byte, M)
	var s string
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		for j := 0; j < N; j++ {
			A[i] = append(A[i], s[j])
		}
	}
	for i := 0; i < M; i++ {
		fmt.Scan(&s)
		for j := 0; j < M; j++ {
			B[i] = append(B[i], s[j])
		}
	}
	// fmt.Println(A)
	// fmt.Println(B)
	if N == M {
		N++
	}
	for i := 0; i < N-M; i++ {
		for j := 0; j < N-M; j++ {
			c := true
			for y := 0; y < M; y++ {
				for x := 0; x < M; x++ {
					// fmt.Println(y, x, i, j, y+i, x+j)
					if A[y+i][x+j] != B[y][x] {
						c = false
						break
					}
				}
			}
			if c == true {
				fmt.Println("Yes")
				return
			}
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
A,B,C,X,Y = map(int,input().split())

price = X * A + Y * B
for a in [0,abs(X-Y),X]:
    for b in [0,abs(X-Y),Y]:
        c = max(X-a,Y-b)*2
        price = min(price,a*A + b*B + c*C)

print(price)

Measured memory_bytes: 9188
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	Sstring := []rune(S)
	characters := len(Sstring)
	for i := 0; i < characters; i++ {
		if T != S {
			S = string(Sstring[characters-1]) + string(Sstring[:characters-1])
			Sstring = []rune(S)
		} else {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  rep(i, n) cin >> s[i];
  rep(i, m) cin >> t[i];

  vector<vector<ll>> dp(n + 1, vector<ll>(m + 1, 0));
  FOR(i, 1, n + 1) {
    FOR(j, 1, m + 1) {
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mod) % mod;
      if (s[i - 1] == t[j - 1]) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] + 1) % mod;
    }
  }
  cout << (dp[n][m] + 1) % mod << endl;






  
  return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=200005;
char s[max_n];
int n;
int dp[max_n];
int nex[max_n][26];
char ans[max_n];
int main(){
    scanf(" %s",s+1);
    int n=strlen(s+1);
    for(int j=0;j<26;j++){
        nex[n+1][j]=n+1;
        for(int i=n;i>=1;i--){
            if(s[i]-'a'==j)nex[i][j]=i;
            else nex[i][j]=nex[i+1][j];
        }
    }
    dp[n+1]=1;
    for(int i=n;i>=1;i--){
        int mx=0;
        for(int j=0;j<26;j++)mx=max(mx,nex[i][j]);
        if(mx==n+1)dp[i]=1;
        else dp[i]=1+dp[mx+1];
    }
    int now=1;
    for(int i=1;i<=dp[1];i++){
        for(int j=0;j<26;j++){
            int nx=nex[now][j];
            if(i+dp[nx+1]==dp[1]){
                ans[i]=j+'a';
                now=nx+1;
                break;
            }
        }
    }
    ans[dp[1]+1]=0;
    printf("%s\n",ans+1);
    return 0;
}

Measured memory_bytes: 21632
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	int ans=0,ans1=0;
	map<int,int> mp;
	map<int,int> mp2;
	for(int i=0;i<m;i++){
		int p; string s; cin >> p >> s;
		if(mp[p]==0){
			if(s=="AC"){
				ans++;
				mp[p]=1;
			}
			else{
				mp2[p]++;
			}
		}
	}
	for(int i=1;i<=n;i++){
		if(mp[i]){
			ans1+=mp2[i];
		}
	}
	cout << ans << " " << ans1 << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define MAX_N 2001

int n,m, power[MAX_N][3];
double p[MAX_N],dp[5],ex[MAX_N][3], score[] = {5.0,3.0,2.0};

void compute_ex(int type) {
  rep(i,m+1) {
    rep(_,5) dp[_] = 0.0;
    dp[0] = dp[1] = 1.0;
    REP(j,1,n) {
      if( i == 0 ) {
        dp[0] = 1.0;
        dp[1] = 0.0;
        break;
      }
      int index = ( i * power[0][type] ) / power[j][type];
      if( i && ( i * power[0][type] ) % power[j][type] == 0 ) {
        --index;
      }
      index = min(m,index);
      assert( 0 <= index );
      double win_p = p[index];
      dp[0] *= ( 1.0 - win_p );
      for(int k=3;k>=1;--k) {
        dp[k+1] += dp[k] * ( 1.0 - win_p );
        dp[k]    = dp[k] * win_p;
      }
    }
    ex[i][type] = ( dp[1] + dp[2] + dp[3] ) * score[type] + dp[0] * -1.0;
  }
}

void compute() {
  p[0] = 1.0;
  rep(i,m) {
    for(int j=i;j>=0;--j) {
      p[j+1] += p[j] / 3.0;
      p[j]    = p[j] * 2.0 / 3.0;
    }
  }
  REP(i,1,m+1) p[i] += p[i-1];

  rep(i,3) compute_ex(i);
  
  double maxi = -DBL_MAX;
  rep(i,m+1) rep(j,m+1) {
    if( i + j > m ) break;
    int k = m - ( i + j );
    maxi = max(maxi,ex[i][0]+ex[j][1]+ex[k][2]);
  }
  printf("%.10f\n",maxi);
}

int main() {
  cin >> n >> m;
  rep(i,n) rep(j,3) cin >> power[i][j];
  compute();
  return 0;
}

Measured memory_bytes: 1264
{-# OPTIONS_GHC -O #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Storable as V
import qualified Data.Vector.Storable.Mutable as MV
import qualified Data.IntMap as M
import qualified Data.Set as S

findUF :: MV.IOVector Int -> Int -> IO Int
findUF uf x = do
    p <- MV.unsafeRead uf x
    if p == -1
        then return x
        else do
                f <- findUF uf p
                MV.unsafeWrite uf x f
                return f

gp :: M.IntMap (S.Set Int, S.Set Int) -> V.Vector Int -> MV.IOVector Int -> Int -> Int -> IO (M.IntMap (S.Set Int, S.Set Int))
gp am _ _ n i | n==i = return am
gp am ps uf n i = do
    -- index iのroot (0..)
    ri <- findUF uf i
    let r = if ri == -1 then i else ri
    -- root indexをキーとして、(index, pi)をグルーピング
    let um = case M.lookup r am of
                Just (gis, gps) -> M.insert r (S.insert i gis, S.insert (ps V.! (i-1)) gps) am
                Nothing -> M.insert r (S.singleton i, S.singleton $ ps V.! (i-1)) am
    --
    gp um ps uf n (i+1)

main = do
    [n,m] <- map read.words <$> getLine

    -- 順列読込 / ByteString -> Vector.Storable
    ps <- V.unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine

    -- (xi, yi)をUnionFind -> Vector.Storable.Mutable
    uf <- MV.replicate (n+1) (-1)
    replicateM_ m $ do
        [x,y] <- unfoldr (B.readInt.B.dropWhile (==' ')) <$> B.getLine
        px <- findUF uf x
        py <- findUF uf y
        when (px /= py) $ MV.unsafeWrite uf py px
    
    -- UnionFind木の根をkeyとして、(indexのSet, PiのSet)のMap
    ms <- gp M.empty ps uf (MV.length uf) 1

    -- Mapの各keyについて、indexのSetとPiのSetの重複の数の合計
    print $ sum $ M.map (\(s1,s2) -> intnum s1 s2) ms

-- setの重複の数
intnum s1 s2 = length $ S.intersection s1 s2

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

long long n, mi = 1e18, ans;

int main(){
//      cin.tie(0);
//      ios::sync_with_stdio(false);
        cin >> n;
        for(int i=0; i<5; ++i){
            long long t;
            cin >> t;
            mi = min(mi, t);
        }
        ans = (n + mi - 1) / mi;
        cout << ans + 4 << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ad(x) ((x - 1 ^ 1) + 1)

typedef long long ll;
const int N = 100054, M = N * 2;

int n, m, E = 0, L;
int to[M], first[N], next[M];
int p[N], dep[N], ssize[N]; // signed size
int cnt = 0, buf[N];

inline void addedge(int u, int v) {
	to[++E] = v, next[E] = first[u], first[u] = E;
	to[++E] = u, next[E] = first[v], first[v] = E;
}

void dfs(int x) {
	int i, y; ssize[x] = -(dep[x] & 1) | 1;
	for (i = first[x]; i; i = next[i])
		if (!~p[y = to[i]])
			p[y] = x, dep[y] = dep[x] + 1, dfs(y), ssize[x] += ssize[y];
		else if (dep[x] < dep[y])
			L = i;
//	fprintf(stderr, "ssize[%d] = %d\n", x, ssize[x]);
}

int main() {
	int i, u, v, incr; ll ans = 0;
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; ++i) scanf("%d%d", &u, &v), addedge(u, v);
	memset(p, -1, sizeof p), p[1] = 0, dfs(1);
	if (m == n - 1) {
		if (ssize[1]) return puts("-1"), 0;
		for (i = 1; i <= n; ++i) ans += abs(ssize[i]);
		return printf("%lld\n", ans), 0;
	}
	u = to[ad(L)], v = to[L];
	assert(m == n && dep[u] < dep[v]);
	if ((dep[u] ^ dep[v]) & 1) {
		if (ssize[1]) return puts("-1"), 0;
		for (i = v; i != u; i = p[i]) buf[cnt++] = ssize[i];
		++cnt, std::nth_element(buf, buf + cnt / 2, buf + cnt);
		for (i = 0; i < cnt; ++i) ans += abs(buf[i] - buf[cnt / 2]) - abs(buf[i]);
	} else {
		if (ssize[1] & 1) return puts("-1"), 0;
		incr = -ssize[1] / 2, ans = abs(incr);
		for (i = v; i != u; i = p[i]) ssize[i] += incr;
		for (; i; i = p[i]) ssize[i] += 2 * incr;
	}
	for (i = 1; i <= n; ++i) ans += abs(ssize[i]);
	printf("%lld\n", ans);
	return 0;
}


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

int main(){
    string str;
    int a[26] ={};
    int i;
    while(getline(cin, str)){
        for(i=0; i < str.size(); i++){
            if(str[i] >= 'a' && str[i] <= 'z') a[str[i] - 'a']++;
            else if(str[i] >= 'A' && str[i] <= 'Z') a[str[i] - 'A']++;
        }
    }
    for(i=0; i < 26; i++){
        cout << (char)('a' + i) << " : " << a[i] << endl;
    }
}


Measured memory_bytes: 3224
input_n = input()
n = int(input_n)

input_L = input()
L = str(input_L)

listL = L.split(' ')

max = 0
tmp1 = 0
tmp2 = 0
result = 0

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            if int(listL[i]) != int(listL[j]) and int(listL[j]) != int(listL[k]) and int(listL[k]) != int(listL[i]):
                if int(listL[i]) > int(listL[j]):
                    max = int(listL[i])
                    tmp1 = int(listL[j])
                else :
                    max = int(listL[j])
                    tmp1 = int(listL[i])
                if int(listL[k]) > max:
                    tmp2 = max
                    max = int(listL[k])
                else :
                    tmp2 = int(listL[k])
                if max < (tmp1 + tmp2):
                    result += 1

print(str(result))


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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
    int A,B,C,K;
    cin >> A >>B >>C >>K;
    int sum = 0;

    int a_num=A;
    if(A>K){
      a_num =K;
    }
    K -= a_num;
    sum += a_num;

    int b_num =B;
    if(B>K){
      b_num = K;
    }
    K -= b_num;

    int c_num = C;
    if(C>K){
      c_num = K;
    }
    sum -= c_num;
    printl(sum);
}


Measured memory_bytes: 3620
#include <iostream>

using namespace std;

char hoge, fuga, piyo;

int main()
{
  cin >> hoge >> fuga >> piyo;
  if (hoge == 'a' || fuga == 'a' || piyo == 'a')
  {
    if (hoge == 'b' || fuga == 'b' || piyo == 'b')
    {
      if (hoge == 'c' || fuga == 'c' || piyo == 'c')
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

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

typedef struct node {
    int key;
    struct node *parent, *left, *right;
} Node;

Node *root;

void Search(int key) {
    Node *x = root;
    while (x != NULL) {
        if (key == x->key) {
            cout << "yes" << endl;
            return;
        }
        if (key < x->key) x = x->left;
        else x = x->right;
    }
    cout << "no" << endl;
}

void Insert(int key) {
    Node *x = root, *y = NULL, *z;    
    z = (Node *)malloc(sizeof(Node));
    z->left = NULL;
    z->right = NULL;
    z->parent = NULL;
    z->key = key;
    //cout << root << endl;
    while (x != NULL) {
        //cout << x << endl;
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    //cout << "ok" << endl;
    z->parent = y;
    //cout << y << endl;

    if (y == NULL) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;
}

void mid_dfs(Node *x) {
    if (x->left != NULL) mid_dfs(x->left);
    cout << " " << x->key;
    if (x->right != NULL) mid_dfs(x->right);
}

void pre_dfs(Node *x) {
    cout << " " << x->key;
    if (x->left != NULL) pre_dfs(x->left);
    if (x->right != NULL) pre_dfs(x->right);
}

void print() {
    mid_dfs(root);
    cout << endl;
    pre_dfs(root);
    cout << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string ope;
        cin >> ope;

        if (ope == "insert") {
            int k;
            cin >> k;
            Insert(k);
        }
        else if (ope == "find") {
            int k;
            cin >> k;
            Search(k);
        }
        else {
            print();
        }
    }
}



Measured memory_bytes: 21916
_ = input()
a = [int(x) for x in input().split()]

odd = []
m4 = []
m2 = 0
for i in a:
    if i % 2 != 0:
        odd.append(i)
    elif i % 4 == 0:
        m4.append(i)
    else:
        m2 = 1
else:
    lodd = len(odd)
    if lodd == 0 or lodd + m2 - 1 <= len(m4):
        print("Yes")
    else:
        print("No")

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a) for(int i = 0; i < (a); ++i)

vector<double> p;
vector<vector<double>> dp;
double flip(int startPos, int hReq)
{
    if(hReq <= 0) return 1;
    if(hReq > startPos + 1) return 0;
    if(startPos == 0 && hReq == 1) return p[0];
    if(startPos < 0) return 0;
    if(dp[startPos - 1][hReq - 1] == -1)
    {
        dp[startPos - 1][hReq - 1] = flip(startPos - 1, hReq - 1);
    }
    if(dp[startPos - 1][hReq] == -1) 
    {
        dp[startPos - 1][hReq] = flip(startPos - 1, hReq);
    }
    dp[startPos][hReq] = p[startPos] * dp[startPos - 1][hReq - 1] + (1 - p[startPos]) * dp[startPos - 1][hReq];
    return dp[startPos][hReq];
} 
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    dp.assign(n, vector<double>(n/2 + 2, -1));
    p.assign(n, 0);
    FOR(i, n) cin >> p[i];
    cout << setprecision(12);
    cout << flip(n - 1, (n)/2 + 1);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,x,y; cin>>w>>h>>x>>y;
    double ans = (double)h*w/2;
    cout<<setp(12)<<ans<<" "<<(2*x==w&&2*y==h)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        int K = scanner.nextInt();
        int X = scanner.nextInt();
        
        if((K * 500) >= X){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
	}
}

Measured memory_bytes: 35572
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n, k, s;

int ans[100010];

int main()
{
	scanf("%d%d%d", &n, &k, &s);
	
	int pAns = 0;
	for (int i = 0 ; i < k ; i++) {
		ans[pAns] = s;
		pAns++;
	}
	
	for (int i = k ; i < n ; i++) {
		if (s == 1000000000) {	//这种情况下后续反正达不到 
			ans[pAns] = 1;
			pAns++;
		} else {
			ans[pAns] = s + 1;
			pAns++;
		}
	}
	
	
	
	
	printf("%d", ans[0]);
	for (int i = 1 ; i < n ; i++)
		printf(" %d", ans[i]);
	
	return 0;
}



Measured memory_bytes: 1664