akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T> void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T> void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U> bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U> bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T> bool even(T n) { return ! (n & 1); }
template<class T> bool odd(T n) { return n & 1; }
template<class T> ll rup(T a, T b) { return a % b ? a / b + 1 : a / b; }
template<class T> ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T> ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;
ll intpow(ll a, ll n, ll _mod=numeric_limits<ll>::max()) { ll p=1; while (n) { if (n&1) p=p*a%_mod; a=a*a%_mod; n>>=1; } return p; } 
ll modc(ll a, char op, ll b, ll _mod=mod) { a %= _mod; b %= _mod; ll res = 1; switch(op) {
        case '+': res = (a + b) % _mod; break;
        case '-': res = (a - b) % _mod; break;
        case '*': res = a * b % _mod; break;
        case '/': res = modc(a, '*', modc(b, '^', _mod-2, _mod), _mod); break;
        case '^': res = intpow(a, b, _mod); break;
        case 'P': rep(i, a-b+1, a+1) res = modc(res, '*', i, _mod); break;
        case 'C': res = modc(modc(a, 'P', b, _mod), '/', modc(b, 'P', b, _mod)); break; } if (res < 0) res += _mod; return res; }


int main()
{
        ll N, A;
        cin >> N >> A;
        vll x(N+1);
        rep(i, 1, N+1) cin >> x[i];

        ll ans = 0;
        
        ll dp[N+1][3000][60];
        rep(i, 0, N+1) rep(j, 0, 3000) rep(k, 0, 60) dp[i][j][k] = 0;
        dp[0][0][0] = 1;

        rep(i, 1, N+1) {
                rep(j, 0, 3000) {
                        rep(k, 0, N) {
                                dp[i][j][k] += dp[i-1][j][k];
                                if (j - x[i] >= 0) {
                                        dp[i][j][k+1] += dp[i-1][j - x[i]][k];
                                }
                        }
                }
        }
        rep(k, 1, N+1) {
                ans += dp[N][k * A][k];
        }
        
        //print2d(dp, -1, 100);

        cout << ans << endl;

}


