akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#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()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    cin >> N;
    V<int> a(N);
    rep(i, N) cin >> a[i];

    V<pii> vec(N);
    rep(i, N) vec[i] = mp(a[i], i);
    sort(ALL(vec));
    reverse(ALL(vec));
    int la = TEN(9) + 10, pos = N;
    ll num = 0;
    V<ll> ans(N);

    for (int pt = 0; pt < N; ++pt) {
        ans[pos] += num * (la - vec[pt].fi);
        la = vec[pt].fi;
        chmin(pos, vec[pt].se);
        num++;
    }
    ans[pos] += la * num;
    for (ll x : ans) {
        cout << x << '\n';
    }
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_N 1000000
#define INF 1000000

int a[MAX_N];
int b[MAX_N];


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  char c[3];
  
  for (int i = 0; i < 3; i++) {
    c[i] = S[i];
  }

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

  if(c[0] == c[1] && c[1] == c[2]) cout << "No" << endl;
  else  cout << "Yes" << endl;

  return 0;
  
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    int x,y;
    cin >> x >> y;
    if(x==y) a[i]=1;
  }
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(a[i]&&a[i+1]&&a[i+2]) ans++;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N;
    cin >> N;
    const ll MOD = 1e9 + 7;
    auto Add = [&](ll& x, ll y) { x = ( x + y % MOD ) % MOD; };
    auto Mul = [&](ll& x, ll y) { x = ( x * y % MOD ) % MOD; };
    vector<ll> dp(N+1), c(N+1);
    dp[0] = 1, c[0] = 1;
    for ( int i = 1; i <= N; i++ ) {
        Add(dp[i], dp[i-1]);
        if ( i >= 3 ) Add(dp[i], c[i-3]);
        Add(c[i], c[i-1]);
        Add(c[i], dp[i]);
    }
    ll ans = 0;
    for ( int i = 0; i <= N-2; i++ ) {
        ll x = dp[i];
        Mul(x, N-1);
        Mul(x, N-1);
        Add(ans, x);
    }
    {
        ll x = dp[N];
        Add(ans, x);
    }
    {
        ll x = dp[N-1];
        Mul(x, N-1);
        Add(ans, x);
    }
    for ( int i = 0; i <= N-2; i++ ) {
        ll x = dp[i];
        Mul(x, i+1);
        Add(ans, x);
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;

  int dp[n];
  dp[0] = 0;
  for ( int i = 1; i < n; i++ ) {
    dp[i] = dp[i-1];
    dp[i] += ( s[i-1] == 'A' && s[i] == 'C' ) ? 1 : 0;
  }

  while ( q-- > 0 ) {
    int l, r;
    cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;
  }
  return 0;
}


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

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int A;
    cin >> A;
    if(A>=1200)puts("ARC");
    else puts("ABC");
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main() {
	int i, j, k;
	int N, M, K;

	string S;
	cin >> S;

	const int na = 753;
	j = S[0] - '0';
	j *= 10;
	j += S[1] - '0';
	j *= 10;
	j += S[2] - '0';
	
	int ans = abs(j - na);
	rep(i, 3, S.size()) {
		j %= 100;
		j *= 10;
		j += S[i] - '0';
		ans = min(ans, abs(j - na));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//const int INF = 1e9;//INT_MAX=1<<31-1=2147483647
const ll INF = (ll)1e18;//1<<63-1=9223372036854775807
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



signed main() {
	ll s,c;
	cin >> s >> c;
	if(s*2>=c){
		p(c/2);
		return 0;
	}
	c=c-s*2;
	p(s+c/4);
		

	return 0;
}



Measured memory_bytes: 256
/*Program from Luvwgyx*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=5e2+10;
char s[maxn][maxn],a[maxn][maxn],b[maxn][maxn];
int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
void print(int x){
    if(x<0)putchar('-'),x=-x;
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
void write(int x){print(x);puts("");}
int main(){
    int n=read(),m=read();
    for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
    for(int i=1;i<=n;i+=2)for(int j=1;j<=m;j++)a[i][j]='#';
    for(int i=2;i<=n;i+=2)for(int j=1;j<=m;j++)a[i][j]='.';
    for(int i=1;i<=n;i+=2)for(int j=1;j<=m;j++)b[i][j]='.';
    for(int i=2;i<=n;i+=2)for(int j=1;j<=m;j++)b[i][j]='#';
    for(int i=1;i<=n;i++ )for(int j=1;j<=m;j++)if(s[i][j]=='#')a[i][j]=b[i][j]='#';
    for(int i=1;i<=n;i++ )a[i][1]='#',a[i][m]='.';
    for(int i=1;i<=n;i++ )b[i][1]='.',b[i][m]='#';
    for(int i=1;i<=n;i++ )printf("%s\n",a[i]+1);puts("");
    for(int i=1;i<=n;i++ )printf("%s\n",b[i]+1);
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string.h>
#define M 36

int N;

typedef struct {
  char suit;
  int value;
}Card;

Card C[M],S[M];


void bubblesort(Card *C,int N){
  int i,j;
  Card tmp;
  
  for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if(C[j].value<C[j-1].value){
	tmp=C[j-1];
	C[j-1]=C[j];
	C[j]=tmp;
    }
  }
}
}

void selectionsort(Card *C,int N){
  int i,j,minj;
  Card tmp;
  
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(C[j].value<C[minj].value){
	minj=j;
      }
    }
    tmp=C[minj];
    C[minj]=C[i];
    C[i]=tmp;
  }
}


int isStable(Card *in,Card *out,int N){
  int a=0,b=0,i;
  
  for(i=0;i<N;i++){
    if(strcmp(&in[i].suit,&out[i].suit)==0) a++;
  }
  for(i=0;i<N;i++){
    if(in[i].value==out[i].value) b++;
  }
 
  if(a!=b) return 0;

  else return 1;
}
    
 

int main(){
  int N,i;
  
  

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf(" %c%d",&C[i].suit,&C[i].value);
    S[i]=C[i];
  }
  
  

  bubblesort(C,N);
  
  for(i=0;i<N-1;i++){
  printf("%c%d ",C[i].suit,C[i].value);
  }
  printf("%c%d\n",C[N-1].suit,C[N-1].value);
  

  printf("Stable\n");

  selectionsort(S,N);
   for(i=0;i<N-1;i++){
  printf("%c%d ",S[i].suit,S[i].value);
  }
  printf("%c%d\n",S[N-1].suit,S[N-1].value);
  


  if(isStable(C,S,N)==0){
    printf("Not stable\n");
}
  else printf("Stable\n");
  

  return 0;
}


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

vector<vector<P>> G;
vector<int> ans;

void dfs(int v, int p, int color){
    ans[v] = color;
    for(auto nv : G[v]){
        if(nv.first == p) continue;
        if(nv.second & 1) dfs(nv.first, v, 1-color);
        else dfs(nv.first, v, color);
    }
}

int main() {
    int n;
    cin >> n;
    G.assign(n, vector<P>());
    rep(i,n-1){
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }
    ans.assign(n, 0);
    dfs(0, -1, 1);
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <functional>
#include <queue>

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

#define p2(a, b) cout << a << "\t" << b << endl
#define p3(a, b, c) cout << a << "\t" << b << "\t" << c << endl

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

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

int main() {
    ll a,b;
    cin >> a >> b;
    ll ans = 0;
    for(ll i = a; i <= b; ++i) {
        string s = to_string(i);
        string t = s;
        reverse(s.begin(), s.end());
        if (s == t) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
const int M=1000006;
int f[M],inv[M];
int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
	f[0]=1;
	rep(i,1,M){
		f[i]=(1LL*i*f[i-1])%hell;
	}
	inv[M-1]=expo(f[M-1],hell-2,hell);
	for(int i=M-2;i>=0;i--){
		inv[i]=(1LL*(i+1)*inv[i+1])%hell;
	}
}
int C(int n,int r){
	return (1LL*((1LL*f[n]*inv[r])%hell)*inv[n-r])%hell;
}
void solve(){
	compute();
    int n,m,k,ans=0;
    cin>>n>>m>>k;
    rep(r,0,k+1){
    	ans=(ans+C(n-1,r)*m%hell*expo(m-1,n-1-r,hell)%hell)%hell;
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 19280
N, M, K = map(int, input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
n = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
for i in range(K+1):
    temp = M*pow(M-1, N-1-i, p) * cmb(N-1, i, p)
    ans = (ans+ temp)%p
print(ans%p)

Measured memory_bytes: 128068
# -*- coding: utf-8 -*-
h, w = map(int, input().split())

s = [input() for i in range(h)]
l = [[0 for j in range(w)] for i in range(h)]
r = [[0 for j in range(w)] for i in range(h)]
u = [[0 for j in range(w)] for i in range(h)]
d = [[0 for j in range(w)] for i in range(h)]

for i in range(h):
    for j in range(w):
        l[i][j] = 0 if s[i][j] == '#' else 1 + (0 if j == 0 else l[i][j - 1])
    for j in range(w - 1, -1, -1):
        r[i][j] = 0 if s[i][j] == '#' else 1 + (0 if j == w - 1 else r[i][j + 1])

for j in range(w):
    for i in range(h):
        u[i][j] = 0 if s[i][j] == '#' else 1 + (0 if i == 0 else u[i - 1][j])
    for i in range(h - 1, -1, -1):
        d[i][j] = 0 if s[i][j] == '#' else 1 + (0 if i == h - 1 else d[i + 1][j])

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
print(ans)

Measured memory_bytes: 184708
#include <bits/stdc++.h>
typedef long long ll;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define All(x) (x).begin(),(x).end()
using namespace std;

signed main() {
	ll N,K;
	cin >> N >> K;
	vector<ll> A(N);

	vector<ll> bitadd(63, 0);
	for(auto &a : A) cin >> a;
	for(ll j=0;j<63;j++) {
		ll cnt1 = 0;
		for(int i=0;i<N;i++) {
			if(A[i] & (1LL << j)) cnt1++;
		}
		ll cnt0 = N - cnt1;
		if(cnt0 > cnt1) {
			bitadd[j] = (1LL << j) * (cnt0 - cnt1);
		}
	}

	ll ans = 0;
	ll asum = accumulate(A.begin(), A.end(), 0LL);
	ll pre = 0;

	for(ll i=62;i>=0;i--) {
		if(K & (1LL << i)) {
			ll tmpsum = asum;
			for(ll j=0;j<i;j++) tmpsum += bitadd[j];
			tmpsum += pre;
			ans = max(ans, tmpsum);
			pre += bitadd[i];
		}
	}
	ans = max(ans, pre + asum);
	cout << ans << endl;
}

Measured memory_bytes: 1024
s=gets.chomp.chars
t=gets.chomp.chars
ls=[nil]*26
lt=[nil]*26
ci=0
s.each.with_index do |c,i|
  if !ls[c.ord-97]
    ls[c.ord-97]=ci
    ci+=1
  end
  s[i]=ls[c.ord-97]
end
ci=0
t.each.with_index do |c,i|
  if !lt[c.ord-97]
    lt[c.ord-97]=ci
    ci+=1
  end
  t[i]=lt[c.ord-97]
end
puts s==t ? "Yes" : "No"


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

int main() {
int n;
cin>>n;
int len[n];
map<string,int> m;
string temp;
int l;
for(int i=0;i<n;i++){
    cin>>temp;
    cin>>l;
    m.insert({temp,i});
    len[i]=l;
}
string s;
cin>>s;
auto it= m.find(s);
int ind= it->second;
int ans=0;
for(int i=ind+1;i<n;i++){
    ans+= len[i];
}
cout<<ans;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define repr(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define all(x) (x).begin(),(x).end()
//#define DEBUG
#ifdef DEBUG
#include "debug.cpp"
#endif
using namespace std;

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

    int n; cin >> n;
    long* a = new long[n];
    long** b = new long*[n];
    rep(i, n)
    {
        cin >> a[i];
        b[i] = a + i;
    }
    sort(b, b + n, [](const long* k, const long* l){return *k < *l;});
    for (int i = 0; i < n; i += 2)
    {
        *b[i] = -1;
    }
    long sum = 0;
    for (int i = 0; i < n; i += 2)
    {
        sum += a[i] >= 0;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, k;
  cin >> n >> k;
  set<int> st;
  REP(i, k){
    int d;
    cin >> d;
    st.insert(d);
  };
  FORe(i, n, 100000){
    string s = to_string(i);
    int m = s.size();
    bool ok = true;
    REP(i, m) if(st.count(s[i]-'0')) ok = false;
    if(ok){
      cout << i << endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
  int n, a, b ;
  cin >> n >> a >> b ;
  if(a*n > b)
  {
  	cout << b << endl; 
  }
  else 
  {
cout << a*n << endl ;
  }
  return 0 ; 
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/

int main() {
	int x,y;
	std::cin >> x >> y;
	int l=x*2;
	int r=x*4;
	if(y<l||y>r||y%2==1) {
		print("No");
	} else print("Yes");
}


Measured memory_bytes: 3632
// Created by ...
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'

#define vll vector< ll >
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<ll,ll> 
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;
using ll = long long;
ll md=MD;

ll exp(ll a,ll b){ll r=1ll;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(ll a,ll b){if(a<b)return a; return b;}
ll Max(ll a,ll b){if(a>b)return a; return b;}
int32_t main() {
    IOS;

        long double a,b;
        cin>>a>>b;
        cout<<(long long)(a*b);
    return 0;
}

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

int main() {
  int n;cin>>n;
  vector<int> w(n);
  int cnt=0;
  rep(i,n){
    cin>>w[i];
    cnt+=w[i];
  }
  int a=0,ans=1e9;
  rep(i,n-1){
    a+=w[i];
    ans=min(ans,abs(cnt-a-a));
  }
  cout<<ans<<endl;
}

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

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int x, ans = 0;
    scanf("%d", &x);
    int tmp = x / 500;
    ans += tmp * 1000;
    x -= tmp * 500;
    ans += (x / 5) * 5;
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>


int top,S[1000];

void push(int x){
  S[++top]=x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[1];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }else{
      push(atoi(s));
        
    }
  }
  printf("%d\n",pop());
  return 0;
}

Measured memory_bytes: 548
# include<iostream>
using namespace std;
const  int MAXN = 2e5+5;
int A[MAXN];
int B[MAXN];
int C[MAXN];
int main ()
{
	 long long N,K;
	 cin>>N>>K;

	 for(int i=1;i<=N;i++)
	 {
	 	 cin>>A[i];
	 }
	 

	 long long id=1;
	 long long t=0;
      C[t++]=1;
     while(B[id]==0)
     {
     	  B[id]=1;
     	  id = A[id];
          C[t++]=id;	 
	 }
	 
	 long long begin;
	 for(int i=0;i<t;i++)
	 {
	 	   if(C[i]==id)
	 	   {
	 	   	   begin = i;
	 	   	   break;
			}
	 }
	 
	

	 begin++;
	 if(K<=begin)
     {
     	  cout<<C[K]<<endl;
	 }
	 else
	 {
	 	   cout<<C[(K-begin)%(t-begin)+begin]<<endl; 
		  }	 
	 
	  
	  
	
	
}

Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  string S;
  cin>>S;
  sort(all(S));
 string T="abcdefghijklmnopqrstuvwxyz";
 for(ll i=0;i<26;i++) {
   bool a=true;
   for(auto x:S) {
     if(x==T[i]) {
       a=false;
     }
   }
   if(a) {
    cout<<T[i]<<endl;
    return 0;
   }
   }

     cout<<"None"<<endl;
   
 }

Measured memory_bytes: 3788
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int X,A,B;

int main(){
    cin>>X>>A>>B;
    out((X-A)%B);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;

int vs[10];

int main(void) {
  int res = 0;
  int mini = 10;
  REP(i, 5) {
    scanf("%d", &vs[i]);
    res += (vs[i] + 9) / 10 * 10;
    if(vs[i] % 10 != 0) {
      mini = min(mini, vs[i] % 10);
    }
  }
  res = res - 10 + mini;
  cout << res << endl;
  return 0;
}


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

char S [15];
char T [15];
char U [15];
int A;
int B;

scanf ("%s %s", S, T);
scanf ("%d %d", &A, &B);
scanf ("%s", U);

if (S[0] == U[0]){

	printf ("%d %d\n", A-1, B);
}
else if (T[0] == U[0]) {

printf ("%d %d\n",A, B-1);
}


	return 0;
}


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

int main(){
  int n; cin >> n;
  vector<int> a(n-1);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<int> ans(n+1);
  for(int i = 0; i < n-1; i++) ans[a[i]]++;
  for(int i = 1; i <= n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

bool compare(pair<int, int> a, pair<int, int> b)
{
  return a.second < b.second;
}

int main()
{
  int N;
  string S[2];
  cin >> N >> S[0] >> S[1];
  vector<int> t;
  for (int i = 0; i < N; ++i)
  {
    if (S[0][i] == S[1][i])
    {
      t.push_back(1);
    }
    else
    {
      t.push_back(2);
      ++i;
    }
  }
  long long ans = 0;
  if (t[0] == 1)
    ans = 3;
  else
    ans = 6;
  int last = t[0];
  for (int i = 1; i < t.size(); ++i)
  {
    if (last == 1)
    {
      if (t[i] == 1)
      {
        ans *= 2ll;
        last = 1;
      }
      else
      {
        ans *= 2ll;
        last = 2;
      }
    }
    else if (last == 2)
    {
      if (t[i] == 1)
      {
        last = 1;
      }
      else
      {
        ans *= 3ll;
        last = 2;
      }
    }
    ans %= mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>

using namespace std;

static const int kModulo = 998'244'353;

int pow(int x, int y) {
    if (y == 0)
        return 1;
    if (y % 2)
        return 1LL * pow(x, y - 1) * x % kModulo;
    int v = pow(x, y / 2);
    return 1LL * v * v % kModulo;
}

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

    int N, A, B; int64_t K; cin >> N >> A >> B >> K;

    vector<int> fact(N + 1), ifact(N + 1);
    fact[0] = ifact[0] = 1;
    fact[1] = ifact[1] = 1;
    for (int i = 2; i <= N; ++i) {
        fact[i] = 1LL * fact[i - 1] * i % kModulo;
        ifact[i] = pow(fact[i], kModulo - 2);
    }

    auto comb = [&](int N, int K) {
        int aux = 1LL * fact[N] * ifact[K] % kModulo;
        return 1LL * aux * ifact[N - K] % kModulo;
    };

    int answer = 0;
    for (int x = 0; x <= N; ++x) {
        int64_t left = K - 1LL * x * A;
        if (left < 0)
            break;
        if (left % B)
            continue;
        int64_t y = left / B;
        if (y > N)
            continue;
        answer = (answer + 1LL * comb(N, x) * comb(N, y)) % kModulo;
    }

    cout << answer << "\n";
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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


int main() {

    ll N, M, L;
    cin >> N >> M >> L;
    vector<vector<ll>> d(N, vector<ll>(N, INF));
    REP(i, N) d[i][i] = 0;
    ll a, b, c;
    REP(i, M){
        cin >> a >> b >> c;
        a--;
        b--;
        d[a][b] = c;
        d[b][a] = c;
    } 
    ll Q;
    cin >> Q;
    vector<ll> s(Q), t(Q);
    REP(i, Q) {
        cin >> s[i] >> t[i];
        s[i]--;
        t[i]--;
    }


    REP(k, N) REP(i, N) REP(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    vector<vector<ll>> d1(N, vector<ll>(N, INF));
    REP(i, N) REP(j, N) if (i != j && d[i][j] <= L) d1[i][j] = 1;
    REP(i, N) d1[i][i] = 0;
    REP(k, N) REP(i, N) REP(j, N) d1[i][j] = min(d1[i][j], d1[i][k] + d1[k][j]);

    REP(i, Q){
        int ans = d1[s[i]][t[i]] < INF ? d1[s[i]][t[i]] - 1 : -1;
        cout << ans << endl;
    }

    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	double t, x;
	cin >> t >> x;
	cout << fixed << setprecision(12) << t / x << endl;
}

Measured memory_bytes: 256
import sys
from functools import reduce

N, x = list(map(int, input().split()))
arr = list(map(int, input().split()))

if x == 0:
    print(reduce(lambda acc, x: acc + x, arr))
    sys.exit()

cnt = 0
prv = 0

for i in range(N):
    diff = max(arr[i] + prv - x,0)
    cnt += diff
    arr[i] -= diff
    prv = arr[i]

print(cnt)


Measured memory_bytes: 14684
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  long t1,t2;
  cin >> t1 >> t2;
  long a1,a2,b1,b2;
  cin >> a1 >> a2 >> b1 >> b2;
  long c1 = a1 - b1;
  long c2 = a2 - b2;
  if(c1 > 0 && c2 > 0){
    cout << 0 << endl;
    return 0;
  }
  if(c1 < 0 && c2 < 0){
    cout << 0 << endl;
    return 0;
  }
  if(abs(c1)*t1 > abs(c2)*t2){
    cout << 0 << endl;
    return 0;
  }
  if(abs(c1)*t1 == abs(c2)*t2){
    cout << "infinity" << endl;
    return 0;
  }
  long tmp = abs(c1)*t1;
  long d = abs(c2)*t2 - abs(c1)*t1;
  cout << (tmp / d) + (tmp + d - 1)/d << endl;
}


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

int main() {
  	int A, B, C, D;
  	cin >> A >> B >> C >> D;
  
  	int ta, ao;
  	ta = (C - 1) / B + 1;
  	ao = (A - 1) / D + 1;
  
  	if (ta <= ao) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define all(v)          v.begin(),v.end()

#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

// inline int setBit(int n,int pos) { return n = n | (1 << pos); }
// inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
// inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }

// int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
// int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// unsigned int num = rng();
// shuffle(V.begin(), V.end(), rng);

/******************************************************************************************/

// const int MAX = 500010;
// const int INF = 0x3f3f3f3f;
// const int MOD = 1000000007;

// inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
// inline int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
// inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }


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

    // freopen("in", "r", stdin); 
    // freopen("out", "w", stdout);
    
    
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;
    cout << max(b - a - k, 0) << '\n';
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int w, h;
    cin >> w >> h;
    vector<string> s(w+1);
    REP(i,w) cin >> s[i];
    REP(i,w) s[i].push_back('.');

    int x = 0;
    REP(i,w) REP(j,h) x += (s[i][j] == '#');

    int i = 0, j = 0, y = 1;
    while (i < w-1 || j < h-1){
        y++;
        if (s[i+1][j] == '#'){
            i++;
            continue;
        }
        if (s[i][j+1] == '#'){
            j++;
            continue;
        }
        cout << "Impossible" << endl;
        return 0;
    }

    if (x == y) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools
import math

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]
d = 0
lis = [x for x in range(N)] # 0からn-1までのリスト
 
permutations_lis = itertools.permutations(lis)# 全ての場合のリストを生成

for one_case in permutations_lis:
    i = 0
    for num in one_case:
        if i == 0:
            a = num
            i += 1
            continue

        x = ((xy[num][0])-(xy[a][0]))**2
        y = ((xy[num][1])-(xy[a][1]))**2
        d += (x + y) **(1/2)

        a = num

print(d / math.factorial(N))

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

int main()
{
    int x,a,b;
    cin >> x >> a >> b;
    
    if(b>a)
    {
        if(x>=b-a)
        {
            cout<< "safe";
        }
        else
        {
            cout << "dangerous";
        }
    }
    else if(a>b)
    {
        cout << "delicious";
    }
    else
    {
        cout << "delicious";
    }
    
    
    
}




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

#define bit(n) (1 << n)

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

    int m, k;
    cin >> m >> k;
    int others = 0;
    for (int i = 0; i < bit(m); i++) {
        if (i != k) {
            others ^= i;
        }
    }
    if (k == 0) {
        for (int i = 0; i < bit(m); i++) {
            if (i > 0) {
                cout << ' ';
            }
            cout << i << ' ' << i;
        }
        cout << endl;
    } else if (k == others) {
        cout << k;
        for (int i = 0; i < bit(m); i++) {
            if (i != k) {
                cout << ' ' << i;
            }
        }
        cout << ' ' << k;
        for (int i = bit(m) - 1; i >= 0; i--) {
            if (i != k) {
                cout << ' ' << i;
            }
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}

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

using namespace std;

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

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vector<ll> p(a),q(b),r(c);
	rep(i,a)cin>>p[i];
	rep(i,b)cin>>q[i];
	rep(i,c)cin>>r[i];

	sort(all(p));
	reverse(all(p));
	sort(all(q));
	reverse(all(q));

	vector<ll> tmp;
	rep(i,x) tmp.push_back(p[i]);
	rep(i,y)tmp.push_back(q[i]);
	rep(i,c)tmp.push_back(r[i]);

	sort(all(tmp));
	reverse(all(tmp));
	ll ans=0;
	rep(i,x+y)ans+=tmp[i];

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 9792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  string s,t;
  while(cin>>s,s!="."){
	cin>>t;
	//cout<<"A"<<endl;
	vector<string> vs[2],vt[2];
	int cnt=0;
	string tmp="";
	for(int i=0;i<s.size();i++){
	  if(s[i]=='"'){
		vs[cnt%2].push_back(tmp);
		tmp="";
		cnt++;
	  }else tmp+=s[i];
	}
	vs[cnt%2].push_back(tmp);
	//cout<<"A"<<endl;
	
	tmp="";
	cnt=0;
	for(int i=0;i<t.size();i++){
	  if(t[i]=='"'){
		vt[cnt%2].push_back(tmp);
		tmp="";
		cnt++;
	  }else tmp+=t[i];
	}
	vt[cnt%2].push_back(tmp);
	//	cout<<"A"<<endl;
	int flg=0;
	for(int i=0;i<2;i++)
	  if(vs[i].size()!=vt[i].size()){
		cout<<"DIFFERENT"<<endl;
		flg=1;
		break;
	  }
	if(flg)continue;
	//	cout<<"A"<<endl;
	int f=0;
	for(int i=0;i<vs[0].size();i++){
	  if(vs[0][i]!=vt[0][i])f+=2;
	}
	for(int i=0;i<vs[1].size();i++){
	  if(vs[1][i]!=vt[1][i])f+=1;
	}
	if(f==0)cout<<"IDENTICAL"<<endl;
	else if(f==1)cout<<"CLOSE"<<endl;
	else cout<<"DIFFERENT"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    int maxi = 0;
    rep(i,0,N){
        int x;
        cin >> x;
        if(maxi > x){
            cout << "No" << endl;
            return 0;
        }
        if(maxi < x){
            maxi = x-1;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
diff = A - B
if diff % 2 == 0:
    print(abs(diff//2))
else:
    l = A - 1
    r = N - B
    if l < r:
        print((B - l - 2)//2 + l + 1)
    else:
        print((N - A - r - 1)//2 + r + 1)


Measured memory_bytes: 2940
import copy

def check_lots(start, goal, line):
    for i in range(len(line)):
        for j in range(len(line[i])):
            if line[i][j] == 1:
                if j == start - 1:
                    start -= 1
                elif j == start:
                    start += 1
    return start == goal

while True:
    n = int(input())
    if n == 0:
        break
    m = int(input())
    s = int(input())
    d = int(input())
    l = []
    for i in range(d):
        l.append([0] + list(map(int, list(input()))) + [0])
    d_ans = 0
    n_ans = 0
    if check_lots(m, s, l):
        print(0)
    else:
        for i in range(d):
            for j in range(1, n):
                l_tmp = copy.deepcopy(l[:])
                if sum(l[i][j-1:j+2]) > 0:
                    continue
                l_tmp[i][j] = 1
                if check_lots(m, s, l_tmp):
                    d_ans = i + 1
                    n_ans = j
                    break
            else:
                continue
            break
        if d_ans:
            print(d_ans, n_ans)
        else:
            print(1)



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

int main() {
  int N, L;
  cin >> N >> L;
  if ((L < 0) && (N + L - 1 < 0))
  cout << ((N - 1) * (N + 2 * L - 2) / 2) << endl;
  else if ((L > 0) && (N + L - 1 > 0))
  cout << ((N - 1) * (N + 2 * L) / 2) << endl;
  else
  cout << (N * (N + 2 * L - 1) / 2) << endl;
}


Measured memory_bytes: 256
while 1:
        n = input()
        if n == 0: break
        a,b = (0,0)
        for i in range(n):
                x = map(int, raw_input().split())
                if x[0] > x[1]:
                        a += x[0] + x[1]
                elif x[0] < x[1]:
                        b += x[0] + x[1]
                else:
                        a += x[0]
                        b += x[0]
        print str(a) + ' ' + str(b)

Measured memory_bytes: 4476
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
#define p(s) std::cout << s ;
#define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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;
}

//想定解答との絶対誤差または相対誤差が 10−6以下の場合+1以上だしておく。適当に15とかでもおｋ．
//cout << fixed << setprecision(15);

int main() {
    int N;
    cin >> N;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    vi a(N);
    rep(i, 0, N) {
        cin >> a[i];
    }
    int res = INF;
    sort(a.begin(), a.end());
    rep(i, a.front(), a.back()+1) {
        int sum = 0;
        rep(j, 0, N) {
            sum += int(pow(a[j]-i, 2));
        }
        res = min(res, sum);
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

signed main()
{
    int n, k;
    cin >> n >> k;
    vi a(n);
    forn(i, n) cin >> a[i];
    int L = 0, R = 1e9;
    while (L + 1 < R)
    {
        ll cnt = 0;
        int M = (L + R) / 2;
        for (int i = 0; i < n; i++)
        {
            int z = (a[i] + M - 1) / M;
            cnt += z - 1;
        }
        if (cnt <= k) R = M;
        else L = M;
    }
    cout << R;
}


Measured memory_bytes: 4044
def main():
    A, B = map(int, input().split())
    S = input()
    for i in range(A+B+1):
        if i == A:
            if S[i] != "-":
                print("No")
                return
        elif not S[i].isdigit():
            print("No")
            return
    print("Yes")

main()

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n,q;
string a;
char s[e5];
char t[e5];
char d[e5];

ll ans_l,ans_r;

bool solve_left(ll x){
  for(ll i = 0;i < q;i++){
    if(s[x] == t[i]){
      if(d[i] == 'L') x--;
      else x++;
      if(x <= 0) return true;
      if(x > n) return false;
    }
  }
  return false;
}

bool solve_right(ll x){
  for(ll i = 0;i < q;i++){
    if(s[x] == t[i]){
      if(d[i] == 'L') x--;
      else x++;
      if(x <= 0) return true;
      if(x > n) return false;
    }
  }
  return true;
}

int main(){
  cin >> n >> q;
  cin >> a;
  for(ll i = 1;i <= n;i++){
    s[i] = a[i-1];
  }

  for(ll i = 0;i < q;i++){
    cin >> t[i] >> d[i];
  }
  ll bottom = 0;
  ll top = n+1;
  while(top-bottom > 1){
    ll middle = (top+bottom)/2;
    if(solve_left(middle)) bottom = middle;
    else top = middle;
  }
  ans_l = bottom;
  bottom = 0;
  top = n+1;
  while(top-bottom > 1){
    ll middle = (top+bottom)/2;
    if(solve_right(middle)) bottom = middle;
    else top = middle;

  }
  ans_r = top;
  cerr << ans_l << " " << ans_r << endl;
  cout << ans_r-ans_l-1 << endl;

}


Measured memory_bytes: 4868
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;


int count(vvi x, vvi f){
    int cnt = 0;
    rep(i, 5)rep(j, 2){
        if(x[i][j] && f[i][j]) cnt++;
    }
    return cnt;
}

int main(){
    //入力部
    int n;
    cin >> n;
    vector<vvi> F(n, vvi(5, vi(2)));
    rep(i, n){
        rep(j, 5){
            cin >> F[i][j][0] >> F[i][j][1];
        }
    }
    vvi P(n, vi(11));
    rep(i, n){
        rep(j, 11){
            cin >> P[i][j];
        }
    }

    vvi confirm(5, vi(2));

    //処理部
    int ans = -INF;
    rrep(i, (1<<10) - 1){
        vvi x(5, vi(2));
        int tmp_i = i;
        rep(xi, 5){
            x[xi][0] = (tmp_i&1);
            x[xi][1] = ((tmp_i>>1)&1);
            tmp_i = tmp_i>>2;
        }
        
        int bene = 0;
        
        //printf("%d:\n", i);
        rep(j, n){
            bene += P[j][count(x, F[j])];
            //printf("%d ", P[j][count(x, F[j])]);
        }
        //printf("\n\n");

        if(ans < bene){
            confirm = x;
            ans = bene;
            //printf("%d %d\n", i, bene);
        }
    }

    /*
    rep(i, n){rep(j, 5){
        rep(k, 2){
            printf("%d, ", F[i][j][k]);
        }
        printf("\n");
    }printf("\n");}
    
    
    rep(i, 5){rep(j, 2){
        printf("%d, ", confirm[i][j]);
    }printf("\n");}
    */


    //出力部
    cout << ans << endl;

    return 0;
}

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

int main() {
  string s,ans="yes";
  cin >> s;
  sort(s.begin(),s.end());
  for(long i=0;i<s.size()-1;i++) {
    if(s[i]==s[i+1]) ans="no";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
#

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    w, h, x, y = input_int_list()
    area = (w * h) / 2
    bl = (w == 2 * x and h == 2 * y)
    print(area, 1 if bl else 0)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61860