akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    string S; cin >> S;
    Ans(S[2] == S[3] && S[4] == S[5], "Yes", "No");

    return 0;
}


Measured memory_bytes: 256
n, _k = map(int, raw_input().split())
w = [int(raw_input()) for i in xrange(n)]

l, r = max(w), sum(w)
while r > l:
    P = (r + l) / 2
    c = P
    k = _k - 1
    for wi in w:
        if c >= wi: c -= wi
        else:
            c = P - wi
            k -= 1
            if k < 0:
                break
    if k >= 0:
        r = P
    else:
        l = P + 1
print l

Measured memory_bytes: 7328
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, M;

int main() {
    scanf("%lld %lld\n", &N, &M);
    vector<ll> A(N, 0);
    ll a, b;
    REP(i, M) {
        scanf("%lld %lld\n", &a, &b);
        A[a--]++;
        A[b--]++;
    }
    REP(i, N) {
        if(A[i]%2) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
struct Edge{
	int next,to;
}edge[maxn*2];
int fi[maxn],se=1,col[maxn],ans=0;
inline void add_edge(int u,int v){edge[++se].next=fi[u],fi[u]=se,edge[se].to=v;}
inline void add(int u,int v){add_edge(u,v),add_edge(v,u);}
void dfs(int x,int fa,int c){
	int w=0;
	for(int i=fi[x];i;i=edge[i].next){
		int v=edge[i].to;if(v==fa)continue;
		w++;w+=(w==c);dfs(v,x,col[i/2]=w);
	}
	ans=max(ans,w);
}
int main(){
	int n,u,v;scanf("%d",&n);
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),add(u,v);
	dfs(1,0,0);
	printf("%d\n",ans);
	for(int i=1;i<n;i++)printf("%d\n",col[i]);
	return 0;
}

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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    char b;
    cin >> b;

    if(b == 'A')ppp('T');
    if(b == 'T')ppp('A');
    if(b == 'C')ppp('G');
    if(b == 'G')ppp('C');




    return 0;
}


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

#define int long long 
#define ll long long 
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define vi vector<ll>
#define mod 1000000007
#define full(a) a.begin(),a.end()
#define inf INT_MAX
#define minf INT_MIN
ll n,k;
ll frog(ll i,ll a[],ll dp[]){
    if(i==n-1)return 0;
    if(dp[i]!=-1)return dp[i];

    ll q=INT_MAX;
    for(int r=1;r<=k;r++)
        if(i+r<n)q=min(q,abs(a[i+r]-a[i])+frog(i+r,a,dp));
        else break;

    return dp[i]=q;
}


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

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    cin>>n>>k;
    ll h[n];
    ll dp[n];
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++)cin>>h[i];

    cout<<frog(0,h,dp);
    
    

    return 0; 
 }
    

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

 const int INF = 1e9+7;

int main() {
	int n,k;
	cin >> n >> k;
	double ans = 0;
	for(int i=1; i<=n; i++){
		int now = i;
		double p = 1.0;
		while(now<k){
			p /= 2;
			now *= 2;
		}
		ans += p;
	}
	cout << fixed << setprecision(15) << ans/n << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_098_A
{
	class Program
	{
		static void Main(string[] args)
		{
			int  a, b, max;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);

			max = a + b;
			if (max < a - b) max = a - b;
			if (max < a * b) max = a * b;

			Console.WriteLine(max);
			Console.ReadKey();
			 
		}
	}
} 

Measured memory_bytes: 13140
// myfirstatcoder.cpp : アプリケーションのエントリ ポイントを定義します。

#include "bits/stdc++.h"
#define rep(i,cc,n) for(int i=cc;i<(n);++i)
#define drep(i,cc,n) for(int i=cc;i>(n);--i)
#define llrep(i,cc,n) for(long long i=cc;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	long double rad,ans;
	double b_rad = m / 60.0;
	double a_rad = (h + b_rad) / 12.0;
	rad = (a_rad - b_rad) * 2*M_PI;
	if (rad < 0)
		rad = -rad;
	ans = a * a + b * b - 2 * a * b * cosl(rad);
	ans = sqrtl(ans);
	//ans = pow(ans, 0.5);
	cout << fixed << setprecision(20) << ans << endl;
}

/*
ライブラリ
・std
::::sqrt(); sqrtl();
::::cos(); cosl();
・iomanip
::::cout << fixed << setprecision(16) << double(sum) << endl;
・string
::::str.at(0)
::::str.length()
::::str.pop_back();
::::str.erase(str.begin()+2, str.end());  //要素3から終わりまで削除
・vector<int>
::::vector<int> a(n,-1);
::::vector<int> s;  s.push_back()
::::vector<vector<int>> A(N,vector<int>(M));  A[i][j] = i;
・map<string,int>
・sort(a.begin(),a.end());

関数
・rep_2(i,0,1<<n) … ２のN乗ループ
・while(node[v] == -1) … ノードの探索と生成
・gcd(int, int) … 最大公約数 int
・find_string(str, str) … 文字列検索 bool
*/

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

