akhauriyash/Code-Regression huggingface dataset:
def Diagonal_String(c1, c2, c3):

    return c1[0] + c2[1] + c3[2]

def main():
    c1 = str(input())
    c2 = str(input())
    c3 = str(input())
    print(Diagonal_String(c1 , c2 , c3))

if __name__ == '__main__':
    main()

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

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

fn main() {
    let n: usize = read();
    let mut ans = 0;
    for i in 1..n+1 {
        if !(i % 3 == 0 || i % 5 == 0) {
            ans += i
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2136
import sys
input = sys.stdin.readline

# A - Simple Calculator
x, y = map(int, input().split())

if x < y:
	if x >= 0:
		print(y - x)
	elif x <= 0 and y > 0:
		if abs(x) > y:
			print(abs(x) - y + 1)
		else:	
			count = y - abs(x) + 1
		
			if count > 0:
				print(min(count, abs(x) + y))
			else:
				print(abs(x) + y)
	else:
		print(abs(x) - abs(y))
else:
	if y > 0:
		print(x- y + 2)
	elif y == 0:
		print(x + 1)
	elif x >= 0 and x >= abs(y):
		print(x - abs(y) + 1)
	elif x >= 0 and x < abs(y):
		print(abs(y) - x + 1)
	else:
		print(abs(y) - abs(x) + 2)

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

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

map<char, int> mp;

int main() {
	int n;
	cin >> n;
	mp['S'] = 1 << 14; mp['S']--;
	mp['H'] = 1 << 14; mp['H']--;
	mp['C'] = 1 << 14; mp['C']--;
	mp['D'] = 1 << 14; mp['D']--;
	for (int i = 0; i < n; i++) {
		char m; int r;
		cin >> m >> r;
		r--;
		if (m == 'S')
			mp[m] ^= (1 << r);
		if (m == 'H')
			mp[m] ^= (1 << r);
		if (m == 'C')
			mp[m] ^= (1 << r);
		if (m == 'D')
			mp[m] ^= (1 << r);
	}
	int cnt;
	for (cnt = 1; mp['S'] != 1; mp['S'] >>= 1) {
		if (mp['S'] & 1)
			cout << "S " << cnt << endl;
		cnt++;
	}
	for (cnt = 1; mp['H'] != 1; mp['H'] >>= 1) {
		if (mp['H'] & 1)
			cout << "H " << cnt << endl;
		cnt++;
	}
	for (cnt = 1; mp['C'] != 1; mp['C'] >>= 1) {
		if (mp['C'] & 1)
			cout << "C " << cnt << endl;
		cnt++;
	}
	for (cnt = 1; mp['D'] != 1; mp['D'] >>= 1) {
		if (mp['D'] & 1)
			cout << "D " << cnt << endl;
		cnt++;
	}
	return 0;
}



Measured memory_bytes: 3092
/*  -*- coding: utf-8 -*-
 *
 * 2808.cc: Password
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_L = 400000;
const int EN1 = 26;
const int EN2 = EN1 * 26;
const int EN3 = EN2 * 26;
const int EN4 = EN3 * 26;

/* typedef */

/* global variables */

char s[MAX_L + 4];
bool us1[EN1], us2[EN2], us3[EN3], us4[EN4];

/* subroutines */

void printstr(int l, int k) {
  for (int i = 0; i < l; i++, k /= 26) s[i] = (k % 26) + 'a';
  for (int i = l - 1; i >= 0; i--) putchar(s[i]);
  putchar('\n');
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  while (n--) {
    scanf("%s", s);
    int k1 = 0, k2 = 0, k3 = 0, k4 = 0;
    for (int i = 0; s[i]; i++) {
      int d = s[i] - 'a';
      k4 = k3 * 26 + d;
      k3 = k2 * 26 + d;
      k2 = k1 * 26 + d;
      k1 = d;

      us1[k1] = true;
      if (i >= 1) {
	us2[k2] = true;
	if (i >= 2) {
	  us3[k3] = true;
	  if (i >= 3) us4[k4] = true;
	}
      }
    }
  }

  for (int i = 0; i < EN1; i++)
    if (! us1[i]) {
      printstr(1, i);
      return 0;
    }

  for (int i = 0; i < EN2; i++)
    if (! us2[i]) {
      printstr(2, i);
      return 0;
    }

  for (int i = 0; i < EN3; i++)
    if (! us3[i]) {
      printstr(3, i);
      return 0;
    }

  for (int i = 0; i < EN4; i++)
    if (! us4[i]) {
      printstr(4, i);
      return 0;
    }

  return 0;
}



Measured memory_bytes: 3984
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var graph = new List<Tuple<int, long>>[N].Select(x => new List<Tuple<int, long>>()).ToArray();
            for (var i = 0; i < N - 1; i++)
            {
                var abc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var a = abc[0] - 1;
                var b = abc[1] - 1;
                long c = abc[2];
                graph[a].Add(new Tuple<int, long>(b, c));
                graph[b].Add(new Tuple<int, long>(a, c));
            }

            var QK = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var Q = QK[0];
            var K = QK[1] - 1;

            var queue = new Queue<int>();
            queue.Enqueue(K);
            var costs = Enumerable.Repeat((long)1e18 + 1, N).ToArray();
            costs[K] = 0;
            while (queue.Any())
            {
                var current = queue.Dequeue();
                foreach (var next in graph[current])
                {
                    if (costs[next.Item1] <= costs[current] + next.Item2) continue;
                    costs[next.Item1] = costs[current] + next.Item2;
                    queue.Enqueue(next.Item1);
                }
            }


            var query = new Tuple<int, int>[Q];
            for (var i = 0; i < Q; i++)
            {
                var xy = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                query[i] = new Tuple<int, int>(xy[0] - 1, xy[1] - 1);
            }

            for (var i = 0; i < Q; i++)
            {
                var x = query[i].Item1;
                var y = query[i].Item2;
                Console.WriteLine(costs[x] + costs[y]);
            }
        }
    }
}


