akhauriyash/Code-Regression huggingface dataset:
from math import cos, sin, radians

pos = [0, 0]
b1 = 0
angle = 0
while True:
    a, b = map(int, raw_input().split(','))
    if a == 0 and b == 0:
        break
    rad = radians(angle)
    pos[0] += -sin(rad)*a
    pos[1] += cos(rad)*a
    angle += b
print -int(pos[0])
print int(pos[1])

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

int main()
{
	set<int> st;
	for(int i=0;i<=101;i++)
		st.insert(i);
	int n,x;
	cin>>x>>n;
	for(int i=1;i<=n;i++)
	{
		int p;
		cin>>p;
		st.erase(p);
	}
	int ans=0;
	for(auto it:st)
		if(abs(it-x)<abs(ans-x))
			ans=it;
	cout<<ans;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,x,y;
	cin>>x>>y;
	for(i=0;i<=x;i++){
		for(j=0;j<=x;j++){
			if(i+j==x&&2*i+4*j==y){
				cout<<"Yes"; return 0;
			}
		}
	}
	cout<<"No";
	return 0;	
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main
//------------------------------------------

signed main(){
    // 入力
    int a, b, k, c;
    cin >> a >> b >> k;
    if(a>=k){
        cout << a - k <<" "<< b;
    }
    else if(b>=k-a){
        cout << 0 <<" "<< b - (k - a);
    }
    else{
        cout << 0 <<" "<< 0;
    }
}


Measured memory_bytes: 256
while True:
    n=int(input())
    A=0
    B=0
    C=0
    D=0
    E=0
    F=0
    G=0
    H=0
    I=0
    J=0
    if n==0:
        break
    for i in range(n):
        a=int(input())
        if a==0:
            A=A+1
        elif a==1:
            B=B+1
        elif a==2:
            C=C+1
        elif a==3:
            D=D+1
        elif a==4:
            E=E+1
        elif a==5:
            F=F+1
        elif a==6:
            G=G+1
        elif a==7:
            H=H+1
        elif a==8:
            I=I+1
        else:
            J=J+1
    if A>0:
        print('*'*A)
    else:
        print('-')
    if B>0:
        print('*'*B)
    else:
        print('-')
    if C>0:
        print('*'*C)
    else:
        print('-')
    if D>0:
        print('*'*D)
    else:
        print('-')
    if E>0:
        print('*'*E)
    else:
        print('-')
    if F>0:
        print('*'*F)
    else:
        print('-')
    if G>0:
        print('*'*G)
    else:
        print('-')
    if H>0:
        print('*'*H)
    else:
        print('-')
    if I>0:
        print('*'*I)
    else:
        print('-')
    if J>0:
        print('*'*J)
    else:
        print('-')


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout<<endl
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())

typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

int main()
{
	string s, t;
	cin >> s >> t;
	co(t + s);
	return 0;
}


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

int eu(int a, int b){ // a > b
  int r=a%b;
  if(r==0) return b;
  return eu(b,r);
}

int main(){
  int n,m;
  cin>> n >> m;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin>> a[i];
  
  for(int i=0; i<n; i++) a[i]/=2;
  sort(a.begin(),a.end()); reverse(a.begin(),a.end());
  int64_t lcm=a[0];
  for(int i=1; i<n; i++){
    int64_t new_lcm=lcm*a[i]/eu(lcm,a[i]);
    if(new_lcm/lcm%2==0 || new_lcm/a[i]%2==0 || new_lcm>m){
      cout<< 0 << endl;
      return 0;
    }
    lcm=new_lcm;
  }
  
  int ans=0;
  for(int i=lcm; i<=m; i+=2*lcm) ans++;
  cout<< ans <<endl;
  return 0;
}
//a/2の奇数倍が最小公倍数(b)ならbの奇数倍が半公倍数

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>

using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;

