akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

void print_queen(vector<int> queen_pos)
{
  rep(i, 8)
  {
    rep(j, 8)
    {
      if (j == queen_pos[i])
        cout << "Q";
      else
      {
        cout << ".";
      }
    }
    cout << endl;
  }
}

bool is_ok_queen(vector<int> queen_pos)
{
  for (int i = 0; i < 8; i++)
  {
    for (int j = i + 1; j < 8; j++)
    {
      int dist_x = i - j;
      int dist_y = queen_pos[i] - queen_pos[j];
      if (dist_x == dist_y || dist_x == -dist_y)
        return false;
    }
  }
  return true;
}

int main()
{
  int k;
  cin >> k;
  vector<pair<int, int> > queen_pos(k);

  rep(i, k)
  {
    cin >> queen_pos[i].first >> queen_pos[i].second;
  }

  vector<int> root(8);
  rep(i, 8)
  {
    root[i] = i;
  }
  sort(root.begin(), root.end());
  do
  {
    bool is_ok = true;
    rep(i, k)
    {
      if (root[queen_pos[i].first] != queen_pos[i].second)
        is_ok = false;
    }

    if (!is_ok)
      continue;
    else if (is_ok_queen(root))
    {
      print_queen(root);
      return 0;
    }
  } while (next_permutation(root.begin(), root.end()));

  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;
const ll inf = 1e12;


int n;
double x[maxn], y[maxn];
char d[maxn];


double sim(double t) {
    double xlo=inf,xhi=-inf,ylo=inf,yhi=-inf;
    for (int i=0; i<n; i++) {
	double X = x[i];
	double Y = y[i];
	if (d[i]=='U') Y += t;
	if (d[i]=='D') Y -= t;
	if (d[i]=='L') X -= t;
	if (d[i]=='R') X += t;
	xlo=min(xlo,X);
	xhi=max(xhi,X);
	ylo=min(ylo,Y);
	yhi=max(yhi,Y);
    }

    return (xhi-xlo)*(yhi-ylo);
}

const double eps = 1e-7;

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

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>x[i]>>y[i]>>d[i];
    }

    double lo = 0;
    double hi = 2e8;


    for (int iter=0; iter<500; iter++) {
	double mid1 = lo + (hi-lo)/3;
	double mid2 = hi - (hi-lo)/3;
	double res1 = sim(mid1);
	double res2 = sim(mid2);
	if (res1 < res2) {
	    hi = mid2;
	} else {
	    lo = mid1;	    
	}
    }

    cout<<fixed<<setprecision(15)<<sim(lo)<<endl;    //15 too much..?
    return 0;
}


Measured memory_bytes: 5452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(k%2) cout << b-a << endl;
  else cout << a-b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cctype>
#include<string>

using namespace std;

int main()
{
  int n,m;

  while(1){
    
    int high=0,p[50][1000];

    cin>>n>>m;
    if(n==0 && m==0)return 0;
    for (int i=0;i<m;i++){
      for(int j=0;j<n;j++){
	cin>>p[i][j];
      }
    }

    for (int i=0;i<n;i++){
      int s=0;
      for(int j=0;j<m;j++){
	s+=p[j][i];
      }
      if(high<s){
	high=s;
	}
    }
    cout<<high<<endl;
  }
      return 0;
  
}