Measured memory_bytes: 67132
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
    String S = sc.next();
	StringBuilder X = new StringBuilder();
    for(int i =0; i<S.length(); i++){
    	X.append("x");
    }
    System.out.println(X.toString());

  }
}


Measured memory_bytes: 22864
//itp1_topic2_d
#include <bits/stdc++.h>
using namespace std;
int main(){
  int W, H;
  cin>>W>>H;
  int x, y, r;
  cin>>x>>y>>r;
  if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
    }



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5+10;
typedef long long ll;
int N, T;
int a[MAXN];

int main() {
    scanf("%d %d", &N, &T); 
    for(int i=0;i<N;i++) scanf("%d", &a[i]);
    ll ans = T;
    for(int i=0;i<N-1;i++) {
        ans += min(T, a[i+1]-a[i]);
    }
    printf("%lld\n", ans);

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
	vite;
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	lli n;
	cin>>n;
	lli a[n];
	for(lli i=0;i<n;i++) cin>>a[i];
	lli sum=0,p[n+1]={0};
	for(lli i=n-1;i>=0;i--) p[i]=(p[i+1]+a[i])%mod;
	for(lli i=0;i<n;i++){ sum+=a[i]*p[i+1];sum%=mod;}
	cout<<sum;
	cout<< endl;
	// cout<< fixed << setprecision(6) << 1.0 * clock() / CLOCKS_PER_SEC;
	return 0;
}

Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	double a, b, C;
	double PI = acos(-1);
	double rad = 0;

	cin >> a >> b >> C;

	double S, L, h;

	rad = C * PI / 180;
	S = 0.5 * a * b * sin(rad);
	L = a + b + sqrt(pow(a, 2.0) + pow(b, 2.0) - 2 * a * b * cos(rad));
	h = b * sin(rad);

	cout << fixed << setprecision(8) << S << endl;
	cout << fixed << setprecision(8) << L << endl;
	cout << fixed << setprecision(8) << h << endl;

}


Measured memory_bytes: 3428
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
#define ll long long
ll a[maxn],b[maxn];
main()
{
    int n,k;scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%lld%lld",&a[i],&b[i]);
    ll ans=0;
    for(int i=1;i<=n;i++)if((k|a[i])==k)ans+=b[i];
    for(int i=0;i<=30;i++)if(k>>i&1)
    {
        ll t=((ll)k>>(i+1))*(1ll<<(i+1))+(1ll<<i)-1;
        //printf("%d\n",t);
        ll tmp=0;
        for(int i=1;i<=n;i++)if((t|a[i])==t)tmp+=b[i];
        ans=max(ans,tmp);
    }
    printf("%lld\n",ans);

    return 0;
}


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

public class Main {
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		//String str = "10 9 4";
		int x;
		String[] num = str.split(" ", 0);
		int a = Integer.parseInt(num[0]); //3
		int b = Integer.parseInt(num[1]); //8
		int c = Integer.parseInt(num[2]); //1

		if (a > b) {
			x = a;
			a = b;
			b = x;
		}
		if (b > c){
			x = b;
			b = c;
			c = x;
		}		
		if (a > b) {
			x = a;
			a = b;
			b = x;
		}
		System.out.println(a + " " + b + " " + c);
        }
}

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

struct data {
  string name;
  long long x;
};
bool operator<(const data &l, const data &r) {
  if(l.x != r.x) return l.x > r.x;
  return l.name < r.name;
}

long long n, m, k, l;
vector<data> v;
set<string> fav;
vector<long long> lst;

long long solve();
bool ch(long long top);

int main() {
  while(1) {
    cin >> n >> m >> k >> l;
    if(n + m + k + l == 0) break;
    v.resize(n);
    lst.clear();
    fav.clear();
    for(int i = 0; i < n; ++i) cin >> v[i].name >> v[i].x;
    for(int i = 0; i < m; ++i) {
      string s;
      cin >> s;
      fav.insert(s);
    }
    cout << solve() << endl;
  }
  return 0;
}