int main()
{
	string s;
	cin >> s;
	for(int i =0;i<3;i++){
		for(int j= 0;j<3;j++){
			if(s[i] != s[j]) return cout << "Yes\n",0;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int num[20];
bool can[100000];

void dfs(int i,int sum){
  can[sum] = 1;
  if( sum>2000 || i == n) return;
  dfs(i+1,sum+num[i]);
  dfs(i+1,sum);
}

int main(){

  cin>>n;
  for(int i=0;i<n;i++)cin>>num[i];
  dfs(0,0);
  int q;
  cin>>q;
  while(q--){
    int a;
    cin>>a;
    cout<<(can[a]? "yes":"no")<<endl;

  }


  return 0;
}

Measured memory_bytes: 3092
#include <cstdio>
#include <iostream>
#include <string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>

const long long INF = 1000000007;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int , pii> piii;
typedef pair<pii, pii> piiii;

ll n, k;
ll candy[111];
ll dp[101][100011]; //dp[n][k] : 1~n까지 k이하 개의 캔디 나눠주기, dp[N][K]-dp[N][K-1]구하면됨.

ll ret(ll a, ll b) {
	if (a > 0) return a % b;
	if (a%b == 0) return 0;
	return b + a % b;
}


int main() {	
	scanf("%lld %lld", &n, &k);
	ll sum=0;
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", candy + i);
		fill(dp[i], dp[i] + k + 1, 0);
		sum += candy[i];
	}
	if (k == 0) {
		printf("1\n");
		return 0;
	}
	if (k > sum) {
		printf("0\n");
		return 0;
	}
	for (ll i = 0; i <= k; i++) {
		if (i > candy[1]) dp[1][i] = candy[1] + 1;
		else dp[1][i] = i + 1;
	}
	for (ll i = 1; i <= n; i++) dp[i][0] = 1;

	for (ll i = 2; i <= n; i++) {
		for (ll j = 1; j <= k; j++) {
			if (candy[i] >= j) dp[i][j] = ret(dp[i][j - 1] + dp[i - 1][j], INF);
			else dp[i][j] = ret(dp[i][j - 1] + dp[i - 1][j] - dp[i - 1][j - 1 - candy[i]], INF);
		}
	}
	
	printf("%lld", ret(dp[n][k] - dp[n][k - 1],INF));
	
}


Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin >> n;
  vector<ll> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i]--;
    b[a[i]]=i;
  }
  set<ll> st,st2;
  ll ans=0;
  st.insert(-1);
  st.insert(n);
  st2.insert(1);
  st2.insert(-n);
  for(int i=0;i<n;i++){
    auto itr=st.upper_bound(b[i]);
    auto itr2=st2.upper_bound(-b[i]);
    ans+=(*itr-b[i])*(b[i]+*itr2)*(i+1);
    st.insert(b[i]);
    st2.insert(-b[i]);
  }
  cout << ans << endl;
}

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