Measured memory_bytes: 3272
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static int E;
		 static int F;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int A = 100*sc.nextInt();
	        int B = 100*sc.nextInt();
	        int C = sc.nextInt();
	        int D = sc.nextInt();
	        E = sc.nextInt();
	        F = sc.nextInt();
	        boolean[] a = new boolean[40];
	        for(int i=0;A*i<=F;i++) {
	        	for(int j=0;A*i+B*j<=F;i++) {
	        		a[(A*i+B*j)/100]=true;
	        	}
	        }
	        boolean[] bi = new boolean[3005];
	        for(int i=0;C*i<F;i++) {
	        	for(int j=0;C*i+D*j<F;j++) {
	        		bi[C*i+D*j]=true;
	        	}
	        }
	        int cnt=0;
	        int[] b = new int[3005];
	        for(int i=0;i<3005;i++) {
	        	if(bi[i]==true) {
	        		b[cnt]=i;
	        		cnt++;
	        	}
	        }
	        	        
	        Arrays.sort(b);
	        double max = 0;
	        String ans = A + " 0";
	        for(int i=1;i<40;i++) {
	        	if(a[i]==false)continue;
	        	int w = i*100;
	        	int l=-1;
	        	int r=3005;
	        	while(r-l>1) {
	        		int m = l+(r-l)/2;
	        		int s = b[m];
	        		if(Isok(w,s)==true) {
	        			l=m;
	        		} else {
	        			r=m;
	        		}
	        	}
	        	double t=0;
	        	if(l>=0&&l<3005) {
	        		t = 100.0*b[l]/(i*100+b[l]);
	        	} 
	        	if(max<t) {
	        		ans=(i*100+b[l]) + " " + b[l];
	        		max=t;
	        	}
	        }
	        
	        System.out.println(ans);
	    }
		 
		static boolean Isok(int a,int b) {
			double p=E*a/100;
			int w=a+b;
			if(p<b)return false;
			if(w>F)return false;
			
			return true;
		}
	}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll r;
    cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int n;  cin >> n;
  vector<ll> v(n),v2(n);
  rep(i,0,n){
    cin >> v[i];
    v2[i] = v[i];
  }
  sort(all(v2));
  ll l=v2[n/2], r=v2[(n/2)-1];
  rep(i,0,n){
    ll ans = 0;
    if(l>v[i]){
      ans = l;
    }else{
      ans = r;
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 5376
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>

#define N 100002
#define D 12
using namespace std;
struct edge { int nxt,point,v;};

struct node {
	int v,c,d;
};

edge e[N << 1];

node a[N];
int n,m,Q,f[N][D],cnt;

void add(int u1,int v1) {
	e[++cnt].nxt = e[u1].point;
	e[u1].point = cnt;
	e[cnt].v = v1;
}

void insert(int u1,int v1) {
	add(u1,v1);
	add(v1,u1);
}

int main() {
	scanf("%d %d",&n,&m);
	cnt = 0;
	for (int i = 1; i <= m; ++i) {
		int u1,v1;
		scanf("%d %d",&u1,&v1);
		insert(u1,v1);
	}
	memset(a,0,sizeof(a));
	scanf("%d",&Q);
	for (int i = 1; i <= Q; ++i) {
		scanf("%d %d %d",&a[i].v,&a[i].d,&a[i].c);
		f[a[i].v][a[i].d] = max(f[a[i].v][a[i].d],i);
	}
	for (int i = 9; i >= 0; --i)
		for (int j = 1; j <= n; ++j)
			for (int p = e[j].point; p; p = e[p].nxt)
				f[j][i] = max(f[j][i],f[e[p].v][i + 1]);
	//for (int i = 1;i <= 9; ++i)
	for (int i = 1; i <= n; ++i) {
		int M = 0;
		for (int j = 0; j <= 10; ++j)
			M = max(M,f[i][j]);
		printf("%d\n",a[M].c);
	}
	return 0;
}


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

int main() {
	vector<int> n(4);
    for(int i=0;i<4;i++){
      cin >> n.at(i);
    }
    sort(n.begin(),n.end());
    if(n.at(0)==1 && n.at(1)==4 && n.at(2)==7 && n.at(3)==9){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);   
    Int a, b, c, d, e, n;
    cin >> n >> a >> b >> c >> d >> e;
    Int mi = min({a, b, c, d, e});
    Int res = (n % mi == 0) ? 0 : 1;
    res += n / mi;
    dump(4LL + res);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll S(ll x){
  ll sum = 0;
  while(x > 0){
    sum += x%10;
    x /= 10;
  }
  return sum;
}

int main(){
  ios::sync_with_stdio(false);
  
  map<ll,int> memo;
  REP(i,5,17){
    rep(j,10000){
      ll x = j;
      rep(k,i-5){ x *= 10; x += 9; }
      memo[x] = 1;
    }
  }
  vector<ll> v;
  FOR(it,memo){
    if(it->first == 0) continue;
    v.push_back(it->first);
  }


  int K;
  cin >> K;

  K = min(K, (int)v.size());
  int i=0;
  while(K>0){
    ll n = v[i];
    bool flg = true;
    REP(j,i+1,v.size()){
      ll m = v[j];
      if(m * S(n) - n * S(m) < 0){
        flg = false;
        break;
      }
    }
    if(flg){
      cout << n << endl;
      K--;
    }
    i++;
  }
  
  return 0;
}



Measured memory_bytes: 8184
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define m_k make_pair
using namespace std;
const int N=2100;
int n,z,w,a[N],vi[N][2],dp[N][2];
int DP(int pos,int op)
{
	if (vi[pos][op]) return dp[pos][op];
	if (op==0)
	{
		int tmp=(pos==0)?w:a[pos];
		int MAX=abs(tmp-a[n]);
		for (int i=pos+1;i<n;i++) MAX=max(MAX,DP(i,1));
		vi[pos][op]=1;dp[pos][op]=MAX;
		return MAX;
	}
	else
	{
		int tmp=(pos==0)?z:a[pos];
		int MIN=abs(tmp-a[n]);
		for (int i=pos+1;i<n;i++) MIN=min(MIN,DP(i,0));
		vi[pos][op]=1;dp[pos][op]=MIN;
		return MIN;
	}
}
signed main()
{
	scanf("%d%d%d",&n,&z,&w);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%d\n",DP(0,0));
}

Measured memory_bytes: 3872
#include<iostream>
#include<vector>
#include<cstring>
#define ll long long 
using namespace std;
ll ans;
char s[10];
bool vis[10];
int len;
void dfs(int x, int flag)
{
	vis[x] = flag;
	if (x == len - 1)
	{
		/*
		for (int i = 1; i < len; i++)
			cout << vis[i];
		cout << endl;
		*/
		ll tmp = 0;
		ll x = 0;
		ll sqr = 1;
		for (int i = len - 1; i >= 0; i--)
		{
			tmp += (s[i] - '0') * 1ll * sqr;
			if (vis[i])
			{
				x += tmp;
				tmp = 0;
				sqr = 1;
			}
			else
				sqr *= 10;
		}
		ans += x;
		return;
	}
	dfs(x + 1, 1);
	dfs(x + 1, 0);
}
int main()
{
	cin >> s;
	len = strlen(s);
	dfs(0, 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n,p,i,a[51];
main(){
	for(;~scanf("%d", &n),n;) {
		for(a[n]=p=i=0;i<n;i++)scanf("%d",&a[i]);
		for(i=1;i<=n;i++){
			if(a[i-1]+1!=a[i]) {
				if(i-p-1)printf(n-i?"%d-%d ":"%d-%d\n",a[p],a[i-1]);
				else printf(n-i?"%d ":"%d\n",a[p]);
				p=i;
			}
		}
	}
	exit(0);
}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (r * i + g * j > n) continue;
      if ((n - (r * i + g * j)) % b == 0) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(void)
{
    int a,b,i;
    scanf("%d %d",&a,&b);
    if(a == b)
    {
        for(i = 0;i < a;i++)
        {
            printf("%d",a);
        }
    }
    else if(a > b)
    {
        for(i = 0;i < a;i++)
        {
            printf("%d",b);
        }
    }
    else if(a < b)
    {
        for(i = 0;i < b;i++)
        {
            printf("%d",a);
        }
    }
    return 0;
}

Measured memory_bytes: 128
N=int(input())
S=[input() for _ in range(N)]
import collections
C=collections.Counter(S)
Ca=list(sorted(C.items(), key=lambda x:x[1], reverse=True))
ca=Ca[0][1]
ans=[]
for c in Ca:
    if c[1]==ca: ans.append(c[0])
    else: break
ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 122832
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, q;
  string s;
  cin >> n >> q >> s;
  
  vl NumAC(n-1);
  rep(i, n-1) {
    if(i>0) NumAC[i] = NumAC[i-1];
    if(s.substr(i,2)=="AC") NumAC[i]++;
  }
  
  ll l, r;
  rep(_, q) {
    cin >> l >> r;
    if(l==1) cout << NumAC[r-2] << newl;
    else cout << NumAC[r-2]-NumAC[l-2] << newl;
  }
  return 0;
}

Measured memory_bytes: 4224
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
inline int in(){int x;scanf("%lld",&x);return x;}
const int N=5e5+3;
const int mod=1e9+7;
int f[N],inv[N];
int modp(int a,int b)
{
	if(b==0)return 1;
	int u=modp(a,b/2);
	u=(u*u)%mod;
	if(b&1)return (a*u)%mod;
	return u;
}
int choose(int n,int r)
{
	if(n<r)return 0;
	int res=f[n]*inv[n-r];
	res%=mod;res*=inv[r];
	res%=mod;
	return res; 
}
int32_t main()
{
	int n=in();int m=in();
	f[0]=1;inv[0]=modp(1,mod-2);
	for(int i=1;i<=m;i++)f[i]=(f[i-1]*i)%mod;
	inv[m]=modp(f[m],mod-2);
	for(int i=m-1;i>=0;i--)inv[i]=((i+1)*inv[i+1])%mod;
	int ans=0,cur=1,tmp;
	for(int i=0;i<=n;i++)
	{
		tmp=choose(m-i,n-i)*choose(n,i);tmp%=mod;
		tmp*=f[n-i];tmp%=mod;
		ans+=(cur*tmp);cur=-cur;
		ans+=mod;ans%=mod;
	}	
	int perm=choose(m,n)*f[n];perm%=mod;
	cout<<(ans*perm)%mod;
	
}

Measured memory_bytes: 11328
#include <bits/stdc++.h>
using namespace std;
const int Maxn=200005,mod=1e9+7,inv2=(mod+1)/2;
int a[Maxn],s[Maxn],pre[Maxn],f[Maxn],invf[Maxn];
struct node{
	int l,r,v,cnt;
}Tree[4*Maxn];
int ksm(int x,int k){
	int ret=1,tmp=x;
	while(k){
		if(k&1)ret=1ll*ret*tmp%mod;
		tmp=1ll*tmp*tmp%mod;k>>=1;
	}
	return ret;
}
int inv(int x){return ksm(x,mod-2);}
void PushUp(int v){
	Tree[v].v=(Tree[2*v].v+Tree[2*v+1].v)%mod;
	Tree[v].cnt=Tree[2*v].cnt+Tree[2*v+1].cnt;
}
void Build(int v,int l,int r){
	Tree[v]=(node){l,r,0,0};
	if(l==r)return;
	Build(2*v,l,(l+r)/2);
	Build(2*v+1,(l+r)/2+1,r);
}
void Modify(int v,int pos,int val){
	if(Tree[v].l==Tree[v].r){
		Tree[v].v=(Tree[v].v+val)%mod;
		Tree[v].cnt++;
		return;
	}
	if(pos<=Tree[2*v].r)Modify(2*v,pos,val);
	else Modify(2*v+1,pos,val);
	PushUp(v);
}
int Askv(int v,int l,int r){
	if(r<Tree[v].l||Tree[v].r<l)return 0;
	if(l<=Tree[v].l&&Tree[v].r<=r)return Tree[v].v;
	return (Askv(2*v,l,r)+Askv(2*v+1,l,r))%mod;
}
int Askc(int v,int l,int r){
	if(r<Tree[v].l||Tree[v].r<l)return 0;
	if(l<=Tree[v].l&&Tree[v].r<=r)return Tree[v].cnt;
	return Askc(2*v,l,r)+Askc(2*v+1,l,r);
}
int main(){
	int n,g=1,ans=0;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)s[a[i]]++;
	for(int i=n;i>=1;i--)s[i]+=s[i+1];
	for(int i=1;i<=n;i++)s[i]-=n-i;
	for(int i=1;i<=n;i++){
		int cur=1ll*(s[i]-1)*inv(s[i])%mod;
		if(!cur||i==1)pre[i]=i;
		else pre[i]=pre[i-1];
		f[i]=1ll*(i==1?1:f[i-1])*max(cur,1)%mod;
		invf[i]=inv(f[i]);
	}
	for(int i=n;i>=1;i--)g=1ll*g*s[i]%mod;
	Build(1,1,n);
	for(int i=1;i<=n;i++){
		ans=(ans+1ll*g*inv2%mod*Askv(1,pre[a[i]],a[i])%mod*f[a[i]])%mod;
		Modify(1,a[i],invf[a[i]]);
	}
	Build(1,1,n);
	for(int i=n;i>=1;i--){
		ans=(ans+1ll*g*Askc(1,1,a[i]-1)-1ll*g*inv2%mod*Askv(1,pre[a[i]],a[i]-1)%mod*f[a[i]])%mod;
		Modify(1,a[i],invf[a[i]]);
	}
	cout<<(ans+mod)%mod<<"\n";
	return 0;
}

Measured memory_bytes: 14720
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>

using namespace std;
using ll = long long;
using ld = long double;

#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);                                     // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
/********** for each macro **********/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))


int main(void)
{
	string s; cin >> s;
	if (s == "SUN")
		cout << 7;
	else if (s == "MON")
		cout << 6;
	else if (s == "TUE")
		cout << 5;
	else if (s == "WED")
		cout << 4;
	else if (s == "THU")
		cout << 3;
	else if (s == "FRI")
		cout << 2;
	else
		cout << 1;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nk = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            if (nk[0] == 1)
            {
                Console.WriteLine("0");
                return;
            }

            List<int> directions = Console.ReadLine().ToCharArray().Select(v => v == 'L' ? 0 : 1).ToList();

            List<int> comparison1 = new List<int>(directions);
            List<int> comparison2 = new List<int>(directions);

            comparison1.RemoveAt(0);
            comparison2.RemoveAt(comparison2.Count - 1);

            int currentHappiness = comparison1.Zip(comparison2, (one, two) => one == two ? 1 : 0).Sum();

            int expectedHappiness = Math.Min(nk[0] - 1, currentHappiness + (nk[1] * 2));

            Console.WriteLine(expectedHappiness.ToString());
        }
    }
}


