akhauriyash/Code-Regression huggingface dataset:
S=list(input())
T=list(input())

from collections import Counter
Counter_S=Counter(S)
Counter_T=Counter(T)
S_num=list(Counter_S.values())
T_num=list(Counter_T.values())

S_num.sort()
T_num.sort()

if S_num==T_num:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 91060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<double> V(N);
    for(int i = 0; i < N; ++i){
        cin >> V[i];
    }

    sort(V.begin(), V.end());
    double ans = V[0];
    for(int i = 1; i < N; ++i){
        ans = (ans + V[i])/2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

typedef pair<ll, ll> P;

int main() {
    INIT;

    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> a(H, vector<ll>(W));
    rep(i, H) rep(j, W) cin >> a[i][j];

    vector<ll> b;
    rep(i, H) {
        if (i % 2 == 0) {
            rep(j, W) b.pb(a[i][j]);
        } else {
            repr(j, W - 1) b.pb(a[i][j]);
        }
    }

    // repv(b) cout << *it << " ";
    // cout << endl;

    vector<pair<P, P>> ans;

    rep(i, SZ(b) - 1) {
        if (b[i] % 2 == 1) {
            b[i]--;
            b[i + 1]++;

            ll yc = i / W;
            ll xc;
            if (yc % 2 == 0) {
                xc = i % W;
            } else {
                xc = (W - 1) - i % W;
            }
            xc++;
            yc++;

            ll yn = (i + 1) / W;
            ll xn;
            if (yn % 2 == 0) {
                xn = (i + 1) % W;
            } else {
                xn = (W - 1) - (i + 1) % W;
            }
            xn++;
            yn++;

            P pc = make_pair(yc, xc);
            P pn = make_pair(yn, xn);
            ans.pb({pc, pn});
        }
    }

    cout << SZ(ans) << endl;
    rep(i, SZ(ans)) {
        cout << ans[i].first.first << " " << ans[i].first.second << " "
             << ans[i].second.first << " " << ans[i].second.second << endl;
    }

    return 0;
}

Measured memory_bytes: 11336
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,x,c,d,counter;
    cin>>a>>b>>x;
    c=a/x;
    d=b/x;
    if(a%x==0)counter=(d-c)+1;
    else counter=d-c;
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int p[100002];
int r[100002];

void init(int n){
    for (int i = 0; i < n; ++i) {
        p[i]=i;
        r[i]=0;
    }
}


int find(int x){
	if(x != p[x]){
		p[x] = find(p[x]);
    }
   	return p[x];
}
     
void union_set(int x,int y){
	x = find(x);
	y = find(y);
	if(x==y) return;
	if(r[x] < r[y]){
		p[x] = y;	
	}else{
		p[y] = x;
		if(r[x] == r[y])r[x]++;
	}
	return ;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<ll>a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	if(n==1){
		cout << 0 << endl;
		return 0;
	}
	if(n==2&&m==1){
		cout << 0 << endl;
		return 0;
	}
	init(n);
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		union_set(x,y);
	}
	vector<ll>v(n,inf);
	vector<ll>w;
	set<int> st;
	for(int i=0;i<n;i++){
		int t = find(i);
		st.insert(t);
		if(v[t]!=inf){
			if(v[t]>a[i]){
				w.push_back(v[t]);
				v[t] = a[i];
			}else{
				w.push_back(a[i]);
			}
		}else{
			v[t] = a[i];
		}
	}
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		if(v[i]!=inf){
			ans += v[i];
		}
	}
	int cnt = st.size();
	if(cnt==1){
		cout << 0 << endl;
		return 0;
	}
	if(2*(cnt-1)>n){
		cout << "Impossible" << endl;
	}else{
		sort(w.begin(),w.end());
		for(int i=0;i<cnt-2;i++){
			ans += w[i];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
int main() {
     int N;
     cin >> N;
     int S = 0;
     int T = N;
     while(T > 0){
          S += T % 10;
          T = T / 10;
     }  
     if(N % S == 0) cout << "Yes" << endl;
     else cout << "No" << endl;
}

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

int main() {
  int a,b,c;  cin>>a>>b>>c;
  int n; cin>>n;
  int x,y,ans=0;
  rep(x,n/a+1){
    rep(y,n/b+1){
      if(n >= a*x + b*y && (n-a*x-b*y) % c == 0){ans++;}
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int max(const int x,const int y){return y<x?x:y;}
int main()
{
  int N=IN(),M=IN(),K=IN(),i=0,j=0,count=0,A[200000],B[200000];long long sum=0;
  while(i<N){A[i++]=IN();}
  while(j<M){B[j]=IN();if(sum+B[j]>1ll*K){break;}sum+=B[j++];}
  count=j--;i=0;
  while(i<N)
  {
    sum+=A[i++];
    while(sum>K&&j>=0)sum-=B[j--];
    if(sum>K)break;
    count=max(count,i+j+1);
  }
  return printf("%d\n",count),0;
}

Measured memory_bytes: 3164
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> w(n); REP(i, n) cin >> w[i];
  int ans = INF;
  FOR(i, 1, n) {
    int s1 = 0, s2 = 0;
    REP(j, i) s1 += w[j];
    FOR(j, i, n) s2 += w[j];
    ans = min(ans, abs(s1 - s2));
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [input() for i in range(N)]
ans = 'Yes'
for i in range(N-1): 
    if a[i][-1] != a[i+1][0]: # 最後の文字と次の文頭の文字が一致してなければNo
        ans = 'No'
    if a.count(a[i]) > 1: # その単語が2回以上でてきた場合はNo
        ans = 'No'
if a.count(a[N-1]) > 1:
        ans = 'No'
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
   int n,i,j;
   int flag=0;
   cin>>n;
   for(i=1;i<=9;i++)
   {
       for(j=1;j<=9;j++)
       {
           if(i*j==n)
           {flag=1;
           break;
           }
       }
   }
   if(flag)
    cout<<"Yes";
   else
    cout<<"No";

}



Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <cstdio>
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <complex>

using namespace std;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
#define PB push_back
#define MP make_pair
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

char str[88888];
int DP[88888][11];
int main(){
	while(1){
		scanf("%s", str);
		if(str[0] == '0')return 0;
		memset(DP, 0, sizeof(DP));
		int n = strlen(str);
		DP[0][str[0]-'0'] = 1;
		FOR(i,1,n){
			REP(j,11){
				if(i%2)DP[i][j] += DP[i-1][(j+(str[i]-'0'))%11];
				else DP[i][j] += DP[i-1][(j+11-(str[i]-'0'))%11];
			}
			if(str[i]!='0'){
				if(i%2)DP[i][11-(str[i]-'0')]++;
				else DP[i][str[i]-'0']++;
			}
		}
		int ret = 0;
		FOR(i,1,n){
			ret += DP[i][0];
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 5060
#include <stdio.h>

char x[200010];
int s1[200010],s2[200010];
int main()
{
	int a;
	scanf("%d",&a);
	scanf("%s",x+1);
	for(int i=1;i<=a;i++) s1[i] = s1[i-1] + (x[i]=='R'?1:0);
	for(int i=1;i<=a;i++) s2[i] = s2[i-1] + (x[i]=='W'?1:0);
	
	int ans = a;
	for(int i=1;i<=a+1;i++)
	{
		int b = s2[i-1];
		int c = s1[a] - s1[i-1];
		int d = b>c?b:c;
		ans = ans<d?ans:d;
	}
	printf("%d",ans);
}

Measured memory_bytes: 3488
#include <iostream>
#include <tuple>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;
void init();
#define REP(var, num) for(sll var = 0; var < num; var++)
typedef signed long long sll;
typedef unsigned long long ull;
/*
numeric_limits<sll>::max()
*/

int main() {
    init();
    sll y,m,d;
    char s;
    cin >> y>>s>>m>>s>>d;
    if (y < 2019 || (y == 2019 && m < 4) || (y == 2019 && m == 4 && d <= 30))
    cout << "Heisei" << endl;
    else
    cout << "TBD" << endl;
    return 0;
}

void init() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
using namespace std;
int num(int a, int b, int c) {
	return abs(b - a) + abs(c - b);
}
signed main()
{
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int mini = 1000;
	mini=min(num(a, b, c), mini);
	mini = min(num(a, c, b), mini);
	mini = min(num(b, a, c), mini);
	mini = min(num(b, c, a), mini);
	mini = min(num(c, b, a), mini);
	mini = min(num(c, a, b), mini);
	cout << mini;
}

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

int main() {
	int N, P[20010], R[20010];
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
		R[P[i]] = i;
	}
	for (int i = 1; i <= N; i++) {
		if (i != 1) cout << " ";
		cout << 25000 * i;
	}
	cout << endl;
	for (int i = 1; i <= N; i++) {
		if (i != 1) cout << " ";
		cout << 25000 * (N - i) + R[i];
	}
}

Measured memory_bytes: 768
<?php
fscanf(STDIN, "%d %d", $a, $b);
$squareNumber = (integer)($a . $b);
for ($i = 1; $i < $squareNumber; $i++) {
	if ($i * $i === $squareNumber) {
		echo 'Yes' . "\n";
		return 0;
	}
}
echo 'No' . "\n";


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

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

int main()
{
    int N;
    cin >> N;
    vector<int> num(1e+5+1, 0);
    REP(i, N){
        int A;
        cin >> A;
        ++num[A];
    }
    int Q;
    cin >> Q;

    long long ans = 0;
    REP(i, 1e+5+1) ans += i*num[i];
    REP(i, Q){
        int B, C;
        cin >> B >> C;
        ans += (C-B)*num[B];
        num[C] += num[B];
        num[B] = 0;
        cout << ans << endl;
    }

    return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL sgn(LL x){
  if(!x) return 0;
  return x / abs(x);
}

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

  LL N; cin >> N;
  VL xs(N);
  REP(i,N) cin >> xs[i];
  VL acc(N);
  acc[0] = xs[0];
  FOR(i,1,N) acc[i] = acc[i-1] + xs[i];

  LL ans = 1e18;
  for(LL sg_=-1;sg_<=1;sg_+=2){
	LL sg = sg_;
	LL sum = 0;
	LL tmp = 0;
	REP(i,N){
	  if(sgn(acc[i] + sum) != sg){
		tmp += abs(acc[i] + sum) + 1;
		if(sg > 0){
		  sum += -(acc[i] + sum) + 1;
		}
		else{
		  sum += -(acc[i] + sum) - 1;
		}
	  }
	  sg *= -1;
	}
	mini(ans, tmp);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e9+7

int main(){
	int n,k;
	cin >>n>>k;
	vector<long long int>a(n);
	vector<long long int>s;
	rep(i,n){
		cin>>a[i];
	}
	rep(i,n){
		long long int tmp =a[i];
		s.push_back(tmp);
			for (int j=i+1;j<n;++j){
			tmp += a[j];
			s.push_back(tmp);
		}
	}
	sort(s.begin(),s.end());
	long long int ans=0;
	for (int i=40;i>=0;--i){
		int cnt=0;
		rep(j,s.size())
			if (((ans+(1LL<<i))&s[j])==(ans+(1LL<<i))){
				cnt++;
			}
		if (cnt>=k){
			ans+=(1LL<<i);
		}
	}
	cout <<ans;
}

Measured memory_bytes: 6516
N, X, Y = map(int, input().split())
ans = [0]*N

A, B = N-(Y-X-1), Y-X-1
for i in range(1, A):
    ans[i] += A - i
ans[1] -= 1

if B % 2 == 0:
    C = [x for x in range(1, B//2 + 1)]
    C = C[1:] + C + [B//2 + 1]

    for i in range(len(C)):
        for j in range(1, X):
            ans[C[i] + j] += 1
        for j in range(1, N-Y+1):
            ans[C[i] + j] += 1

    for i in range(1, (B+2)//2):
        ans[i] += (B+2)
    ans[(B+2)//2] += (B+2)//2


else:
    C = [x for x in range(1, B//2 + 2)]
    C = C[1:] + C

    for i in range(len(C)):
        for j in range(1, X):
            ans[C[i] + j] += 1
        for j in range(1, N-Y+1):
            ans[C[i] + j] += 1

    for i in range(1, (B+2)//2 + 1):
        ans[i] += (B+2)


for i in range(1, N):
    print(ans[i])

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#include<queue>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 11234567890123456789
using namespace std;

ll lcm(ll a, ll b){
	ll root_a = a;
	ll root_b = b;
	ll tmp;
	/* 自然数 a > b を確認・入替 */
	if (a<b){
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	ll r = a % b;
	while (r != 0){
		a = b;
		b = r;
		r = a % b;
	}
	if (!(root_a % b)) return (root_a / b)*root_b;
	else return (root_b / b)*root_a;
}

int main(){
	ll n; cin >> n;
	vl t(n);
	ll mini = INF;
	ll ans = 1;
	rep(i, n){
		cin >> t[i];
		if (!i) ans = t[i];
		ans = lcm(ans, t[i]);
		mini = min(mini, t[i]);
	}ll maxi = 0;
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
char ch[2005][2005];
int a[2002][2002],b[2002][2002],c[2002][2002],d[2002][2002],n,m,i,j,x,maxim;
int main()
{
    cin>>n>>m;
    for(i=1; i<=n; i++)
        cin>>ch[i]+1;
    for(i=1; i<=n; i++)
        for(j=1; j<=m; j++)
            if(ch[i][j]=='.')
            {
                a[i][j]=a[i][j-1]+1;
                b[i][j]=b[i-1][j]+1;
            }
    for(i=n; i>=1; i--)
        for(j=m; j>=1; j--)
            if(ch[i][j]=='.')
            {
                c[i][j]=c[i][j+1]+1;
                d[i][j]=d[i+1][j]+1;
            }
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        if(ch[i][j]=='.')
    {
        x=a[i][j-1]+c[i][j+1]+b[i-1][j]+d[i+1][j]+1;
        if(x>maxim)maxim=x;
    }
    cout<<maxim;
    return 0;
}


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

int main()
{
  int a[100]={0};
  int N;
  int sum=0;
  int squ=0;
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>a[i];
    sum+=a[i];
    squ+=a[i]*a[i];
  }
  cout<<(sum*sum-squ)/2<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
//~ #pragma GCC optimize("Ofast, unroll-loops")
#include <iostream>
//~ #include <algorithm>
#include <vector>
#include <ctime>
#include <unordered_set>
#include <string>
#include <map>
#include <unordered_map>
#include <random>
#include <set>
#include <cassert>
#include <string.h>
#include <stack>
#include <functional>
#include <queue>
#include <numeric>
#include <bitset>
#include <iterator>
#include <algorithm>
#include <sstream>


#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
#define ii pair<int,int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);


using namespace std;
const int maxn = 1e5 + 10;
const int MAX = 1e3 + 10;
const int  mod = 1e9 + 7;
typedef vector<int> vi;
typedef long long ll;

int n, dp[maxn] , sum[maxn];

bool val[maxn];

int digsum( int n ) {
	int sum = 0;
	while(n){sum+= (n%10),n/=10;}
	return sum;
}

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	 
	cin >> n;
	for(int i =1 ;i <= n;i++)sum[i] = digsum(i);
	
	int ans = inf;
	for(int i = n -1;i >= n/2; --i){
		ans = min ( ans,   sum[n-i] + sum[n - (n-i)]  );
	}
	
	
	cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 640
A,B,K = map(int,input().split())

def print_ans(A,B):
        print(A,end=" ")
        print(B)


if A+B<=K:
    print("0 0")
elif A==B and A==0:
    print(A,end=" ")
    print(B)
else:

    if K>=A: 
        K-=A 
        A=0
        B-=K
        print_ans(A,B)
    else: 
        A-=K
        K=0
        print_ans(A,B)
        


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}


int main(){

    int a,b,c,n;
   
    cin >> n;
    
    a = ceil(double(n)/2);
    
    cout << a << endl;
    

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++) {
		cout << "x";
	}
	cout << endl;
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
 int h,m,s,t;
 scanf("%d",&t);
 if(0<=t && t<86400){
  h=t/3600;
  t=t%3600;
  m=t/60;
  s=t%60;
 }
 printf("%d:%d:%d\n",h,m,s);
 return 0;
}

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

int d[101];

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> d[i];
  }
  sort(d, d+N);
  int ans = 1;
  for (int i = 1; i < N; i++) {
    if (d[i] > d[i-1]) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<complex>
#include<list>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;




const ll INF = 1e18+7;


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


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);

	int n;
	cin >> n;
	list<int> lst;
	for (int i = 0; i < n; i++)
	{
		int c;
		string s;
		cin >> s;
		if (s == "insert") {
			cin >> c;
			lst.push_front(c);
		}
		if (s == "delete") {
			cin >> c;
			for (auto itr = lst.begin(); itr != lst.end();itr++) {
				if (*itr == c) {
					lst.erase(itr);
					break;
				}
			}
		}
		if (s == "deleteFirst") {
			lst.pop_front();
		}
		if (s == "deleteLast") {
			lst.pop_back();
		}
	}

	int cnt = 0;
	for (auto itr = lst.begin(); itr != lst.end(); itr++) {
		if (cnt++)cout << " ";
		cout << *itr;
	}
	cout << endl;



	return 0;
}



Measured memory_bytes: 34444
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
bool check(int n,int m,int x,int y) {return x>=0&&x<n&&y>=0&&y<m;}

set<int> d[1111][1111];
int main() {
  int n,m;
  cin >> n >> m;
  int a[n][m];
  vector<PP> v;
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> a[i][j];
      v.push_back(PP(a[i][j],P(i,j)));
    }
  }
  sort(v.begin(),v.end());
  int ans=0;
  for(int i=0; i<v.size(); i++) {
    int x=v[i].second.first,y=v[i].second.second;
    if(!d[x][y].size()) d[x][y].insert(v[i].first);
    if(d[x][y].size()>1) ans++;
    for(int k=0; k<4; k++) {
      int xx=x+dx[k],yy=y+dy[k];
      if(!check(n,m,xx,yy)) continue;
      if(a[x][y]<a[xx][yy]) {
        set<int>::iterator it=d[x][y].begin();
        for(int j=0; j<2; j++,it++) {
          if(it==d[x][y].end()) break;
          d[xx][yy].insert(*it);
        }
        while(d[xx][yy].size()>2) d[xx][yy].erase(d[xx][yy].begin());
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 160580
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<P> suzu(N);
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        suzu[i] = P(-a,i);
    }
    sort(suzu.begin(),suzu.end());
    vector<ll> cnt(N,0);
    int id = inf;
    suzu.emplace_back(0,0);
    for(int i=0; i<N; i++){
        chmin(id,suzu[i].second);
        cnt[id] += (ll)abs(suzu[i+1].first-suzu[i].first)*(i+1);
    }
    for(int i=0; i<N; i++){
        cout << cnt[i] << "\n";
    }
    return 0;
}

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

int main() {
    int n;
    long long ans = 0;
    cin >> n;
    vector<int> a(n + 1);
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        cin >> a.at(i);
        mp[i + a.at(i)]++;
    }

    for (int i = 1; i <= n; i++) {
        int x = i - a.at(i);
        if(x <= 0) continue;
        else ans += mp[x];
    }
    cout << ans << endl;
}

Measured memory_bytes: 14320
import numpy as np

n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]

cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        dist=0
        for k in range(d):
            dist+=(x[i][k]-x[j][k])**2
        for dist2 in range(int(np.sqrt(dist))+1):
            if dist2**2==dist:
                cnt+=1
print(cnt)


Measured memory_bytes: 21432
<?php
$s = trim(fgets(STDIN));

function F_kai($f_s){
	$c = strlen($f_s);
	if($c == 1){
		return ture;
	}
	if($c % 2 == 0){
		$left = substr($f_s, 0, $c / 2);
		$right = strrev(substr($f_s, $c / 2));
		if($left != $right){
			return false;
		}
		return true;
	}
	$left = substr($f_s, 0, floor($c / 2));
	$right = strrev(substr($f_s, ceil($c / 2)));
	if($left != $right){
		return false;
	}
	return true;
}

$ret = F_kai($s);
if($ret){
	$ret = F_kai(substr($s, 0, floor(strlen($s) / 2)));
	if($ret){
		echo 'Yes';
		exit;
	}
}

echo 'No';
?>


Measured memory_bytes: 4728
def main():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    res = 0
    for i in range(0, a + 1):
        for j in range(0, b + 1):
            for k in range(0, c + 1):
                if i * 500 + j * 100 + k * 50 == x:
                    res += 1
    print(res)


if __name__ == '__main__':
    main()


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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int price1,price2,price3;
    price1 = a*x + b*y;
    price2 = c*max(x,y)*2; //ABピザを max(x,y)*2 買い、余らせる
    price3 = c*min(x,y)*2;//ABピザを min(x,y)*2 買い、残りを買う
    if(x > y) price3 += a*(x-y);
    else if(x < y) price3 += b*(y-x);
    cout << min(min(price1,price2),price3) << endl;
    return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

a,b,k = getNM()

turn = "taka"
for i in range(k):

    if turn == "taka":
        if a %2 == 1:
            a -= 1
        a = a//2
        b += a

        turn = "ao"

    else:
        if b % 2 == 1:
            b -= 1
        b = b//2
        a += b
        turn= "taka"


print(a,b)

Measured memory_bytes: 3316
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		solve();
	}

	private static void solve() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pr = new PrintWriter(System.out);

		while (true) {
			int n = sc.nextInt();
			if(n==0) break;
			boolean[][] plan = new boolean[n][30];
			@SuppressWarnings("unchecked")
			Set<Integer>[] set = new Set[n];
			for (int k = 0; k < n; k++) {
				set[k] = new HashSet<Integer>();
				int tmp = sc.nextInt();
				for(int s=0;s<tmp;s++){
					plan[k][sc.nextInt()-1] = true;
					set[k].add(k);
				}
			}
			boolean finish = false;
			for(int d=0;d<30;d++){
				Set<Integer> tmp = new HashSet<Integer>();
				for(int s=0;s<n;s++){
					if(plan[s][d]){
						tmp.addAll(set[s]);
					}
				}
				for(int s=0;s<n;s++){
					if(plan[s][d]){
						set[s].addAll(tmp);
						if(set[s].size()==n){
							pr.println(d+1);
							finish = true;
							break;
						}
					}
				}
				if(finish) break;
			}
			if(finish!=true) pr.println(-1);
		}
		pr.flush();
		sc.close();

	}
}

Measured memory_bytes: 95256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	a, b, c, d := scanInt(), scanInt(), scanInt(), scanInt()

	for {
		c -= b
		if c <= 0 {
			fmt.Println("Yes")
			return
		}
		a -= d
		if a <= 0 {
			fmt.Println("No")
			return
		}
	}
}


Measured memory_bytes: 1752
#include <iostream>
#define MOD 1000003
using namespace std;
typedef long long ll;
ll Mf[MOD+1];
void Mfi(){
    Mf[0]=Mf[1]=1;
    for(int i=2;i<MOD+1;i++)Mf[i]=(Mf[i-1]*i)%MOD;
}
ll Mp(ll a, ll b){
    if(b==0)return 1;
    else if(b%2==0)return Mp((a*a)%MOD, b/2);
    return (a*Mp(a, b-1))%MOD;
}
ll Mc(ll a, ll b){
    if(a<b)return 0;
    ll c = (Mf[a]*Mp(Mf[a-b], MOD-2))%MOD;
    return (c*Mp(Mf[b], MOD-2))%MOD;
}
ll solve(ll x, ll d, ll n){
    if(x == 0)return 0;
    if(d == 0)return Mp(x, n);
    if(d == 1){
        if(x+n-1 >= MOD)return 0;
        return ( Mf[x+n-1] * Mp(Mf[x-1], MOD-2) )%MOD;
    }
    return ( solve((x * Mp(d, MOD-2)) % MOD, 1, n) * Mp(d, n) ) % MOD;
}
int main(void){
    int q;
    cin >> q;;
    Mfi();
    for(int i=0;i<q;i++){
        ll x, d, n;
        cin >> x >> d >> n;
        cout << solve(x, d, n) << endl;
    }
}


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

namespace エクサウィザーズ
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            string ans = "No";
            if (abc[0] == abc[1] && abc[1] == abc[2]) { ans = "Yes"; }
            Console.WriteLine(ans);
        }
    }
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vec a = ivec(m);
    int su = sum_(a);
    if (su <= n)
        print(n - su);
    else
        print(-1);

    return 0;
}


Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[1001][1001],mod=1000000007;
int n,m;
char mat[1001][1001];

ll solve(int i,int j)
{
    if(i<0 || j<0 || i>=n || j>=m) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    dp[i][j]=0;
    if(mat[i][j]=='#') return dp[i][j]=0;
    return dp[i][j]=(solve(i-1,j)+solve(i,j-1))%mod;
}


int main()
{
    int a,b; cin>>n>>m;
    
  memset(dp,-1,sizeof(dp));
  
  for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>mat[i][j];
  dp[0][0]=1;
  cout<<solve(n-1,m-1);
  
}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

string a, b, c;
bool ab[4010], ac[4010], bc[4010];
int ans = INF;

signed main() {
	cin >> a >> b >> c;
	int x = (int)a.size(), y = (int)b.size(), z = (int)c.size();
	for (int i = -y; i <= x; i++) {
		bool bl = true;
		for (int j = max((int)0, i); j < min(y + i, x); j++) {
			if (a[j] != '?'&&b[j + i * -1] != '?'&&a[j] != b[j + i * -1]) {
				bl = false;
				break;
			}
		}
		if (bl) {
			ab[i + 2005] = true;
		}
	}
	for (int i = -z; i <= x; i++) {
		bool bl = true;
		for (int j = max((int)0, i); j < min(z + i, x); j++) {
			if (a[j] != '?'&&c[j + i * -1] != '?'&&a[j] != c[j + i * -1]) {
				bl = false;
				break;
			}
		}
		if (bl) {
			ac[i + 2005] = true;
		}
	}
	for (int i = -z; i <= y; i++) {
		bool bl = true;
		for (int j = max((int)0, i); j < min(z + i, y); j++) {
			if (b[j] != '?'&&c[j + i * -1] != '?'&&b[j] != c[j + i * -1]) {
				bl = false;
				break;
			}
		}
		if (bl) {
			bc[i + 2005] = true;
		}
	}
	for (int i = -y; i <= x; i++) {
		for (int j = -z; j <= x; j++) {
			bool bl = true;
			if (!ab[i + 2005] || !ac[j + 2005] || (((i <= j && j - i <= y) || (j <= i && i - j <= z)) && (!bc[j - i + 2005]))) {
				bl = false;
			}
			if (bl) {
				ans = min(ans, max({ i + y,j + z,x }) - min({ (int)0,i,j }));
			}
		}
	}
	for (int i = -x; i <= y; i++) {
		for (int j = -z; j <= y; j++) {
			bool bl = true;
			if (!ab[i*-1 + 2005] || !bc[j + 2005] || (((i <= j && j - i <= x) || (j <= i && i - j <= z)) && (!ac[j - i + 2005]))) {
				bl = false;
			}
			if (bl) {
				ans = min(ans, max({ i + x,j + z,y }) - min({ (int)0,i,j }));
			}
		}
	}
	for (int i = -x; i <= z; i++) {
		for (int j = -y; j <= z; j++) {
			bool bl = true;
			if (!ac[i*-1 + 2005] || !bc[j*-1 + 2005] || (((i <= j && j - i <= x) || (j <= i && i - j <= y)) && (!ab[j - i + 2005]))) {
				bl = false;
			}
			if (bl) {
				ans = min(ans, max({ i + x,j + y,z }) - min({ (int)0,i,j }));
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
constexpr ll mod = ll(1e9 + 7);
#define endl '\n'
 
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
  // cin >> TT;
  while (TT--) {
    ll x;
    cin >> x;
    ll v = lcm(360,x);
    cout << v/x << endl;
  }
}


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

int main()
{
	int a, b, c, d;
	int sum1 = 0, sum2 = 0;
	scanf("%d%d%d%d", &a, &b, &c, &d);

	if (abs(a - c) <= d || (abs(a - b <= d) && abs(b - c) <= d))
	{
		printf("Yes\n");
	}

	else
		printf("No\n");



	
}



Measured memory_bytes: 128
use std::cmp::max;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a = Vec::new();
    for i in 0..n {
        let b: i64 = itr.next().unwrap().parse().unwrap();
        a.push((b, i as i64));
    }
    a.sort();
    a.reverse();

    let mut dp = vec![vec![0; 2020]; 2020];
    for i in 0..n {
        for j in 0..i + 1 {
            let k = i - j;
            dp[j + 1][k] = max(dp[j + 1][k], dp[j][k] + a[i].0 * (j as i64 - a[i].1).abs());
            dp[j][k + 1] = max(
                dp[j][k + 1],
                dp[j][k] + a[i].0 * ((n - k - 1) as i64 - a[i].1).abs(),
            );
        }
    }

    let mut ans = 0;
    for i in 0..n + 1 {
        ans = max(ans, dp[i][n - i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 34100
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;


int main() {
    int n;
    cin>>n;
    int ans=0;
    vector<vector<pair<int,int> > >vec(n, vector<pair<int,int> >());
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        for(int j=0, x, y;j<a;j++){
            cin>>x>>y;
            vec.at(i).push_back(make_pair(x, y));
        }
    }
    // 誰が正直者なのかを全通り数え上げる。
    for(int bit=0;bit<(1<<n);bit++){
        // bitから何番目の人が正直者なのかを数える
        vector<int>a;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                a.push_back(i);
            }
        }
        // 正直者の人だけ全探索
        bool flag=true;//そのbitの組み合わせがあり得るのかについてのフラグ。
        for(int i:a){
            for(auto j:vec.at(i)){
                if((j.second==0 && count(a.begin(), a.end(), j.first-1)!=0) or (j.second==1 && count(a.begin(), a.end(), j.first-1)==0)){ //count(a.begin(), a.end(), j.first!=0だけだと、正直者でない人が言った証言もcountされてしまっている
                    flag=false;
                    break;
                }
            }
            if(!flag)break;
        }

        if(flag){
            ans=max(ans,__builtin_popcount(bit));
        }
    }
    cout<<ans<<endl;







    return 0;
}


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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_set<lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,m;
vll a;
graph tree;
mat d;
set<lli> used;
lli k = 0;
lli ans = 0;

void dfs(lli x,lli s){
  used.insert(x);
  d[s].push_back(a[x]);
  for(lli y : tree[x]){
    if(used.count(y) == 0) dfs(y,s);
  }
}

void error(){
  cout << "Impossible" << endl;
  exit(0);
}

int main(){
  cin >> n >> m;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  for(lli i = 0;i < m;i++){
    lli a,b;
    cin >> a >> b;
    tree[a].insert(b);
    tree[b].insert(a);
  }
  d = mat(n);
  for(lli i = 0;i < n;i++){
    if(used.count(i) == 0) dfs(i,i);
  }
  for(lli i = 0;i < n;i++){
    if(d[i].size() != 0){
      k++;
      auto x = min_element(d[i].begin(),d[i].end());
      ans += *x;
      d[i].erase(x);
    }
  }
  if(k == 1){
    cout << 0 << endl;
    return 0;
  }
  k = (k-1)*2-k;
  vll b;
  for(lli i = 0;i < n;i++){
    for(lli j = 0;j < d[i].size();j++){
      b.push_back(d[i][j]);
    }
  }
  if(b.size() < k) error();
  sort(b.begin(),b.end());
  ans += accumulate(b.begin(),b.begin()+k,0ll);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 29600
#include <iostream>
#include <cstdio>
#include <cstring>
#define ll long long
const int MAXN = 1e5 + 7;
const ll p = 1e9 + 7;
const ll inv2 = 500000004ll;
ll n, m;
ll a[MAXN];
struct rec
{
    int x, y;
} q[MAXN];
ll f[3500][3500];

inline ll ksm(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = ans * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return ans;
}

int main()
{
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i <= m; i++)
    {
        scanf("%lld%lld", &q[i].x, &q[i].y);
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            f[i][j] = a[i] < a[j];
        }
    }
    for (int i = 1; i <= m; i++)
    {
        f[q[i].x][q[i].y] = f[q[i].y][q[i].x] = inv2 * (f[q[i].x][q[i].y] + f[q[i].y][q[i].x]) % p;
        for (int j = 1; j <= n; j++)
        {
            if (j != q[i].x && j != q[i].y)
            {
                f[j][q[i].x] = f[j][q[i].y] = inv2 * (f[j][q[i].x] + f[j][q[i].y]) % p;
                f[q[i].y][j] = f[q[i].x][j] = inv2 * (f[q[i].y][j] + f[q[i].x][j]) % p;
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j < i; j++)
        {
            ans += f[i][j];
        }
    }
    printf("%lld", ans % p * ksm(2, m) % p);
    return 0;
}

Measured memory_bytes: 86272
n = int(input())
a = [int(i) for i in input().split()]
count = 0

max_n = 0

for i in range(n):
    if max_n < a[i]:
        max_n = a[i]
    if max_n-a[i]>1:
        count += 1

if count >= 1:
    print("No")
else:
    print("Yes")

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

int main() {
  int N;
  cin>>N;
  int64_t t=0;
  for(int i=0;i<=N;i++) {
    t+=i;
  }
  for(int i=0;i<=N;i+=3) {
    t-=i;
  }
  for(int i=0;i<=N;i+=5) {
    t-=i;
  }
  for(int i=0;i<=N;i+=15) {
    t+=i;
  }
  cout<<t<<endl;
  return 0;
}


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


int main(){
    ll N;cin>>N;
    ll a[100010];
    rep(i,0,N)cin>>a[i];
    sort(a,a+N);
    double sta=a[N-1]/2.0,MIN=99999999999999.0;
    ll ans;
    rep(i,0,N-1){
        if(MIN>abs((double)a[i]-sta)){
            MIN=(double)min(MIN,abs((double)a[i]-sta));
            ans=a[i];
        }
    }
    cout<<a[N-1]<<" "<<ans<<endl;
    
}







Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
double dp[3004][3004]; 
int main()
{
	ll N,i,j;
	cin>>N;
	double a[N],sum=0.00;
	for(i=0;i<N;i++) cin>>a[i];
	dp[0][0]=(1.00-a[0]); dp[0][1]=a[0];
	for(i=1;i<N;i++)
	{
		for(j=0;j<=i+1;j++)
		{
			if(j==0) dp[i][j]=dp[i-1][j]*(1.00-a[i]);
			else if(j==i+1) dp[i][j]=dp[i-1][j-1]*a[i];
			else  dp[i][j]=dp[i-1][j]*(1.00-a[i])+dp[i-1][j-1]*a[i];
		}
	}
	for(j=(N+1)/2;j<=N;j++)
	{ sum+=dp[N-1][j]; }
	std::cout << std::fixed;
    std::cout << std::setprecision(10);
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    int n;
    cin>>n;
    vector<ll> v(n),sum_p(n),sum_m(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    ll ans_p=0;
    if(v[0]<=0){//sum[0]をプラスにする場合
        ans_p+=(abs(0-v[0])+1);
        sum_p[0]=1;
    }else{
        sum_p[0]=v[0];
    }
    for(int i=1;i<n;i++){
        sum_p[i]=sum_p[i-1]+v[i];
        if(i%2==1 && sum_p[i]>=0){//iは奇数のときマイナス
            ans_p+=(sum_p[i]+1);
            sum_p[i]=-1;
        }else if(i%2==1 && sum_p[i]<0){
            continue;
        }else if(i%2==0 && sum_p[i]<=0){//iは偶数のときプラス
            ans_p+=(abs(0-sum_p[i])+1);
            sum_p[i]=1;
        }else if(i%2==0 && sum_p[i]>0){
            continue;
        }
    }
    
    ll ans_m=0;
    if(v[0]>=0){//sum[0]をマイナスにする場合
        ans_m=(v[0]+1);
        sum_m[0]=-1;
    }else{
        sum_m[0]=v[0];
    }
    for(int i=1;i<n;i++){
        sum_m[i]=sum_m[i-1]+v[i];
        if(i%2==1 && sum_m[i]<=0){//iは奇数のときプラス
            ans_m+=(abs(0-sum_m[i])+1);
            sum_m[i]=1;
        }else if(i%2==1 && sum_m[i]>0){
            continue;
        }else if(i%2==0 && sum_m[i]>=0){
            ans_m+=(abs(0-sum_m[i])+1);
            sum_m[i]=-1;
        }else if(i%2==0 && sum_m[i]<0){
            continue;
        }
    }
    cout<<min(ans_p,ans_m)<<endl;
    return 0;
}

Measured memory_bytes: 2560