long long solve() {
  sort(v.begin(), v.end());
  for(int i = 0; i < n; ++i)
    if(fav.find(v[i].name) != fav.end()) lst.push_back(i);
  long long l = 0, r = min(k, m) + 1;
  while(r - l > 1) {
    long long now = (l + r) / 2;
    if(ch(now))
      l = now;
    else
      r = now;
  }
  return l;
}

bool ch(long long top) {
  long long remain = l, under = top;
  for(int i = 0; i < top; ++i) {
    long long nowid = lst[i];
    if(nowid <= k - under) {
      --under;
      continue;
    }
    remain -= v[k - under].x - v[nowid].x +
              (v[nowid].name > v[k - under].name);
  }
  return remain >= 0;
}


Measured memory_bytes: 18500
X = int(input())
i = 2
A = [0 for _ in range(X+1)]
A[1] = 1
while i**2 <= X:
  A[i**2] = i**2
  p = 3
  while i**p <= X:
    A[i**p] = i**p
    p += 1
  i += 1
print(max(A))

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
	int board[41][101];
	int num_w,num_b;//w  for  0  b  for 1;
	int i,j;
	while(scanf("%d %d",&num_w,&num_b)!=EOF)
	{
		for(i=1;i<=20;i++)
		{
			for(j=1;j<=100;j++)
			{
				board[i][j]=0;
			}
		}
		for(i=21;i<=40;i++)
		{
			for(j=1;j<=100;j++)
			{
				board[i][j]=1;
			}
		}
		if(num_b>1)
		{
			for(i=1;i<=20;i+=2)
			{
				for(j=1;j<=100;j++)
				{
					if(j%2==1)
					{
						board[i][j]=1;
						num_b--;
					}
					if(num_b==1)
					{
						break;
					}
				}
				if(num_b==1)
				{
					break;
				}
			}
		}
		
		if(num_w>1)
		{
			for(i=40;i>=21;i-=2)
			{
				for(j=1;j<=100;j++)
				{
					if(j%2==1)
					{
						board[i][j]=0;
						num_w--;
					}
					if(num_w==1)
					{
						break;
					}
				}
				if(num_w==1)
				{
					break;
				}
			}
		}
		
		printf("40 100\n");
		
		for(i=1;i<=40;i++)
		{
			for(j=1;j<=100;j++)
			{
				if(board[i][j]==0)
				{
					printf(".");
				}else {
					printf("#");
				}
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 128
def main():
    N, D, A = (int(i) for i in input().split())
    P = [[int(i) for i in input().split()] for j in range(N)]
    P.sort()
    X = [x[0] for x in P]
    H = [h[1] for h in P]
    diff = [H[0]] + [H[i+1] - H[i] for i in range(N-1)]
    BIT = [0] * (N+1)

    def BIT_query(idx):
        """ A1 ~ Aiまでの和(1-index) """
        res_sum = 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx & -idx
        return res_sum

    def BIT_update(idx, x):
        """ Aiにxを加算(1-index) """
        while idx <= N:
            BIT[idx] += x
            idx += idx & -idx
        return

    def BIT_init(A):
        for i, e in enumerate(A):
            BIT_update(i+1, e)

    BIT_init(diff)
    from bisect import bisect_right
    ans = 0
    for left in range(N):
        x = P[left][0]
        h = BIT_query(left+1)
        if h > 0:
            cur = (h + A - 1) // A
            damage = cur * A
            BIT_update(left+1, -damage)
            right = bisect_right(X, x + 2*D)
            BIT_update(right+1, damage)
            ans += cur
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 102692
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int m,f,r,sum;
    while(true){
      m = sc.nextInt();
      f = sc.nextInt();
      r = sc.nextInt();
      sum = m + f;

      if(m == -1 && f == -1 && r == -1){
        break;
      }
      if(m == -1 || f == -1){
        System.out.println("F");
      }
      else if(sum >= 80){
        System.out.println("A");
      }
      else if(sum >= 65){
        System.out.println("B");
      }
      else if(sum >= 50){
        System.out.println("C");
      }
      else if(sum >= 30){
        if(r >= 50){
          System.out.println("C");
        }
        else{
          System.out.println("D");
        }
      }
      else{
        System.out.println("F");
      }
    }
  }
}

Measured memory_bytes: 26192
# coding: utf-8
# Your code here!
n=int(input())
s=list(input())
ans=0
t=[]
ss=[]
for i in range(n):
    t.append(s[i:])
    ss.append(t[i].count('R'))
    ss.append(t[i].count('G'))
    ss.append(t[i].count('B'))
#print(t)
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]==s[j]:
            continue
        else:
            if s[i]=='R' and s[j]=='G'or s[i]=='G'and s[j]=='R':
                ans+=ss[3*(j+1)+2]
                if 2*j-i<n:
                    if s[2*j-i]=='B':
                        ans-=1
            if s[i]=='B' and s[j]=='R'or s[i]=='R'and s[j]=='B':
                ans+=ss[3*(1+j)+1]
                if 2*j-i<n:
                    if s[2*j-i]=='G':
                        ans-=1
            if s[i]=='B' and s[j]=='G'or s[i]=='G'and s[j]=='B':
                ans+=ss[3*j+3]
                if 2*j-i<n:
                    if s[2*j-i]=='R':
                        ans-=1
        #print(ans)