const int INF = 1 << 30;

bool solve() {
	int N, M;
	cin >> N >> M;
	if (N == 0) return false;

	vector<int> S(M);
	vector<vector<int>> C(M);
	for(int i = 0; i < M; ++i) {
		cin >> S[i];
		int K;
		cin >> K;
		C[i].resize(K);
		for(auto& c : C[i]) {
			cin >> c;
		}
	}

	vector<int> mi(N + 1, 0), ma(N + 1, 0);
	for(int i = 0; i < M; ++i) {
		for(auto c : C[i]) {
			ma[c] += S[i];
		}
		if (C[i].size() == 1) {
			mi[C[i][0]] += S[i];
		}
	}

	vector<int> mafore(N + 2);
	mafore[0] = 0;
	for(int i = 1; i <= N; ++i) {
		mafore[i] = max(mafore[i - 1], ma[i]);
	}

	vector<int> maback(N + 2);
	mafore[N + 1] = 0;
	for(int i = N; i >= 1; --i) {
		maback[i] = max(maback[i + 1], ma[i]);
	}

	int ans = 0;
	for(int i = 1; i <= N; ++i) {
		int score = max(mafore[i - 1], maback[i + 1]) - mi[i];
		ans = max(ans, score);
	}
	cout << ans + 1 << endl;
	return true;
}

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



Measured memory_bytes: 3508
// HTTF.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(),YES,NO))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(a);i>=(LL)(b);i--)
#define REP(i,b) FOR(i,zero,b)
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb

using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 330;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 30;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;

#define endl "\n" //インタラクティブでは消す
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL DP[SIZE][4];
bool finished[SIZE][4];
LL DP2[SIZE2][SIZE2];
LL DP3[SIZE3][SIZE3][SIZE3];
LL A[SIZE][3];
LL solve2(int x,int c) {
	if (finished[x][c]) return DP[x][c];
	if (x== 0) return 0;
	finished[x][c] = true;
	DP[x][c] = 0;
	REP(i, 3) if(c!=i) MX(DP[x][c], solve2(x-1, i) + A[x][i]);
	return DP[x][c];
}
LL solve() {
	cin >> N;
	EFOR(i, 1,N) {
		REP(j,3)
		cin >> A[i][j];

	}
	cout << solve2(N,3)<<endl;
	return 0;
}




//!!!!!!!!!!!!!!!!!!!実装を詰める!!!!!!!!!!!!!!!!!!!!!!!!!
signed main() {

	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(12);
	solve();
	cin >> N;
	return 0;

}

Measured memory_bytes: 29696
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,m;
int main()
{
	file();
	read(n),read(m);
	printf("%d\n",(m*1900+(n-m)*100)<<m);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

int N;
pair<long long, pair<long long, long long > > P[100000];

int main(void) {
	long long a, b;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%lld %lld", &a, &b);
		P[i] = make_pair(a + b, make_pair(a, b));
	}

	sort(P, P + N);
	
	long long ans = 0;

	for (int i = N-1; i >= 0; i--) {
		if (i % 2 == (N-1) % 2) {
			ans += P[i].second.first;
		}
		else {
			ans -= P[i].second.second;
		}
	}

	printf("%lld\n", ans);



}

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


int main(){


    int n, k, i, x;

    int a = 0;


    cin >> n >> k;


    for( i = 0 ; i < n ; i = i + 1 ){

         cin >> x;

         a += 2 * min( x, k - x );

         }


    cout << a << endl;


    return 0;

    }

Measured memory_bytes: 256
#define ll long long int
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#include<bits/stdc++.h>
//https://atcoder.jp/contests/dp/submissions/12796237
using namespace std;

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

  int arr1[N][2];
  fr(i,0,N)
  {
    cin>>arr1[i][0];
  cin>>arr1[i][1];
  }
  ll Wt[N];
  ll val[N];
  fr(i,0,N)
  {
    Wt[i]=arr1[i][0];
    val[i]=arr1[i][1];
  }
  ll dp[N+1][W+1];
  fr(i,0,N+1){
   dp[i][0]=0;
  }
  fr(i,0,W+1)
  dp[0][i]=0;
    fr(i,1,N+1)
      fr(j,1,W+1)
    {
    if(Wt[i-1]<=j)
      dp[i][j]=max(val[i-1]+dp[i-1][j-Wt[i-1]],dp[i-1][j]);

      else
        dp[i][j]=dp[i-1][j];

    }
  cout<<dp[N][W];
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

struct edge{
	long long from,to,cost;
};
long long V,E;   // 頂点数V,辺E
long long start; // 始点

