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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int W, H, N; scanf("%d %d %d", &W, &H, &N);
  int x, y, a;
  int left = 0, right = W, bottom = 0, top = H;
  for (int i = 0; i < N; ++i) {
    scanf("%d %d %d", &x, &y, &a);
    if (a == 1) { left = max(left, x); }
    else if (a == 2) { right = min(right, x); }
    else if (a == 3) { bottom = max(bottom, y); }
    else if (a == 4) { top = min(top, y); }
  }
  int ans = 0;
  if ((right - left > 0) and (top - bottom > 0)) {
    ans = (right - left) * (top - bottom);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
  int n;
  vector<int> a;
  cin >> n;
  for(int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    a.emplace_back(tmp);
  }
  sort(a.begin(), a.end());
  int b = 0;
  for(auto i:a) {
    if(i==b) {
      cout << "NO";
      return 0;
    } else {
      b=i;
    }
  }
  cout << "YES";
  return 0;
}

Measured memory_bytes: 1400
#include<stdio.h>

int main()
{
 int N;
 int M;
 int i;
 int j;
 int a[200005];
 int b[200005];
 int connect1[200005];
 int connectN[200005];
 int path=0;

 scanf("%d %d",&N, &M);

 for(i=0; i<N; i++) connect1[i]=0;
 for(i=0; i<N; i++) connectN[i]=0;
 for(i=0;i<M;i++) 
 {
   scanf("%d %d",&a[i],&b[i]);
   if (a[i] == 1) connect1[b[i]]=1;
   if (b[i] == N) connectN[a[i]]=1;
 }
 for(i=0; i<N; i++)
 {
  if((connect1[i]==1)&(connectN[i]==1)) path=1;
 }

 if (path==1)
 {
  printf("POSSIBLE\n");
 }else{
  printf("IMPOSSIBLE\n");
 }

return 0;
}