print(ans)

Measured memory_bytes: 132948
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
const int N=100,W=10000;
int n,m,dp[W+1]={0},v[N],w[N];
void solve(){
	for(int i=0;i<n;i++) 
		for(int j=w[i];j<=m;j++) 
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
} 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d%d",&v[i],&w[i]);
	solve();printf("%d\n",dp[m]);
}	


Measured memory_bytes: 3252
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string>
#define ll long long
int main(){
    ll n;
    cin>>n;
    string s;
    s=to_string(n);
    reverse(s.begin(),s.end());
    if(s[0]=='2' || s[0]=='4'|| s[0]=='5'|| s[0]=='7' || s[0]=='9')
     cout<<"hon"<<endl;
     else if(s[0]=='0'|| s[0]=='1'|| s[0]=='6'||s[0]=='8')
     cout<<"pon"<<endl;
     else
     cout<<"bon"<<endl;
     return 0;
     
    
}


Measured memory_bytes: 3664
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, 10**6 + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans = 0
for i in range(N-K+1):
    k = K - 1
    n = N - 1 - i
    t = -(i+1)
    x = A[N-1-i] - A[i]
    ans += x*cmb(n,k,mod)%mod
print(ans%mod)

Measured memory_bytes: 128144
from string import ascii_lowercase
from bisect import bisect


def solve(s):
    pos = [[] for _ in range(26)]
    offset = ord('a')
    for i, c in enumerate(s):
        c = ord(c) - offset
        pos[c].append(i)
    for l in pos:
        l.append(len(s))

    all_char_sequence_start_pos = []
    pos_i = [len(l) - 1 for l in pos]
    while all(pi >= 0 for pi in pos_i):
        i = min(l[pi] for pi, l in zip(pos_i, pos))
        all_char_sequence_start_pos.append(i)
        for j in range(26):
            while pos_i[j] >= 0 and pos[j][pos_i[j]] >= i:
                pos_i[j] -= 1
    all_char_sequence_start_pos.reverse()
    ans = []
    curr = -1
    for i in all_char_sequence_start_pos:
        for c in range(26):
            cj = bisect(pos[c], curr)
            j = pos[c][cj]
            if j >= i:
                ans.append(c)
                curr = j
                break
    return ''.join(chr(c + offset) for c in ans)


print(solve(input().strip()))