Measured memory_bytes: 75328
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0064
"""

import sys


def parse_line(txt):
    txt = txt + '@'
    total = 0
    buff = []
    for c in txt:
        if c.isdigit():
            buff.append(c)
        else:
            if len(buff):
                total += int(''.join(buff))
                buff = []
    return total


def main(args):
    total = 0
    for line in sys.stdin:
        total += parse_line(line.strip())

    # ?????????????¨?
    print(total)

if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7664
import sys
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    values = string_to_int(inputs[0])
    K = int(inputs[1])
    values.sort()
    max_v = values.pop()
    for _ in range(K):
        max_v *= 2
    r = sum(values)
    return r + max_v


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 3572
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	long long int ans = 0;
	cin >> N >> M;
	vector<int>to(N + 1);
	vector<vector<int>>from(N + 1);
	vector<int>dis(N + 1, INT_MAX);
	cin >> K;
	if (K != 1) {
		ans++;
		K = 1;
	}
	for (int i = 2; i <= N; i++) {
		cin >> K;
		to[i] = K;
		from[K].push_back(i);
	}
	queue<int>Q;
	Q.push(1);
	dis[1] = 0;
	while (!Q.empty()) {
		int cn = Q.front();
		Q.pop();
		int c = dis[cn];
		for (auto i : from[cn]) {
			if (dis[i] > c + 1) {
				dis[i] = c + 1;
				Q.push(i);
			}
		}
	}
	priority_queue<pair<int,int>>PQ;
	for (int i = 1; i <= N; i++) {
		if (dis[i] > M) {
			PQ.push({ dis[i],i });
		}
	}
	while (!PQ.empty()) {
		int cn = PQ.top().second;
		int c = PQ.top().first;
		PQ.pop();
		if (dis[cn] != c) {
			continue;
		}
		for (int i = 0; i < M - 1; i++) {
			cn = to[cn];
		}
		to[cn] = 1;
		ans++;
		dis[cn] = 1;
		Q.push(cn);
		while (!Q.empty()) {
			int cn_box = Q.front();
			int c_box = dis[cn_box];
			Q.pop();
			for (auto i : from[cn_box]) {
				if (to[i] == cn_box) {
					dis[i] = c_box + 1;
					Q.push(i);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7672
#include<stdio.h>
int main(void)
{
	int n, x[100], i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &x[i]);
	}
	i = n - 1;
	while (i!=0)
	{
		printf("%d ", x[i]);
		i = i - 1;
	}
	printf("%d\n", x[0]);
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h> 
using namespace std; 
  
#define PI 3.1415 
  
double circumference(double r) 
{ 
    double cir = 2*PI*r; 
    return cir; 
} 
  
// driver function 
int main() 
{ 
  double r;
  cin>>r;
  cout<<circumference(r)<<"\n"; 
  return 0; 
}  


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

using namespace std;

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

typedef long long i64;
typedef pair<i64, i64> pii;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

#define mod 1000000007

i64 power(i64 x, i64 n, i64 M) {
  if (!n) return 1;
  if (n % 2 == 0) {
    i64 t = power(x, n / 2, M);
    return t * t % M;
  }
  return x * power(x, n - 1, M) % M;
}

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 m, n;
  cin >> m >> n;
  cout << power(m, n, mod) << "\n";

  return 0;
}


Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main()
{int n,s,g;
cin>>n;
s=n/10;
g=n%10;
if(s==9||g==9)
{
cout<<"Yes"<<endl;
}
if(s!=9&&g!=9) 
{
cout<<"No"<<endl;
return 0;
}
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = list(map(int, input().split()))
D = []
E = []
for i in range(M):
    B, C = map(int, input().split())
    D.append([C, B])
D = sorted(D, reverse = True)

for j in range(len(D)):
    E += [D[j][0]]*D[j][1]
    if len(E) >= N:
        break

F = sorted(A + E, reverse = True)
print(sum(F[0:N]))

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

using i64 = int64_t;

int popcount(int n){
    int res = 0;
    while(n>0){
        if(n&1)res++;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> v(n, vector<pair<int, int>>());
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        for(int j=0;j<a;++j){
            int x, y;
            cin >> x >> y;
            v[i].emplace_back(x-1, y);
        }
    }

    int ans = 0;
    for(int i=0;i<(1<<n);++i){
        bool ok = true;
        for(int j=0;j<n;++j){
            if(((i>>j)&1)==0)continue;
            for(auto e: v[j]){
                if(((i>>e.first)&1) != e.second){
                    ok = false;
                    break;
                }
            }
            if(!ok)break;
        }
        if(ok)ans = max(ans, popcount(i));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let x: usize = iterator.next().unwrap().parse().unwrap();
    let y: usize = iterator.next().unwrap().parse().unwrap();
    let z: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans = 0;
    for i in 0.. {
        if y * i + z * (i + 1) <= x {
            ans = i;
        } else {
            break;
        }
    }
    ans.to_string()
}


Measured memory_bytes: 2080
#include<stdio.h>
#include<math.h>
#define LL long long int

LL GCD(LL x,LL y)
{
	if(y==0)
		return x;
	return GCD(y,x%y);
}

LL LCM(LL x,LL y)
{
	int i;
	for(i=1;i<=y;i++)
	{
		if((x*i)%y==0)
			return x*i;
	}
	return x*y;
}

int main()
{
	LL i,n,a,b,g,l[10],v[10],t[10];
	for(;scanf("%lld",&n)*n;)
	{
		for(i=0;i<n;i++)
		{
			scanf("%lld%lld",&a,&b);
			g=GCD(a,b);
			l[i]=a/g,v[i]=b/g;
		}
		for(i=2,a=LCM(l[0],l[1]);i<n;i++)
			a=LCM(a,l[i]);
		for(i=0;i<n;i++)
			t[i]=a/l[i]*v[i];
		for(i=2,b=GCD(t[0],t[1]);i<n;i++)
			b=GCD(b,t[i]);
		for(i=0;i<n;i++)
			printf("%lld\n",t[i]/b);
	}
	return 0;
}

Measured memory_bytes: 600
"""
1以上N以下の整数の内、各桁の和がA以上B以下であるものの全ての総和は？