Measured memory_bytes: 3328
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BProblemCommittee {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      vector<int> a(26);
      rep(i, n) {
        string s; cin >> s;
        a[s.front()-'A']++;
      }
      priority_queue<int> que;
      rep(i, 26) {
        if (a[i]>0) {
          que.push(a[i]);
        }
      }
      int ans = 0;
      while(que.size() >= k) {
        ans++;
        vector<int> vec;
        rep(i, k) {
          int p = que.top(); que.pop();
          vec.push_back(p);
        }
        rep(i, k) {
          if (vec[i]-1 > 0) {
            que.push(vec[i]-1);
          }
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BProblemCommittee solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> p(n + k, 0);
  for(int i=0; i<n; i++){
    cin >> p[i];
  }

  int maxi = 0, index, tmp = 0;
  for (int i = 0; i < k; i++){
    tmp += p[i];
  }
  maxi = tmp;
  index = 0;

  for (int i = 0; i < n - k; i++)
  {
    tmp -= p[i];
    tmp += p[i+k];
    if (maxi < tmp)
    {
      maxi = tmp;
      index = i + 1;
    }
  }

  //cout << index << endl;

  double ans = 0;
  vector<ll> sum(1010, 0);
  for (int i = 1; i <= 1000; i++){
    sum[i] = sum[i - 1] + i;
  }

  for (int i = index; i < index + k; i++)
  {
    double e = 0;
    e = (double)sum[p[i]] / p[i];
   
    ans = (double)ans + e;
  }
  printf("%.10f\n", ans);
  return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = input()

arr = [int(a) for a in A.split(' ')]
odd_arr = []

for num in arr:
    if num % 2 == 0:
        odd_arr.append(2)
    else:
        odd_arr.append(1)

odd = 1
for num in odd_arr:
    odd = odd * num

print(3 ** N - odd)


Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP)
 { return firstP.first < secondP.first; }//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll n,a,b,c;
Vi l;

ll cal(ll num,ll aa,ll bb,ll cc){
	if(num == n){
		if(aa>0 && bb>0 && cc>0){
			return abs(aa-a) + abs(bb-b) + abs(cc-c) -30;
		}else{
			return INF;
		}
	}else{
		ll n1 = cal(num+1,aa+l[num],bb,cc)+10;
		ll n2 = cal(num+1,aa,bb+l[num],cc)+10;
		ll n3 = cal(num+1,aa,bb,cc+l[num])+10;
		ll n4 = cal(num+1,aa,bb,cc);
		return min(n1,min(n2,min(n3,n4)));
	}
}

int main(){
	cin>>n>>a>>b>>c;ll lll;
	rep(i,n){
		cin>>lll;l.pb(lll);
	}
	cout<<cal(0,0,0,0)<<endl;
	return 0;
}

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

int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin>>k;
  cout<<a[k-1];
  return 0;
}


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

const int INF = 1e9+5;

int main()
{
	int n;
	scanf("%d",&n);
	vector<int> h(n);

	for(int &x : h)
		scanf("%d",&x);

	vector<int> dp(n , INF);

	dp[0] = 0;
	for(int i =0;i<n;i++)
	{
		for(int j : {i+1 , i+2})
		{
			if(j<n)
			{
				dp[j] = min(dp[j] , dp[i] + abs(h[i] - h[j]));
			}
		}
	}

	printf("%d\n",dp[n-1]);
}



//END














Measured memory_bytes: 1152
n,m=map(int,input().split())
b=[]
for i in range(m):
    b.append(0)
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(1,a[0]+1):
        b[a[j]-1]+=1
c=0
for i in b:
    if i==n:
        c+=1
print(c)

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

int main() {
	int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
	int dx=tx-sx;
	int dy=ty-sy;
	for(int i=0;i<dx;i++){
		cout<<'R';
	}
	for(int i=0;i<dy;i++){
		cout<<'U';
	}
	for(int i=0;i<dx;i++){
		cout<<'L';
	}
	for(int i=0;i<dy;i++){
		cout<<'D';
	}
	cout<<'D';
	for(int i=0;i<dx+1;i++){
		cout<<'R';
	}
	for(int i=0;i<dy+1;i++){
		cout<<'U';
	}
	cout<<'L';
	cout<<'U';
	for(int i=0;i<dx+1;i++){
		cout<<'L';
	}

	for(int i=0;i<dy+1;i++){
		cout<<'D';
	}
	cout<<'R';

	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){

    string S;
    cin >> S;

    map<char, ll> mp;
    mp[S[0]]++;
    mp[S[1]]++;
    mp[S[2]]++;

    if(mp.size() == 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
/*************************** MACROS **************************/
#define itn int
#define ld long double
#define ll long long  
#define ull unsigned long long
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define MOD 1000000007
#define MOD1 998244353
#define MIN_LL -1e18
#define MAX_LL 1e18
#define MAX_INT 1e9
#define MIN_INT -1e9
#define Line cout<<"\n**************************\n\n";
 
 
using namespace std;
 
/*************************** VARIABLES **************************/
 
bool br1,br2,br;

ll n,k,x,y,z,mini,maxi,l,ind,ini,sum,t,len,r,q,imini,w;

string s,s1,s2;


/**************************** FXNS ****************************/

ll a[(int)1e6];

void solve(){

	cin>>n;

	loop(i,0,n)a[i] = MAX_LL;

	loop(i,1,n){

		cin>>x;

		a[i-1] = min(a[i-1],x);
		a[i] = min(a[i],x);
	}

	loop(i,0,n)sum += a[i];

	cout<<sum<<endl;
}
 
/*************************** MAIN ****************************/
 
 int main(){


	/*#ifndef ONLINE_JUDGE
	        freopen("inputNaNtxt", "rt", stdin);
	        freopen("output.txt", "wt", stdout);
	#endif*/
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
 
    solve();

	return 0;
}

Measured memory_bytes: 256
N = int(input())

L = []
R = []

for i in range(N):
    l,r = map(int,input().split())
    L.append(2 * l)
    R.append(-2 * r)

L.sort()
R.sort()
L.reverse()
R.reverse()

ans = 0

now = 0
for i in range(N):
    now += L[i]
    ans = max(ans,now)
    now += R[i]
    ans = max(ans,now)

now = 0
for i in range(N):
    now += R[i]
    ans = max(ans,now)
    now += L[i]
    ans = max(ans,now)

print (ans)


Measured memory_bytes: 57944
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b,t; cin >> a >> b >> t;
    cout << t / a * b << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;


public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		
		int ans = 0;
		for(int i = 0; i < 4; i++) {
			if(N.charAt(i) == '2') {
				ans++;
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21460
N,K=map(int,input().split())
A=list(map(int,input().split()))
from fractions import gcd
g=A[0]
for i in A[1:]:
    g=gcd(g,i)
a=0
if A[0]%g!=K%g:
    a=1
if K>max(A):
    a=1
print(("IM" if a else "" )+"POSSIBLE")

Measured memory_bytes: 14252
/**
 *    author:  math2do
 *    created: 06.09.2020 10:57:41
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  } 
  vector <long long> pre(n);
  pre[0] = arr[0];
  for (int i = 1; i < n; i++) {
    pre[i] = pre[i - 1] + arr[i];
  } 
  auto sum = [&] (int i, int j) {
    long long h = pre[j];
    long long l = (i - 1 >= 0 ? pre[i - 1] : 0);
    return h - l;    
  };
  long long inf = (long long) 1e18;
  vector <vector <long long>> dp(n, vector <long long>(n, inf));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i; j < n; j++) {
      if (i == j) {
        dp[i][j] = 0;
        continue;
      } 
      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + sum(i, j));
      } 
    } 
  } 

  cout << dp[0][n - 1] << endl;
  return 0;
}


Measured memory_bytes: 4492
import sys

n, m, X, Y = map(int, sys.stdin.readline().split())
*x, = map(int, sys.stdin.readline().split())
*y, = map(int, sys.stdin.readline().split())

def main():
    return 'No War' if max(X, max(x)) < min(Y, min(y)) else 'War'

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

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
void read(int &x) {
    char ch; bool ok;
    for(ok=0,ch=getchar(); !isdigit(ch); ch=getchar()) if(ch=='-') ok=1;
    for(x=0; isdigit(ch); x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
#define rg register
const int maxn=2010,mod=1e9+7;
int n,k,ans,f[maxn][maxn],sum[maxn];
int mul(int x,int y){return 1ll*x*y-1ll*x*y/mod*mod;}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int del(int x,int y){return x-y<0?x-y+mod:x-y;}
int mi(int a,int b){
	if(b<=0)return 1;
    int ans=1;
    while(b){
        if(b&1)ans=mul(ans,a);
        b>>=1,a=mul(a,a);
    }
    return ans;
}
int main(){
    read(n),read(k);f[0][n+1]=1;
    for(rg int i=1;i<=k;i++){
    	sum[n+1]=f[i-1][n+1];
    	for(rg int j=n;j;j--)sum[j]=add(sum[j+1],f[i-1][j]);
    	for(rg int j=1;j<=n-i+1;j++)f[i][j]=add(f[i][j],sum[j]);
	}
    printf("%d\n",mul((del(f[k][1],f[k-1][1])),mi(2,n-k-1)));
}

Measured memory_bytes: 15360
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n,vector<int>(3,0));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    rep(i,n-1){
        
        dp[i+1][0] = max(dp[i+1][0],dp[i][1]+a[i+1]);
        dp[i+1][0] = max(dp[i+1][0],dp[i][2]+a[i+1]);
        
        dp[i+1][1] = max(dp[i+1][1],dp[i][0]+b[i+1]);
        dp[i+1][1] = max(dp[i+1][1],dp[i][2]+b[i+1]);
        
        dp[i+1][2] = max(dp[i+1][2],dp[i][0]+c[i+1]);
        dp[i+1][2] = max(dp[i+1][2],dp[i][1]+c[i+1]);
    }
    
    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  char a, b;
  cin >> a >> b;
  if (a == 'H') dump(b);
  else dump(b == 'H' ? 'D' : 'H');
  return 0;
}


Measured memory_bytes: 256
import sys

n = int(sys.stdin.readline().rstrip())

def main():
    a = 1
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a = i
    b = n // a
    ans = len(str(b))
    return ans

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

Measured memory_bytes: 3060
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
struct Edge{
  ll to,dist;
};
ll N;
ll d[2000];
vector<Edge> G[2000];

void dijkstra(ll u){
  REP(i,N)d[i]=INF;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push({0,u});
  while(!que.empty()){
    auto r=que.top();que.pop();
    if(r.first>=d[r.second])continue;
    d[r.second]=r.first;
    
    for(Edge& e: G[r.second]){
      ll dist=d[r.second]+e.dist;
      if(dist>=d[e.to])continue;
      que.push({dist,e.to});
    }
  }
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  bool b=false;
  REPS(i,9)REPS(j,9){
    if(i*j!=N)continue;
    b=true;
  }
  ifYN(b);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int gcd(int,int);
int main(void){
  int a,b;
 
    while(scanf("%d%d",&a,&b) != EOF){
      printf("%d %d\n",gcd(a,b),a / gcd(a,b) * b );
    }
 
  return 0;
}
 
int gcd(int x,int y){
  int t;
  if(x < y) {t=x;x=y;y=t;}
 
  if(y == 0) return x;
  else return gcd(y, x % y);
}

Measured memory_bytes: 596
n = gets.to_i
a = gets.split.map(&:to_i)

counts = Hash.new(0)
a.each do |x|
  counts[x] += 1
end

max = 0
counts.each do |x, n|
  max = [max, counts[x-1] + counts[x] + counts[x+1]].max
end
puts max

Measured memory_bytes: 14724
def main():
    while True:
        buf = input().split()
        if buf[0] == "#":
            return
        g = buf[0]
        y,m,d = map(int,buf[1::])
        y = int(y)
        m = int(m)
        d = int(d)
        if y > 31 or (y == 31 and m >= 5):
            g = "?"
            y -= 30
        print(g,y,m,d)

if __name__ == '__main__':
    main()



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

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

vector<mint> fact, inv_fact, minv;
void prepare(int n) {
  fact.resize(n + 1), inv_fact.resize(n + 1), minv.resize(n + 1);
  for (int i = 0; i <= n; ++i) fact[i] = i ? i * fact[i - 1] : 1;
  inv_fact[n] = power(fact[n], mod - 2);
  for (int i = n; i; --i) inv_fact[i - 1] = i * inv_fact[i];
  for (int i = 1; i <= n; ++i) minv[i] = inv_fact[i] * fact[i - 1];
}
mint binom(int n, int k) {
  if (k < 0 or k > n) return 0;
  return fact[n] * inv_fact[k] * inv_fact[n - k];
}
template<> mint& mint::operator/=(mint r) {
  return *this *= r.v < minv.size() ? minv[r.v] : power(r, mod - 2);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int r0, c0, r1, c1;
  cin >> r0 >> c0 >> r1 >> c1;
  prepare(1e7);
  mint res;
  for (int r = r0; r <= r1; ++r) {
    res += binom(c1 + r + 1, c1) - binom(c0 + r, c0 - 1);
  }
  cout << res.v << '\n';
}


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

int main() {
    
    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }


    return 0;

}





Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace  std ;
typedef long long  ll;
typedef pair<ll, ll> Pll;
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define rad(X) cout << (X) << endl
#define ASH(X) cout << (X) << " "
#define debug(x) cout << #x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define FOR(I,A,B) for(int I = (A); I <= (B); I++)
#define cir(I,B,A) for(int I = (A); I >=(B); I--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define SORT(c) (sort(c.begin(),c.end()))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASES int ___T; cin >> ___T; for(int cs=1;cs<=___T;cs++)
#define FAST()  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
template<typename T>T gcd(T x, T y){if(y==0)return x;else return gcd(y,x%y);}
ll fx[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll fy[] = {0, 1, 1, 1, 0, -1, -1, -1};
vector<ll>a,b,c;
map<ll,ll>m1,m2,m3;

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

void Execute()
{
      int n;
      cin >> n;
      std::vector<int> dp(3);
        std::vector<int> new_dp(3,0);
      FOR(day,1,n)
      {
        std::vector<int> v(3);
        FOR(i,0,2)
        {
          cin >> v[i];
        }



      FOR(i,0,2)
      {
        FOR(j,0,2)
        {
          if(i!=j)
          {
            new_dp[j] = max(new_dp[j],dp[i]+v[j]);
          }
        }
      }


      dp=new_dp;
    }
      cout << max({dp[0],dp[1],dp[2]}) << endl;

}

int32_t main()
{
  //  #ifndef ONLINE_JUDGE
    //freopen("atomm.txt", "r", stdin);
    //#endif

    FAST();
    //CASES

        Execute();

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int i = 0;
    int x[10000];
    int j;

    do
    {
        i++;
        scanf("%d", &x[i]);
    } while (x[i] > 0);
    //「0」を入力したらdo文を抜ける

    for (j = 1; j < i; j++)
    {
        printf("Case %d: %d\n", j, x[j]);
    }

    return 0;
}


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

int main() {
	int a,b,c,t,i,j;
	cin>>a>>b>>c;
	for(i=3;i>0;i--){
		for(j=i;j>0;j--){
			if(a>b){
				t=a;
				a=b;
				b=t;
			}
			if(b>c){
				t=b;
				b=c;
				c=t;
			}
		}
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int count =0;
		
		for(int i=0; i<n; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			count += r-l+1;
		}
		sc.close();
		
		System.out.println(count);

	}

}


Measured memory_bytes: 39452
n,m,s=map(int,input().split())
s=min(s,2500)
edge=[[] for i in range(n*50*51)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    for j in range(a,2501):
        edge[u-1+j*n].append((v-1+(j-a)*n,b))
        edge[v-1+j*n].append((u-1+(j-a)*n,b))
for i in range(n):
    c,d=map(int,input().split())
    for j in range(2501-c):
        edge[i+j*n].append((i+(j+c)*n,d))
    for j in range(2500):
        edge[i+(j+1)*n].append((i+j*n,0))
from heapq import heappush,heappop,heapify
d = [float('inf') for i in range(n*50*51)]
pq = []
heappush(pq,(0,s*n))
while pq:
    weight,u = heappop(pq)
    if d[u]>weight:
        d[u]=weight
        for v,weight in edge[u]:
            heappush(pq,(d[u]+weight,v))
for i in range(1,n):
    print(d[i])

Measured memory_bytes: 149952
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll arr[n+1];
    for(ll i = 1; i <= n; i++)
        cin>>arr[i];
    ll ans = 1;
    map<ll,ll>k;
    k[1] = 0;
    ll cnt = 0;
    while(m--)
    {
        cnt++;
        ans = arr[ans];
        if(k.find(ans) != k.end())
        {
            ll temp = m;
            temp = m%(cnt-k[ans]);
            while(temp--)
                ans = arr[ans];
            break;
        }
        k[ans] = cnt;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 15176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
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() {    
    double a, b, h, m; cin >> a >> b >> h >> m;
    
    double hour = h * (360.0/ 12) + m * (1.0 / 2);
    double minute = m * (360.0/ 60);

    double rhour = hour * M_PI / 180;
    double rminute = minute * M_PI / 180;

    double ax = a * cos(rhour), ay = a * sin(rhour);
    double bx = b * cos(rminute) ,by = b * sin(rminute);
    double dx = abs(ax - bx), dy = abs(ay - by);

    double res = sqrt(dx * dx + dy * dy);
    cout << fixed << setprecision(12);
    cout << res << ln;
}

Measured memory_bytes: 4072
n, m = map(int, input().split())
h = list(map(int, input().split()))
ans_list = [1] * n

for i in range(m):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  if h[a] < h[b]:
    ans_list[a] = 0
  elif h[b] < h[a]:
    ans_list[b] = 0
  elif h[a] == h[b]:
    ans_list[a] = 0
    ans_list[b] = 0

print(sum(ans_list))

Measured memory_bytes: 20120
#include <iostream>
using namespace std;
int main()
{
  int a, b;
  cin>>a>>b;
  
  a*=b;
  a=a%2;
  
  if(a==2 || a==0)
  {
      cout<<"Even"<<endl;
  }
  else
  {
      cout<<"Odd"<<endl;
  }
}

Measured memory_bytes: 256
using namespace std;

#include <stdio.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <algorithm>

#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;

int r, g;

signed main() {
    //freopen("out.txt", "w", stdout);
    scanf("%lld%lld", &r, &g);
    printf("%lld\n", 2 * g - r);
}


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

long long DigitSum( const int iNum )
{
long long iSum;
int X;

	X = iNum;
	iSum = 0;
	while( X > 0 )
	{
		iSum += X % 10;
		X /= 10;
	}

	return iSum;
}


int main( int argc, char *argv[] )
{
int i;
int N;
int A;
int B;
long long iSum;
long long iAns;

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

	cin >> N;
	cin >> A;
	cin >> B;

	iAns = 0;
	for( i = 1; i <= N; i++ )
	{
		iSum = DigitSum( i );
		if( iSum <= B && A <= iSum )
			iAns += i;
	}

	cout << iAns << endl;

	return 0;
}




Measured memory_bytes: 384
N = int(input())
S = input()
he, ta = {}, {}

for i in range(N):
  if not S[i] in he:
    he[S[i]] = i
  if len(he) >= 10:
    break

for i in range(N-1,-1,-1):
  if not S[i] in ta:
    ta[S[i]] = i
  if len(ta) >= 10:
    break
#print(he)
#print(ta)
ans = 0
for hek, hep in he.items():
  for tak, tap in ta.items():
    if hep>=tap:
      continue
    wk = set()
    for i in range(hep+1, tap):
      wk.add(S[i])
      if len(wk) >= 10:
        break
    ans += len(wk)
    #print(ans, wk, hek, tak)
print(ans)

Measured memory_bytes: 3188
def mod(n):
    if n > 0:
        return -(n//2), n%2
    elif n < 0:
        return (-n+1)//2 ,(-n)%2
    else:
        return 0,0
    
def main():
    N = int( input())
    if N == 0:
        print(0)
        return
    ANS = []
    while N != 0:
        N, b = mod(N)
        ANS.append(b)
    print("".join( map( str, ANS[::-1])))
        
if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		int count4 = 0;
		int count2 = 0;
		int odd = 0;

		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(str[i]);

			if (a % 4 == 0) {
				count4++;
			} else if (a % 2 == 0) {
				count2++;
			} else {
				odd++;
			}
		}

		if ((count4 + 1) == odd && count4 + odd == n) {
			System.out.println("Yes");
		} else if (count4 < odd) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 37900
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	cout << (a - 1)*(b - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn sum(mut x:i32)->i32 {
  let mut s=0;
  while(x>0){
    s+=(x%10);
    x/=10;
  }
  s
}

fn main(){
  let n:i32=read();
  let a:i32=read();
  let b:i32=read();
  let mut ans:i32=0;
  for i in 1..(n+1) {
    let mut x:i32=i;
    if sum(x)>=a && sum(x)<=b {
      ans+=x;
    }
  }
  println!("{}",ans);
}


Measured memory_bytes: 4352
# 全部出す版
N,S=gets.chomp.split(' ').map{|n| n.to_i}
is_found = false
0.upto(N){|x|
	if(!is_found)
		t = N-x
		0.upto(t){|y|
			if(!is_found)
				z = t-y
				if(10000*x+5000*y+1000*(z) == S)
					puts "#{x} #{y} #{z}"
					is_found = true
				end
			end
		}
	end
}
if(!is_found)
	puts "-1 -1 -1"
end


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

vector<int> g[200009];
vector<int> cnt(200009, 0);
vector<bool> visited(200009, false);

void dfs(int pos) {
  rep(i, g[pos].size()) {
    int to = g[pos][i];
    if (visited[to]) continue;;
    visited[to] = true;
    cnt[to] += cnt[pos];
    // printf("cnt[%d] = %d, cnt[%d] = %d\n", pos, cnt[pos], to, cnt[to]);
    dfs(to);
  }
  return;
}

int main() {
  int n, q;
  cin >> n >> q;
  vector<int> a(n-1), b(n-1), p(q), x(q);
  rep(i, n-1) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }
  rep(i, q) {
    cin >> p[i] >> x[i];
    --p[i];
  }

  rep(i, n-1) {
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  
  rep(i, q) cnt[p[i]] += x[i];

  visited[0] = true;
  dfs(0);

  rep(i, n-1) printf("%d ", cnt[i]);
  printf("%d\n", cnt[n-1]);

  return 0;
}

Measured memory_bytes: 27392
N = int(input())
B = list(map(int, input().split()))

result = B[-1]
s = B[-1]

for i in range(1, N - 1)[::-1]:
    if B[i - 1] <= B[i]:
        result += B[i - 1]
    else:
        result += B[i]
        
result += B[0]

print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include <functional>

using namespace std;
int main(){
	int N;
	int a[100000];
	
	int n[100000];
	
	int i,j,k;
	
	for(i=0;i<100000;i++){
		n[i]=0;
	}
	cin>>N;
	for(i=0;i<N;i++){
		cin>>a[i];
		n[a[i]-1]++;
		n[a[i]-2]++;
		n[a[i]]++;
	}
	sort(n, n+100000);
	
	cout<<n[99999];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

inline double add(double a, double b){
    return abs(a+b)<(1e-10)*(abs(a)+abs(b)) ? 0.0 : a+b;
}

struct vec{
    double x,y;
    vec operator-(vec b){
        return (vec){add(x,-b.x),add(y,-b.y)};
    }
    vec operator+(vec b){
        return (vec){add(x,b.x),add(y,b.y)};
    }
    vec operator*(double d){
        return (vec){x*d,y*d};
    }
    double dot(vec v){
        return add(x*v.x,y*v.y);
    }
    double cross(vec v){
        return add(x*v.y,-y*v.x);
    }
    double norm(){
        return sqrt(x*x+y*y);
    }
};

pair<vec,vec> cross_point(vec& C1, vec& C2, double r1, double r2){
    vec e1,e2,P1,P2;
    double d=(C2-C1).norm();
    e1=(C2-C1)*(1/d);
    double theta = acos((r1*r1+(C2-C1).dot(C2-C1)-r2*r2)/(2*r1*d));
    e2.x=cos(theta)*e1.x-sin(theta)*e1.y, e2.y=sin(theta)*e1.x+cos(theta)*e1.y;
    P1=C1+e2*r1;
    e2.x=cos(theta)*e1.x+sin(theta)*e1.y, e2.y=-sin(theta)*e1.x+cos(theta)*e1.y;
    P2=C1+e2*r1;
    if(P1.x==P2.x){
        if(P1.y<P2.y) return make_pair(P1,P2);
        else return make_pair(P2,P1);
    }else{
        if(P1.x<P2.x) return make_pair(P1,P2);
        else return make_pair(P2,P1);
    }
}

int main(){
    vec C1,C2;
    double r1,r2;
    cin >> C1.x >> C1.y >> r1;
    cin >> C2.x >> C2.y >> r2;
    auto P = cross_point(C1,C2,r1,r2);
    cout.precision(8);
    cout << fixed;
    cout << P.first.x << " " << P.first.y << " " << P.second.x << " " << P.second.y << endl;
    return 0;
}

Measured memory_bytes: 3504
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() { 
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}




Measured memory_bytes: 3608
N = int(input())
A = list(map(int, input().split()))
num_dict = {}
for a in A:
    if a in num_dict:
        num_dict[a] += 1
    else:
        num_dict[a] = 1

ans = 0
for k, v in num_dict.items():
    if k == v:
        continue
    if k > v:
        ans += v
    else:
        ans += v - k
print(ans)

Measured memory_bytes: 17780
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

const int lim=100005;

int m(int x){
	if(x<0) return -x; return x;
}


int n,k;

int t[lim];
int h[lim];


int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	
	cin>>h[1];
	
	for(int i=2;i<=n;i++){
		cin>>h[i]; t[i]=t[i-1]+m(h[i]-h[i-1]);
		for(int j=i-2;j>0 && j>=i-k; j--) t[i]=min(t[i],t[j]+m(h[j]-h[i]));
	}
	cout<<t[n];
	
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N + 1);
  vll B(N);
  REP(i, 0, N + 1) {
    cin >> A[i];
  }
  REP(i, 0, N) {
    cin >> B[i];
  }

  ll ans = 0;
  REP(i, 0, N) {
    if (A[i]) {
      int c = min(A[i], B[i]);
      ans += c;
      A[i] -= c;
      B[i] -= c;
    }
    if (A[i + 1]) {
      int c = min(A[i + 1], B[i]);
      ans += c;
      A[i + 1] -= c;
      B[i] -= c;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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;
}
typedef long double ld;
int main(){
    ll n;
    ld m;
    cin >> n >> m;
    vector<ld>t(n);
    rep(i,n){
        cin >> t[i];
    }
    ld rx=0.0,ry=0.0;
    ld inv = (ld)(n*(n-1)*(n-2))/6.0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            ld p = (M_PI)*(t[i]+t[j])/m;
            rx += cos(p)*(n+i-j-1)/inv;
            ry += sin(p)*(n+i-j-1)/inv;
            p += M_PI;
            rx += cos(p)*(j-i-1)/inv;
            ry += sin(p)*(j-i-1)/inv;
        }
    }
    cout.precision(20);
    cout<<  fixed << rx <<" " << ry << endl;
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll sum=0;
  rep(i,n) sum += a[i];
  priority_queue<int> pq;
  rep(i,n) pq.push(a[i]);
  rep(i,m){
//    cout << sum << endl;
//    cout << pq.top()/2 << endl;
    int b = (pq.top()+1)/2;
    int c = pq.top()/2;
    sum-=b;
    pq.pop();
    pq.push(c);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1276
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    string a, b, c;
    cin >> n >> a >> b >> c;

    ll ans = 0;
    rep(i, n) {
        if(a[i] == b[i] && b[i] == c[i]) {
            ;
        }
        else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i]) {
            ans++;
        }
        else {
            ans += 2;
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <string>
#include <stack>
#include <iostream>
using namespace std;
int main() {
  string word;
  stack<int> S;
  while (cin >> word) { // 入力がある限り読み込む
    if (word == "+") {
      // 数を2 つpop して、和をpush する
      int n = S.top();
      S.pop();
      n += S.top();
      S.pop();
      S.push(n);
    }
    else if (word == "-") {
      // 数を2 つpop して、差をpush する
      int n = -S.top();
      S.pop();
      n += S.top();
      S.pop();
      S.push(n);
    }
    else if (word == "*") {
      // 数を2 つpop して、積をpush する
      int n = S.top();
      S.pop();
      n *= S.top();
      S.pop();
      S.push(n);
    }
    else {
      // word を数値にしてpush する
      int n = stoi(word);
      S.push(n);
    }
  }
  // S の先頭要素を表示する。
  cout << S.top() << endl;

}


Measured memory_bytes: 3172
#include <iostream>
#include <cstdlib>
#include <deque>

using namespace std;

void del( deque<int>& q, int& pos, int &n ) {
  q.erase( q.begin() + pos );
  n--;
  pos = ( pos + n - 1 ) % n;
}


// AOJ1275: "And Then There Was One"
int main() {
  while( 1 ) {
    int n, k, m;
    cin >> n >> k >> m;
    if( !n && !k && !m ) { return EXIT_SUCCESS; }

    deque<int> stones;
    for( int i = 0; i < n; i++ ) {
      stones.push_back( i + 1 );
    }
    m--;
    del( stones, m, n );
    while( n > 1 ) {
      m = ( m + k ) % n;
      del( stones, m, n );
    }
    cout << stones[ 0 ] << endl;
  }
}

Measured memory_bytes: 1264
def buffet(a, b, c)
  ans = 0
  a.map! { |i| i - 1 }
  prev = -2
  a.each do |i|
    ans += b[i]
    if prev == i - 1
      ans += c[i - 1]
    end
    prev = i
  end
  ans
end

n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)

puts buffet(a, b, c)

Measured memory_bytes: 1788
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, M, K = inpl()
A = inpl()
B = inpl()
ib = M
a = 0
b = sum(B)
ans = 0
for i in range(N+1):
    if i != 0:
        a += A[i-1]
    if a > K:
        break
    while a+b > K:
        if ib > 0:
            ib -= 1
            b -= B[ib]
        else:
            break
    ans = max(ans, i+ib)
print(ans)

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


Measured memory_bytes: 40088
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

// 問題
// 1<=a,b<=N
// a mod b >= K
// 組(a, b)としてありうるものを数えよ
// 1<=N<=10^5
// 
// 0<=K<b, q>=0
// r >= K
// a = bq + r
// r = a-bq
// K<=r<b
// K<=a-bq<b
// K+bq<=a<b(q+1)
// よって1<=b<=Nの範囲でbを総当たりして
// 更にK+bq<=N の範囲でqを総当たり
// これは調和数を考えると実行時間が
// O(NlogN)になるやつ

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;
    ll ans = 0;

    for (ll b = 1; b <= N; ++b) {
        for (ll q = 0; K + b*q <= N; ++q) {
            ll lb = max(1ll, K + b*q);
            ll ub = min(N, b*(q + 1) - 1);
            if(lb<=ub)ans += ub - lb + 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e3+5;
int n,x;
ll sum[maxn];
int a[2005];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum[a[i]]++;
    }
    for(int i=1;i<maxn;i++)
    {
        for(int j=i+1;j<maxn;j++)
        {
            sum[i]+=sum[j];
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)continue;
            int x=abs(a[i]-a[j]);
            int y=a[i]+a[j];
            ll k=sum[x+1]-sum[y];
            if(a[i]>x&&a[i]<y)k--;
            if(a[j]>x&&a[j]<y)k--;
            if(k<0)k=0;
            ans+=k;
        }
    }
    printf("%lld",ans/6);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int d,n;
    cin >> d >> n;
    ll ans = 0;
    if (d ==0) {
        ans = 1;
        ans *= n;
    if (n == 100) ans++;
    } else if(d ==1) {
        ans = 100;
        ans *= n;
    if (n == 100) ans += 100;

    } else if (d ==2) {
        ans = 10000;
        ans *= n;
    if (n == 100) ans += 10000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin >>n>>k;
	int h[n];
	for(int i=0;i<n;i++ ) cin >>h[i];
	int ans[n]={0};
	ans[0]=0;
	for(int i=1;i<n;i++){
		int nn =INT_MAX;
		for(int j=1;j<=k;j++){
			if(i-j>=0)
			nn= min(nn,ans[i-j]+abs(h[i]-h[i-j]));
		}
		ans[i] = nn;
	}
	cout <<ans[n-1]<<"\n";
}


Measured memory_bytes: 1024
import Control.Applicative

maxout [x] = x
maxout (x:y:ys)
    |x>=y = maxout (x:ys)
    |x <y = maxout (y:ys)

main = do
    [n,m] <- (map read . words) <$> getLine
    print (maxout [n+m,n-m,n*m])

Measured memory_bytes: 508
S = input()

direct = set()
for s in S:
    direct.add(s)

if len(direct) == 4:
    print("Yes")
elif (len(direct) == 2) and ('N' in direct) and ('S' in direct):
    print("Yes")
elif (len(direct) == 2) and ('E' in direct) and ('W' in direct):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384