Measured memory_bytes: 12524
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

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

    H[0]--;
    for (int i=1;i<N;++i) {
        if (H[i-1] == H[i]) {

        } else if (H[i-1] < H[i]) {
            H[i]--;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 640
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let s = read::<String>();
    let cs = s.chars().collect::<Vec<_>>();
    let mut count_a = 0;
    let mut count_b = 0;
    for (i, c) in cs.iter().map(|&c| ((c as u8) - b'0') as usize).enumerate() {
        if i % 2 != c {
            count_a += 1;
        }
        if (i + 1) % 2 != c {
            count_b += 1;
        }
    }

    let ans = std::cmp::min(count_a, count_b);
    println!("{}", ans);
}

Measured memory_bytes: 4352
n = int(input())
l = list(map(int, input().split()))
x = [0] * n
x[0] = sum(-l[i] if i & 1 else l[i] for i in range(n))
for i in range(n - 1):
    x[i + 1] = 2 * (l[i] - (x[i] // 2))
print(' '.join(map(str, x)))

Measured memory_bytes: 19176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    bool t = false;
    while (true) {
        C -= B;
        if (C <= 0) {
            t = true;
            break;
        }
        A -= D;
        if (A <= 0) {
            break;
        }
    }

    if (t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main() {
    int n;
    cin >> n;
    int l[n];
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l, l+n, greater<int>());
    int sum = 0;
    for(int i=1;i<n;i++){
        sum += l[i];
    }
    if(l[0] < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define repr(i, a, n) for (ll i = n - 1; (ll)a <= i; i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 + 99);
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
template <typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T>
T mpow(T a, T n)
{
    T res = 1;
    for (; n; n >>= 1)
    {
        if (n & 1)
            res = res * a;
        a = a * a;
    }
    return res;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> e(n, vector<int>(0));
    vector<int> in(n, 0), ans(n);

    rep(i, 0, n + m - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e[a].pb(b);
        in[b]++;
    }

    int root;
    rep(i, 0, n)
    {
        if (!in[i])
        {
            root = i;
            break;
        }
    }

    queue<int> q;
    q.push(root);
    q.push(0);

    while (!q.empty())
    {
        int now = q.front();
        q.pop();
        int mae = q.front();
        q.pop();
        ans[now] = mae;

        rep(i, 0, siz(e[now]))
        {
            if (in[e[now][i]] <= 1)
            {
                q.push(e[now][i]);
                q.push(now + 1);
            }
            else
            {
                in[e[now][i]]--;
            }
        }
    }

    rep(i, 0, n)
    {
        cout << ans[i] << endl;
    }
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ll n,m;
  cin >> n >> m;
  vector<PLL> ab(n);

  rep(i,n){
    cin >> ab[i].first >> ab[i].second;
  }

  sort(all(ab));

  ll ans = 0;
  ll cnt = 0;
  rep(i,n){
    if(cnt + ab[i].second < m){
      //buy all
      ans += ab[i].first * ab[i].second;
      cnt += ab[i].second;
      continue;
    }else{
      ans += ab[i].first *(m-cnt);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20)
#define fi first
#define se second
ll INF = 1LL << 60;
ll mod = 1e9 + 7;
ll modn = 998244353;

int main() {
	int n,k; cin >> n >> k;
	ll ans=k;
	rep(i,n-1) ans*=(k-1);
	cout << ans << endl;
}

Measured memory_bytes: 3612
/* ex5_3
   kohei_suzuki */

#include <stdio.h>
int main(void){
    int height,width;
    scanf("%d %d",&height,&width);

    char square[height][width];
    for(int i=0; i<height ;i++){
        for(int j=0; j<width ;j++){
            scanf(" %c",&square[i][j]);
        }
    }

    int ture_row[height], ture_col[width];
    //表示する行と表示する列を表す0,1列

    for(int i=0; i<height; i++){
        ture_row[i]=0;
        for(int j=0; j<width; j++){
            if(square[i][j] == '#'){
                ture_row[i]=1;
            }
        }
    }

    for(int j=0; j<=width; j++){
        ture_col[j]=0;
        for(int i=0; i<height; i++){
            if(square[i][j]=='#'){
                ture_col[j]=1;
            }
        }
    }

    for(int i=0; i<height; i++){
        if(ture_row[i] == 1){
            for(int j=0; j<width; j++){
                if(ture_col[j] == 1){
                    printf("%c",square[i][j]);
                }
            }
            printf("\n");
        }
    }
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int r, c;
    while (cin >> r >> c, r)
    {
        int ans = 0;
        int d[r][c];

        rep(i, r) rep(j, c) cin >> d[i][j];

        for (int bit = 0; bit < (1 << r); bit++)
        {
            int back[c] = {};

            for (int i = 0; i < r; i++)
            {
                if (bit & (1 << i)) //i行目をひっくり返す
                {
                    rep(j, c) if (d[i][j] == 1) back[j]++;
                }
                else
                {
                    rep(j, c) if (d[i][j] == 0) back[j]++;
                }
            }
            int sum = 0;
            rep(i, c)
            {
                int s = back[i];
                sum += (s > r - s ? s : r - s);
            }
            ans = max(ans, sum);
        }
        OP(ans);
    }
    return 0;
}


Measured memory_bytes: 3508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int w, h, n;
    int[] xs, ys, as;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        w = sc.nextInt();
        h = sc.nextInt();
        n = sc.nextInt();
        xs = new int[n];
        ys = new int[n];
        as = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
            ys[i] = sc.nextInt();
            as[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int oneMax = 0;
        int twoMin = w;
        int threeMax = 0;
        int fourMin = h;
        for (int i = 0; i < n; i++) {
            switch (as[i]) {
                case 1:
                    oneMax = Math.max(oneMax, xs[i]);
                    break;
                case 2:
                    twoMin = Math.min(twoMin, xs[i]);
                    break;
                case 3:
                    threeMax = Math.max(threeMax, ys[i]);
                    break;
                default:
                    fourMin = Math.min(fourMin, ys[i]);
                    break;
            }
        }
        System.out.println(Math.max(twoMin - oneMax, 0) *
                Math.max(fourMin - threeMax, 0));
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, P> PP;

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

//-----------------------------------------------------------------------------

int n,m;
vector<ll> v[100000],data(100000,-1);
set<ll> st;

int root(int);

bool unite(int x,int y) {
	x=root(x),y=root(y);
	if(x!=y) {
		if(data[y]<data[x]) swap(x,y);
		data[x]+=data[y],data[y]=x;
	}
	return x==y;
}

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

int root(int x) {
	return data[x]<0?x:data[x]=root(data[x]);
}

int size(int x) {
	return -data[root(x)];
}

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

	cin>>n>>m;
	REP(i,n) {
		int k; cin>>k;
		REP(j,k) {
			int l; cin>>l; l--;
			v[l].pb(i);
		}
	}

	REP(i,m) {
		if(v[i].size()<2) continue;
		REP(j,v[i].size()-1) {
			unite(v[i][j],v[i][j+1]);
		}
	}

	REP(i,n) {
		st.insert(root(i));
	}

	if(st.size()==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
using namespace std;

int main(){
    int a, b, k;
    cin>>k>>a>>b;
    bool flag = false;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            flag =  true;
            break;
        }
    }
    if(flag){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
string s;
LL ans,len;
LL count(LL a,LL i)
{
    LL s=0;
    LL cnt=i;
    i=pow(2,i);
    s+=i;
    for(int j=1;j<=len-cnt-1;j++)
    {
        s=s*10+i;
        i*=2;
    }
    return a*s;
}
int main()
{
    cin>>s;
    len=s.length();
    for(LL i=0;i<s.length();i++)
    {
        ans+=count(s[i]-'0',i);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;

int main() {
	string str;
	int i;
	while(getline(cin, str)) {
		for(i = 0; i < 26; i++) {
			for(int j = 0; j < str.size(); j++) {
				if(str[j] != ' ' && str[j] != '.') {
					if(str[j] != 'a') {
						str[j] -= 1;
					} else str[j] = 'z';
				}
			}
			for(int j = 0; j < str.size() - 4; j++) {
				if(str[j] == 't' && str[j + 1] == 'h') {
					cout << str <<endl;
					i = 26;
					break;
					//if(str[j + 2] == 'e' ) {
						//cout << str <<endl;
						//i = 26;
						//break;
					//} else if(str[j + 2] == 'i' && str[j + 3] == 's'){
						//cout << str <<endl;
						//i = 26;
						//break;
					//} else if(str[j + 2] == 'a' && str[j + 3] == 't') {
						//cout << str <<endl;
						//i = 26;
						//break;
					//}
				}
			}
			
		}
	}

	return 0;
}

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

int main() {
    int N;
    cin >> N;

    vector<int> v(N);
    for(int i=0; i<N; i++) cin >> v[i];

    int count = 0;

    for(int i=0; i<v.size(); i++) {
        if(i % 2 == 0 and v[i] % 2 == 1) {
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 3592
import sys
from itertools import permutations
n = int(input())
ls = ["".join([str(j) for j in list(i)]) for i in permutations(range(1,n+1))]
p_ls = "".join([i for i in sys.stdin.readline().split()])
q_ls = "".join([i for i in sys.stdin.readline().split()])
print(abs(ls.index(p_ls) - ls.index(q_ls)))

Measured memory_bytes: 6040
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <set>
#include <map>
#include <string>

int main() {
  char buf[5];
  scanf("%s", buf);
  std::string S = buf;

  bool ok = true;
  for (size_t i = 1; i < 4; ++i)
    if (S[i] == S[i-1]) ok = false;

  puts(ok? "Good":"Bad");
}


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

int main(){
	ll h,n;
	cin >> h >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep(i,n){
		cin >> a[i];
		sum += a[i];
	}
	if(sum >= h){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	
    return 0;
}



Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val (N, T) = readLine()!!.split(' ').map { it.toInt() }
    val routes = (0 until N).map {
        val (c, t) = readLine()!!.split(' ').map { it.toInt() }
        Pair(c, t)
    }
    val min = routes.filter { it.second <= T }.map { it.first }.min()
    println(min ?: "TLE")
}


Measured memory_bytes: 38176
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<30)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(0);
}

signed main(){
    init();
    run();
    return 0;
}

bool isok(int a,int b,int x,int y,int tx,int ty){
    return (tx+ty)<=(x+y)&&(a*tx+b*ty)<=(a*x+b*y);
}

void run(){
    int a,b,d;
    while(cin>>a>>b>>d,a){
        int x=inf,y=inf;
        rep(i,100000){
            int tx=i;
            int ty=0;
            // put d on the left side
            if((a*tx-d)>=0&&(a*tx-d)%b==0){
                ty=(a*tx-d)/b;
                if(ty<0)continue;
                if(isok(a,b,x,y,tx,ty)){
                    x=tx;
                    y=ty;
                }
            }
            
            // put d on the right side
            if((a*tx+d)%b==0){
                ty=(a*tx+d)/b;
                if(ty<0)continue;
                if(isok(a,b,x,y,tx,ty)){
                    x=tx;
                    y=ty;
                }
            }
            
            // put d on the left side and both a and b on the right side
            if((d-a*tx)>0&&(d-a*tx)%b==0){
                ty=(d-a*tx)/b;
                if(isok(a,b,x,y,tx,ty)){
                    x=tx;
                    y=ty;
                }
            }   
        }
        cout<<x<<" "<<y<<endl;
    }
}


Measured memory_bytes: 3024
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"input();a=[0]*100000\n"
"for i in input().split():a[int(i)]+=1\n"
"print(max(map(sum,zip(a,a[1:],a[2:]))))\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 11696
char = input()

max_num = 0
max_seq = ''

def include(char):
    for c in char:
        if c not in ['A', 'T', 'G', 'C']:
            return False
    return True

for i in range(len(char)):
    for j in range(i, len(char)):
        sub = char[i:j+1]
        if include(sub):
            if max_num < len(sub):
                max_num = len(sub)
                max_seq = sub

print(max_num)


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


int main(){
  string str;
  cin >> str;
  int count =0;
  
  if(str.size() == 1 ||str.size() == 3 ||str.size() == 5 ||str.size() == 7 
     ||str.size() == 9 ){
    cout << "No" << endl;
  }
  
  else{
  for(int i=0; i < str.size(); i++){
    if(i % 2 == 0){
      if(str.at(i) != 'h'){
        count++;
        break;}
    }
    else{
      if(str.at(i) != 'i'){
        count++;
        break;
      }
    }
  }
  
    if(count == 1){
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    
  }
  }
}



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

int main() {
  string S;
  cin >> S;
  if(S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if(S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else if(S == "Rainy") {
    cout << "Sunny" << endl;
  }
}

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


void solve(long long X, long long Y, long long Z){
	long long A = X; 
	long long B = Y; 
	long long C = Z; 
	swap(A, B); 
	swap(A, C); 
	cout << A << " " << B << " " << C << endl; 
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    long long Z;
    scanf("%lld",&Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
let pi = atan 1. *. 4.

let () = Scanf.scanf "%f %f %f %f" @@ fun l1 l2 h m ->
  let a = 0.5 *. (60.0 *. h +. m) in
  let b = 6.0 *. m in
  let theta = if (a -. b) >= 0. then a -. b else b -. a in
  let th = if theta <= 180. then theta else 360. -. theta in
  let rad = th *. pi /. 180. in
  let c2 = l1 *. l1 +. l2 *. l2 -. 2.0 *. (cos rad) *. l1 *. l2 in
  Printf.printf "%.15f\n" @@ sqrt c2

Measured memory_bytes: 4464
# include <iostream>
using namespace std;
int x,y,s;
void work (void)
{
	if (s+y<x)
	s=x-y;
	if (x*y>s)
	s=x*y;
	cout<<s;
}
int main (void)
{
	cin>>x>>y;
	s=x+y;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX_T = 3000, MAX_M=300;

int M, start, goal,dice[6], *N;

enum status{GOOD, SOSO, BAD};
bool isPositionValid(int p){return 0<=p && p<M;}

int* MakePath(int *path, int from){
	static bool visit[MAX_M] = {};
	static auto checkPath = [&path](int moveto)->int{
		if(!isPositionValid(moveto)){
			return 2*MAX_T;
		}
		else{
			int position = moveto+ N[moveto];
			if(!visit[position]) MakePath(path, position);
			return  path[position]+1;
		}
	};

	if(path==NULL){
		path = new int[M];
		for(int m=0; m<M; m++) path[m] = MAX_T+1;
	}

	visit[from] = true;
	int bestpath = MAX_T;
	if(from==goal)	bestpath = 0;
	else{
		for(int r=0; r<6; r++){
			bestpath = min(bestpath, checkPath(from + dice[r]));
			bestpath = min(bestpath, checkPath(from - dice[r]));
		}
	}
	path[from] = bestpath;
	return path;
}

int main(){
	// 入力
	cin >> M;
	N = new int[M];
	for(int r=0; r<6; r++)	cin >> dice[r];
	cin >> start >> goal;
	for(int m=0; m<M; m++)	cin >> N[m];
	start--;
	goal--;

	int* path = MakePath(NULL, start);
	
	//本番
	int position = start;
	for(int t=0; t<MAX_T; t++){
		if(position == goal) break;
	
		int r;
		cin >> r;
		int d = dice[r-1];

		static auto tryMove = [&path](int moveto, int path_before)->status{
			if(isPositionValid(moveto)){
				int path_new = path[moveto + N[moveto]];
				if(path_before > path_new) return GOOD;
				else if(path_before == path_new) return SOSO;
			}
			return BAD;
		};
	
		int output = 0;
		status forward_status, backward_status;
		forward_status  = tryMove(position + d, path[position]);
		if(forward_status == GOOD) output = 1;

		if(output==0){
			backward_status = tryMove(position - d, path[position]);
			if(backward_status == GOOD) output = -1;
		}

		if(output==0){
			if(forward_status==SOSO) output=1;
			else if(backward_status == SOSO)output=-1;
		}

		position = position + output*d  + (output==0?0:N[position + output*d]);
		cout << output << endl;
	}

	delete[] N;
	delete[] path;
	return 0;
}

Measured memory_bytes: 1304
h, w = list(map(int, input().split()))
a = []
b = [0 for i in range(w)]
for i in range(h):
	ai = list(input())
	a.append(ai)
	for j in range(w):
		if b[j] == 0:
			if ai[j] == "#": 
				b[j] = 1
ans = []
for li in a:
	if li == ["." for i in range(w)]:
		h -= 1
	else:
		ans.append(li)
wd = w
ipl = -1
for i in range(w):
	ipl += 1
	if b[i] == 0:
		wd -= 1
		for j in range(h):
			ans[j].pop(ipl)
		ipl -= 1
w = wd
for i in range(h):
	strp = ""
	for j in range(w):
		strp += ans[i][j] 
	print(strp)

Measured memory_bytes: 3188
N=int(input())
A=list(map(int,input().split()))
B=[0]*(N+1)
C=0
for i in A:
    B[i-1]+=1
for i in B:
    if i>=2:
        C+=i*(i-1)//2
for i in A:
    print(C-B[i-1]+1)


Measured memory_bytes: 32232
#include<bits/stdc++.h>
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 vvi             vector<vi>
#define vb              vector<bool>
#define vvb             vector<vb>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,b)      for(int i=a;i<=b;i++)
#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--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  //c_p_c();
  int  n;
  cin >> n;
  if(n>=30)
    cout<<"Yes";
  else cout<<"No";
  return 0;
}


Measured memory_bytes: 3676
/*#include <stdio.h>
int main(void) {
	int n ,s1, e1, min, dis, a;
	char s2, e2;
	double p = 3.14259265;

	scanf("%d", &n);
	scanf("%d %c",&s1,&s2);
	scanf("%d %c",&e1,&e2);
	if (s1 - e1<0) {
		dis = e1 - s1;
		a = s1;
	}
	else {
		dis = s1 - e1;
		a = e1;
	}

	if (s2 == e2)
		min = dis * 100;
	else if ((s2 == 'S'&&e2 == 'N') || (s2 == 'N'&&e2 == 'S'))
		min = (e1 + s1) * 100;
	else if ((s2 == 'E'&&e2 == 'W') || (s2 == 'W'&&e2 == 'E'))
		min = (e1 + s1) * 100;
	else
		min = dis * 100 + (double)(a * 100 * p) / 2;

		printf("%ld\n", min);
	return 0;
}*/


/*
#include <stdio.h>

int main(void) {
	int n, m = 2, q[50], i, sum = 1;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &q[i]);
	}
	for (i = 0; i < n; i++) {
		do {
			if (q[i] % m == 0) {
				sum += m;
			}
			m++;
		} while (m<q[i]);
		if (q[i] == sum)
			printf("perfect\n");
		else if (q[i] == sum + 1 || q[i] == sum - 1)
			printf("nealy\n");
		else
			printf("neither\n");
	}
	return 0;
}*/


/*
#include <stdio.h>

int main(void) {
	int point = 0, n, d[1000], p[1000], i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &d[i], &p[i]);
	}
	for (i = 0; i < n; i++) {
		switch (d[i]) {
		case 3:
		case 13:
		case 23:
		case 30:
		case 31:
			point += (p[i] * 3) / 100;
			break;
		case 5:
		case 15:
		case 25:
			point += (p[i] * 5) / 100;
			break;
		default:
			point += p[i] / 100;
		}
	}
	printf("%d", point);
	return 0;
}*/
#include <stdio.h>

int main()
{
	char S[4];
	int i, flag = 0;

	scanf("%s", S);

	for (i = 1; i<3; i++) {
		if (S[i] == S[i - 1] )
			flag = 1;
		 if(i == 2 &&((S[i - 1] == S[i - 2])|| S[i] == S[i - 2]))
			flag = 1;
	}
	if (flag == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import heapq
K=int(input())
G=[[((i+1)%K,1)] for i in range(K)]
for i in range(K):
    a=(i*10)%K
    G[i].append((a,0))
def dijkstra(G,s):#Gはi->jの辺をG[i]=[(j,cost),...]で保存
  INF=10**19
  n=len(G)
  d=[INF]*n#n=node数
  d[s]=0
  visited={s}
  que=[(0,s)]
  while(que):
    p=heapq.heappop(que)
    v=p[1]
    visited.add(v)
    for node,cost in G[v]:
      if (node not in visited) and d[node]>d[v]+cost:
        d[node]=d[v]+cost
        heapq.heappush(que,(d[node],node))
  return d

d=dijkstra(G,1)
print(d[0]+1)


Measured memory_bytes: 89376
import math

N, D = map(int, input().split())
inputs = [list(map(int, input().split())) for _ in range(N)]

def compute(point1, point2):
    length = 0
    for item1, item2 in zip(point1, point2):
        length += (item1 - item2) ** 2
    return 1 if int(math.sqrt(length)) ** 2 == length else 0

count = 0
for i in range(N):
    for j in range(i, N):
        if i != j:
            count += compute(inputs[i], inputs[j])

print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  long long N;
  double T, A;
  cin >> N >> T >> A;

  double min_diff = 10000000000;
  int index = -1;
  for (int i = 0; i < N; ++i) {
    double h;
    cin >> h;
    double temp = T - h * 0.006;
    if (abs(temp - A) < min_diff) {
      min_diff = abs(temp - A);
      index = i + 1;
    }
  }

  cout << index << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    if((a+b+c)>=22) cout << "bust";
    else cout << "win";

    return 0;
}

Measured memory_bytes: 3644
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long x=sc.nextLong();
		long ans = 0;
		ans = (x/11)*2;
		long b = x%11;
		if(b != 0) {
			if(b<=6) {
				ans += 1;
			}else {
				ans += 2;
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


Measured memory_bytes: 35824
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(a, b) << " " << max(0, a + b - n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;

int main() {
  int n;
  cin >> n;
  VI a(n);
  VI r(n);
  rep(i, n) {
    int ae;
    cin >> ae;
    r.at(i) = ae;
    a.at(i) = i - ae;
  }
  sort(a.begin(), a.end());
  ll cnt = 0;
  rep(i, n) {
    auto lb = lower_bound(a.begin(), a.end(), r.at(i) + i);
    auto ub = upper_bound(a.begin(), a.end(), r.at(i) + i);
    cnt += ub - lb;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4804