vector<long long> d; // d[i]:=始点から点iまでの距離
edge e[3000];

bool Bellman_Ford(long long start){
    d=vector<long long>(V,LINF);     // 全点をINFで初期化
    d[start]=0;               // startとの距離0
    for(long long i=0;i<V;i++){
		bool update=false;
        for(long long j=0;j<E;j++){
            if(d[e[j].from]!=LINF&&d[e[j].to]>d[e[j].from]+e[j].cost){
                d[e[j].to]=d[e[j].from]+e[j].cost;
                update=true;
                if(i==V-1&&e[j].to==V-1){
        			return false;
        		}
            }
        }
		if(!update) break;
		// if(i==V-1&&update){
		// 	return false;
		// }
    }
    return true;
}

int main(){
	cin>>V>>E;
	rep(i,E){
        long long a,b,c; cin>>a>>b>>c;
        e[i].from=a-1;
        e[i].to=b-1;
        e[i].cost=-c;
    }
    start=0;
	if(!Bellman_Ford(start)){
		cout<<"inf"<<endl;
	}else{
		cout<<-d[V-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String... args) {

		try (Scanner sc = new Scanner(System.in)) {

			long n = sc.nextLong();
			long m = sc.nextLong();

			n = n - 2;
			m = m - 2;

			System.out.println(Math.abs(n * m));

		}

	}

}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template<class A, class B>
inline bool chmax(A &a, const B &b) { return b > a ? a = b, 1 : 0; }

template<class A, class B>
inline bool chmin(A &a, const B &b) { return b < a ? a = b, 1 : 0; }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}} End

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

  int n;
  cin >> n;

  bool same = true;
  map<int, int> cnt[2];
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
    cnt[i&1][v[i]]++;
    if (i && v[i] != v[i-1]) same = false;
  }

  if (same) {
    cout << n / 2 << "\n";
    return 0;
  }

  i64 sum0 = 0, sum1 = 0;
  vector<pii> x, y;
  rep(i, 100010) {
    sum0 += cnt[0][i];
    x.emplace_back(cnt[0][i], i);

    sum1 += cnt[1][i];
    y.emplace_back(cnt[1][i], i);
  }

  sort(all(x), greater<>());
  sort(all(y), greater<>());

  if (x[0].second == y[0].second) {
    int res1 = (sum0 - x[0].first) + (sum1 - y[1].first);
    int res2 = (sum0 - x[1].first) + (sum1 - y[0].first);
    cout << min(res1, res2) << "\n";
  }

  else cout << (sum0 - x[0].first) + (sum1 - y[0].first) << "\n";

  return 0;
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll H,W,K;
  cin>>H>>W>>K;
  vector<string> A(H);
  cin>>A;
  vector<vector<int>> ans(H,vector<int>(W,-1));
  int cnt=1;
  for(int i=0;i<H;i++){
    bool jd=false;
    for(int j=0;j<W;j++){
      if(A[i][j]=='#'){ans[i][j]=cnt; cnt++; jd=true;}
    }
    if(!jd){continue;}
    int ls=-1;
    for(int j=0;j<W;j++){
      if(ans[i][j]!=-1){ls=ans[i][j];}
      ans[i][j]=ls;
    }
    ls=-1;
    for(int j=W-1;j>=0;j--){
      if(ans[i][j]!=-1){ls=ans[i][j];}
      ans[i][j]=ls;
    }
  }
  vector<int> ls;
  for(auto &I:ans){
    if(I[0]!=-1){ls=I; break;}
  }
  for(int i=0;i<H;i++){
    if(ans[i][0]==-1){
      ans[i]=ls;
    }
    else{ls=ans[i];}
  }
  for(auto &I:ans){
    cout<<I<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 1280
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    x, y = MII()
    for i in range(x+1):
        if 4*i + 2*(x-i) == y:
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()

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

int main () {
    int N,count=0;
    cin >> N ;
    vector<int> data(N);
    for(int i=0;i<N;i++){
        cin >> data[i];
    }
    for(int j=0;j<N-2;j++){
        if(data[j]<data[j+1] && data[j+1]<data[j+2]) count++;
        if(data[j]>data[j+1] && data[j+1]>data[j+2]) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
typedef pair<ll, ll> pll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll inf=1e18;
ll p= 998244353;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
   while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll i,j,y,x,k,z,w,g,m,t,n,a,b;
	ll t2,t3,t4,t1;
	    string s;
	    cin>>n;
	    ll arr[n];
	    for(i=0;i<n;i++)
	    cin>>arr[i];
	    ll temp[n/2];
	    t1=0;
	    for(i=0;i<(n/2);i++)
	    {
	    temp[i]=(arr[2*i]^(arr[2*i+1]));
	    t1=t1^temp[i];
	    }
	    ll ans[n];
	    for(i=0;i<(n/2);i++)
	    {
	        ll val=t1^temp[i];
	        ans[2*i+1]=(val^arr[2*i]);
	        ans[2*i]=(val^arr[2*i+1]);
	    }
	    for(i=0;i<n;i++)
	    cout<<ans[i]<<' ';
	 return 0;
	 
           
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

const int MOD = 1e9+7;

int cnt[3], n;
double dp[301][301][301];
bool mark[301][301][301];

double f(int i, int j, int k) {
	if(i+j+k == 0) return 0;
	if(mark[i][j][k]) return dp[i][j][k];
	mark[i][j][k] = true;
	double prob = (double)n/(i+j+k);
	double ret = prob;
	if(i) ret += (double)i*f(i-1,j,k)/(i+j+k);
	if(j) ret += (double)j*f(i+1,j-1,k)/(i+j+k);
	if(k) ret += (double)k*f(i,j+1,k-1)/(i+j+k);

	return dp[i][j][k] = ret;
}


int main() {
	int a;
	scanf("%d", &n);

	for(int i = 1; i <= n; i++)
		scanf("%d", &a), cnt[a-1]++;

	printf("%.15lf\n", f(cnt[0], cnt[1], cnt[2]));
	
    return 0;
}

Measured memory_bytes: 239872
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc063.contest.atcoder.jp/tasks/arc063_b>
問題文============================================================
 N 個の町が一直線上に並んでいます。
 行商人の高橋君は町 1 から出発し、リンゴの売買をしながら町 N へと向かいます。
 
 はじめ高橋君は町 1 におり、リンゴを 1 つも持っていません。
 高橋君は次のいずれかの行動を繰り返し行います。
 
 移動: 町 i (i<N) にいるとき、町 i+1 へ移動する。
 リンゴの売買: リンゴを好きな個数だけ売買する。
 ここで、町 i (1≦i≦N) ではリンゴの買値も売値もともに Ai 円とする。ここで Ai は相異なる整数です。
 1 つの町で売買するリンゴの個数に制限はありませんが、
 旅の中で売買するリンゴの個数は合計で (買う個数と売る個数を合わせて) T 個以下にしなくてはなりません。
 
 高橋君は旅の利益、すなわちリンゴを売った代金から買った代金を引いた値を最大にするように旅をするとします。
 旅が終わったときに持っていたリンゴの価値は考えず、旅の中で売買した金額だけを考えます。
 
 この旅に先立って、
 青木君は任意の町 i に対して Ai を好きな非負整数 Ai' に変えるという操作を好きなだけ行うことができます。
 ただし、この操作は行うごとに |Ai−Ai'| のコストがかかります。
 操作後には異なる町の間でリンゴの値段が同じになっていても構いません。
 
 青木君の目的はできるだけ少ない合計コストの操作で高橋君の利益を少なくとも 1 円下げることです。
 合計コストの最小値を求めてください。
 
 ただし、元の状態で高橋君が 1 円以上の利益を上げられることは仮定して構いません。
 

=================================================================

解説=============================================================

 最大の利益を上げるには、
     手前の町と後の町との差が最も最大となっている町のペアで購入すればいい
 
 よってその町の値段を１変更すれば最適となる。
 
 あとは最大の差のペアが何組あるか調べてその数を示せば、それがコストとなる
 
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N,T; cin >> N >> T;
    vector<ll> A(N);
    for(auto &in:A) cin >> in;
    ll minv = A[0], maxdiff = -LINF;
    for(int i = 0; i < N;i++){
        minv = min(A[i],minv);
        maxdiff = max(maxdiff,A[i] - minv);
    }
    
    ll maxdiff_cnt = 0;
    minv = A[0];
    for(int i = 0; i < N;i++){
        minv = min(A[i],minv);
        if(A[i] - minv == maxdiff) maxdiff_cnt++;
    }
    cout << maxdiff_cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(void){
  long long int a,b,c,d;
  cin>>a>>b>>c>>d;
  long long int t = a*c;
  long long int k = a*d;
  long long int l = b*c;
  long long int m = b*d;
  if(t < k){
    t = k;
  }
  if(l < m){
    l = m;
  }
  if(t < l){
    cout<<l<<endl;
  }else{
    cout<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 3188
rep :: String -> String
rep x = x ++ (rep x)

play :: [String] -> [String]
play ("-":_) = []
play (c:n:rem) = 
  let num = read n :: Int
      len = length c
      shu = map read $ take num $ rem :: [Int]
      tot = sum shu
      o   = take len $ drop tot (rep c)
  in
    o:(play $ drop num rem)

main = do
  c <- getContents
  let l = lines c
      o = play l
  mapM_ putStrLn o

Measured memory_bytes: 4032
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
color=[0,0,0]
ans=1
for i in a:
  ans*=color.count(i)
  ans%=mod
  for j in range(3):
    if color[j]==i:color[j]+=1;break
print(ans%mod)


Measured memory_bytes: 53036
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

const int maxn=200000;
const int maxv=99999999;
const double D=11.4159265358979323846264338328;
const double K=-4.2920367320510338076867830836;

struct point
{
  int x,y;
  
  bool operator <(const point &other) const
  {
    return x<other.x;
  }
};

point p[maxn+10];
int n,m,maxy,sx,sy,tx,ty,tot,c[maxn+10],pos[maxn+10],cnt,t[maxn+10];
double ans;

int main(){
  sx=read();
  sy=read();
  tx=read();
  ty=read();
  if(sx>tx)
    {
      std::swap(sx,tx);
      std::swap(sy,ty);
    }
  n=read();
  for(int i=1;i<=n;i++)
    {
      p[i].x=read();
      p[i].y=read();
    }
  if(sy>ty)
    {
      for(int i=1;i<=n;i++)
        {
          p[i].y=maxv-p[i].y;
        }
      sy=maxv-sy,ty=maxv-ty;
    }
  std::sort(p+1,p+n+1);
  ans=(ty+tx-sy-sx)*100.0;
  for(int i=1;i<=n;i++)
    {
      if((p[i].x>=sx)&&(p[i].y>=sy)&&(p[i].x<=tx)&&(p[i].y<=ty))
        {
          t[++tot]=p[i].y;
        }
    }
  memset(c,63,sizeof c);
  c[0]=cnt=0;
  for(int i=1;i<=tot;i++)
    {
      int res=std::lower_bound(c+1,c+cnt+1,t[i])-c;
      if(res>cnt)
        {
          cnt++;
        }
      c[res]=std::min(c[res],t[i]);
    }
  if(cnt<=tx-sx&&cnt<=ty-sy)
    {
      ans+=cnt*K;
    }
  else
    {
      ans+=(cnt-1)*K+D;
    }
  printf("%.13lf\n",ans);
  return 0;
}


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

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

    int sum = 0;
    rep(i,n.length()) {
        sum += (n[i] - '0');
    }
    if (sum%9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

const int INF = 1 << 30;

int main() {
    int N; cin >> N;
    vector<vector<int>> G(N);
    for(int i = 0; i < N - 1; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    int K; cin >> K;
    vector<int> P(N, -1);
    int v, p;
    for(int i = 0; i < K; ++i) {
        cin >> v >> p; v--;
        P[v] = p;
    }

    vector<int> parity(N);

    auto pfs = [&](auto &&pfs, int cur, int pre, int p) -> bool {
        parity[cur] = p;
        if(P[cur] != -1 and P[cur] % 2 != parity[cur]) return false;
        bool res = true;
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            res &= pfs(pfs, to, cur, 1 - p);
        }
        return res;
    };

    if(!pfs(pfs, v, v, P[v] % 2)) return cout << "No" << '\n', 0;

    vector<pair<int, int>> rng(N);

    auto dfs = [&](auto &&dfs, int cur, int pre) -> pair<int, int> {
        int l = -INF, r = INF;
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            int tl, tr; tie(tl, tr) = dfs(dfs, to, cur);
            tl--, tr++;
            l = max(l, tl), r = min(r, tr);
        }
        if(P[cur] != -1) l = max(l, P[cur]), r = min(r, P[cur]);
        return rng[cur] = {l, r};
    };

    dfs(dfs, v, v);
    for(int i = 0; i < N; ++i) {
        if(rng[i].first > rng[i].second) return cout << "No" << '\n', 0;
    }

    auto efs = [&](auto &&efs, int cur, int pre, int n) -> void {
        P[cur] = n;
        for(auto &to : G[cur]) {
            if(to == pre) continue;
            int l, r; tie(l, r) = rng[to];
            if(l <= n - 1 and n - 1 <= r) efs(efs, to, cur, n - 1);
            else efs(efs, to, cur, n + 1);
        }
    };
    efs(efs, v, v, P[v]);

    cout << "Yes" << '\n';
    for(int i = 0; i < N; ++i) {
        cout << P[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 22272
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	var a, forward, backward int
	for i := 0; i < m; i++ {
		fmt.Scan(&a)
		if a < x {
			forward++
		} else { // x < a
			backward++
		}
	}

	fmt.Println(min(forward, backward))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 100000007LL
using namespace std;

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

int fie[101][101];

int main(void){
	while(1){
		string str;
		cin >> str;
		if(str=="#")break;
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int y=0,x=0;
		memset(fie,-1,sizeof(fie));
		for(int i=0;i<str.size();i++){
			if(str[i]=='b'){
				fie[y][x]=1;
				x++;
			}
			if(str[i]=='/'){
				x=0;
				y++;
			}
			if(str[i]>='0' && str[i]<='9'){
				int v=str[i]-'0';
				for(int i=0;i<v;i++){
					fie[y][x+i]=0;
				}
				x+=v;
			}
		}
		swap(fie[a-1][b-1],fie[c-1][d-1]);
		string res="";
		for(int i=0;i<9;i++){
			int cnt=0;
			int j=0;
			while(fie[i][j]>=0){
				if(fie[i][j]==0)cnt++;
				if(fie[i][j]==1){
					if(cnt>0){
						res+=('0'+cnt);
					}
					cnt=0;
					res+="b";
				}
				j++;
			}
			if(cnt>0){
				res+=('0'+cnt);
			}
			if(j>0)res+="/";
		}
		res=res.substr(0,res.size()-1);
		cout << res << endl;
	}
	return 0;
}

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


int main() {
  int a, b;
  cin >> a >> b;
  int ans = max({a+a-1, b+b-1, a+b});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
face = list(map(int,input().split()))
def Nroll(list):
	a = [list[1],list[5],list[2],list[3],list[0],list[4]]
	return a
def Wroll(list):
	a = [list[2],list[1],list[5],list[0],list[4],list[3]]
	return a
q = int(input())
ql = []
tes = [0,1,2,3,4,5]
for i in range(q):
	qk = list(map(int,input().split()))
	for ii in range(2):
		tes = Wroll(tes)
		for k in range(4):
			tes = Nroll(tes)
			for kk in range(4):
				tes = Wroll(tes)
				if tes[0] == face.index(qk[0]) and tes[1] == face.index(qk[1]):
					ql.append(face[tes[2]])
					break
			else:
				continue
			break
		else:
			continue
		break
for ss in ql:
	print(ss)


Measured memory_bytes: 5612
#include <stdio.h>

int main(void)
{
  int n, q;
  scanf("%d%d", &n, &q);
  char s[n + 1];
  int ac[n + 1];
  scanf("%s", s);
  int c = 0;
  ac[1] = 0;
  for (int i = 1; i < n; i++) {
    ac[i + 1] = s[i - 1] == 'A' && s[i] == 'C' ? ++c : c;
  }
  int l[q], r[q];
  for (int i = 0; i < q; i++) {
    scanf("%d%d", &l[i], &r[i]);
  }
  for (int i = 0; i < q; i++) {
    printf("%d\n", ac[r[i]] - ac[l[i]]);
  }
}


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

int main() {
	int len, k, ans=0;
	cin>>len>>k;
	string str; cin>>str;
	for(int i=0; i<len; i++) ans+=str[i-1]==str[i];
	cout<<min(ans+2*k, len-1)<<'\n';
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int N;
	cin>>N;
	
	vector<vector<pair<int,int>>> V(N,vector<pair<int,int>>());
	
	for(int i=0;i<N;i++){
		int A;
		cin>>A;
		
		for(int j=0;j<A;j++){
			int x,y;
			cin>>x>>y;
			V[i].emplace_back(x-1,y);
		}
	}
	int ans = 0;
	for(int i=0;i<(1<<N);i++){
		bool f = true;
		vector<int> is_honest(N);
		for(int j=0;j<N;j++){
			if((i&(1<<j))==0)is_honest[j]=0;
			else is_honest[j]=1;
		}
		for(int j=0;j<N;j++){
			if(is_honest[j]==0)continue;
			for(int k=0;k<V[j].size();k++){
				if(is_honest[V[j][k].first]!=V[j][k].second){
					f=false;
					break;
				}
			}
		}
		if(f){
			int cnt = 0;
			for(int j=0;j<N;j++){
				if(is_honest[j])cnt++;
			}
			ans = max(cnt,ans);
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <stack>
#include <cmath>
#include <string>
#include <deque>
#include <map>
#include <iomanip>
#include <math.h>
#include <cstdlib>
#include <stdlib.h>
#include <set>
#include <unordered_set>
#include <cassert>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < n; ++i)
#define forn1(i, n) for (int i = 1; i <= n; ++i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll p = 997;
const ll base = 1e9 + 7;
const ll MAXN = 5e5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double PII = 3.14159265358979323846264338327950288419716939937510;
const double Epsilon = 1.19209e-9;
const ld fi = 1.6180339887498948482;
const ll one = 2147483647;
const ll two = 1e9 + 7;
void print_vectorll(vector<ll> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void print_vectorint(vector<int> & a) {
    forn(i, (int)a.size()) {
        cout << a[i] << " ";
    }
    cout << "\n";
}
void read_vector(vector<ll> & a, ll n) {
    ll h;
    forn(i, n) {
        cin >> h;
        a.pb(h);
    }
}
bool check_four(int a){
  int sum = 0;
  while(a){
    sum += a % 10;
    a /= 10;
  }
  return sum % 4 == 0;
}
void upd_max(int & a, int b){
  a = max(a, b);
}
void upd_min(int & a, int b){
  a = min(a, b);
}
ll n, a, b;
bool check_sum(ll ss){
    while(ss){
        if(ss % 10 != a && ss % 10 != b){
            return false;
        }
        ss /= 10;
    }
    return true;
}
ll upd_mod(ll a, ll MOD){
    if (a > MOD){
        a %= MOD;
    }
    return a;
}
ll bin_pow(ll a, ll pow){
    if (pow == 0){
        return 1;
    }
    if (pow == 1){
        return a;
    }
    ll h = bin_pow(a, pow / 2);
    if (pow % 2 == 0){
        return upd_mod(h * h, MOD);
    }
    return upd_mod(upd_mod(h * h, MOD) * a, MOD);
}
//#define DEBUG
int main(){
    FastIO;
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
    #endif // DEBUG
    ll n;
    cin >> n;
    ll ans = 1;
    for (int i = 0; i < 3; ++i){
        ans *= n;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
while N:
    l = 2
    N -= 1
    while N >= ((1<<(l - 1)) - 1)*81:
        N -= ((1<<(l - 1)) - 1)*81
        l += 1
    s = N // (((1<<(l - 1)) - 1)*9) + 1
    N %= ((1<<(l - 1)) - 1)*9
    t = -1
    ans = str(s)
    #print("N = ", N)
    while t < 0:
        for i in range(s):
            if(N >= (1<<(l - 2))):
                N -= (1<<(l - 2))
            else:
                t = i
                break

        if t >= 0:
            continue

        if N >= ((1<<(l - 2)) - 1)*9:
            N -= ((1<<(l - 2)) - 1)*9
            for i in range(s+1, 10):
                if N >= (1<<(l-2)):
                    N -= (1<<(l-2))
                else:
                    t = i
                    break
        else:
            l -= 1
            ans += str(s)
    #print("N = ", N)
    ans += str(t)
    if s > t:
        b = bin(N)[2:]
        ans_ = str(t)*(l - 1 - len(b))
        C = [str(t), str(s)]
    else:
        b = bin(N)[2:]
        ans_ = str(s)*(l - 1 - len(b))
        C = [str(s), str(t)]

    for i in range(len(b)):
        ans_ += C[int(b[i])]
    print(ans+ans_[1:])
    N = int(input())



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    int a, b; cin >> a >> b;
    if (a <= b) cout << a << endl;
    else cout << a-1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N_MAX=300000;
typedef pair<int,int> P;
int main()
{
  int n,nn,k,i,j;
  long long m,t;
  vector<long long> a;
  P b[19];
  decltype(a)::iterator it;
  cin >> k;
  for(i=0;i<=9;i++)
    a.push_back(i);
  b[1].first=0;
  b[1].second=2;
  b[2].first=10;
  for(n=2,m=1;n<19;n++,m*=10){
    for(nn=1;nn<n-1;nn++)
      for(j=b[nn].first;j<b[nn].second;j++){
        a.push_back(m*10+a[j]);
        i++;
      }
    for(j=b[n-1].first;j<b[n].first;j++){
      t=a[j]/m;
      if(t>1){
        a.push_back((t-1)*m*10+a[j]);
        i++;
      }
      if(t>0){
        a.push_back(t*m*10+a[j]);
        i++;
      }
      if(t<9){
        a.push_back((t+1)*m*10+a[j]);
        i++;
      }
    }
    b[n+1].first=i;
    sort(a.begin()+b[n].first,a.end());
    it=lower_bound(a.begin()+b[n].first,a.end(),20*m);
    b[n].second=(int)distance(a.begin(),it);
    if(i>k) break;
  }
  cout << a[k] << endl;
  return 0;
}

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

struct date {
    int y, m, d;
};

int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool isUru(int n) {
    return (n % 4 == 0 && (n % 100 || n % 400 == 0));
}

int main() {
    date d, e;
    while (true) {
        cin >> d.y >> d.m >> d.d >> e.y >> e.m >> e.d;
        if (d.y < 0 || d.m < 0 || d.d < 0 || e.y < 0 || e.m < 0 || e.d < 0) return 0; 
        int count = 0;
        if (e.y - d.y > 1) {
            count += (e.y - d.y - 1) * 365;
        }
        if (d.y == e.y) {
            for (int i = d.m + 1; i < e.m; i++) {
                count += month[i];
            }
        } else {
            for (int i = d.m + 1; i < 13; i++) {
                count += month[i];
            }
            for (int i = 1; i < e.m; i++) {
                count += month[i];
            }
        }
        if (d.y < e.y || d.m < e.m) {
            count += month[d.m] - d.d + 1;
            count += e.d - 1;
        } else {
            count += e.d - d.d;
        }

        if (d.m < 2 && isUru(d.y)) {
            count++;
        }
        if (e.m >= 2 && isUru(e.y)) {
            count++;
        }
        for (int i = d.y + 1; i < e.y; i++) {
            if (isUru(i)) count++;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3004
from bisect import bisect_left, bisect_right
import fileinput


MODULO = 1000000007
n = 0


# HANDLE INPUT
def handle_input():
    iterator = fileinput.input()
    global n
    n = int(next(iterator))
    takahashis = [None] * n
    for i in xrange(n):
        x, v = next(iterator).split()
        takahashis[i] = (int(x), int(v))
    return takahashis


def build_blocks(takahashis):
    result = [-1] * (n + 1)
    max_velocities = [0] * n
    min_velocities = [MODULO] * (n + 1)
    for i in xrange(n):
        max_velocities[i] = max(max_velocities[i - 1], takahashis[i][1])
    for i in xrange(n-1, -1, -1):
        min_velocities[i] = min(min_velocities[i + 1], takahashis[i][1])
    for i in xrange(n):
        current_velocity = takahashis[i][1]
        block_start = bisect_left(max_velocities, current_velocity)
        block_end = bisect_right(min_velocities, current_velocity) - 1
        result[block_end] = max(result[block_end], block_start)
    return result


def compute_possibilities(blocks):
    possibilities = [1] * (n + 2)
    zeros_end_cursor = -2
    for current_position in xrange(n):
        result = 2 * possibilities[current_position - 1]
        # Remove possibiltiies for (00..)1{.....} sequences.
        while zeros_end_cursor < blocks[current_position] - 1:
            result -= possibilities[zeros_end_cursor]
            zeros_end_cursor += 1
        possibilities[current_position] = result % MODULO
    return possibilities[n - 1]


def main():
    takahashis = handle_input()
    takahashis.sort()
    blocks = build_blocks(takahashis)
    return compute_possibilities(blocks)


if __name__ == '__main__':
    print main()


Measured memory_bytes: 40984
package main

import (
        "fmt"
)

func solution(n int, s string) int {
        out, x := 0, 0
        for i := 0; i < n; i++ {
                if s[i] == 'I' {
                        x++
                } else {
                        x--
                }
                out = max(out, x)
        }
        return out
}

func max(x, y int) int {
        if x > y {
                return x
        }
        return y
}
func main() {
        var n int
        var s string
        fmt.Scan(&n, &s)
        fmt.Println(solution(n, s))
}

Measured memory_bytes: 512
n,m = map(int,input().split())

A=[-1]*n

ans=0
for i in range(m):
    s,c = map(int,input().split())
    if A[s-1]!=-1 and A[s-1]!=c :
        ans=-1
        break
    else:
        A[s-1]=c

if A[0]==0 and n!=1 :
    ans=-1

if ans==-1 :
    print(ans)
    exit()
    
if A[0]==-1 and n!=1 :
    A[0]=1
for i in range(n):
    ans*=10
    if A[i]==-1 :
        A[i] = 0
    ans += A[i]



print(ans)

Measured memory_bytes: 9132
#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(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)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 = 2e18;
const ll MOD = 1000000007;
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);


int main() {
  int n;
  cin >> n;
  vl a(n);
  rep1(i, n) {
    cin >> a[i - 1];
    a[i - 1] -= i;
  }
  sort(all(a));
  ll d = a[n / 2];
  ll ans = 0;
  rep (i, n) {
    ans += abs(a[i] - d);
  }
  cout << ans << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, M;
ll K;
ll x[100010];
int k[100010];
int id[100010];
int to[100010];
ll df[100010];
bool vis[100010];
ll nd[100010];
double ans[100010];

int main() {
	scanf("%d", &N);

	rep(i, N) {
		scanf("%lld", &x[i]);
		if (i) df[i-1] = x[i] - x[i-1];
	}

	scanf("%d %lld", &M, &K);

	rep(i, N-1) id[i] = i;

	rep(i, M) {
		scanf("%d", &k[i]);
		--k[i];
		swap(id[k[i]-1], id[k[i]]);
	}

	rep(i, N-1) {
		to[id[i]] = i;//元iがここ
	}

	rep(i, N-1) {
		if (vis[i]) continue;
		vi vec;
		int p = i;

		while (!vis[p]) {
			vis[p] = 1;
			vec.pb(p);
			p = to[p];
		}

		int sz = vec.size();
		int m = K % sz;
		rep(j, sz) {
			nd[vec[(j+m)%sz]] = df[vec[j]];
		}
	}

	ans[0] = x[0];

	rep(i, N-1) ans[i+1] = ans[i] + nd[i];
	rep(i, N) printf("%.10f\n", ans[i]);

	return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll X,K,D;

void input() {
	cin>>X>>K>>D;
}

void solve() {
	if(abs(X)/D > K) {
		cout<<abs(X)-(D*K)<<endl;
		return;
	}
	K-=(abs(X)/D);
	X%=D;
	K%=2;
	if(K==1) X=abs(X)-D;
	cout<<abs(X)<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3644