akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >> s;
	string ans = s;
	ans[3] = *"8";
	cout << ans;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <queue>
using namespace std;


int GetDigit(int n){
	int i = 0;

	while(n > 0){
		n /= 10;
		i++;
	}

	return i;
}
 
int main(){
	int a, b;
	int s;

	while(cin >> a >> b){
		s = a+b;
		cout << GetDigit(s) << endl;
	}

	return 0;
}

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

typedef pair<int, int> P;

int main(){
    while(1){
        int n, w, h; cin>>n>>w>>h;
        if(w == 0) return 0;

        vector<P> cake;
        cake.emplace_back(w, h);
        for(int i=0; i<n; i++){
            int p, s; cin>>p>>s;
            p--;
            int cw = cake[p].first;
            int ch = cake[p].second;
            cake.erase(cake.begin() + p);

            s %= (cw + ch);

            if(s < cw){
                cake.emplace_back(min(s, cw - s), ch);
                cake.emplace_back(max(s, cw - s), ch);
            }
            else{
                s -= cw;
                cake.emplace_back(cw, min(s, ch - s));
                cake.emplace_back(cw, max(s, ch - s));
            }
        }

        vector<int> ans;
        for(int i=0; i<cake.size(); i++){
            ans.emplace_back(cake[i].first * cake[i].second);
        }

        sort(ans.begin(), ans.end());

        for(int i=0; i<ans.size(); i++){
            cout << ans[i] << " \n"[i == ans.size() - 1];
        }
    }
}


Measured memory_bytes: 3088
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var z = longa();
        long n = z[0], a = z[1], b = z[2];
        long ans = n / (a + b);
        ans *= a;
        ans += Min(n % (a + b),a);
        Write(ans);        

    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27464
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

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

	ll h, w, x;
	cin>>h>>w>>x;
	
	map<pair<ll,ll> , ll> mp;
	for(int i=0;i<x;i++){
			ll a,b ;
			cin>>a>>b;
			for(int j=-1;j<=1;j++){
					for(int k=-1;k<=1;k++){
							mp[{a+j,b+k}]++;
					}
			}
	}
	
	vector<ll> ans(10);
	ans[0] = (h-2) * (w-2);
	
	for(auto c : mp){
			pair<ll,ll> pr = c.first;
			if(pr.first > 1 && pr.first < h && 1 < pr.second && w > pr.second)
				ans[c.second]++ , ans[0]--;
	}
	
	for(auto i : ans){
			cout<<i<<"\n";
	}cout<<endl;
}


Measured memory_bytes: 56576
n,m=map(int,input().split())

if n<2 and m<2:
  print(0)
  exit()