20 以下の整数のうち、各桁の和が 2 以上 5 以下なのは、
2, 3, 4, 5, 11, 12, 13, 14, 20 です。これらの合計である 84 を出力します。
"""

def summaker(n):
  sum1 = 0
  while n > 0:
    
    sum1 += n % 10
    n = n // 10
  return sum1

N, A, B = map(int, input().strip().split(' '))
total = 0
for i in range(1, N + 1):
  sum1 = summaker(i)
  if A <= sum1 <= B:
    total += i

print(total)

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

int main()
{
    int n;
    cin >> n;
    int a[n + 5];
    rep(i,n){
        cin >> a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e6 + 1;
	
	void doIt() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int C[] = new int[N];
		int A[][] = new int[N][M];
		for(int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			for(int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		int min = MAX;
		for(int i = 1; i < (1 << N); i++) {
			int num[] = new int[M];
			int p = 0;
			for(int j = 0; j < N; j++) {
				if(((i >> j) & 1) == 1) {
					p += C[j];
					for(int k = 0; k < M; k++) {
						num[k] += A[j][k];
					}
				}
			}
			boolean ok = true;
			for(int j = 0; j < M; j++) {
				if(num[j] < X) {
					ok = false;
				}
			}
			if(ok) min = Math.min(min, p);
			
		}
		
		System.out.println((min == MAX)?-1:min);
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}

}


Measured memory_bytes: 37364
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// ----------------------------------------------------------------------------

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int ans=mod;
  for(int c=0; c<=200000; c+=2){
    int sum=0;
    if(X>c/2){
      sum += (X-c/2)*A;
    }
    if(Y>c/2){
      sum += (Y-c/2)*B;
    }
    sum += c*C;
    chmin(ans,sum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
tes = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        tes[i].append([x - 1, y])
ans = 0 
for tf_s in itertools.product(range(2), repeat = n):
    for i in range(n):
        if tf_s[i] == 0:
            continue
        for x, y in tes[i]:
            if tf_s[x] != y:
                break
        else:
            continue
        break
    else:
        ans = max(ans, tf_s.count(1))
print(ans)


Measured memory_bytes: 9156
#include<bits/stdc++.h>
using namespace std;
int main()
{
   
   int n,q; cin>>n>>q;
   vector<int>sf(n+1,0),p(n+1,0);
   int ac=0;
   int cnt=0;
   while(q--)
   {
    int x;
    string s;
    cin>>x>>s;
    if(s=="WA" && sf[x]!=1)
    {
        
        cnt++;
        p[x]++;
    }
    if(s=="AC" && sf[x]!=1)
    {
    sf[x]=1;
    
    ac++;
    }
    }
    for(int i=1;i<=n;i++)
    {
    if(sf[i]!=1 && p[i]>=1 )
        cnt-=p[i];
    }
    cout<<ac<<" "<<cnt;
    
   
   
   
   
   

}
    

Measured memory_bytes: 1024
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, k = tin()
	#s = input()	
	al = lin()
	al.sort(reverse = True)
	ss=sum(al)
	arrive=[0]*k
	arrive[0]=1
	useful_set=set()
	for v in al:
		ss -= v
		u_max=0
		if v >=k:
			useful_set.add(v)
			continue
		for i, _ in enumerate(arrive):
			p = k-i-1
			is_on = arrive[p]
			if is_on==1 and p+v >= k:
				useful_set.add(v)
				u_max=k
			elif is_on==1:
				arrive[p+v] = 1
				u_max=max(u_max, p+v)
		if u_max + ss >= k:
			useful_set.add(v)
	ret=0
	for v in al:
		if v not in useful_set:
			ret += 1
	return ret
			
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var N = long.Parse(Console.ReadLine());
            var mod = 26;
            var ans = "";
            long t = 0;
            while (N != 0) {
                N--;
                t = N % mod;
                ans = (char)(t + 'a') + ans;
                N /= mod;
            }
                Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27328
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll a=in(),b=in(),c=in();
    if(c-a-b<0){
        cout<<"No"<<endl;
    }else{
        cout<<(4*a*b<(c-a-b)*(c-a-b)?"Yes":"No")<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
 
  ll N ;
  ll ans = 1e18 ;
  cin >> N ;
  vector<ll> A(N) ;
  rep(i,N) cin >> A.at(i) ;
  ll full = 0 ;
  ll part = 0 ;
  rep(i,N) full += A.at(i) ;
  rep(i,N-1){
    part += A.at(i) ;
    full -= A.at(i) ;
    ans = min( abs(full - part) , ans ) ;
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>

using namespace std;

int a, b, n;
string t;
char s[100100], u[100100], v[100100];

int check ( char a[100100], int n ) {
    int i = 1; int j = n;
    while ( i <= j ) {
        if ( a[j] != a[i] ) {
            return 1;
        }
        i++; j--;
    }
    return 0;
}

int main () {
    cin >> t;
    for ( int i = 0; i < t.size(); i++) {
       n++; s[n] = t[i];
    }
    for ( int i = 1; i <= n; i++) {
        if (i <= (n - 1) / 2 ) {
            a++; u[a] = s[i];
        }
        if ( i >= (n + 3) / 2 ) {
            b++; v[b] = s[i];
        }
    }
    if ( check(s, n) == 0 && check(u, a) == 0 && check(v, b) == 0 ) {
        cout <<"Yes";
    }
    else {
        cout <<"No";
    }
}


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

int main() {
    int n; cin >> n;
    for(int i = 0; i <= 30; ++i) for(int j = 0; j <= 30; ++j) 
        if(i * 4 + j * 7 == n) return !printf("Yes");
    puts("No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
  int n;
    cin >> n;
    int cur = 1;
    int brk = n;
    for(int i = 0; i < n; ++i)
    {
        int x;
        cin >> x;
        if(x == cur) {
            brk--;
            ++cur;
        }
    }
    if(brk == n) cout << -1 << '\n';
    else cout << brk << '\n';
    return 0;

}


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

int main()
{
   int m,a;
   cin>>m>>a;
   if((m+a)%2==0)
   {
       cout<<(m+a)/2<<endl;
       return 0;
   }
  else
   {
   cout<<(m+a)/2+1<<endl;
   return 0;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    ll n,m;
    string s,t;
    cin>>n>>m>>s>>t;
    bool ok=true;
    if(n>m){
        swap(n,m);
        swap(s,t);
    }
    ll gcd=GCD(n,m);
    ll lcm=n/GCD(n,m)*m;
    ll nn =  n/gcd;
    ll mm =  m/gcd;
    for(int i=0; i<gcd; i++){
        if(s[i*nn]!=t[i*mm]) ok=false;
    }
    if(ok) cout<<n/GCD(n,m)*m<<endl;
    else cout<<-1<<endl;    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 100005
#define all(x) x.begin(),x.end()
#define l_b lower_bound
#define u_b upper_bound
#define pb push_back
#define MOD 1000000007
void fastio(void);

int main(){
    fastio();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n,num,k,sum=0,la;
    cin>>n>>k;
    vector<int> arr(n);
    for(la=0;la<n;la++)
        cin>>arr[la];
    sort(all(arr));
    for(la=0;la<k;la++)
        sum+=arr[la];
    cout<<sum<<endl;

    return 0;
}

void fastio(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

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

int main() {
    int N;
    cin >> N;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];

    H[0]--;
    bool ok = true;
    for (int i=1; i<N; ++i) {
        if (H[i] > H[i-1]) H[i]--;
        if (H[i] < H[i-1]) ok = false;
    }

    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long
#define maxn 500000
int num[maxn];
int main() {
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &num[i]);
	}
	ll ans = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			ans += num[i] * num[j];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    vector<pair<int, long long>> seq;
    long long int id, p, q;
    for (int i = 0; i < n; ++i) {
      cin >> id >> p >> q;

      bool flag = true;
      for (auto &v : seq) {
        if (v.first == id) {
          flag = false;
          v.second += p * q;
          break;
        }
      }
      if (flag)
        seq.push_back(make_pair(id, p * q));
    }

    bool flag2 = true;
    for (auto &v : seq) {
      if (v.second >= 1e6) {
        cout << v.first << endl;
        flag2 = false;
      }
    }

    if (flag2)
      cout << "NA" << endl;
  }
}


Measured memory_bytes: 3120
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b)
            System.out.println("a < b");
           else if (a > b)
                System.out.println("a > b");
            else if (a == b)
                System.out.println("a == b");

   }
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll H, W;
  scanf("%lld %lld", &H, &W);

  ll h, w;
  scanf("%lld %lld", &h, &w);

  ll ans = H * W - H * w - h * W + w * h;

  cout << ans << endl;
}


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

using namespace std;

int main(void)
{
	int a, b, x;
	int flag = 0;
	cin >> a >> b >> x;
	for (int i = 0; i <= b; i++)
	{
		if (x == (a+i))
		{
			flag = 1;
			break;
		}
	}
	if (flag == 1)
	{
		cout << "YES "<< endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int l = ni();
		int r = ni();
		r = Math.min(r, l + 2019);
		int result = Integer.MAX_VALUE;
		for(int i = l; i <= r; i++) {
			for(int j = i + 1; j <= r; j++) {
				result = Math.min(result, ((i % 2019) * (j % 2019) % 2019));
				if(result == 0) {
					System.out.println(result);
					return;
				}
			}				
		}

		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 22740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        long k = s.nextLong();
        if(k%2==0) System.out.println((k*k)/4);
        else System.out.println((k/2)*((k/2)+1));


    }




}


class Scanner
{
    StringTokenizer st;
    BufferedReader br;

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

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

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

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

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

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

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


}

Measured memory_bytes: 25360
#include<stdio.h>
int main()
{
    int n1,n2,n3=3;
    scanf("%d%d",&n1,&n2);
    n1=n1*n2*n3;
    if(n1%2==1){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  if (n%2) {
    rep(i, n/2)
      ans -= a[i]*2;
    ans -= a[n/2]+a[n/2+1];
    rep(i, n/2+1)
      ans += a[i+n/2]*2;
    ll tmp = 0;
    rep(i, n/2)
      tmp += a[i+n/2+1]*2;
    tmp += a[n/2]+a[n/2-1];
    rep(i, n/2+1)
      tmp -= a[i]*2;
    chmax(ans, tmp);
  } else {
    ans += a[n/2-1]-a[n/2];
    rep(i, n/2)
      ans -= a[i]*2;
    rep(i, n/2)
      ans += a[i+n/2]*2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 62;

int main()
{
  int N, M;
  bool even[100000] = {};

  cin >> N >> M;

  // 握手補題があるため
  
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    even[x] ^= 1;
    even[y] ^= 1;
  }

  for(int i = 0; i < N; i++) {
    if(even[i]) {
      cout << "NO" << endl;
      return (0);
    }
  }

  cout << "YES" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    ll n,d;
    cin>>n>>d;
    vector<ll> x(n),y(n);
    for(int i=0; i<n; i++) cin>>x[i]>>y[i];
    int ans = 0;
    ll dd = d*d;
    for(int i=0; i<n; i++){
        ll tmp = powl(x[i],2)+powl(y[i],2);
        if(tmp<=dd){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6408
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod =998244353;
typedef pair<int, int> P;
int a[200006];
signed main() {
	int n, m; cin >> n >> m;
	int N = n + n;
	rep(i, 2 * n)cin >> a[i];
	sort(a, a + N);
	int lb = -1, ub = m;
	while (ub - lb > 1) {
		int mi = (ub + lb) / 2; //[0,mi] [m,m+mi]
		int lb2 = -1, ub2 = n;
		while (ub2 - lb2 > 1) {
			int mi2 = (ub2 + lb2) / 2;
			int res = 0;
			rep(i, mi2) {
				res = max(res, a[i] + a[mi2*2-1 - i]);
			}
			if (res <= mi)lb2 = mi2;
			else ub2 = mi2;
		}

		int lb3 = -1, ub3 = n;
		while (ub3 - lb3 > 1) {
			int mi2 = (ub3 + lb3) / 2;
			int res = inf;
			rep(i, mi2) {
				res = min(res, a[N - 1 - i] + a[N - 2 * mi2 + i]);
			}
			if (res < m)ub3 = mi2;
			else lb3 = mi2;
		}
		int res2 = 0;
		rep(i, lb3)res2 = max(res2, a[N - 1 - i] + a[N - 2 * lb3 + i]);
		if (res2 > m + mi)lb = mi;
		else if (lb2 + lb3  >= n)ub = mi;
		else lb = mi;

//		cout << mi << ' ' << lb2 << ' ' << lb3 << endl;
	}

	int aa = 0;
	rep(i, n)aa = max(aa, (a[i] + a[N - 1 - i]) % m);
	cout << min(aa,ub) << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


int main()
{
  int i, j;
  int H, W;
  cin >> H >> W;
  vector<vector<char>> array;

  vector<vector<int>> cut;
  cut.resize(2);
  cut.at(0).resize(H); // i行目削除 -> cut[0][i] = 1
  cut.at(1).resize(W); // i列目削除 -> cut[][j] = 1

  // input array's data
  array.resize(H);
  for(i=0;i<H;i++){
    array.at(i).resize(W);
    for(j=0;j<W;j++){
      cin >> array[i][j];
    }
  }

  // 行を削除
  int white;
  for(i=0;i<H;i++){
    white = 1;
    for(j=0;j<W;j++){
      if(array[i][j] == '#'){
        white = 0;
        break;
      }
    }
    if(white == 1){
      cut[0][i] = 1;
    }
  }

  // 列を削除
  for(i=0;i<W;i++){
    white = 1;
    for(j=0;j<H;j++){
      if(array[j][i] == '#'){
        white = 0;
        break;
      }
    }
    if(white == 1){
      cut[1][i] = 1;
    }
  }

  int p;
  // 出力
  for(i=0;i<H;i++){
    p = 0;
    for(j=0;j<W;j++){
      if(cut[0][i] == 0 && cut[1][j] == 0){
        cout << array[i][j];
        p = 1;
      }
    }
    if(p==1) cout << endl;
  }

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
loop = 1
loop_check = [0] * N
loc = A[0]
Cycle = [1]

while loop_check[loc -1] == 0:
  Cycle.append(loc)
  loop_check[loc - 1] = loop
  loc = A[loc - 1] 
  loop += 1
x = loop - loop_check[loc - 1]
if K > loop_check[loc - 1]:
  K = (K - loop_check[loc - 1]) % x + loop_check[loc - 1]
print(Cycle[K])

Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long h,n,ans=0;
    cin>>h>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
        ans+=arr[i];
    }
    if(ans>=h)
    {
        cout<<"Yes"<<endl;
    }
    else
        cout<<"No"<<endl;

    return  0;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
 
 class Main{
 
   public static boolean search(int A[],int n,int key){
		
		int left =0;
		int mid;
		int right =n;
		
		while(left<right){
			mid=(left+right)/2;
			if(key==A[mid]) 
				return true; 
			if(key>A[mid])
				left=mid+1;
			else if(key<A[mid])
				right =mid;
		}
		return false;
	}

    public static void main(String[] args) {
        int A[]=new int[1000000];
        int i,j,n,q,key,sum=0;
         
        Scanner s =new Scanner(System.in);
        n=s.nextInt();
        for(i=0;i<n;i++){
            A[i]=s.nextInt();
        }
         
        q=s.nextInt();
        for(j=0;j<q;j++){
            key=s.nextInt();

            if(search(A,n,key))
                          sum++;
        }
      System.out.println(sum);
    }
 
}

Measured memory_bytes: 83892
#!/usr/bin/env fsharpi

open System;

let ParseIntN ( str : string ) =
    str.Split(' ')
    |> Array.map System.Int32.Parse

let ParseInt1 ( str : string ) =
    ParseIntN str |> fun arr -> arr.[0]

let ParseInt2 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1])

let ParseInt3 ( str : string ) =
    ParseIntN str |> fun arr -> (arr.[0],arr.[1],arr.[2])

let ReadLinesN ( n : int ) =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.take n

let ReadLines =
    fun _ -> Console.ReadLine()
    |> Seq.initInfinite
    |> Seq.takeWhile ((<>) null)

type cost = int
type vertex = int
type edge = vertex * vertex * cost
type graph = System.Collections.Generic.Dictionary<vertex, cost> array

let DGraph (n : int) (edges : edge list) : graph =
    let g : graph = Array.init n (fun _ -> new System.Collections.Generic.Dictionary< vertex, cost>())
    List.iter (fun (f,t,c) -> g.[f].[t] <- c) edges
    g

let Graph (n : int) (edges : edge list) : graph =
    let redges = List.map (fun (f,t,c) -> (t,f,c)) edges
    DGraph n <| List.append edges redges

let Nodes (g: graph) : int =
    Array.length g

let Edges (g: graph) : edge list =
    seq { for i = 0 to ( Nodes g ) - 1 do yield (i,Seq.zip g.[i].Keys g.[i].Values) } 
    |> Seq.map (fun (f,ts) -> Seq.map (fun (t,c) -> ( f,t,c ) ) ts )
    |> Seq.fold Seq.append Seq.empty
    |> Seq.toList

let WarshallFloyd (g : graph) : cost[,] =
    let nodes = Nodes g
    let costs = Array2D.init nodes nodes (fun f t -> match f,t with
                                                     | _ when f = t -> 0
                                                     | _ when g.[f].ContainsKey t -> g.[f].[t]
                                                     | _ -> (System.Int32.MaxValue / 2))
    for m = 0 to (nodes - 1) do
        for f = 0 to (nodes - 1) do
            for t = 0 to (nodes - 1) do
                costs.[f,t] <- min  costs.[f, t] (costs.[f,m] + costs.[m,t])
            done
        done
    done
    costs

let (n,m) = ParseInt2 <| Console.ReadLine()
let edges = ReadLinesN m |> Seq.map ParseInt3 |> Seq.map (fun (f,t,ci) -> (f-1,t-1,ci)) |> Seq.toList
let costs = edges |> Graph n |> WarshallFloyd
edges
|> List.filter (fun (f,t,c) -> costs.[f,t] <> c )
|> List.length
|> Console.WriteLine


Measured memory_bytes: 14044
#include<bits/stdc++.h>
using namespace std;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9+21;
const long long LINF = (long long) 1e18;
const long double PI = 2 * acos((long double)0);
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
#define Mahmud main()
#define endl "\n"
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define alla(arr,n) arr,arr+n
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define pb push_back
///Debug
#define dbg1(x) std::cerr<<#x<<"="<<(x)<<endl;
#define dbg2(x,y) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z) std::cerr<<#x<<"="<<(x)<<','<<#y<<"="<<(y)<<','<<#z<<"="<<(z)<<endl;
#define dbgArr(arr,n) cerr<<#arr<<"=["; printArray(arr,n,0,93); cerr<<endl;
///traversing
#define rep(n) for(int i=0;i<n;++i)
#define trv(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();++i)
///necessary functions
inline ll Int()
{
    ll _x=0,_tmp=1;
    char _tc=getchar();
    while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
    if( _tc == '-' ) _tc=getchar(), _tmp = -1;
    while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
    return _x*_tmp;
}
inline long double Double()
{
    long double d;
    scanf("%Lf",&d);
    return d;
}
ll lcm(ll a,ll b)
{
    return a/__gcd(a,b)*b;
}
int ton(string x)
{
    int y;
    std::istringstream ss(x);
    ss >> y;
    return y;
}
template<typename T>
string tostring(T x)
{
    ostringstream ss;
    ss << x ;
    return ss.str();
}

///Current Code vars
#define N 100010
long long n,k,a,b,c,d;
int arr[N+1],brr[N+1];
///Current Code functions

string s;

void solve()
{
    cin>>a>>b>>c;
    dbg3(a,b,c);
    c = b - c;
    dbg1(c);

    if(c >= 0)
    {
        puts("delicious");
        return;
    }
    c = abs(c);
    if(c <= a)
    {
        puts("safe");
        return;
    }
    if(c > a)
    {
        puts("dangerous");
        return;
    }
}

int Mahmud
{
    // ios_base::sync_with_stdio(0); //cin.tie(0);
  //#ifdef _LOCAL_
    //freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
  //while(1)
    solve();
  //#ifdef _LOCAL_
    //printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
  //#endif
    return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define sqr(x) ((x)*(x))

double dist(vector<double> &a, vector<double> &b) {
  double ret = 0;
  for (int i = 0; i < a.size(); i++) {
    ret += sqr(a[i] - b[i]);
  }
  return sqrt(ret);
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n, d;
  cin >> n >> d;
  vector<vector<double>> v(n, vector<double>(d));
  for (auto &i : v) for (auto &j : i) cin >> j;
  int ans = 0;
  for (int i = 0; i < n - 1; i++)
  for (int j = i + 1; j < n; j++) {
    double t = dist(v[i], v[j]);
    if (abs(t - trunc(t)) < 1e-6) ans++;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

#define vin(v, N) for (long long i = 0; i < N; i++) cin >> v.at(i)
#define lin(n) long long n; cin >> n
#define chin(x) char x; cin >> x;
#define sin(s) string s; cin >> s;
#define vlin(v, N) vector<long long> v(N); for (long long i = 0; i < N; i++) cin >> v.at(i)

#define rep(i, n) for (int i = 0; i < (n); ++i)


int main(){
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for(int i = 0; i < N; ++i) cin >> P[i];
    for(int i = 0; i < N; ++i) cin >> Q[i];
    vector<int> ind(N);
    iota(ind.begin(), ind.end(), 1);
    ll int cnt = 0;
    ll int p, q;
    do{
        if(ind == P) p = cnt;
        if(ind == Q) q = cnt;
        cnt++;
    } while (next_permutation(ind.begin(), ind.end()));
    cout << abs(q - p) << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
a = 0
b = 0
sub = 0
for i in range(N):
  if S[i] == '(':
    a += 1
  else:
    b += 1
  if a-b <= sub:
    sub = a-b
S = '('*max((-sub),0)+S+')'*max(a-b-sub,0)
print(S)

Measured memory_bytes: 3060
from math import factorial

k = int(input())
n = 10000
primes = [2]
for i in range(3, n, 2):
    all(i % p != 0 for p in primes) and primes.append(i)

primes = [i for i in primes if i%5 == 1][:k]
print(*primes)

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll n; cin >> n;
  string s; cin >> s;
  ll x= 0;

  ll ans = 0;

  REP(i, n) {
    switch(s[i]) {
    case 'I':
      x++;
      if(x>ans) ans = x;
      break;
    case 'D':
      x--;
    }
  }
  
  
   cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int a[9];
  REP(i, 9) cin >> a[i];
  int n;
  cin >> n;
  int b[n];
  REP(i, n) cin >> b[i];

  REP(i, n) {
    REP(j, 9) {
      if (a[j] == b[i])
        a[j] = 0;
      else
        continue;
    }
  }

  int l1, l2, l3, l4, l5, l6, l7, l8;
  l1 = a[0] + a[1] + a[2];
  l2 = a[3] + a[4] + a[5];
  l3 = a[6] + a[7] + a[8];
  l4 = a[0] + a[3] + a[6];
  l5 = a[1] + a[4] + a[7];
  l6 = a[2] + a[5] + a[8];
  l7 = a[0] + a[4] + a[8];
  l8 = a[2] + a[4] + a[6];
  if (l1 == 0 || l2 == 0 || l3 == 0 || l4 == 0 || l5 == 0 || l6 == 0 ||
      l7 == 0 || l8 == 0)
    cout << "Yes";
  else
    cout << "No";
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;

#define all(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back

void solve() {
    int n; cin >> n;
    vi a(n + 1);
    for (ll x = 1; x <= 120; x++) {
        for (ll y = 1; y <= 120; y++) {
            for (ll z = 1; z <= 120; z++) {
                ll t = x * x + y * y + z * z + x * y + y * z + z * x;
                if (t <= n) a[t]++;
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        cout << a[i] << '\n';
    }
}

int main() {
    solve();
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll mod=ll(1e9+7);



int main()
{
	IOS;
   string s;
   cin>>s;
   REP(i,s.size()){
      if(i!=3) cout<<s[i];
      else cout<<8;
   }
   cout<<'\n';

	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        int r = sc.nextInt();
        Console.WriteLine(r * r);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
<?php

while(1){

	list($H,$W)=explode(" ",trim(fgets(STDIN)));

	if($H==0 && $W==0){

		break;
	}


	$boolflg=true;
	$rowflg=true;

	for($i=1;$i<=$H;$i++){

			if($rowflg){

				// print "#";
				$boolflg=false;
			}else{

				// print ".";
				$boolflg=true;

			}

		for($j=1;$j<=$W;$j++){


			if($boolflg){

				print ".";
				$boolflg=false;

			}else{

				print "#";
				$boolflg=true;

			}

			if($j==$W){

				print "\n";
			}



		}

	// ?????¢
	$rowflg = $rowflg ? false : true;

	}

	print "\n";

}

// while($input<>""){
// 	$array_data[]=$input;
// 	$input=trim(fgets(STDIN));
// }


// foreach($array_data as $val){

// 	$array_temp[]=explode(" ",$val);
// }

Measured memory_bytes: 15356
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;


int dp[d5];
bool use[d5];
vector<int> edge[d5];

void dfs(int i){
    use[i]=true;
    int now=dp[i];
    for(auto e:edge[i]){
        if(!use[e])dfs(e);
        now=max(now,dp[e]);
    }
    dp[i]=now+1;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        x--;
        y--;
        edge[x].push_back(y);
    }
    //dp[i]:頂点iから始めた時の最大の距離
    for(int i=0;i<d5;i++)dp[i]=0;
    for(int i=0;i<d5;i++)use[i]=false;
    for(int i=0;i<n;i++){
        if(use[i])continue;
        else dfs(i);
    }
    int res=0;
    for(int i=0;i<d5;i++)res=max(res,dp[i]);
    cout<<res-1<<endl;
}

Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e14)

using namespace std;

int N,C;
int x[100003];
int v[100003];
int used[100003];

int sumv1[100003];
int max1[100003];

int sumv2[100003];
int max2[100003];

signed main()
{
    cin >> N >> C;
    REPS(i,N) cin >> x[i] >> v[i];

    for (int i = 1; i <= N; ++i)
        sumv1[i] = sumv1[i-1] + v[i];

    for (int i = 1; i <= N; ++i)
        max1[i] = sumv1[i] - 2*x[i];

    for (int i = 1; i <= N; ++i)
        max1[i] = max(max1[i-1], max1[i]);

    for (int i = N; i > 0; --i)
        sumv2[i] = sumv2[i+1] + v[i];

    for (int i = N; i > 0; --i)
        max2[i] = sumv2[i] - 2*(C - x[i]);

    for (int i = N; i > 0; --i)
        max2[i] = max(max2[i+1], max2[i]);


    int ans = 0;
    REPS(i, N)
    {
        ans = max(ans, max1[i-1] + sumv2[i] - (C - x[i]));
    }

    REPS(i, N)
    {
        ans = max(ans, max2[i+1] + sumv1[i] - x[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760