Measured memory_bytes: 15584
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //input
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        double a = n/1.08;
        long b = (long)Math.ceil(a);

        if (Math.floor(b*1.08) != n)
        {
            System.out.println(":(");
        }else
        {
            System.out.println(b);
        }

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m, s;
    cin >> n >> m >> s;
    s = min(s, 2450);
    vector<vector<pair<int, pair<int, long long> > > >g(n + 3);
    for(int i = 1; i <= m; i++){
        int u, v, a;
        long long b;
        cin >> u >> v >> a >> b;
        g[u].push_back(make_pair(v, make_pair(a, b)));
        g[v].push_back(make_pair(u, make_pair(a, b)));
    }
    vector<int>c(n + 3);
    vector<long long>d(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> c[i] >> d[i];
    }
    long long dist[n + 3][2500];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= 2450; j++){
            dist[i][j] = 1e18;
        }
    }
    priority_queue<pair<long long, pair<int, int> >, vector<pair<long long, pair<int, int> > >, greater<pair<long long, pair<int, int> > > >pq;
    pq.push(make_pair(0, make_pair(1, s)));
    dist[1][s] = 0;
    while(!pq.empty()){
        long long time = pq.top().first;
        int u = pq.top().second.first, coin = pq.top().second.second;
        pq.pop();
        if(dist[u][coin] < time){
            continue;
        }
        dist[u][coin] = time;
        for(int i = 0; i < g[u].size(); i++){
            int v = g[u][i].first, cost = g[u][i].second.first;
            long long t = g[u][i].second.second;
            if(coin >= cost){
                if(dist[v][coin - cost] > time + t){
                    dist[v][coin - cost] = time + t;
                    pq.push(make_pair(time + t, make_pair(v, coin - cost)));
                }
            }
        }
        int cur = min(2450, coin + c[u]);
        long long cost = dist[u][coin] + d[u];
        if(cost < dist[u][cur]){
            dist[u][cur] = cost;
            pq.push(make_pair(cost, make_pair(u, cur)));
        }
    }
    for(int i = 2; i <= n; i++){
        long long ans = 1e18;
        for(int j = 0; j <= 2450; j++){
            ans = min(ans, dist[i][j]);
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 6112
#include<iostream>
using namespace std;
int main() {
    bool cards[4][14];
    int n, num;
    char mark;
    for (int m=0; m<4; m++){
        for (int k=1; k<=13; k++){
            cards[m][k] = 0;
        }
    }
    cin >> n;
    for (int i=0; i<n; i++){
        cin >> mark >> num;
        if (mark == 'S') cards[0][num] = 1;
        if (mark == 'H') cards[1][num] = 1;
        if (mark == 'C') cards[2][num] = 1;
        if (mark == 'D') cards[3][num] = 1;
    }
    for (int m=0; m<4; m++){
        for (int l=1; l<=13; l++){
            if (cards[m][l]) continue;
            if (m == 0) mark = 'S';
            if (m == 1) mark = 'H';
            if (m == 2) mark = 'C';
            if (m == 3) mark = 'D';
            cout << mark << " " << l << endl; 
        }
    }
    return 0;
}


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

int n, m, q;
int A[50];

/*bool check(int x, int y){//第一引数は整数m、第二引数は繰り返す条件
    for(int i = y - 1; i >= 0; i--){
        if((x < A[i]) && (i - 1 >= 0)){
            x -= A[i - 1];
            check(x, i - 1);
        } 
    }
    if(x == 0) return true;
    else return false;
}*/

bool solve(int i, int m){
    if(m == 0) return true;
    if(i >= n) return false;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main(void){
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];

    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> m;
        if(solve(0, m)) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
using System;
class Program {
    static void Main(string[] args) {
        //整数の入力
        //int a = int.Parse(Console.ReadLine());
        //スペース区切りの整数の入力
        //string[] input = Console.ReadLine().Split(' ');
        string input = Console.ReadLine();
        //int b = int.Parse(input[0]);
        //int c = int.Parse(input[1]);
        //文字列の入力
        //string s = Console.ReadLine();
        //出力
        int counter = 0;
        int max = 0;
        for(int i=0;i<3;i++){
            if(input[i] == 'R'){
                counter++;
                if(counter > max){
                    max = counter;
                }
            }
            else{
                counter = 0;
            }
        }
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 25848
#理解できていない
def floor_sum(n, m, a, b):
    res = 0
    while True:
        res += (n * (b // m)) + (a // m) * (n * (n - 1) // 2)
        a %= m
        new_n = (a * n + b) // m
        new_m = a
        new_a = m
        if not new_n:
            return res
        b -= new_n * m
        res += (b // a + n) * new_n
        new_b = b % a
        n, m, a, b = new_n, new_m, new_a, new_b


t = int(input())
for _ in range(t):
    n, m, a, b = map(int, input().split())
    print(floor_sum(n, m, a, b))


Measured memory_bytes: 71396
# -*- coding: utf-8 -*-

import sys


class UnionFind:
    '''
    配列を用いたUnionFind
    '''

    def __init__(self, size):
        self.table = [i for i in range(size)]

    def find(self, x):
        '''
        xのグループ番号を返す
        '''
        return self.table[x]

    def union(self, val, y):
        '''
        Fennecは0
         SnukeはN-1とすることで、O(1)にする
         '''
        self.table[y] = val

    def same(self, x, y):
        '''
        xとyが同じグループならtrue
        '''
        x1 = self.find(x)
        y1 = self.find(y)
        return x1 == y1

    def get_table(self):
        return self.table
# python template for atcoder1


sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
adj = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

Un = UnionFind(N)
S = [N-1]
F = [0]
S_or = N-1
F_or = 0


def oneStep(turn):
    ret = []
    if turn == 1:
        while S:
            c = S.pop(0)
            for i in adj[c]:
                if not Un.same(S_or, i) and not Un.same(F_or, i):
                    Un.union(S_or, i)
                    ret.append(i)
    else:
        while F:
            c = F.pop(0)
            for i in adj[c]:
                if not Un.same(S_or, i) and not Un.same(F_or, i):
                    Un.union(F_or, i)
                    ret.append(i)
    return ret


turn = 0
while S or F:
    if turn == 1:
        if len(S) != 0:
            S = oneStep(turn)
        turn = 0
    else:
        if len(F) != 0:
            F = oneStep(turn)
        turn = 1

cntF = Un.get_table().count(0)
cntS = Un.get_table().count(N-1)
if cntF > cntS:
    ans = "Fennec"
else:
    ans = "Snuke"
print(ans)


Measured memory_bytes: 25276
n=int(input())
s=input()
stack=[]
l=0
r=0
for c in s:
    if len(stack)>0 and stack[-1]=='(' and c==')':
        stack.pop()
    else:
        stack.append(c)
if len(stack)==0:
    print(s)
else:
    for c in stack:
        if c==')':
            l+=1
        else:
            r+=1
    print('('*l+s+')'*r)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    ll N; cin >> N;
    map<ll, ll> mp;

    ll Maxi = 0;
    rep(i, N) {
        ll a; cin >> a;
        mp[a - 1]++; mp[a]++; mp[a + 1]++;
        Maxi = max(Maxi, a);
    }

    ll ans = -1;
    rep(i, Maxi + 1) ans = max(ans, mp[i]);
    cout << ans << endl;
}

Measured memory_bytes: 9912
//リーダーを一つずらすと値への影響はリーダー分のみ
//累積和？？
#include <bits/stdc++.h>
using namespace std;

int N;
string s;

int main() {
    cin >> N >> s;
    vector<int> sumleader(N);
    for (int i = 1; i < N; i++) if (s[i] == 'E') sumleader[0]++;
    for (int i = 1; i < N; i++) {
        sumleader[i] += sumleader[i-1];
        if (s[i-1] == 'W') sumleader[i]++;
        if (s[i] == 'E') sumleader[i]--;
    }
    int ans = *min_element(sumleader.begin(), sumleader.end());
    cout << ans << endl;
}

Measured memory_bytes: 1796
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
char a[1002];
int d[5];
int main()
{
	scanf("%s",a);
	int n=strlen(a);
	for(int i=0;i<n;i++)
		if(a[i]=='N')d[1]=1;
		else if(a[i]=='W')d[3]=1;
		else if(a[i]=='S')d[2]=1;
		else if(a[i]=='E')d[4]=1;
	if((d[1]+d[2])%2==0&&(d[3]+d[4])%2==0)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	c_p_c();
	int l; cin >> l;

	double ans = l / 3.0;

	ans = (ans * ans * ans);

	cout << ps(ans, 7) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char s[20];
  
  scanf("%s", s);

  for (int i=0; s[i]!='\0'; i++)
    if (s[i]==',') s[i] = ' ';
  
  printf("%s\n", s);
  
  return 0;
  
}

Measured memory_bytes: 128
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

i = 0
AB_comb = [0] * N
for b in range(N):
    tmp = AB_comb[b - 1]
    while i < N and A[i] < B[b]:
        tmp += 1
        i += 1
    AB_comb[b] += tmp

i = 0
ABC_comb = [0] * N
for c in range(N):
    tmp = ABC_comb[c - 1]
    while i < N and B[i] < C[c]:
        tmp += AB_comb[i]
        i += 1
    ABC_comb[c] += tmp

print(sum(ABC_comb))

"""
import bisect
N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
for i in range(N):
    upi = bisect.bisect_left(A, B[i])
    dwi = bisect.bisect_right(C, B[i])
    ans += upi*(N - dwi)

print(ans)
"""


Measured memory_bytes: 25268
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int a, b;
llong M[MAX];

int confirmation(llong I) {
	int i = 0;
	for( int j=0; j<b; j++) {
		llong s = 0;
		while( s + M[i] <= I) {
			s += M[i];
			i++;
			if ( i==a ) return a;
		}
	}
	return i;
}

int workout() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = confirmation(mid);
		if (v >= a) right = mid;
		else left = mid;
	}
	return right;
}

main() {
	cin >> a >> b;
	for ( int i = 0; i < a; i++) cin >> M[i];
	llong ans = workout();
	cout << ans << endl;
}



Measured memory_bytes: 3876
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int N=200010;
int a[N];
ll s[N];
ll ab(ll x){return max(x,-x);}
int main(){
    int n,i,j;
    ll ans=1ll<<55,all;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
    all=s[n];
    for(i=1;i<n;i++)
        ans=min(ans,ab(s[n]-2*s[i]));
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

long long lucas(int n){
	if(n == 0) return 2;
	else if(n == 1) return 1;
	else{
		long long tmp1 = 2, tmp2 = 1, ans = 0;
		for(int i = 2; i <= n; i++){
			ans = tmp1 + tmp2;
			tmp1 = tmp2;
			tmp2 = ans;
		}
		return ans;
	}
}

int main(){
	int n;
	cin >> n;
	cout << lucas(n) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm> 
#include <iterator> 
#include <map> 
 
using namespace std;
 
string po;
long long int A,B,N;
map<int,int> p;
long int pass=0;
long int ab=0;
int main(){
	scanf("%lld %lld %lld",&N,&A,&B);
	cin>>po;
	for(int i=0;i<N;i++){
		if(po[i]=='a'&&pass<(A+B)){p[i]=10;pass++;}
		if(po[i]=='b'&&pass<(A+B)&&ab<B){p[i]=10;pass++;ab++;}
	}
 
	for(int i=0;i<N;i++){
		if(p[i]==10)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 5376
#include<algorithm>
#include<cmath>
#include<cstdint>
#include<cstdio>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<(b); ++i)
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(v) begin(v), end(v)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

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

  string s;
  cin >> s;

  for(;;) {
    s = s.substr(0, s.size()-1);
    if (s.size() % 2 == 0) {
      if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2)) {
        cout << s.size() << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long int 
#define endl '\n'
#define PI  3.14159265358979323846
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MAX 1000
using namespace std;
 
//ll gcd(ll n,ll m){
//	if(m==0)
//	return n;
//	if(n<m)
//	swap(n,m);
//	while(n%m!=0)
//	{
//		ll temp=n;
//		n=m;
//		m=temp%m;
//	}
//	return m;
//}

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


int main() {
    ll n,i,j,k;
    cin>>n>>k;
    ll h[n];
    for(i=0;i<n;i++)
    cin>>h[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(i=2;i<n;i++)
    {
    	dp[i]=INT_MAX;
    	for(j=i-1;j>=i-k && j>=0;j--)
    	{
    		dp[i]=min(dp[i],abs(h[i]-h[j])+dp[j]);
		}
	}
	cout<<dp[n-1];
}






Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    int n,m;cin>>n>>m;
    vector<vector<int> >G(3*n+1);
    rep(i,m){
        int u,v;cin>>u>>v;
        G[u].pb(v+n);
        G[u+n].pb(v+2*n);
        G[u+2*n].pb(v);
    }
    int s,t;cin>>s>>t;
    queue<int>q;
    q.push(s);
    int ans=-1;
    vector<int>depth(3*n+1,-1);
    depth[s]=0;
    while(!q.empty()){
        int k=q.front();
        q.pop();
        if(k==t){
            ans=depth[t];
            break;
        }
        rep(i,G[k].size()){
            int e=G[k][i];
            if(depth[e]>=0)continue;
            q.push(e);
            depth[e]=depth[k]+1;
        }
    }
    cout<<(ans==-1?ans:ans/3)<<endl;
}

Measured memory_bytes: 17792
object Main extends App {
  val hmhmk = scala.io.StdIn.readLine()
  val hmhmkArray = hmhmk.split(" ").map(_.toInt).toSeq
  val start = hmhmkArray(0) * 60 + hmhmkArray(1)
  val end = hmhmkArray(2) * 60 + hmhmkArray(3)
  val k = hmhmkArray(4)
 
  println(end - start - k)
 
}

Measured memory_bytes: 54776
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <sstream>
#include <numeric>
using namespace std;

int main(){
    int a,b,t ;
    cin >> a >> b >> t ;
    cout << (t/a)*b << endl ;
}

Measured memory_bytes: 256
//package com.company;
// Always comment out package when submitting.

import java.io.*;
import java.util.*;

public class Main {
    public static class Task {
        private static int mod = 1_000_000_007;
        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            List<Integer> seq = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                int y = sc.nextInt();
                if (seq.size() == 0 || seq.get(seq.size() - 1) != y) {
                    seq.add(y);
                }
            }
            n = seq.size();
            long[] val = new long[200001];
            long[] dp = new long[n + 1];
            dp[0] = 1;
            for (int i = 0; i < n; i++) {
                int v = seq.get(i);
                dp[i + 1] = (dp[i] + val[v]) % mod;
                val[v] = (val[v] + dp[i]) % mod;
            }
            pw.println(dp[n]);
        }
    }

    // template, actual code is in class Task.
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));
        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.err.println("Memory increased: " + (usedMemoryAfter - usedMemoryBefore) / 1000000);
//        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    // Faster IO with BufferedReader wrapped with Scanner
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 47208
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	bool f=false;
	REP(i,n) {
		if(b<=a+(n-1-i)*d-c*i&&b>=a+(n-1-i)*c-d*i) f=true;
	}
	if(f) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
from collections import deque

INF = 10101010

def main():
    h,w = map(int,input().split())
    s = []
    for i in range(h):
        s.append(input())

    d = [[INF for j in range(w)] for i in range(h)]
    d[0][0] = 0
    que = deque()
    que.append((0,0))
    while len(que):
        y,x = que.pop()
        for dx,dy in [(1,0),(-1,0),(0,1),(0,-1)]:
            nx,ny = x+dx, y+dy
            if 0 <= nx < w and 0 <= ny < h:
                if s[ny][nx] != '#' and d[ny][nx]>d[y][x]+1:
                    d[ny][nx] = d[y][x]+1
                    que.append((ny,nx))

    if d[h-1][w-1] == INF:
        return -1

    ans = -(d[h-1][w-1]+1)
    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                ans += 1
    return ans

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


Measured memory_bytes: 43500
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,m,gr=0,num=0,ans=0;
  cin >> n >> m;
  ll a[n],sum[n+1];
  map<ll,ll> mp;
  sum[0]=0;
  mp[0]++;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum[i+1]=sum[i]+a[i];
    mp[sum[i+1]%m]++;
  }
  for(auto i:mp){
    ans += (i.second*(i.second-1))/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define END(a) {cout << (a) << "\n"; return 0;}
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n; cin >> n;
    multiset<int> set;//作るスライム
    FOR(i, 0, 1 << n) {
        int in; cin >> in;
        set.insert(in);
    }

    priority_queue<int> now;
    now.push(*--set.end()); set.erase(--set.end());
    FOR(i, 0, n) {
        priority_queue<int> next;
        while (!now.empty()) {
            int mom = now.top(); now.pop();
            auto itr = set.lower_bound(mom);
            if (itr == set.begin()) {
                cout << "No\n";
                return 0;
            }
            next.push(mom);
            next.push(*--itr);
            set.erase(itr);
        }
        now = next;
    }
    cout << "Yes\n";
}

Measured memory_bytes: 14928
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		
		int h = s / 3600;
		int m = (s % 3600) / 60;
		int sec = s % 60;
		
		System.out.println(h + ":" + m + ":" + sec);
	}
}



Measured memory_bytes: 26332
A, B, C, D, E, F = map(int, input().split(" "))

# 900
water = set()
for a in range(F//(100*A)+1):
	for b in range(F//(100*B)+1):
		w = A*a + B*b
		if w > F//100:
			break
		water.add(w)
water.remove(0)

suger = set()
for c in range(F//C+1):
	for d in range(F//D+1):
		s = C*c + D*d
		if s > F:
			break
		suger.add(s)

# print(water, suger)

max_num = 0
max_w, max_s = A, 0
for w in water:
	for s in suger:
		if 100*w+s > F or s > E*w:
			continue
		# print(w*100, s)
		if max_num < s/w:
			max_num = s/w
			max_w, max_s = w, s

print(100*max_w+max_s, max_s)
		


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];

    sort(all(v));

    ld ans = v[0];
    rep(i, n-1) {
        ans = (ans + v[i+1]) / 2;
    }
    
    printf("%.8Lf\n", ans);

    return 0;
}

Measured memory_bytes: 3788
import copy


N=int(input())
A=[]
X=[]#X[i][j]=人i+1曰く、人X[i][j]は↓
Y=[]#Y[i][j]である(1=正直、0=不親切)
for i in range(N):
    A.append(int(input()))
    Lx=[]
    Ly=[]
    for j in range(A[i]):
        x,y=map(int,input().split())
        Lx.append(x)
        Ly.append(y)
    X.append(copy.copy(Lx))
    Y.append(copy.copy(Ly))

#print(A,X,Y)

def check(letter,n=N,a=A,x=X,y=Y):#letterは二進数の文字列
    for k in range(n):
        if letter[k]=='1':#人k-1が正直者として
            number=a[k]#主張の数
            for l in range(number):
                if y[k][l]!=int(letter[x[k][l]-1]):#人kが嘘つきなら
                    return False
                    break
            else:
                continue
            break
    else:
        return True


L=[]
for m in range(2**N):
    bin_str=bin(m)[2:]
    if len(bin_str)<N:
        bin_str=(bin_str[::-1]+'0'*(N-len(bin_str)))[::-1]
    L.append(bin_str)
#print(L)


ans=0
for p in range(len(L)):
    if check(L[p]):
        #print(L[p],check(L[p]))
        ans=max(ans,L[p].count('1'))

print(ans)





        





Measured memory_bytes: 6004