elif n<2:
  print(m*(m-1)//2)
elif m<2:
  print(n*(n-1)//2)
else:
  print(m*(m-1)//2+n*(n-1)//2)

Measured memory_bytes: 3060
# AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
# 文字 b が入力されます。これは A, C, G, T のいずれかです。
# 塩基 b と対になる塩基を表す文字を出力するプログラムを書いてください。

b = gets.chomp

case b
when "A"
    puts "T"
when "T"
    puts "A"
when "C"
    puts "G"
when "G"
    puts "C"
end

Measured memory_bytes: 1788
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
n,k = map(int,input().split())
for i in range(1,k + 1):
    if n - k + 1 < i:
        print(0)
        continue
    else:
        print(C(n - k + 1,i) * C(k - 1,i - 1) % 1000000007)

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

#define STRING(str) #str

template <typename T >
void print_vec_1d(vector<T> x, string name) {
	cout << name << endl;
	cout << "[ ";
	for (int i=0;i<x.size();i++) {
		cout << x[i];
		if (i != x.size()-1) cout << ", ";
		else cout << " ]" << endl;
	}
}

const int mod = 1e9+7;
const int comb_N = 3e5;
vector<long long> fact(comb_N, 0LL);
vector<long long> inverse(comb_N, 0LL);

long long modpow(long long a, long long x) {
    long long tmp = x;
    long long val = a;
    long long ret = 1LL;
    while (tmp>0) {
        if (tmp%2 == 1) ret = ret*val%mod;
        val = val*val%mod;
        tmp /= 2;
    }
    return ret;
}


long long modinv(long long a) {
    return modpow(a, mod-2);
}

long long comb(long long n, long long k) {
    if (n<0 || k<0 || n<k) return 0;
    return fact[n]*(inverse[k]*inverse[n-k]%mod)%mod;
}

void calc_comb() {
    fact[0] = 1;
    inverse[0] = 1;
    for (int i=1;i<comb_N;i++) {
        fact[i] = fact[i-1]*(long long)i%mod;
        inverse[i] = modinv(fact[i]);
    }
}
int main() {
	int S;
	cin >> S;

	calc_comb();
	long long ans = 0LL;
	for (int i=1;i<=S;i++) {
		if (S-3*i<0) continue;
		ans = (ans+comb(S-3*i+(i-1), i-1))%mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7868
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    ll k;
    cin >> n >> k;
    ll a[200005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    ll s[200005];
    s[0] = 0;
    for(int i = 1; i <= n; i++) s[i] = (s[i - 1] + a[i - 1]) % k;
    map<ll, ll> mp;
    ll ans = 0;
    for(int i = 0; i <= n; i++){
        if(i >= k) mp[s[i - k]]--;
        ans += mp[s[i]];
        mp[s[i]]++;
    }
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;

const int MAXA = 100001;

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

	int n;
	cin >> n;
	vector<int> cost(n), w(n);
	for (int i = 0; i < n; i++) {
		cin >> cost[i] >> w[i];
	}

	int m = min((1 << 9) - 1, n);
	vector<vector<int>> dp(m + 1, vector<int>(MAXA, 0));
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j < MAXA; j++) {
			dp[i][j] = dp[i / 2][j];
			if (j >= w[i - 1]) {
				dp[i][j] = max(dp[i][j], dp[i / 2][j - w[i - 1]] + cost[i - 1]);
			}
		}
	}

	int q;
	cin >> q;
	while (q--) {
		int v, L;
		cin >> v >> L;

		vector<int> lowers;
		while (v > m) {
			lowers.push_back(v - 1);
			v /= 2;
		}

		int ans = 0;
		for (int mask = 0; mask < (1 << lowers.size()); mask++) {
			int tot_cost = 0, tot_w = 0;
			for (int i = 0; i < lowers.size(); i++) {
				if ((mask >> i) & 1) {
					tot_cost += cost[lowers[i]];
					tot_w += w[lowers[i]];
				}
			}
			if (tot_w <= L) {
				ans = max(ans, tot_cost + dp[v][L - tot_w]);
			}
		}

		cout << ans << '\n';
	}
}

Measured memory_bytes: 206372
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	queue<pair<string, int>> q;
	
	for(int i = 0; i < n; i++) {
		string p;
		int proc;
		cin >> p >> proc;
		q.push(make_pair(p, proc));
	}

	queue<pair<string, int>> ans;
	int sum_of_time = 0;

	while(!q.empty()) {
		pair<string, int> tmp;
		tmp = q.front();
		string name;
		int time;
		name = tmp.first;
		time = tmp.second;
		q.pop();
		if(time - m <= 0) {
			ans.push(make_pair(name, time+sum_of_time));
			sum_of_time += time;
		}
		else {
			q.push(make_pair(name, time-m));
			sum_of_time += m;
		}
	}

	while(!ans.empty()) {
		pair<string, int> out;
		out = ans.front();
		ans.pop();
		cout << out.first << " " << out.second << endl;
	}

}




Measured memory_bytes: 6124
import math
a,b,h,m=map(int,input().split())

def kakudo(hour,mini):
    jikan=30*hour+0.5*mini
    fun=6*mini
    k=min(abs(jikan-fun),360-abs(jikan-fun))
    
    k=k*math.pi/180
    return k 

def cal(k):
    c=a**2+b**2-2*a*b*math.cos(k)
    return c**0.5

ans=cal(kakudo(h,m))
print(ans)


Measured memory_bytes: 9488
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main() {
    int l,r;cin >> l >> r;
    if(r-l>2019)cout << 0 << endl;
    else{
        ll ans = INF;
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                chmin<ll>(ans,(i*j)%2019);
            }
        }
    cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  int Q; cin >> Q;
  REP(i,Q){
	int x, ans = 0;
	cin >> x;
	set<int> s;
	for(;;){
	  if(x / 10 == 0) break;
	  if(s.find(x) != s.end()){
		ans = -1; break;
	  }
	  s.insert(x);
	  int nxt = 0, t1 = x, t2 = 0;
	  for(int p=10;x/p!=0;p*=10){
		t1 = x / p;
		t2 = x % p;
		nxt = max(nxt, t1*t2);
	  }
	  x = nxt;
	  ++ans;
	}
	cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
using namespace std;
#define loop(i,a,b) for(int i=a; i<(int)(b); i++)
#define rep(i,n) loop(i,0,n)

bool win(const string & s, char c){
    rep(j, 3){
        if (s[3 * j] == c && s[3 * j + 1] == c && s[3 * j + 2] == c) return true;
        if (s[j] == c && s[3 + j] == c && s[6 + j] == c) return true;
    }
    if ((s[0] == c&&s[8] == c) || (s[2] == c&&s[6] == c)){
        return s[4] == c;
    }
    return false;
}

int main(){
    string s;
    while (cin >> s){
        char ans;
        if (win(s, 'o')) ans = 'o';
        else if (win(s, 'x')) ans = 'x';
        else ans = 'd';
        cout << ans << endl;
    }
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, a, b;
    cin >> n >> a >> b;
    if(n == 1 && a == b)
    {
        cout << 1;
    }
    else if( b < a)
    {
        cout << 0;
    }
    else if(n == 1 && a != b)
    {
        cout << 0;
    }

    else
    {
        cout << (n-2)*b - (n-2)*a + 1;
    }




}


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

using namespace std;

int main() {
	string s;
	cin >> s;

	int n = s.size();
	vector<int> a(n + 1, 0);

	for (int i = 0; i < n; i++) {
		if (s[i] == '<') {
			a[i+1] = a[i] + 1;
		}
	}

	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') {
			a[i] = max(a[i], a[i+1] + 1);
		}
	}

	long long ans = accumulate(a.begin(), a.end(), 0LL);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2820
#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;ll MM = 1000000000;ll mod = MM + 7;
/*
int main(){
ll l,r; cin>>l>>r;

}*/
int main(){
  ll n,d,ans=0; cin>>n>>d;
  vector<vector<int>>x(n,vector<int>(d));
rep(i,n){
rep(k,d) cin>>x.at(i).at(k);
}
 rep(i,n-1){
 for(int k=i+1;k<n;k++){
   ll cnt=0;
 rep(p,d){cnt+=pow(x.at(i).at(p)-x.at(k).at(p),2);}
   if(cnt>=3600){
   for(int p=60;p<130;p++){
   if(cnt==pow(p,2))ans++;
   }
   }
 
    else{
   for(int p=0;p<60;p++){
   if(cnt==pow(p,2))ans++;
   }
   }
 
 } 
 } 
  cout<<ans  <<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
	int n;
	long long int k;
	static int a[200010];
	static int order[200010];

	cin >> n;
	cin >> k;
	for(int i=1; i <= n; i++){
		cin >> a[i];
	}
	for(int i=1; i <= n; i++){
		order[i] = -1;
	}


	int temp = 1;
	int size = 0;
	int loopstart;
	int begin;

	//kが短くてループしない場合
	if(k <= n){
		for(int i = 0; i < k; i++){
		temp = a[temp];
		}
		cout << temp;
		return 0;
	}


	for(int i = 0; i <= n+1; i++){
		if(order[temp] == -1){
			order[temp] = i;
		}else{
			size = i - order[temp];
			loopstart = temp;
			begin = order[temp];
			break;
		}
		temp = a[temp];
	}

	long long int newk;
	newk = (k - (long long int)begin) % (long long int)size;
	
	temp = loopstart;
	//cout << temp << " ";
	for(int i = 0; i < newk; i++){
		temp = a[temp];
		//cout << temp << " ";
	}
	/*cout << endl;
	cout << loopstart << endl;
	cout << size << endl;
	cout << newk << endl;*/
	cout << temp;

}


Measured memory_bytes: 5196
using System;

namespace B
{
    class Program
{
        static int[] ToIntAry(string[] str)
        {
            int len = str.Length;
            int[] intary = new int[len];
            for (int i = 0;i < len;i++)
            {
                intary[i] = int.Parse(str[i]);
            }
            return intary;

        }
        static void Main(string[] args)
        {
            int[] NK = ToIntAry(Console.ReadLine().Split(' '));
            int[] Owner;
            int[] Sunuke = new int[NK[0]];
            int D;
            int Count = 0;
            
            for(int i = 0; i< NK[1];i++)
            {
                D = int.Parse(Console.ReadLine());
                Owner = ToIntAry(Console.ReadLine().Split(' '));
                foreach(int a in Owner)
                {
                    Sunuke[a-1]++;
                }
            }
            foreach(int s in Sunuke)
            {
                if(s < 1)
                {
                    Count++;
                }
            }
            Console.WriteLine(Count);
        }
    }
}


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

using namespace std;
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ld long double

int main()
{
	IOS;
	int r;
	cin >>r;
	cout <<3*pow(r,2)<<"\n";
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int maxn=60;
string A,B;
int Next[maxn];

void getnext()
{
	int j=0,k=-1;
	Next[0]=-1;
	while(j<B.size())
	{
		if(k==-1 || B[j]==B[k])
		{
			j++,k++;
			Next[j]=k;
		}
		else k=Next[k];
	}
}

int KMP()
{
	int i=0,j=0,cnt=0;
	while(i<A.size())
	{
		if(j==-1 || A[i]==B[j])
		{
			i++,j++;
		}
		else j=Next[j];
		if(j==B.size())
		{
			cnt++,j=0;
		}
	}
	return cnt;
}

int main()
{
	ios;
	int N;
	cin>>N>>A;
	B="ABC";
	getnext();
	cout<<KMP()<<"\n";
	return 0;
}

Measured memory_bytes: 3500
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n, n) {
		vector<int>a, b;
		for (int i = 0; i < n; i++) {
			int k; cin >> k;
			a.push_back(k);
		}
		sort(a.begin(), a.end());
		int dskjfasdjkdfsjk = 0;
		for (int i = 1; i <= 2 * n; i++) {
			if (dskjfasdjkdfsjk == a.size() || a[dskjfasdjkdfsjk] != i)b.push_back(i);
			else dskjfasdjkdfsjk++;
		}
		int now = 0;
		while (true) {
			for (size_t i = 0; i < a.size(); i++) {
				if (a[i] > now) {
					now = a[i];
					a.erase(a.begin() + i);
					goto gotou;
				}
			}
			now = 0;
		gotou:if (a.size() == 0)goto end;
			for (size_t i = 0; i < b.size(); i++) {
				if (b[i] > now) {
					now = b[i];
					b.erase(b.begin() + i);
					goto gotoba;
				}
			}
			now = 0;
		gotoba:if (b.size() == 0)goto end;
		}
	end:if (a.size() == 0) {
			printf("%d\n0\n",b.size());
		}
		else {
			printf("0\n%d\n", a.size());
		}
	}
}

Measured memory_bytes: 3216
n = int(input())
xlst = list(map(int, input().split()))

import math

c1 = math.ceil(sum(xlst)/n)
c2 = math.floor(sum(xlst)/n)
s1 = [(c1-x)**2 for x in xlst]
s2 = [(c2-x)**2 for x in xlst]

print(min(sum(s1),sum(s2)))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int checkPrimeNumber(int n)
{
  int x = 1 ;

  for(int i = 2; i <= n/2; ++i)
  {
      if(n%i == 0)
      {
          x= 0;
          break;
      }
  }
  return x;
}

int main()
{
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    for(int i=n;i<=100009;i++)
    {
      if(checkPrimeNumber(i))
        {
            cout<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)

ll N;
ll A[100010];

int main() {
    cin >> N;
    ll cnt = 0;
    ll sum = 0;
    ll m;
    rep(i,N){
        cin >> A[i];
        if (i==0) m = abs(A[0]);
        if (A[i] <= 0) cnt ++;
        sum += abs(A[i]);
        m = min(m,abs(A[i]));
    }
    if (cnt % 2 ==0) cout << sum << endl;
    else cout << sum-m*2 << endl;
    return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 2e5 + 55;

int n, k;
int p[maxN], lf[maxN], rt[maxN];

void preCal(){
	for(int i = 1; i <= n; i++){
		lf[i] = i;
		if(i > 1 && p[i - 1] < p[i]){
			lf[i] = lf[i - 1];
		}
	}

	for(int i = n; i > 0; i--){
		rt[i] = i;
		if(i < n && p[i] < p[i + 1]){
			rt[i] = rt[i + 1];
		}
	}
}

deque<int> mxDeck, mnDeck;

void insertMx(int i){
	while(!mxDeck.empty() && p[mxDeck.back()] < p[i]){
		mxDeck.pop_back();
	} 
	mxDeck.push_back(i);
}

void popMx(int i){
	while(!mxDeck.empty() && mxDeck.front() < i){
		mxDeck.pop_front();
	}
}

int getMx(){
	assert(!mxDeck.empty());
	return p[mxDeck.front()];
}

void insertMn(int i){
	while(!mnDeck.empty() && p[mnDeck.back()] > p[i]){
		mnDeck.pop_back();
	}
	mnDeck.push_back(i);
}

int getMn(){
	assert(!mnDeck.empty());
	return p[mnDeck.front()];
}

void popMn(int i){
	while(!mnDeck.empty() && mnDeck.front() < i){
		mnDeck.pop_front();
	}
}

void solve(){
	ll fRes = 0;
	
	for(int i = 1; i < k; i++){
		insertMx(i);
		insertMn(i);
	}
	
	bool fl = false;
	set<pair<int, int> > se;
	for(int i = 1; i + k - 1 <= n; i++){
		int j = i + k - 1;

		insertMx(j);
		insertMn(j);

		popMx(i);
		popMn(i);

		int l = i, r = j;
		
		if(mnDeck.size() == k){
			fl = true;		
			continue;
		}
		
		if(i > 1 && p[i - 1] < getMn()){
			l = lf[i - 1];
		}
		if(i + k <= n && getMx() < p[i + k]){
			r = rt[i + k];
		}
		//cerr << i << ' ' << j << ' ' << getMx() << '\n';
		se.insert(make_pair(l, r));
	}

	cout << (int)se.size() + fl << '\n';
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> k;

	for(int i = 1; i <= n; i++){
		cin >> p[i];
	}

	preCal();

	solve();

	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
         
int main() {
  int N,a,b;
  cin >> N;
  a = N % 1110;
  b = N % 1000;
  if (a < 10){
  cout << "Yes" << endl;
  } else if ((b % 111) == 0){
  cout << "Yes" << endl;
  } else{
  cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
def main():
    N = int(input())
    A = deque([int(input()) for i in range(N)])
    MAX = max(A)
    MAX2 = 0
    Ms = [-1]*N
    for i in range(N):
        if A[i] == MAX:
            if MAX2 != 0:
                Ms[i] = MAX2
            else:
                A[i] = 0
                MAX2 = max(A)
                Ms[i] = MAX2
        else:
            Ms[i] = MAX
    for i in range(N):
        print(Ms[i])

if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> abc(N, vector<int>(3));
  rep(i, N) {
    rep(j, 3) {
      cin >> abc[i][j];
    }
  }

  vector<vector<int>> dp(N+1, vector<int>(3, 0));

  rep(i, N) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k]);
      }
    }
  }
  int ans = 0;
  rep(i, 3) {
    ans = max(ans, dp[N][i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <vector>
#include <limits.h>
#include <cmath>
using namespace std;
using ll=long long;
int main(){
    vector<ll> memo(2000);
    for(int i=0;i<2000;i++){
        memo[i]=pow(i,5);
    }
    //cout<<memo[1999]<<endl;
    int x;
    cin>>x;
    for(int i=0;i<2000;i++){
        for(int j=0;j<2000;j++){
            if(memo[i]-memo[j]==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }else if(memo[i]+memo[j]==x){
                cout<<i<<" "<<-j<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 4216
s = [x for x in list(map(str, input()))]

ans = 0
acgt = 0

for x in s:
    if x == 'A' or x == 'T' or x == 'G' or x == 'C':
        acgt += 1
        ans = max(acgt, ans)
    else:
        acgt = 0

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 


int main() {
    int n;
    cin >> n;
    double r;
    vector<int> xs(n);
    rep(i, n) {
        cin >> xs[i];
        r += xs[i]; 
    }
    r /= n;
    int ri = static_cast<int>(r);
    if (r - ri > 0.5) ri += 1;
    int ret = 0;
    rep(i, n) {
        ret += (xs[i] - ri) * (xs[i] - ri);
    }
    cout << ret << endl;
}

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

int main(){
  string s;
  cin >> s;
  for ( int i = 0; i < s.size()-1; i++ ){
    if ( s[i] == 'A' && s[i + 1] == 'C' ){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

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

  if ( a < b ) {
    printf("a < b\n");
} else if ( a == b ) {
    printf("a == b\n");
} else { 
    printf("a > b\n");
}
    return 0;
}


Measured memory_bytes: 2124
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
int partition(int A[],int p,int r)
{
	int x=A[r];
	int i=p-1;
	for(int j=p;j<r;j++)
	{
		if(A[j]<=x)
		{
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[++i],A[r]);
	return i;
}

int main()
{
	int n;
	cin>>n;
	int *A=new int[n];
	for(int i=0;i<n;i++)cin>>A[i];
	int p=partition(A,0,n-1);
	for(int i=0;i<n;i++)
	{
		if(i)cout<<" ";
		if(i==p)cout<<"[";
		cout<<A[i];
		if(i==p)cout<<"]";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3440
#include<iostream>
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

/*ここから*/
//10^6程度の扱いが可能
//縮約まで完了済み

int V;//頂点の個数
int E;//辺の個数
P e[2000010];//辺の組み
int conn=0;//連結数
int t[2000010];//親情報の記録媒体

void Conn(){  
    for(int i=1;i<=V;i++){
        t[i]=i;
    }
    for(int i=0;i<E;i++){
        int a,b;
        a=e[i].first;
        b=e[i].second;
        //同一連結成分か？
        while(t[a]!=t[t[a]]){
            t[a]=t[t[a]];
        }
        while(t[b]!=t[t[b]]){
            t[b]=t[t[b]];
        }
        if(t[a]!=t[b]){
            if(t[a]<t[b]){
                t[t[b]]=t[a];
                t[b]=t[a];
            }
            else{
                t[t[a]]=t[b];
                t[a]=t[b];
            }
        }
    }
    for(int i=1;i<=V;i++){
        if(t[i]==i){conn++;}
    }
}

/*ここまで*/

/*用例*/

int main(){ 
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        e[i].first=a;
        e[i].second=b;
    }

    V=n;E=m;
    Conn();

    cout<<conn<<endl;//連結数

    return 0;
}

Measured memory_bytes: 4736
#include <cstdio>
#include <vector>
#include <algorithm>
const long long MOD = 1000000007;
long long fib[88];
std::vector < std::pair < long long, long long > > V[87];
bool Under(long long a, long long b, long long x, long long y, int d)
{
	if (d == 0)
		return a <= x && b <= y;
	if (d == 1)
		return b <= x && a + b <= y;
	return fib[d - 2] * a + fib[d - 1] * b <= x && fib[d - 1] * a + fib[d] * b <= y;
}
void List(std::vector < std::pair < long long, long long > > &V, long long a, long long b, long long x, long long y, int d)
{
	if (d == 1)
	{
		V.push_back({ a, b });
		return;
	}
	for (long long i = a + b; ; i += b)
		if (Under(b, i, x, y, d - 1))
			List(V, b, i, x, y, d - 1);
		else
			return;
}
long long count(long long x, long long y, int d)
{
	long long O = 0;
	for (auto i : V[d])
		if (i.second <= x && i.first + i.second <= y)
			O = (O + (y - i.first) / i.second + std::max(x - i.first, i.second - 1) / i.second) % MOD;
	return O;
}
int main()
{
	fib[0] = 1;
	fib[1] = 1;
	fib[2] = 2;
	fib[3] = 3;
	for (int i = 4; i <= 87; i++)
		fib[i] = fib[i - 1] + fib[i - 2];
	for (int i = 2; i <= 85; i++)
	{
		long long x = fib[i + 2] - 1, y = fib[i + 2] - 1;
		for (long long j = 2; ; j++)
			if (Under(1, j, x, y, i - 1))
				List(V[i], 1, j, x, y, i - 1);
			else
				break;
	}
	int Q;
	long long x, y;
	for (scanf("%d", &Q); Q--; )
	{
		scanf("%lld%lld", &x, &y);
		if (x > y)
			std::swap(x, y);
		for (int i = 85; ; i--)
		{
			if (i == 1)
			{
				printf("1 %lld\n", x * y % MOD);
				break;
			}
			if (x >= fib[i] && y >= fib[i + 1])
			{
				printf("%d %lld\n", i, count(x, y, i));
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4096
import kotlin.math.PI

fun main() {
    val r = readInt()
    val ans = r * 2 * PI
    println(ans)
}

private fun read() = readLine()!!

private fun readInt() = read().toInt()

private fun readLong() = read().toLong()

private fun readDouble() = read().toDouble()

private fun readListString() = read().split(" ")

private fun readListInt() = readListString().map { it.toInt() }

private fun readListLong() = readListString().map { it.toLong() }

private fun readListDouble() = readListString().map { it.toDouble() }

private fun readMatrixString(n: Int): List<List<String>> {
    val matrix = mutableListOf<List<String>>()
    for (i in 0 until n) {
        val list = readListString()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixInt(n: Int): List<List<Int>> {
    val matrix = mutableListOf<List<Int>>()
    for (i in 0 until n) {
        val list = readListInt()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixDouble(n: Int): List<List<Double>> {
    val matrix = mutableListOf<List<Double>>()
    for (i in 0 until n) {
        val list = readListDouble()
        matrix.add(list)
    }
    return matrix
}

private fun readMatrixLong(n: Int): List<List<Long>> {
    val matrix = mutableListOf<List<Long>>()
    for (i in 0 until n) {
        val list = readListLong()
        matrix.add(list)
    }
    return matrix
}



Measured memory_bytes: 34656
#!/usr/bin/env python3
import numpy as np
n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))
ans = 0
for i in range(n):
    a = np.array(list(map(int, input().split())))
    if sum(a * b) + c > 0: ans += 1
print(ans)

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

using namespace std;

int main() {
    string S;
    int N;

    cin >> N;
    cin >> S;

    int off = 'A';
    int max = 'Z';
    for (int i = 0; i < S.length(); i++) {
        S[i] = off+((S[i]-off+N)%(max-off+1));
    }

    cout << S << endl;

    return 0;
}

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

int main(){
      string s;cin >> s;
      int a = stoi(s.substr(0, 2));
      int b = stoi(s.substr(2, 2));
      if(a <= 12 && b <= 12 && a > 0 && b > 0)cout << "AMBIGUOUS";
      else if(a > 0 && a <= 12 && b > 12)cout << "MMYY";
      else if(a > 12 && b <= 12 && b > 0)cout << "YYMM";
      else if(a == 0 && b <= 12 && b > 0)cout << "YYMM";
      else if(a > 0 && a <= 12 && b == 0)cout << "MMYY";
      else if(a == 0 && b == 0)cout << "NA";
      else if(a > 12 && b > 12)cout << "NA";
      else if(a == 0 && b > 12)cout << "NA";
      else if(a > 12 && b == 0)cout << "NA";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if (k <= a + b) ans = min(k , a);
    else ans = a - (k - (a + b));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
	    List<int> input = IO.GetIntList();
	    int k = input[0];
	    int x = input[1];
	    Console.WriteLine((k*500>=x)?"Yes":"No");
	}

}

static class IO
{
    static public string GetString() { return Console.ReadLine(); }
    static public int GetInt() { return int.Parse(Console.ReadLine()); }
    static public long GetLong() { return long.Parse(Console.ReadLine()); }
    static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
    static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
    static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
    static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	string S, T; cin >> S >> T;

	int ans = 10000;
	REP(i,S.length() - T.length() + 1){
		int cnt = 0;
		REP(j, T.length()){
			if(S[i+j] == T[j]) cnt++;
		}
		int tmp = T.length() - cnt;
		ans = min(ans, tmp);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3596
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,k,c;
int a[100111];
int main()
{
	getiii(n,c,k);
	for(int i=1;i<=n;i++)geti(a[i]);
	sort(a+1,a+n+1);
	int cnt=0;
	for(int i=1;i<=n;)
	{
		int j=i,lft=c;
		while(j<=n&&lft>0&&a[j]<=a[i]+k)j++,lft--;
		i=j;
		cnt++;
	}
	putsi(cnt);
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <set>
#include <ctime>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;
#define LL long long
const double eps=1e-10;
#define M 1005
#define Mod 1000003
#define fr(i,s,t) for(int i=s;i<=t;i++)
void read(LL &x) {
    x = 0;
    LL f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -f;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar();
    }
    x *= f;
    return;
}
LL m,d,ans;
int main(){
	read(m),read(d);
	for(int i=1;i<=m;i++){
		for(int j=1;j<=d;j++){
			if(j%10<2||j/10<2)
				continue;
			if((j%10)*(j/10)==i){
				ans++;
			}
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

int n, ans=0;
int a[N], b[N];
vector<pair<int, int> > v;

int32_t main()
{
	IOS;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
		v.push_back({a[i]+b[i], i});
	}
	sort(v.rbegin(), v.rend());
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
			ans+=a[v[i].second];
		else
			ans-=b[v[i].second];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3568
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define SZ(x) ((int)(x).size())
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 19, maxS = 513, mod = 998244353;
const long long INF = 1000000000000000000ll;

bool is(char* t, int n)
{
	FOR(i, 0, n)
		if (t[i] != t[n-1-i])
			return false;
	return true;
}

char T[maxN];

void solve()
{
	int n;
	scanf ("%d", &n);
	long double a = n / 3.0;
	printf("%.9Lf\n", a*a*a);	
}
 
int main()
{
	int t;
	t=1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#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)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int ans=0;
    vvi a(3,vi(3));
    vvi flag(3,vi(3));
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vi b(n);
    rep(i,n){
        cin >> b[i];
        rep(j,3){
            rep(k,3){
                if(b[i] == a[j][k]) flag[j][k] = 1;
            }
        }
    }

    rep(i,3){
        if(flag[i][0] && flag[i][1] && flag[i][2]) ans++;
        if(flag[0][i] && flag[1][i] && flag[2][i]) ans++;
    }
    if(flag[0][0] && flag[1][1] && flag[2][2]) ans++;
    if(flag[0][2] && flag[1][1] && flag[2][0]) ans++;

    /*
    rep(i,3){
        rep(j,3){
            cout << flag[i][j] << " ";
        }
        cout << endl;
    }
    */

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
#define 	  endl 			'\n'
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    	
        string s; cin >> s;
        int tot = 0;
        for(auto x:s){
        	tot += (x - '0');
        	tot %= 9;
        }
        if(tot)
        	cout << "No";
        else cout << "Yes";
    	return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
int32_t main()
{


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int max1 = INT_MIN, max2 = INT_MIN;
	int n;
	cin >> n;
	int arr[n], s[n];
	for (int i = 0; i < n; i++)
	{
		cin >> s[i];
		if (s[i] > max1)
		{
			max2 = max1;
			max1 = s[i];
		}
		else
		{
			if (s[i] > max2)
				max2 = s[i];
		}

	}
	//cout << max1 << max2;
	for (int i = 0; i < n; i++)
	{
		if (s[i] != max1)
		{
			cout << max1 << endl;
		}
		else
			cout << max2 << endl;
	}

}

Measured memory_bytes: 3200
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
right = -C
result = 0
for _ in range(N):
    v = 0
    for i, Ai in enumerate(list(map(int, input().split()))):
        v += Ai * B[i]
    if v > right:
        result += 1
print(result)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
template <class T> void chmin(T& a, const T& b) { if (b < a) a = b; }
const char* LF = "\n";
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

ll D, G;
vector<ll> pi;
vector<ll> ci;
vector<ll> pa;
int ans = 1e6;

void dfs(int d, int cnt, ll pt, int flag) {
    if (pt >= G) {
        chmin(ans, cnt);
    }

    FOR(i, d+1, D+1) {
        dfs(i, cnt + pi[i], pt + pa[i], flag | (1 << (i - 1)));
    }

    int ds = -1;
    for (int i=D; i>=1; i--) {
        if ((flag & (1 << (i - 1))) == 0) {
            ds = i;
            break;
        }
    }
    if (ds != -1) {
        REP(i, pi[ds]-1) {
            pt += 100 * ds;
            cnt++;
            if (pt >= G) {
                chmin(ans, cnt);
            }
        }
    }
}

signed main() {
    cin >> D >> G;

    pi.resize(D+1);
    ci.resize(D+1);
    pa.resize(D+1);

    FOR(i, 1, D+1) {
        cin >> pi[i] >> ci[i];
        pa[i] = 100 * i * pi[i] + ci[i];
    }

    dfs(0, 0, 0, 0);
    cout << ans << LF;

    return 0;
}

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

using namespace std;

int main() {
	int n, count = 0;
	string s;
	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') count++;
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  string s; cin>>s;

  string z = "";
  rep(i, 26) z.push_back('z');
  string ans = z;

  vector<bool> used(26, false);
  int n = s.size();
  rep(i, n) {
    used[s[i]-'a'] = true;
    string t = s.substr(0, i);
    rep(j, 26) {
      if (used[j]) continue;
      string u = t + char('a' + j);
      if (s < u) ans = min(ans, u);
    }
  }
  rep(i, 26) {
    if (used[i]) continue;
    ans = min(ans, s + char('a' + i));
  }

  if (ans == z) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string S;
    cin >> S;
    int n = S.size();
    vector<int> a(n+1,0);
    REP(i, n){
        if(S[i] == '<'){
            a[i+1] = max(a[i+1], a[i]+1);
        }
    }
    RREP(i,n){
        if(S[i] == '>'){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    ll ans = 0;
    for(auto&& i : a){
        ans += i;
    }
    pr(ans);
}

Measured memory_bytes: 2820
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, a, b, c, d,aa,bb,kin;
	cin >> n >> a >> b >> c >> d;
	aa = 0;
	kin = 0;
	while (aa < n) {
		aa = aa + a;
		kin =b + kin;
	}
	aa = kin;
	bb = 0;
	kin = 0;
	while (bb < n) {
		bb = bb + c;
		kin = d + kin;
	}
	bb = kin;
	cout << min(aa, bb) << endl;
}


Measured memory_bytes: 3136