int main() {
  int N;
  string S;
  cin >>N;
  cin>>S;
  int m=3000001;
  vector<int> west(N);
  vector<int> east(N);

  if(S[0]=='W'){
    west[0] = 1;
  }
  if(S[0]=='E'){
    east[0] = 1;
  }

  for(int i=1;i<=N-1;i++){
    if(S[i]=='W'){
      west[i] = west[i-1]+1;
      east[i] = east[i-1];
    }
    if(S[i]=='E'){
      west[i] = west[i-1];
      east[i] = east[i-1]+1;
    }
  }

  //for(int i=0;i<N;i++){
   // cout<<west[i]<<" "<<east[i]<<endl;
  //}

  for(int i=0;i<N;i++){
    int c=0;
    if(i==0) c = east[N-1]-east[0];
    else if(i==N-1) c= west[N-2];
    else c = west[i-1] +east[N-1]- east[i];
    m=min(m,c);
  }
cout<<m<<endl;

  }


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::vector<int64_t> a(n);
  std::cin >> a;

  const auto sum = summation(a.cbegin(), a.cend());

  std::set<int64_t> y;
  int64_t i = 1;
  while (i * i <= sum) {
    if (sum % i == 0) {
      y.insert(i);
      y.insert(sum / i);
    }
    i++;
  }

  for (auto itr = y.crbegin(); itr != y.crend(); itr++) {
    const auto val = *itr;

    std::multiset<int64_t> tmp;

    int64_t count = 0;
    for (const auto j : a) {
      tmp.insert(j % val);
      count += j % val;
    }
    if (count % val != 0) {
      break;
    }
    const auto n = count / val;

    const auto least = a.size() - n;

    int64_t con = 0;
    auto itr2 = tmp.cbegin();
    for (int64_t i = 0; i < least; i++, itr2++) {
      con += *itr2;
    }

    if (con <= k) {
      std::cout << val << std::endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
using namespace std;

using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;

int N;
Graph G;

vector<int> ans;

void dfs(int v, int p, int c) {
	ans[v] = c;
	for(auto e : G[v]) {
		if(e.first == p) continue;
		if(e.second % 2 == 1) dfs(e.first, v, 1 - c);
		else dfs(e.first, v, c);
	}
}

int main() {
	scanf("%d", &N);
	G.assign(N, vector<Edge>());
	for(int i = 0; i < N - 1; i++) {
		int u, v, w;
		scanf("%d %d %d", &u, &v, &w);
		G[u-1].push_back(Edge(v-1, w));
		G[v-1].push_back(Edge(u-1, w));
	}
	
	ans.assign(N, 0);
	dfs(0, -1, 0);
	
	for(auto v : ans) printf("%d\n", v);
	
	return 0;
}

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

using namespace std;

const int maxn = 1e5 + 20, maxx = 102;

int a[maxx], n, m;
vector<int> fard;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 0; i < m; i++) 
	{
		cin >> a[i];
		if (a[i] % 2) fard.push_back(i);
	}
//	sort(fard.begin(), fard.end());
	if (m == 1 && n == 1) return cout << 1 << endl << 1 << endl << 1 << endl, 0;
	if (m == 1) return cout << a[0] << endl << 2 << endl << a[0] - 1 << " " << 1 << endl, 0;
	if (fard.size() > 2) return cout << "Impossible" << endl, 0;
	if (fard.size())
		swap(a[m-1], a[fard[0]]);
	if (fard.size() > 1)
		swap(a[0], a[fard[1]]);
//	if (fard.size() == 2 && n == 2) return cout << a[0] << " " << a[1] << endl << 1 << endl << 2 << endl, 0;
//	if (a[0] == 1 && a[m-1] == 1) while (true) cout << 0 / 0 << endl;
//	if (a[0] == 1) swap(a[0], a[m-1]);
	for(int i = 0; i < m; i++)
		cout << a[i] << " ";
	cout << endl << (a[0] == 1 ? m - 1 : m) << endl;
	for(int i = 0; i < m; i++) 
	{
		if (!i)
		{
			if (a[i] != 1) cout << a[i] - 1 << " ";
		}
		else if (i == m-1) cout << a[i] + 1 << " ";
		else	cout << a[i] << " ";
	}
	cout << endl;
//	for(int i = 0; i < m; i++) cout << a[i] << " ";
//	cout << endl << 1 << endl << n << endl;
//	cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c;
    d =(a+b+c);
    if(d % 2 == 0)
    {
        if(d/2 == a || d/2 == b || d/2 == c)
        {
            cout << " Yes " ;
        }
        else
        {
            cout << " No " ;
        }
    }

    else
    {
        cout << "No ";
    }





    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>

int main(){
    int n;
    double a,x,x2;
    while(true){
        scanf("%d", &n);
        if(n==0){
            break;
        }
        x = x2 = 0;
        for(int i = 0; i<n; i++){
            scanf("%lf", &a);
            x += a;
            x2 += (a*a);
        }
        printf("%lf\n", sqrt(x2/n - (x/n)*(x/n)));
    }
    return 0;
}


Measured memory_bytes: 2732
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

int main(){
    string s;
    cin >> s;
    ll n=s.size();
    ll cnt=0;
    ll temp=1;
    ll last;
    ll first;
    int p=1;
    int q=0;
    rep(i,n){
        if(i==n-1){
            //cerr<<temp<<endl;
            if(temp==n){
                q=1;
            }
            cnt+=temp/2;
            last=temp;
            continue;
        }
        if(s[i]==s[i+1]){
            temp++;
        }else{
            //cerr<<temp<<endl;
            if(p){
                first=temp;
            }
            p=0;
            cnt+=temp/2;
            temp=1;
        }
    }
    cerr<<cnt<<endl;
    ll k;
    cin >> k;
    if(q){
        ll tp=n*k/2;
        cout<<tp<<endl;
        return 0;
    }
    ll ans=0;
    ans=k*cnt;
    if(s[0]==s[n-1]){
        cerr<<first<<last<<endl;
        ans-=(first/2+last/2-(first+last)/2)*(k-1);
        cout<<ans<<endl;
    }else{
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol]<<",";cerr<<"}"<<endl;}
#define inf 100000000
#include<queue>
#define N 1001000
int n,m,i,o,p,ans;
vector<int> a[N],b;
priority_queue<int,vector<int>,greater<int> > q;
int main()
{
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		scanf("%d %d",&o,&p);
		a[o].pb(p);
	}
	int t=0;
	for (i=0;i<=m;i++)
	{
		for (int j=0;j<a[i].size();j++)
		{
			if (t<i) t++,q.push(a[i][j]);
			else
			{
				q.push(a[i][j]);
				b.pb(q.top());q.pop();
			}
		}
	}
	//pr(t);
	sort(b.begin(),b.end(),greater<int>());
//	pri(b,b.size()-1);
	int s=m+1;
	ans=b.size();
	for (i=0;i<b.size();i++)
	{
		if (s==t+1) break;
		if (b[i]<s) s--,ans--;
	}
	printf("%d\n",ans);
}
	

