akhauriyash/Code-Regression huggingface dataset:
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b,q;cin>>a>>b>>q;
  int S[a]; rep(i, a) {cin>>S[i];}
  int T[b]; rep(i, b) {cin>>T[i];}
  dump_1d(S, a);
  dump_1d(T, b);

  rep(i, q){
    int res = INF;
    int x;cin>>x;
    auto p = upper_bound(S, S+a, x)-S;
    auto q = upper_bound(T, T+b, x)-T;
    // r,r
    if (p<a and q<b) chmin(res, max(S[p]-x,T[q]-x));
    // l,l
    if (p>0 and q>0) chmin(res, max(abs(S[p-1]-x),abs(T[q-1]-x)));
    // r,l
    if (p<a and q>0) chmin(res, (S[p]-x)+(x-T[q-1])+min((S[p]-x), (x-T[q-1])));
    // l,r
    if (p>0 and q<b) chmin(res, (x-S[p-1])+(T[q]-x)+min((x-S[p-1]), (T[q]-x)));
    cout << res << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 2944
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(a//b)


Measured memory_bytes: 5592
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int ans=0;
		if(n>=2) {
			ans += n*(n-1)/2;
		}
		if(m>=2) {
			ans+=m*(m-1)/2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 22996
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char a[110][110];
int dp[3000][3000];
int s1[110][110],s2[110][110];
int n,m,xz,yz;

int id1(int x,int y)
{
    return (x-1)*(n-xz+1)+y;
}

int id2(int x,int y)
{
    return (x-1)*(m-yz+1)+y;
}

int main()
{
    #ifdef waltz
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
            if (a[i][j]=='E')
            {
                xz=i;yz=j;
            }
    for (int i=1;i<=n;i++)
    {
        s1[i][0]=0;
        for (int j=1;j<=m;j++)
        {
            s1[i][j]=s1[i][j-1];
            if (a[i][j]=='o') s1[i][j]++;
        }
    }
    for (int i=1;i<=m;i++)
    {
        s2[i][0]=0;
        for (int j=1;j<=n;j++)
        {
            s2[i][j]=s2[i][j-1];
            if (a[j][i]=='o') s2[i][j]++;
        }
    }
    for (int i=1;i<=xz;i++)
        for (int j=1;j<=n-xz+1;j++)
            for (int p=1;p<=yz;p++)
                for (int q=1;q<=m-yz+1;q++)
                {
                    int x=id1(i,j),y=id2(p,q);
                    dp[x][y]=0;
                    if (i>1)
                    {
                        int t=dp[id1(i-1,j)][y];
                        if (j-1<=xz-i&&min(q+yz-1,m-(p-1))>=max(yz-p,q-1)) t+=s1[xz-i+1][min(q+yz-1,m-(p-1))]-s1[xz-i+1][max(yz-p,q-1)];
                        dp[x][y]=max(dp[x][y],t);
                    }
                    if (j>1)
                    {
                        int t=dp[id1(i,j-1)][y];
                        if (i-1<=n-xz+1-j&&min(q+yz-1,m-(p-1))>=max(yz-p,q-1)) t+=s1[xz+j-1][min(q+yz-1,m-(p-1))]-s1[xz+j-1][max(yz-p,q-1)];
                        dp[x][y]=max(dp[x][y],t);
                    }
                    if (p>1)
                    {
                        int t=dp[x][id2(p-1,q)];
                        if (q-1<=yz-p&&min(j+xz-1,n-(i-1))>=max(xz-i,j-1)) t+=max(0,s2[yz-p+1][min(j+xz-1,n-(i-1))]-s2[yz-p+1][max(xz-i,j-1)]);
                        dp[x][y]=max(dp[x][y],t);
                    }
                    if (q>1)
                    {
                        int t=dp[x][id2(p,q-1)];
                       // printf("%d %d %d\n",min(j+xz-1,n-(i-1)),max(xz-i,j-1),t);
                        if (p-1<=m-yz+1-q&&min(j+xz-1,n-(i-1))>=max(xz-i,j-1)) t+=s2[yz+q-1][min(j+xz-1,n-(i-1))]-s2[yz+q-1][max(xz-i,j-1)];
                        dp[x][y]=max(dp[x][y],t);
                    }
                   // printf("%d %d %d %d %d\n",i,j,p,q,dp[x][y]);
                }
    printf("%d\n",dp[id1(xz,n-xz+1)][id2(yz,m-yz+1)]);
    return 0;
}


Measured memory_bytes: 30208
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = LI()
    cnt = 0
    s = sum(A)
    for a in A:
        if a < s/(M*4):
            pass
        else:
            cnt += 1
    if cnt >= M:
        print('Yes')
    else:
        print('No')


main()



Measured memory_bytes: 7752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int x,ans=0;
signed main(){
	cin>>x;
	if(x>=400&&x<=599){ans=8;
	}
	else if(x>=600&&x<=799)ans=7;
	else if(x>=800&&x<=999)ans=6;
	else if(x>=1000&&x<=1199)ans=5;
	else if(x>=1200&&x<=1399)ans=4;
	else if(x>=1400&&x<=1599)ans=3;
	else if(x>=1600&&x<=1799)ans=2;
	else{
		ans=1;
	}
	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

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

	int n,k;
	long long int t;
	vector <long long int> v;
	long long int sum = 0;
	long long int res = 0;
	cin >> n >> k;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		sum += t;
		res = gcd(res,t);
		v.push_back(t);
	}	

	vector <long long int> a;
	for(int i=1;i<=sqrt(sum);i++)
	{
		if(sum%i==0)
		{
			if(sum/i==i)
			{
				a.push_back(i);
			}
			else
			{
				a.push_back(i);
				a.push_back(sum/i);
			}
		}
	}

	sort(a.begin(),a.end());
	for(int i=0;i<a.size();i++)
	{
		vector <long long int> temp;
		for(int j=0;j<n;j++)
		{
			int kk = (v[j]%a[i]);
			temp.push_back(kk);
			/*
			if(kk<=a[i]-kk)
			{
				pos += kk;
			}
			else
			{
				neg += (a[i] - kk);
			}
			*/
		}
		sort(temp.begin(),temp.end());
		for(int j=0;j<n;j++)
		{
			long long int cnt = 0;
			long long int pos = 0;
			long long int neg = 0;
			for(int K=0;K<temp.size();K++)
			{
				if(K<=j)
				{
					pos += temp[K];
				}
				else
				{
					neg += (a[i] - temp[K]);
				}
			}
			if(pos<=neg)
			{
				cnt += pos;
				neg-=pos;
				if(neg%a[i]==0)
				{
					cnt += neg;
					if(cnt <= k)
					{
						res = max(res,a[i]);
						break;
					}
				}
			}
			else
			{
				cnt += neg;
				pos-=neg;
				if(pos%a[i]==0)
				{
					cnt += pos;
					if(cnt <= k)
					{
						res = max(res,a[i]);
						break;
					}
				}
			}
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 3712
n = list(map(int, input().split()))
x = [list(map(int, input().split())) for i in range(n[0])]
ans = []
for i in x:
  if n[1] >= i[1]:
    ans.append(i[0])
if ans == []:
  print('TLE')
else:
  print(sorted(ans)[0])


Measured memory_bytes: 9176
#!/usr/bin/env python
#-*- coding: utf-8 -*-

if __name__ == '__main__':
    N = int(raw_input())
    l = map(int, raw_input().split())
    cnt = 0
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if l[j] < l[minj]:
                minj = j
        if i != minj:
            l[i], l[minj] = l[minj], l[i]
            cnt += 1
    print ' '.join(map(str, l))
    print cnt


Measured memory_bytes: 4660
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a,b,c,d,e]
l1 = [a%10,b%10,c%10,d%10,e%10]
l2 = [(a//10)*10+10,(b//10)*10+10,(c//10)*10+10,(d//10)*10+10,(e//10)*10+10]
for i in range(len(l)):
    if l[i]%10 == 0:
        l1[i] = 10
        l2[i] -= 10
print((sum(l2)-(10-(min(l1)))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}


int main(void){
    string result = "No";
    ll N;
    cin >> N;
    vector<ll> L;
    rep(i, N){
        ll x;
        cin >> x;
        L.push_back(x);
    }
    
    ll sum = 0;
    ll max = 0;
    rep(i, N){
        sum += L[i];
        max = std::max(max, L[i]);
    }
    sum -= max;
    
    if(max < sum){
        result = "Yes";
    }
    
    cout << result << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int N_MAX = 250000;
int main()
{
  int n,k,t,i,j;
  string ss;
  string s[N_MAX];
  cin >> ss >> k;
  n=ss.size();
  for(i=0,t=0;i<n;i++)
    for(j=1;j<=k;j++,t++){
      if(i+j>n) break;
      s[t]=ss.substr(i,j);
    }
  sort(s,s+t);
  j=0;
  ss="";
  for(i=0;i<t;i++){
    if(s[i]!=ss){
      ss=s[i];
      j++;
    }
    if(j==k){
      cout << s[i] << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3328
d = int(input())
clst = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
last = [0 for _ in range(26)]

def score_minus(d, q):
    minus = 0
    for c, ls in zip(clst, last):
        minus += c * (d - ls)
    minus -= clst[q] * (d - last[q])
    return minus
    
ans = 0
for i in range(d):
    tmp = 0
    for q in range(26):
        tmp_score = s[i][q] - score_minus(i, q)
        if tmp_score > tmp:
            tmp = tmp_score
            max_q = q
    print(max_q + 1)
    last[max_q] = i

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

using namespace std;

int main()
{
  int R, C;
  char prog[21][21];
  cin >> R >> C;
  for(int i = 0; i < R; i++){
    for(int j = 0; j < C; j++) cin >> prog[i][j];
  }
  typedef pair<int, int> P;
  typedef pair<P, P> PP;
  bool visited[21][21][16][5];
  memset(visited, false, sizeof(visited));
  queue<PP> que;
  int left = 0, right = 1, up = 2, down = 3;
  int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
  bool flag = false;
  que.push(PP(P(0, 0), P(right, 0)));
  while(!que.empty()){
    PP p = que.front(); que.pop();
    int x = p.first.first, y = p.first.second, d = p.second.first, mem = p.second.second;
    if(x < 0 || C <= x || y < 0 || R <= y){
      x = (x + C) % C;
      y = (y + R) % R;
    }
    if(visited[x][y][d][mem]) continue;
    visited[x][y][d][mem] = true;
    switch(prog[y][x]){
    case '<': que.push(PP(P(x-1, y), P(left, mem))); break;
    case '>': que.push(PP(P(x+1, y), P(right, mem))); break;
    case '^': que.push(PP(P(x, y-1), P(up, mem))); break;
    case 'v': que.push(PP(P(x, y+1), P(down, mem))); break;
    case '_': 
      if(mem == 0) que.push(PP(P(x+1, y), P(right, mem)));
      else que.push(PP(P(x-1, y), P(left, mem)));
      break;
    case '|':
      if(mem == 0) que.push(PP(P(x, y+1), P(down, mem)));
      else que.push(PP(P(x, y-1), P(up, mem)));
      break;
    case '?':
      for(int i = 0; i < 4; i++){
	que.push(PP(P(x+dx[i], y+dy[i]), P(i, mem)));
      }
      break;
    case '+': que.push(PP(P(x+dx[d], y+dy[d]), P(d, (mem+1)%16))); break;
    case '-': que.push(PP(P(x+dx[d], y+dy[d]), P(d, (mem+15)%16))); break;
    case '@': flag = true; break;
    case '.': que.push(PP(P(x+dx[d], y+dy[d]), P(d, mem))); break;
    default:
      que.push(PP(P(x+dx[d], y+dy[d]), P(d, prog[y][x]-'0')));
      break;
    }
    if(flag) break;
  }
  cout << (flag ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
int main() {
	int a, b; std::cin >> a >> b;
	if (a == b) std::cout << 0 << std::endl;
	else if (std::abs(a - b) % 2 == 1) std::cout << "IMPOSSIBLE\n";
	else std::cout << (a + b) / 2 << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
using namespace std;
#include<math.h>
#include<string.h>
#include<queue>
#include<stdio.h>
int main()
{
	//ifstream in("1.txt",ios::in);
	long long a,b,c;
	scanf("%lld%lld.%lld",&a,&b,&c);
	long long s = a*b,temp = a*c;
	temp=temp/100,s+=temp;
	cout<<s<<endl;
	//in.close();
	return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  for(a : S){
    if(a + N > 'Z'){
      a = 'A' + a + N - 'Z' - 1;
    }else{
      a = a + N;
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
arr = [int(x) for x in input().split()]
k = sum(arr)
k = k/(4*m)
cnt=0
for i in range(n):
  if arr[i]>=k:
    cnt+=1
if cnt>=m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
n,m=map(int,input().split())
li=[0]*n
ok=0
ng=0
pro=set()
for i in range(m):
    p,s=map(str,input().split())
    p=int(p)
    if s=="WA":
        li[p-1]+=1
    else:
        if not p in pro:
            ok+=1
            ng+=li[p-1]
            pro.add(p)
print(ok,ng)

Measured memory_bytes: 18276
#include <stdio.h>

int main(){
	int k, i, cont1=0, cont=0;
	scanf("%i", &k);
	i=k;
	while(i--){
		if(i%2==0){
			cont++;
		}
		else
		cont1++;
	}
	printf("%i\n", cont*cont1);

}

Measured memory_bytes: 128
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
lint n,a,b,c,d;
int main(){
  cin>>n>>a>>b>>c>>d;
  REP(i,n){
    lint K=i,L=n-1-i;
    lint lb=a+(-K*d+c*L),ub=a+(-K*c+d*L);
    if(lb<=b && b<=ub){
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  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("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let n: usize = read();
    let a: u64 = read();
    let b: u64 = read();
    let mut x: Vec<u64> = (0..n).map(|_| read()).collect();

    x.sort();
    let mut ret = 0;
    for i in 1..n {
        ret += std::cmp::min((x[i] - x[i - 1]) * a, b);
    }

    println!("{}", ret);
}


Measured memory_bytes: 2816
#include<iostream>
#include<stdio.h>
int main()
{
    int k, n;
    scanf("%d %d", &k, &n);
    int max = 0;
    int arr[n];
    for(int i = 0; i < n; i++)
        scanf("%d", &arr[i]);
    max = arr[0] + (k - arr[n - 1]);
    for (int i = 0; i < n - 1; i++)
    {
      if(max < arr[i + 1] - arr[i])
      {
        max = arr[i + 1] - arr[i];
      }
    }
    printf("%d", k - max);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long,long>
#define INF 1000000000000000000
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; }
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<int, int> mp;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
class Union_Find {
private:
	vector<int> par;
	vector<int> rank;
public:
	Union_Find(int n) {
		rep(i, n) {
			par.push_back(i);
			rank.push_back(0);
		}
	}
	int find(int x) {
		if (par.at(x) == x) return x;
		else return par.at(x) = find(par.at(x));
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank.at(x) < rank.at(y)) {
			par.at(x) = y;
		}
		else {
			par.at(y) = x;
			if (rank.at(x) == rank.at(y)) rank.at(x)++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int>h(n);
	rep(i, n)cin >> h[i];
	int now = 10000000000;
	for (int i = n - 1; i >= 0; i--) {
		now = min(h[i], now);
		if (now < h[i] && h[i] - now != 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
	ll a,b;
	cin >> a >> b;
	ll ans=0;
	if(a>=2){
		ans+=a*(a-1)/2;
	}
	if(b>=2){
		ans+=b*(b-1)/2;
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    vector<ll> A(N+1);
    vector<ll> B(N);
    ll cnt = 0;
    for(int i=0;i<N+1;i++) {
        cin >> A.at(i);
    }
    for(int i=0;i<N;i++) {
        cin >> B.at(i);
    }
    for(int i=0;i<N;i++) {
        if(A.at(i)-B.at(i) >= 0) {
            cnt += B.at(i);
        }else{
            cnt += A.at(i);
            if(A.at(i+1) - abs(A.at(i)-B.at(i)) >= 0) {
                cnt += abs(A.at(i)-B.at(i));
                A.at(i+1) = A.at(i+1) - abs(A.at(i)-B.at(i));
            }else{
                cnt += A.at(i+1);
                A.at(i+1) = 0;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4696
// Problem : A - Study Scheduling
// Contest : AtCoder - NOMURA Programming Competition 2020
// URL : https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

void solve(){
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int t1 = h1*60 + m1;
    int t2 = h2*60 + m2;
    int en = t2 - k;
    int ans = en - t1;
    cout<<ans<<endl;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int t;
    //cin>>t;
    t = 1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;
typedef long long ll;
/*
  AOJ power
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B&lang=jp
  繰り返し2乗法
*/

ll power(int m,int n)
{
  if(n==0) return 1;
  if(n&1) return m*power(m,n-1) % ll(1e9+7);
  ll k=power(m,n/2);
  return k*k % ll(1e9+7);
}
int main()
{
  int n,m;
  cin>>m>>n;
  cout<<power(m,n)<<"\n";
}



Measured memory_bytes: 3100
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

bool form1(int x){
	return ((x-1)%3 == 0);
}

bool form0(int x){
	return (x >= 15005 && x%2==1);
}
int main(){
	int n;
	cin>>n;
	if(n==3){
		cout<<2<<" "<<5<<" "<<63<<endl;
		return 0;
	}
	int cnt=0;
	//if(n%2==0){
	if(form0(n)){
		int k=1;
		for(;k<=14999;k++) cout<<2*k<<" ";k--;
		int rem=n-k;
		for(int l=0;l<rem;l++)	cout<<3+6*l<<" ";
		cout<<endl;	
	}
	else{
	if(form1(n-2)) {
		// output n-2 even numbers or till 30000 rest are odds of the form 3+6*n;
		int k=1;
		for(;k<=min(n-4,15000);k++) {cout<<2*k<<" ";}k--;
		int rem=n-k;	
		for(int l=0;l<rem;l++) {cout<<3+6*l<<" ";}
		cout<<endl;	
	}
	else{
		int k=1;
		for(;k<=min(n-2,15000);k++) {cout<<2*k<<" ";}k--;
		int rem=n-k;	
		for(int l=0;l<rem;l++) {cout<<3+6*l<<" ";}
		cout<<endl;	
	}
	}
	//cout<<cnt<<endl;
}

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

int main()
{
  string ans = "";
  string s = "";
  cin >> s;
  int length = s.length();
  for (int i = 0; i < length; i++) {
    if (s[i] == '0') {
      ans += "0";
    }
    else if (s[i] == '1') {
      ans += "1";
    }
    else {
      if (ans != "") ans.pop_back();
    }
  }

  cout << ans << endl;
}

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

using namespace std;
using ll=long long;
using vi=vector<int>;
using vl=vector<ll>;
using vs=vector<string>;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define rep(i, a, n) for (int i = (n); i < (a); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)

template<typename T,typename U>
void Inparray(T &f,U n){
  for(int i=0;i<n;i++) cin>>f[i];
}

template<typename T,typename U>
void Printarray(T f,U n){
  for(int i=0;i<n;i++) i!=n ? cout<<f[i]<<" " : cout<<f[i];
}

void flagfunc(bool flag,string A,string B){
  flag ? cout<<A<<endl : cout<<B<<endl;
}

void flag2func(bool flag){
  flag ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}

void flag3func(bool flag){
  flag ? cout<<"YES"<<endl : cout<<"NO"<<endl;
}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,x;cin>>n>>x;
  int m,a=1000,ans=0;
  for (int i = 0; i < n; ++i){
  	cin>>m;
  	a=min(m,a);
  	x-=m;
  	ans++;
  }
  cout<<x/a+ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll x;
bool prime[101010];
int main() {
    cin>>x;

    REP(i, 0, 101010) prime[i]=true;
    for(int i=2; i*i<101010; i++){
        for(int j=i*2; j<101010; j+=i){
            prime[j]=false;
        }
    }
    REP(i, x, 101010){
        if(prime[i]){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> dp(H + 1, vector<int>(W, 0)); dp[0][0] = 1;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            for (int k = 0; k < 1 << (W - 1); k++)
            {
                bool ok = true;
                for (int l = 0; l < W - 2; l++)
                {
                    if(((k >> l) & 1) && ((k >> (l + 1)) & 1)) ok = false;
                }
                if(ok){
                    if(j >= 1 && ((k >> (j - 1)) & 1)){
                        dp[i + 1][j - 1] += dp[i][j];
                        dp[i + 1][j - 1] %= mod;
                    }
                    else if(j <= W - 2 && ((k >> j) & 1)){
                        dp[i + 1][j + 1] += dp[i][j];
                        dp[i + 1][j + 1] %= mod;
                    }
                    else{
                        dp[i + 1][j] += dp[i][j];
                        dp[i + 1][j] %= mod;
                    }
                }
            }
        }
    }

    cout << dp[H][K - 1] << endl;
}

Measured memory_bytes: 256
li=list(input())
N=int(len(li))
liR=reversed(li)
liR=list(liR)
A=False
B=False
C=False
if li==liR:
    A=True

liF=li[0:round((N-1)/2)]
liFR=reversed(liF)
liFR=list(liFR)
if liF==liFR:
    B=True

liB=li[round((N+1)/2):N]
liBR=reversed(liB)
liBR=list(liBR)
if liB==liBR:
    C=True

if A==True and B==True and C==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n,x = map(int,input().split())
m = [0]*n

for i in range(n):
  m[i] = int(input())
c = 0
if sum(m) >= x:
  for i in range(n):
    if x >= 0:
      x = x - m[i]
      c += 1
    else:
      break
  print(c)
else:
  x = x - sum(m)
  c = len(m)
  c += int(x/min(m))
  print(c)

Measured memory_bytes: 38476
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
	public static void main(String[] args) {
	    Scanner sc = new Scanner(in);
	    int A = sc.nextInt(), B = sc.nextInt(),
	        C = sc.nextInt(), D = sc.nextInt();
	    int ans = min(A,B) + min(C,D);
		out.println(ans);
	}
}

Measured memory_bytes: 35784
#include<stdio.h>

int judge(int *,int,int,int);

/*作成可能か判定する関数*/
int judge(int *A,int n,int m,int i)
{ 
  if(m == 0){
    return 1;
  }
  if(i >= n) {
    return 0;
  }

  judge(A,n,m,i+1) || judge(A,n,m-A[i],i+1); /*再帰*/
}

int main()
{
  int n,q,i;
  int A[20],m;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(judge(A,n,m,0) == 1) { /*作成可能か判定*/
    printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}



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

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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,K,rs=0,mind=INF;
    cin >> N >> K;

    vector<ll> A(N);

    for(ll i = 0;i < N;i++)
        cin >> A.at(i);
    
    sort(A.begin(),A.end());
    
    for(ll i = 1;i < N;i += K -1){
        rs++;
    }

    cout << rs << endl;
}

Measured memory_bytes: 1024
program main
implicit none
integer ::n , m
integer , allocatable :: x(:), y(:)
integer :: i
integer :: a

read(*,*) n,m 
if( n.ge.m ) then
   write(*,'(i0)') 0
   stop
end if
allocate(x(m))
allocate(y(m-1))
read(*,*) x
call heapsort(m,x)
do i = 1, m-1
   y(i) = x(i+1)-x(i)
end do
call heapsort(m-1,y)

a = 0
do i = 1, m-n
   a = a + y(i)
end do

write(*,'(i0)') a
deallocate(x)
deallocate(y)

stop
contains
subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)
  
  integer ::i,k,j,l
  integer :: t

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        end if
     end if
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        end if
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        end if
     end do
     array(i)=t
  end do
end subroutine heapsort


end program main


Measured memory_bytes: 1536
S = list(input())


def check():
    # 使われている文字種のセットを得る
    char_set = set(S)
    # 2種類でなければNo
    if len(char_set) != 2:
        return "No"
    # それぞれの文字種が2個ずつでなければNo
    for c in char_set:
        if S.count(c) != 2:
            return "No"
    # ここまで来たらYes
    return "Yes"


print(check())

Measured memory_bytes: 2940
def main():
  N = int(input())
  a = list(map(int, input().split()))

  rate = [3199, 2799, 2399, 1999, 1599, 1199, 799, 399, 1]

  c = [0] * len(rate)

  for v in a:
    for i, r in enumerate(rate):
      if(v > r):
        c[i] += 1
        break

  count = 0
  ans = [0,0]

  for v in c[1:]:
    if(v > 0):
      count += 1

  ans[0] = ans[1] = count

  if(c[0] > 0):
    if(count == 0):
      ans[0] = 1
      ans[1] = c[0]
    else:
      ans[1] += c[0]


  print(" ".join(map(str, ans)))


if __name__ == "__main__":
  main()

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;

int main(void) {
  int n, a[5001];
  long long int sum, mx;
  
  while(cin>>n && n) {
    for(int i = 0; i < n; i++) cin >> a[i];

    mx=-100000*5001;
    for(int i = 0; i < n; i++) {
      sum=0;
      for(int j = i; j < n; j++) {
	sum+=a[j];
	mx=max(mx, sum);
      }
    }
    cout<<mx<<endl;
  }

  return 0;
}

Measured memory_bytes: 1176
s = list(input())

#不等号の向きを記録する
memo = ""

#不等号の連続した個数を記録する
cnt = 0

#1つ前に数えた不等号の連続した個数を記録する
before_cnt = 0

#出力する答え
ans = 0

#文字列Sの連続した不等号の向きを数える
for x in s:
    #初めはmemoが空白なので,memoに不等号の向きを記録
    if memo == "":
        memo = x
    
    #不等号の向きが同じ場合は、数を1カウントしてループに戻る
    if memo == x:
        cnt += 1
        
    #不等号の向きが異なる場合
    else:
        #ansに和を加算する
        ans += cnt * (cnt+1) // 2
        
        if memo == ">":
            if before_cnt < cnt:
                ans -= before_cnt
            else:
                ans -= cnt
        before_cnt = cnt
        cnt = 1
        memo = x
else:
    ans += cnt * (cnt+1) // 2
    if before_cnt < cnt:
        if memo == ">":
            ans -= before_cnt
    else:
        if memo == ">":
            ans -= cnt
    before_cnt = cnt
    cnt = 0
 
print(ans)

Measured memory_bytes: 7836
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main()
{

  string s;
  cin >> s;

  map<char,ll> m;

  rep(i,sz(s))
  {
    m[s[i]]++;
  }

  ll ans = min(m['0'],m['1']) * 2;

  cout << ans << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main()
{
	int n;
	std::vector<int> L(209);

	cin >> n;
	rep(i, 2 * n) cin >> L[i];

	//////compute/////////

	sort(L.begin(), L.end(), greater<int>());

	int ans = 0;

	for (int i = 0; i < n; ++i) ans += L[2 * i + 1];

	cout << ans << endl;



}

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


using namespace std;


vector<int> score (string s, int e) {
    vector<int> result = {0, 0};

    for (int i=e-1; i>=0; i--) {
        if (s[i] == 'L') break;

        result[(e-i+1)%2]++;
    }

    for (int i=e; i<s.size(); i++) {
        if (s[i] == 'R') break;

        result[(i-e+1)%2]++;
    }

    return result;
}


int main() {
    string s; cin >> s;
    int n = s.size();

    vector<int> divs;
    for (int i=1; i<n; i++) {
        if (s[i-1] == 'R' and s[i] == 'L') {
            divs.push_back(i);
        }
    }

    vector<int> ans(n, 0);

    for (int e: divs) {
        auto ret = score(s, e);
        ans[e-1] += ret[0];
        ans[e] += ret[1];
    }

    for (int e: ans) cout << e << ' '; cout << endl;
    return 0;
}



Measured memory_bytes: 1280
import sys
input = sys.stdin.readline
import bisect

N = int(input())
# 逆順にする
A = [int(input()) for _ in range(N)][::-1]

dp = [float("inf")] * N

# 広義単調増加列の長さの最大値を求める
# https://mathtrain.jp/tantyou
for a in A:
    idx = bisect.bisect_right(dp, a)
    dp[idx] = a

answer = bisect.bisect_left(dp, float("inf"))
print(answer)

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

int main() {
    int N;
    cin >> N;
    int f_x = 0;
    int n = N;
    while (n > 0) {
        f_x += n % 10;
        n /= 10;
    }
    if (N % f_x == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
n,x = map(int,input().split())
a = list(map(int,input().split()))
res = 0
a.sort()

for i in range(n):
    if i == n-1:
        if a[i] == x:
            res += 1
        else:
            break
    elif a[i] <= x:
        x -= a[i]
        res += 1

print(res)


Measured memory_bytes: 2940
sa = list(input())
sb = list(input())
sc = list(input())
ai, bi, ci = 0, 0, 0
user = "a"
ans = ""
while True:
    if user == "a":
        if len(sa) == 0:
            ans = "A"
            break
        user = sa.pop(0)
    elif user == "b":
        if len(sb) == 0:
            ans = "B"
            break
        user = sb.pop(0)
    elif user == "c":
        if len(sc) == 0:
            ans = "C"
            break
        user = sc.pop(0)
print(ans)


Measured memory_bytes: 3064
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(long long int i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); vect(A);for(long long i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
ll p=1e5;

int main()
{
    /*#ifndef ONLINE_JUDGE
       freopen ("input.txt" , "r" , stdin);
		// freopen ("OUTPUT.txt" , "w" , stdout);
	#endif
    */
	fio;
    string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;
    cin>>s;
    ll h=0;
    forin(i,0,6)
    {
        if(s==a[i])
        {
            h=i;
        }
    }
    cout<<7-h<<endl;
}



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

int main() {
  string n;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < (int)n.size(); i++) {
    sum += ((int)n.at(i) - 48);
  }
  if (sum % 9 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main(){
 	int a,b,c,d;
	cin >> a >> b >> c >> d;
	
	if(abs(a-c) <= d || abs(a-b) <=d  && abs(b-c) <= d)
	  	cout << "Yes" << endl;
	else
      	cout << "No" << endl;
}


Measured memory_bytes: 256
import collections

n=int(input())
arr=list(map(int,input().split()))
dp=[[[0]*(n+1) for _ in range(n+1)] for _ in range(n+1)]
cnt=collections.Counter(arr)
for total in range(1,n+1):
  for three in range(total+1):
    for two in range(total-three+1):
      one=total-two-three
      dp[one][two][three]+=n/total
      if one!=0:
        dp[one][two][three]+=dp[one-1][two][three]*one/total
      if two!=0:
        dp[one][two][three]+=dp[one+1][two-1][three]*two/total
      if three!=0:
        dp[one][two][three]+=dp[one][two+1][three-1]*three/total
print(dp[cnt[1]][cnt[2]][cnt[3]])

Measured memory_bytes: 368944
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int s;
	cin >> s;
	int top = s / 100;
	int btm = s % 100;

	if (top == 0 && btm == 0)
	{
		cout << "NA";
		return 0;
	}

	if (top == 0 && btm > 12){
		cout << "NA";
		return 0;
	}
	if (btm == 0 && top > 12)
	{
		cout << "NA";
		return 0;
	}

	if (top == 0 && btm < 13)
	{
		cout << "YYMM";
		return 0;
	}
	if (btm == 0 && top < 13)
	{
		cout << "MMYY";
		return 0;
	}

	bool topm = true;
	bool btmm = true;

	if (12 < top){
		topm = false;
	}

	if (12 < btm){
		btmm = false;
	}

	if (topm == true && btmm == false){
		cout << "MMYY";
	}
	else if (topm == false && btmm == true)
	{
		cout << "YYMM";
	}
	else if (topm == false && btmm == false){
		cout << "NA";
	}
	else{
		cout << "AMBIGUOUS";
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int five=0, seve=0;

  for (int i=0; i<3; i++) {
    int n;
    scanf("%d", &n);

    if (n==5) five++;
    else if (n==7) seve++;
  }

  printf("%s\n", five==2 && seve==1 ? "YES": "NO");
  return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		char[] t = n().toCharArray();

		int count = 0;
		int w = 0;
		for (char c : t) {
			count++;
			if (c == 'o') {
				w++;
			}
		}

		if (w + 15 - count >= 8) {
			out("YES");
		} else {
			out("NO");
		}

	}

	/*
	 * 以下メソッド集
	 */
	static int[] sort(int[] n) {
		Arrays.sort(n);
		return n;
	}

	static long[] sort(long[] n) {
		Arrays.sort(n);
		return n;
	}

	static int ketasuu(int n) {
		String str = "" + n;
		return str.length();
	}

	static int account(String str) {
		String target = "AC";
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if (target.equals(str.substring(i, i + target.length()))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static long min(long d, long e) {
		return Math.min(d, e);
	}

	static int min(int a, int b) {
		return (int) Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        vector<bool> S(13, false), H(13, false), C(13, false), D(13, false);
        _i64 n, number; char mark; cin >> n;
        _rep(i, n) {
            cin >> mark >> number;
            switch(mark) {
                case 'S': S[number - 1] = true; break;
                case 'H': H[number - 1] = true; break;
                case 'C': C[number - 1] = true; break;
                case 'D': D[number - 1] = true; break;
            }
        }
        _rep(i, 13) { if(S[i] == false) { cout << "S " << i + 1 << endl; } }
        _rep(i, 13) { if(H[i] == false) { cout << "H " << i + 1 << endl; } }
        _rep(i, 13) { if(C[i] == false) { cout << "C " << i + 1 << endl; } }
        _rep(i, 13) { if(D[i] == false) { cout << "D " << i + 1 << endl; } }
    }
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,a;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);
  a=A.at(0);
  rep(i,N-1){
    a=a^A.at(i+1);
  }
  rep(i,N){
    ll x=a^A.at(i);
    cout << x << " ";
  }
  cout << endl;
}

Measured memory_bytes: 4736