Measured memory_bytes: 28664
#include<iostream>
#include<cstdio>
const int N=105;
int n,a[2][N];
int main() {
    scanf("%d",&n);
    for(int j=0;j<2;j++) for(int i=1;i<=n;i++) scanf("%d",a[j]+i), a[j][i]+=a[j][i-1];
    int ans=a[0][1]+a[1][n];
    for(int i=2;i<=n;i++) ans=std::max(ans,a[0][i]+a[1][n]-a[1][i-1]);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m;
  cin >> n >> m;
  if (n % 2 == 1) {
    FOR(i, 1, m + 1) { cout << i << " " << n + 1 - i << endl; }
    return 0;
  }

  vector<bool> seen(n + 1, false);
  ll cnt = 0;
  ll l = n / 2, r = n / 2 + 1;
  while (true) {
    cout << l << " " << r << endl;
    seen[l] = seen[r] = true;
    cnt++;
    l--, r++;
    if (cnt == m) {
      return 0;
    }
    if (abs(r - l) >= n / 2) {
      break;
    }
  }
  while (true) {
    if (abs(r - l) % 2 == 1) {
      l--;
    }
    cout << l << " " << r << endl;
    l--, r++;
    if (l == 0) {
      l = n;
    }
    cnt++;
    if (cnt == m) {
      return 0;
    }
  }
}

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

int main(){
    string s;
    cin >> s;
    vector<bool> isexist(26, false);
    for(int i = 0; i < s.length(); i++) isexist[s[i]-'a'] = true;
    string ans = "None";
    for(int i = 0; i < 26; i++){
        if(!isexist[i]){
            ans = (i+'a');
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

vec<int> ans(1000000,-1);

int main() {
    int N,M;
    cin >> N >> M;
    vec<vec<int>> G(N,vec<int>());
    rep(i,M){
        int A,B;
        cin >> A >> B;
        --A,--B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    queue<pair<int,int>> q;
    q.push({0,0});
    while(!q.empty()){
        int now = q.front().first;
        int par = q.front().second;
        q.pop();
        if(ans[now] != -1) continue;
        ans[now] = par+1;
        for(auto e:G[now]){
            q.push({e,now});
        }
    }


    cout << "Yes" << endl;
    for(int i=1;i<N;++i){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 15800
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(10);
#define int long long
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define tr(x) for(auto it:x)
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
int N=100001;
int mod=1e9+7;
int min(int a,int b){if(a<b) return a; else return b;}
int max(int a,int b){if(a>b) return a; else return b;}
int power(int a,int b){int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int p, int q){if(p%q==0) return q; else{return gcd(q,p%q);}} 
int32_t main()
{
    IOS;
    int t=1;
    //cin>>t;
    while(t--) 
    {
    	int a, b, c, k;
    	cin>>a>>b>>c>>k;
    	cout<<min(k,a)-max(k-a-b,0);
    }
    return 0;
}

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

int main()
{
  int n, m, c, cnt = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  
  for(int i=0; i<m; i++)
  {
    cin >> b[i];
  }
  for(int i=0; i<n; i++)
  {
    int score = c;
    for(int j=0; j<m; j++)
    {
      int a;
      cin >> a;
      score += a * b[j];
    }
    if(score > 0)
      cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
int main()
{
	string s;
	cin >> s;
	int n;
	n=s.size();
	int a[100010]={};
	a[0]=1;
	repp(i, 1, n+1)
	{
		if(i>4)
		{
			if((s[i-1]=='m')&&(s[i-2]=='a')&&(s[i-3]=='e')&&(s[i-4]=='r')&&(s[i-5]=='d'))
			{
				if(a[i-5]==1)
				{
					a[i]=1;
				}
			}
			if((s[i-1]=='e')&&(s[i-2]=='s')&&(s[i-3]=='a')&&(s[i-4]=='r')&&(s[i-5]=='e'))
			{
				if(a[i-5]==1)
				{
					a[i]=1;
				}
			}
		}
		if(i>5)
		{
			if((s[i-1]=='r')&&(s[i-2]=='e')&&(s[i-3]=='s')&&(s[i-4]=='a')&&(s[i-5]=='r')&&(s[i-6]=='e'))
			{
				if(a[i-6]==1)
				{
					a[i]=1;
				}
			}
		}
		if(i>6)
		{
			if((s[i-1]=='r')&&(s[i-2]=='e')&&(s[i-3]=='m')&&(s[i-4]=='a')&&(s[i-5]=='e')&&(s[i-6]=='r')&&(s[i-7]=='d'))
			{
				if(a[i-7]==1)
				{
					a[i]=1;
				}
			}
		}
	}
	if(a[n]==1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

ll mygcd(ll x,ll y){
    if(x <= y){
        if(x == 0)
            return y;
        else
            return mygcd(y%x,x);      
    }else{
        if(y == 0)
            return x;
        else
        {
            return mygcd(y,x%y);
        }
        
    }
}

ll lcdcalc(ll N,ll C,ll D){
    ll c = N / C;
    ll d = N / D;

    ll g = mygcd(C,D);

    ll lcd = C / g * D;

    ll nlcd = N / lcd;

    return N - c - d + nlcd;
    
}

int main(){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;

    cout << lcdcalc(B,C,D) - lcdcalc(A-1,C,D) << endl;

}

Measured memory_bytes: 3604
a,b = map(int, input().split())
if a%3 == 0 or b%3 == 0:
    print(0)
else:
    #二通り考えられる
    x = a // 2
    tmp = a*b
    for i in range(b):
        s = a * (i+1)
        t = (b-i-1)*x
        u = a*b-s-t
        tmp = min(tmp,max(s,t,u)-min(s,t,u))
    y = b // 2
    tmpa = a*b
    for i in range(a):
        s = b * (i+1)
        t = (a-i-1)*y
        u = a*b-s-t
        tmpa = min(tmpa,max(s,t,u)-min(s,t,u))
    tmpb = a*b

    print(min(tmp,tmpa,a,b))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n, m;
    cin >> n >> m;    
    
    bool ans = false;
    vector<bool> v(n, false);

    rep(i, m){
        int a, b;
        cin >> a >> b;

        if(a == 1){
            if(v[b-1] == true)
                ans = true;
            else    
                v[b-1] = true;
        }
        if(b == n){
            if(v[a-1])
                ans = true;
            else
                v[a-1] = true;
        }
    }

    if(ans)
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE LambdaCase            #-}
{-# LANGUAGE MagicHash             #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE MultiWayIf            #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE ViewPatterns          #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Storable         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [h, w] <- map read.words <$> getLine :: IO [Int]
    B.PS p 0 l <- C.hGetNonBlocking IO.stdin (h*(w+1))
    let mat = U.unsafeFromForeignPtr0 p l
    print $ solve h (w+1) mat

solve :: Int -> Int -> U.Vector Word8 -> Int
solve h w mat = subtract 1 . U.maximum $ U.zipWith (+) lr ud
  where
    trans :: U.Vector Int -> U.Vector Int
    trans m = U.concatMap (\i ->
      U.map (U.unsafeIndex m) $ U.iterateN w (+h) i
      )
      $ U.generate h id

    lr :: U.Vector Int
    lr = U.concatMap (\i ->
          U.scanl1' (\acc x -> if x == 0 then 0 else max acc x)
            . U.postscanr' (\c acc -> if c /= B.c2w '.' then 0 else acc + 1) 0
            $ U.unsafeSlice (i * w) w mat
        )
        $ U.generate h id

    ud :: U.Vector Int
    ud = trans
        . U.concatMap (\j ->
            U.scanl1' (\acc x -> if x == 0 then 0 else max acc x)
              . U.postscanr' (\c acc -> if c /= B.c2w '.' then 0 else acc + 1) 0
              $ U.map (U.unsafeIndex mat) $ U.iterateN h (+w) j
        )
        $ U.generate w id


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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	string a,b;
	cin>>a>>b;
	if(sz(a)>sz(b)){
		cout<<"GREATER";
		return 0;
	}
	if(sz(a)<sz(b)){
		cout<<"LESS";
		return 0;
	}
	for(int i=0;i<sz(a);i++){
		if(a[i]!=b[i]){
			if((int)a[i]>(int)b[i]){
				cout<<"GREATER";
				return 0;
			}
			else{
				cout<<"LESS";
				return 0;
			}
		}
	}
	cout<<"EQUAL";
	
	
}

Measured memory_bytes: 3596
def con(n, lists):
  cnt = 0
  for i in range(1, n-1):
    if lists[i-1] > lists[i] > lists[i+1] or lists[i+1] > lists[i] > lists[i-1]:
      cnt += 1
  return cnt

n = int(input())
p = list(map(int, input().split()))
print(con(n, p))

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    vector<int> x(5);
    rep(i, 5) cin >> x[i];
    rep(i, 5) {
        if(x[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N)cin >> A[i];
    vector<int> res(N);
    rep(i,N){
        res[A[i]-1]=i+1;
    }
    rep(i,N)cout << res[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

const int MAX = 8;
bool G[MAX][MAX];

int dfs(int v, int n, bool visited[MAX]) {
    bool all_visited = true;

    rep(i, n) {
        if(!visited[i]) {
            all_visited = false;
        }
    }

    if(all_visited) {
        return 1;
    }

    int ret = 0;

    rep(i, n) {
        if(!G[v][i]) {
            continue;
        }
        if(visited[i]) {
            continue;
        }

        visited[i] = true;

        ret += dfs(i, n, visited);

        visited[i] = false;
    }

    return ret;
}

int main() {
    int n, m;
    cin >> n >> m;

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a][b] = G[b][a] = true;
    }

    bool visited[MAX];
    rep(i, n) {
        visited[i] = false;
    }
    visited[0] = true;
    
    cout << dfs(0, n, visited);
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())
a = a-1

def calc(input):
  if(input%4 == 1):
    return 1
  elif(input%4 == 2):
    return 1^input
  elif(input%4 == 3):
    return 0
  else:
    return input
  
print(calc(a)^calc(b))
  

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define size_of(a) (int)a.size()

typedef double Double;
Double EPS = 1e-9;

typedef struct Point {
	Double x, y;
	Point (Double _x, Double _y) : x(_x), y(_y) {}
	
	Point operator + (const Point& a) const {
		return Point(this->x + a.x, this->y + a.y);
	}
	
	Point operator - (const Point& a) const {
		return Point(this->x - a.x, this->y - a.y);
	}
	
	Point operator * (Double a) const {
		return Point(this->x * a, this->y * a);
	}
	
	Point operator / (Double a) const {
		return Point(this->x / a, this->y / a);
	}
} Vector;

Double norm(const Point& a) {
	return a.x * a.x + a.y * a.y;
}

Double abs(const Point& a) {
	return sqrt(norm(a));
}

Vector unit_vector(const Vector& a) {
	return a / abs(a);
}

Double angle(Double a, Double b, Double c) {
	return acos((b * b + c * c - a * a) / (2.0 * b * c));
}

Point rotate(const Vector& v, Double s) {
	return Point(v.x * cos(s) - v.y * sin(s),
				  v.x * sin(s) + v.y * cos(s));
}

struct Circle {
	Point c; Double r;
	Circle(Point _c, Double _r) : c(_c), r(_r) {}
};

int circle_intersect(const Circle& a, const Circle& b) {
	Double d = abs(a.c - b.c);
	if (a.r + b.r + EPS < d) return 0;
	if (b.r + d + EPS < a.r) return -3;
	if (a.r + d + EPS < b.r) return -4;
	if (fabs(a.r + b.r - d) < EPS) return 1;
	if (fabs(b.r + d - a.r) < EPS) return 3;
	if (fabs(a.r + d - b.r) < EPS) return 4;
	return 2;
}

vector< Point > cross_point(const Circle& a, const Circle& b) {
	vector< Point > res;
	Point x = unit_vector(b.c - a.c) * a.r;
	int ci = circle_intersect(a, b);
	
	if (ci > 0) {
		if (ci != 2) {
			res.push_back(a.c + x);
		} else {
			Double s = angle(b.r, abs(b.c - a.c), a.r);
			res.push_back(a.c + rotate(x, s));
			res.push_back(a.c + rotate(x, -s));
		}
	}
	
	return res;
}

bool inter(const Circle& c, const Point& p) {
	Double dist = abs(c.c - p);
	return dist < c.r + EPS;
}

int n;
vector< Circle > vc;

void solve() {
	vector< Point > vp;
	for_(i,0,n) vp.push_back(vc[i].c);
	
	for_(i,0,n) for_(j,i+1,n) {
		vector< Point > vv = cross_point(vc[i], vc[j]);
		for_(k,0,size_of(vv)) vp.push_back(vv[k]);
	}
	
	int ans = 0;
	for_(i,0,size_of(vp)) {
		int cnt = 0;
		for_(j,0,n) if (inter(vc[j], vp[i])) ++cnt;
		ans = max(ans, cnt);
	}
	
	cout << ans << endl;
}

int main() {
	while (cin >> n, n) {
		vc.clear();
		
		for_(i,0,n) {
			Double x, y; scanf("%lf,%lf", &x, &y);
			vc.push_back(Circle(Point(x,y), 1.0));
		}
		
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 1372
#include<bits/stdc++.h>
using namespace std;
int fun(long long int n)
{
    if(n<0)
        return -n;
    else
        return n;
}
int main()
{
    long long int n,i,a[105],max,j;
    while(scanf("%lld",&n)==1)
    {
        for(i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
        }
        max=fun(a[0]-a[1]);
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                if(max<fun(a[i]-a[j]))
                    max=fun(a[i]-a[j]);
            }
        }
        printf("%lld\n",max);
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)
int gcd(int a, int b){if(a>b) swap(a,b); return a==0 ? b : gcd(b%a,a);}

bool isHEISEI(int y,int m,int d){
    return (y == 2019) ? (m == 4 ? true : (m < 4) ) : (y < 2019);
}

int main(){
    int Y,M,D;
    scanf("%d/%d/%d",&Y,&M,&D);
    printf( isHEISEI(Y,M,D) ? "Heisei\n" : "TBD\n" );
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define max(a,b) (a>b?a:b)
int N,M,W[400],i,j,k,S[400],L[400],P[400],r,dp[400];

int main()
{
	scanf("%d",&N);
	for(i=0;i<N;i++)scanf("%d%d%d",S+i,L+i,P+i);
	memset(dp,-1,sizeof(dp));
	dp[0]=0;
	for(i=0;i<N;i++)
		for(j=S[i];j<400;j++)
			for(k=max(0,j-L[i]);k<=j-S[i];k++)
				if(dp[k]!=-1)
					dp[j]=max(dp[j],dp[k]+P[i]);

	scanf("%d",&M);
	for(i=0;i<M;i++)scanf("%d",W+i);
	for(i=0;i<M;i++)
		if(dp[W[i]]==-1)
		{
			puts("-1");
			return 0;
		}
	for(i=0;i<M;i++)
		printf("%d\n",dp[W[i]]);
	return 0;
}

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

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

  if(A[A.length() - 1] == B[0] && B[B.length() - 1] == C[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
int ans=0;

void dfs(ll a,ll n){
	if(a>n) return;
	ll x=a;
	vector<bool> b(3);
	while(x>0){
		if(x%10==7) b.at(0)=true;
		else if(x%10==5) b.at(1)=true;
		else b.at(2)=true;
		x/=10;
	}
	bool flg=true;
	rep(i,3) if(!b.at(i)) flg=false;
	if(flg) ans++;
	dfs(a*10+7,n);
	dfs(a*10+5,n);
	dfs(a*10+3,n);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;cin >> n;
	dfs(0,n);
	cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)


int main() {
  int n;
  cin >>n;
  
  vector<int> p(n);
  rep(i,n) {
  cin >> p[i];
  }
  
  sort(all(p));
  
  cout << p[n-1]-p[0] << endl;

}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val a, b = sc.nextInt()
  val s = sc.next()

  val split = s.split("-")

  def isNums(str: String) = str.toList.forall(c => c.isDigit)

  def isOK(): Boolean = {
    if (split.length == 2) {
      val p1 = split(0)
      val p2 = split(1)
      if (p1.length == a && p2.length == b) {
        if (isNums(p1) && isNums(p2)) {
          return true
        }
      }
    }
    return false
  }

  val result = if (isOK()) "Yes" else "No"
  println(result)
}



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

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

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

const int MOD = 1e9 + 7;


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

    ll a, b;
    cin >> a >> b;
    ll ans = __gcd(a,b);
    cout << a * b / ans << endl;

    return 0;
}



Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " << a << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("/home/kushagra/Desktop/Kushagra/input.txt", "r", stdin);
	freopen("/home/kushagra/Desktop/Kushagra/output.txt", "w", stdout);
#endif
	ll n, x, t;
	cin >> n >> x >> t;
	ll k = ceil(n * 1.0 / x * 1.0);
	ll z = k * t;
	cout << z << endl;
	return 0;
}

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

typedef long long ll;
#define rep(i, n) for(ll i=0; i<n; i++)
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define sz(v) ll(v.size)


void solve(long long N){
    cout << 180 * N - 360 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void rle(string &s, vector<pair<char,int>> &t){
    int j=0;
    t={make_pair(s[0],1)};
    for(int i=1; i<s.size(); ++i){
        if(s[i]==s[i-1]){
            ++t[j].second;
        }else{
            t.push_back(make_pair(s[i],1));
            ++j;
        }
    }
}
int main(){
	string s; cin >> s;
    vector<pair<char,int>> t;
    rle(s,t);

    int n=t.size();
    for(int i=0; i<n; i+=2){
        int nt=t[i].second+t[i+1].second;
        vector<int> v(nt,0);
        v[t[i].second-1]=nt/2; //second-1が偶数と仮定
        v[t[i].second]=(nt+1)/2;
        if(t[i].second%2==1){
            swap(v[t[i].second-1],v[t[i].second]);
        }
        for(int k : v) cout << k << " ";
    }
    cout << endl;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int temp = A - 2 * B;
    if (temp < 0) temp = 0;
    cout << temp << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    a = II()
    print(a+a**2+a**3)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9168
import java.util.*;

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

        if(13<=A){
            System.out.println(String.valueOf(B));
        }else if(6 <= A){
            System.out.println(String.valueOf(B/2));
        }else{
            System.out.println(String.valueOf(0));
        }
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <stack>
#include <tuple>
#include <vector>
#include <atcoder/dsu>

int main() {
  int N;
  std::cin >> N;
  std::vector<std::tuple<int, int, int>> cities(N);
  for (int i = 0; i < N; ++i) {
    int x, y;
    std::cin >> x >> y;
    cities[i] = {x, y, i};
  }
  std::sort(cities.rbegin(), cities.rend());
  std::stack<std::pair<int, int>> seen;
  atcoder::dsu dsu(N);
  for (const auto [x, y, i] : cities) {
    int max_y = y;
    while (!seen.empty() && seen.top().first > y) {
      max_y = std::max(max_y, seen.top().first);
      dsu.merge(seen.top().second, i);
      seen.pop();
    }
    seen.emplace(max_y, i);
  }
  for (int i = 0; i < N; ++i) {
    std::cout << dsu.size(i) << std::endl;
  }
  return 0;
}


Measured memory_bytes: 6428
// Problem : B - Mix Juice
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_b?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    int sum=0;
    vector<int>v(n);
    	for(int i=0;i<n;i++){
    		cin>>v[i];
    	}
    	sort(v.begin(),v.end());
    	for(int i=0;i<m;i++){
    		sum+=v[i];
    	}
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>

using namespace std;

int main()
{
    int n; cin >> n;
    map<char,int> freq;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        freq[s[0]]++;
    }
    long ans = 0;
    vector<int> choices;
    for (char c : { 'M', 'A', 'R', 'C', 'H' })
        choices.push_back(freq[c]);
    for (int i =   0; i <= choices.size()-3; i++)
    for (int j = i+1; j <= choices.size()-2; j++)
    for (int k = j+1; k <= choices.size()-1; k++)
    {
        ans += (long)choices[i] * choices[j] * choices[k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import { readFileSync } from 'fs'

const transpose = <T>(a: T[][]) =>
  a[0].map((_, c) => a.map(r => r[c]))

const mapWithPrev = <T, U>(list: T[], fn: (prev: U, value: T) => U, init: U) => {
  const result = [] as U[]
  let prev = init
  for (const value of list) {
    result.push(prev = fn(prev, value))
  }
  return result
}

function main(input: string) {
  const [header, ...lines] = input.split('\n')
  const grid = lines.map(v => v.split(''))

  const fn = (list: string[]) =>
    mapWithPrev(list, (prev, value) => {
      if (value === '#') return { value: 0 }
      const current = prev.value === 0 ? { value: 0 } : prev
      current.value += 1

      return current
    }, { value: 0 })
      .map(v => v.value)

  const horizontalList = grid.map(fn)

  const verticalList = transpose(
    transpose(grid).map(fn)
  )

  const resultGrid = grid.map((row, r) =>
    row.map((_, c) => horizontalList[r][c] + verticalList[r][c] - 1)
  )

  const max = Math.max(...resultGrid.map(v => Math.max(...v)))

  console.log(max)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 305116
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))
n = ii()
A = iil()

cum = 0
ope = 0
# first plus case
for i,item in enumerate(A):
    cum += item
    if i%2 == 0 and cum <= 0:
        ope += abs(cum)+1
        cum = 1
    elif i%2 == 1 and cum >= 0:
        ope += cum+1
        cum = -1
#    print(cum)
tmp = ope

cum = 0
ope = 0
# first minus case
for i,item in enumerate(A):
    cum += item
    if i%2 == 1 and cum <= 0:
        ope += abs(cum)+1
        cum = 1
    elif i%2 == 0 and cum >= 0:
        ope += cum+1
        cum = -1
#print(tmp,ope)
print(min(tmp,ope))

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

typedef long long ll;

const ll N = 1e5 + 10;
ll a[N], ps[N];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n);
    ps[0] = a[0];
    for (int i = 1; i < n; i++)
        ps[i] = ps[i - 1] + a[i];
    ll ans = 1;
    for (int i = n - 2; ~i; i--) 
        if (ps[i] * 2 >= a[i + 1])
            ans++;
        else
            break;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792