akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstdint>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

typedef pair<int, int> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int digits(int n)
{
	int count = 0;
	while (n > 0)
	{
		n /= 10;
		count++;
	}
	return count;
}
ll combination(ll n, ll r)
{
	if (r * 2 > n)
		r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i)
	{
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
int GCD(int x, int y)
{
	return x ? GCD(y % x, x) : y;
}
vector<int> divisor(int n)
{
	vector<int> value;
	FOR(i, 1, pow(n, 0.5) + 1)
	{
		if (i <= sqrt(n))
		{
			if (n % i == 0)
			{
				value.push_back(i);
				if (i * i != n)
				{
					value.push_back(n / i);
				}
			}
		}
	}
	return value;
}

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n), sum(n);
	ll st = 0;
	//multiset<int>sum;
	rep(i, n)
	{
		cin >> a[i];
		st += a[i];
		sum[i] = st;
		//sum.insert(st);
	}
	int cnt = 1;
	ll ans = 0;
	sort(all(sum));
	rep(i, n-1)
	{
		/*if(sum[i]==0){
			ans++;
		}*/
		if (sum[i] == sum[i + 1])
		{
			cnt++;
		}
		else if (cnt > 1)
		{
			if(sum[i]==0){
				cnt++;
			}
			ans += (ll)(cnt - 1) * cnt / 2;
			cnt = 1;
		}
		else
		{
			if (sum[i] == 0)
			{
				ans += cnt;
			}
			cnt = 1;
		}
		/*cout<<cnt<<" ";
		cout<<ans<<" ";
		cout << sum[i] << endl;*/
	}
	if (cnt > 1)
	{
		if(sum[n-1]==0){
				cnt++;
		}
		ans += (ll)(cnt - 1) * cnt / 2;
		cnt = 1;
	}
	if(cnt==1&&sum[n-1]==0&&n==1){
		ans++;
	}
	cout << ans << endl;
	//cout<<cnt<<endl;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) throws Exception {
	    Scanner sc = new Scanner(System.in);   
	    
	    int X = Math.min(sc.nextInt(), sc.nextInt());
	    int Y = Math.min(sc.nextInt(), sc.nextInt());
	    
	    System.out.println(X+Y);
	}    
}	

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000;

struct max_flow {
	struct edge { int to, cap, rev; };
	int V;
	vector<vector<edge>> G;
	vector<int> itr, level;

	max_flow(int V) : V(V) { G.assign(V,vector<edge>()); }

	void add_edge(int from, int to, int cap) {
		G[from].push_back((edge) {to, cap, (int) G[to].size()});
		G[to].push_back((edge) {from, 0, (int) G[from].size()-1});
	}

	void bfs(int s) {
		level.assign(V,-1);
		queue<int> q;
		level[s] = 0; q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for(auto &e: G[v]){
				if (e.cap > 0 and level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int& i = itr[v]; i < (int) G[v].size(); ++i) {
			edge& e = G[v][i];
			if (e.cap > 0 and level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int run(int s, int t) {
		int ret = 0, f;
		while (bfs(s), level[t] >= 0) {
			itr.assign(V,0);
			while ((f = dfs(s, t, INF)) > 0) ret += f;
		}
		return ret;
	}
};

int main() {
	int n; cin >> n;
	vector<int> p(n), q(n), p_root(n, -1), q_root(n, -1);
	for (int i = 0; i < n; ++i) cin >> p[i];
	for (int i = 0; i < n; ++i) cin >> q[i];
	for (int i = 0; i < n; ++i) {
		if (p_root[i] >= 0) continue;
		p_root[i] = i;
		int cur = i;
		while (p_root[p[cur]] < 0) {
			p_root[p[cur]] = i;
			cur = p[cur];
		}
	}
	for (int i = 0; i < n; ++i) {
		if (q_root[i] >= 0) continue;
		q_root[i] = i;
		int cur = i;
		while (q_root[q[cur]] < 0) {
			q_root[q[cur]] = i;
			cur = q[cur];
		}
	}

	max_flow D(2*n+2);
	int S = 2*n; int T = 2*n+1;

	for (int i = 0; i < n; ++i) {
		if (p[i] != i) {
			if (p[i] == q[i]) D.add_edge(q_root[i]+n, p_root[i], 1);
		}
		else D.add_edge(S, i, 1);
		D.add_edge(p_root[i], q_root[i]+n, 1);

		if (q[i] == i) D.add_edge(q_root[i]+n, T, 1);
	}

	cout << n - D.run(S, T) << endl;
	return 0;
}

Measured memory_bytes: 20452
#include<iostream>
using namespace std;
int main()
{
   int a,b,aa,zzz;
  cin >> a >> b >> aa ;
    if(a%b==0)
    {
      
      
      
      
      
      
           zzz=a/b;
    }
  else
  {
          zzz=a/b+1;
  }
   cout <<  zzz*aa         << "\n" ;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
  ll n, d;cin>>n>>d;
  ll cnt=0;
  
  ll a[n][d];
  rep(i, n){
    rep(j, d) cin>>a[i][j];
  }
  rep(i, n){
    for(ll j=i+1; j<n; j++) {
      ll s=0;
      rep(k, d) {
        s+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      if(sqrt(s)==floor(sqrt(s))) cnt++;
    }
  }
  cout << cnt;
}
      

Measured memory_bytes: 3668
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N int
  var A []int
  NextInt(&N)
  NextIntVec(&A)
  S := make([]int, 0)
  M := MaxInt(A...)
  if M <= 0 {
    Write(M)
    Write(N - 1)
    i := N - 1
    for ; A[i] < M; i-- { S = append(S, i + 1) }
    for j := 0; j < i; j++ { S = append(S, 1) }
    for _, s := range S { Write(s) }
    return
  }
  O, E := 0, 0
  for i := 0; i < N; i += 2 { O += MaxInt(A[i], 0) }
  for i := 1; i < N; i += 2 { E += MaxInt(A[i], 0) }
  F := func (k int) {
    for ; k >= 0; k -= 2 {
      if A[k] > 0 { continue }
      S = append(S, k + 1);
      N--
      if k != 0 && k != N { N-- }
    }
    if k % 2 != 0 || A[0] <= 0 {
      S = append(S, 1)
      N--
    }
  }
  if O >= E {
    F(((N - 1) / 2) * 2)
  } else {
    F((N / 2) * 2 - 1)
  }
  for i := 0; i < N / 2; i++ { S = append(S, 2) }
  Write(MaxInt(O, E))
  Write(len(S))
  for _, s := range S { Write(s) }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 768
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

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

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<gcd(a,b)<<endl;
    
    
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  string s; cin >> s;
  int K; cin >> K;
  int N = s.size();
  rep(idx,N){
    if (idx==N-1){
      int n = s[idx] - 'a';
      n = (n + K)%26;
      s[idx] = 'a' + n;
      break;
    }


    int dist = ('z'+1-s[idx])%26;
    if (dist<=K ) {
      K -= dist;
      s[idx] = 'a';
    }
  }
  cout << s << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define rep(i, n) for(int i=0;i<n;i++)
int ddmin(int i,int j,int k,int l,int m){
  if(i<=j && i<=k && i<=l && i<=m){
return i;
  }
   if(j<=i && j<=k && j<=l && j<=m){
return j;
  }
  if(k<=j && k<=i && k<=l && k<=m){
return k;
  }
  if(l<=j && l<=k && l<=i && l<=m){
return l;
  }
   if(m<=j && m<=k && m<=l && m<=i){
return m;
  }
}
  
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  int A,B,C,D,E;
  if(a%10==0) A=a/10;
  else A=a/10+1;
   if(b%10==0) B=b/10;
  else B=b/10+1;
   if(c%10==0) C=c/10;
  else C=c/10+1;
   if(d%10==0) D=d/10;
  else D=d/10+1;
   if(e%10==0) E=e/10;
  else E=e/10+1;
  int last=ddmin((a-1)%10,(b-1)%10,(c-1)%10,(d-1)%10,(e-1)%10);
   cout<< (A+B+C+D+E)*10+last-9 <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
  int a = 0;
  int n = 0;
  int i;
  scanf("%d",&a);
    
   for(i = 1 ; i <= a ; i++){
     if(1 <= i && i <= 9){
       n++;
       continue;
     }
     else if (10 <= i && i <= 99){
       continue;
     }
     else if(100 <= i && i <= 999){
       n++;
       continue;
     }
     else if(1000 <= i && i <= 9999){
       continue;
     }
     else if(10000 <= i && i <= 99999){
       n++;
       continue;
     }
     else if(i = 100000){
       continue;
     }
   }
   printf("%d",n);
   return 0;
}

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

using namespace std;

int N;

int dfs(int remain, int num, int seven, int five, int three) {
	if (remain == 0) return (seven + five + three == 3 && num <= N && num != 0) ? 1 : 0;
	else {
		int sum = dfs(remain - 1, num * 10 + 7, 1, five, three);
		sum += dfs(remain - 1, num * 10 + 5, seven, 1, three);
		sum += dfs(remain - 1, num * 10 + 3, seven, five, 1);
		sum += dfs(0, num, seven, five, three);

		return sum;
	}
}

int main() {
	cin >> N;
	int digit = (int)log10(N);

	cout << dfs(digit+1, 0, 0, 0, 0) << endl;

	return 0;
}

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

const int maxn=1e5+10;

int n,m,a[maxn],b[maxn],t[maxn],t0[maxn],Ans;
int tote,FIR[maxn],TO[maxn<<1],NEXT[maxn<<1];
bool exist[maxn],vis[maxn];

void addedge(int u,int v)
{
	TO[++tote]=v;
	NEXT[tote]=FIR[u];
	FIR[u]=tote;
}

void dfs(int u)
{
	vis[u]=1;
	for (int p=FIR[u];p;p=NEXT[p])
	{
		int v=TO[p];
		if (!vis[v]) dfs(v);
	}
}

int main()
{
#ifdef h10
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
#endif
	int i;
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]),a[0]^=a[i];
	for (i=1;i<=n;i++)
		scanf("%d",&b[i]),b[0]^=b[i];
	memcpy(t,a,sizeof(a));
	sort(t,t+n+1);
	memcpy(t0,b,sizeof(b));
	sort(t0,t0+n+1);
	for (i=0;i<=n;i++)
		if (t[i]!=t0[i]) {puts("-1"); return 0;}

	m=unique(t,t+n+1)-t-1;

	for (i=0;i<=n;i++)
		a[i]=lower_bound(t,t+m+1,a[i])-t;
	for (i=0;i<=n;i++)
		b[i]=lower_bound(t,t+m+1,b[i])-t;

	exist[a[0]]=exist[b[0]]=1;

	for (i=1;i<=n;i++)
		if (a[i]!=b[i])
		{
			exist[a[i]]=exist[b[i]]=1;
			addedge(a[i],b[i]);
			addedge(b[i],a[i]);
			Ans++;
		}
	for (i=0;i<=m;i++)
		if (exist[i]&&!vis[i])
			dfs(i),Ans++;
	Ans-=Ans!=0;
	printf("%d\n",Ans);
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200003,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    ll ans=0;
    
    for(int i=1;i<=N;i++){
        if(i%3&&i%5) ans+=i;
    }
    
    cout<<ans<<endl;
}


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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int n = a*b;
    int m = c*d;

    if(n > m){
        cout << n << endl;
    }
    else cout << m << endl;
    
    return 0;
}

Measured memory_bytes: 3612
from collections import deque

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    D = deque(A)
    d = D.popleft()
    tmp = deque([d])
    cnt = 0
    while D:
        if cnt % 2 == 0:
            i = D.pop()
            tmp.appendleft(i)
            if D:
                j = D.pop()
                tmp.append(j)
        else:
            i = D.popleft()
            tmp.appendleft(i)
            if D:
                j = D.popleft()
                tmp.append(j)
        cnt += 1

    ans = 0
    for i in range(N-1):
        ans += abs(tmp[i+1] - tmp[i])

    D = deque(A)
    d = D.pop()
    tmp = deque([d])
    cnt = 0
    while D:
        if cnt % 2 == 0:
            i = D.popleft()
            tmp.appendleft(i)
            if D:
                j = D.popleft()
                tmp.append(j)

        else:
            i = D.pop()
            tmp.appendleft(i)
            if D:
                j = D.pop()
                tmp.append(j)
        cnt += 1

    a = 0
    for i in range(N-1):
        a += abs(tmp[i+1] - tmp[i])

    print(max(a,ans))

if __name__ == "__main__":
    main()

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

string s;
long cnt[2019];

void solve() {
    cin >> s;
    long now = 0;
    long ans = 0;
    long p = 1;
    cnt[0] = 1;
    for (int i = s.size(); i--; ) 
    {
        now = (now + (s[i] - '0') * p) % 2019;
        ans += cnt[now]++;
        p = p * 10 % 2019;
    }
    cout << ans << endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int white = H*W;
		white -= h*W + w*(H-h);
		System.out.println(white);
	}
}


Measured memory_bytes: 23124
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){
	while(true) {
		auto NMP = readInts();
		auto N = NMP[0];
		auto M = NMP[1];
		auto P = NMP[2];
		if(N == 0 && M == 0 && P == 0) {
			return;
		}
		int[] X;
		for(int i; i < N; ++i) {
			X ~= readInt();
		}
		auto sum = reduce!("a+b")(0, X);
		writeln(X[M-1] == 0 ? 0: sum * (100-P) / X[M-1]);
	}
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL a[100001];
int se=0;
int fo=0;
int main(){
    cin>>N;
    REP(i,N){
        cin>>a[i];
        if(a[i]%4==0){
           fo++;
        }else if(a[i]%2==0){
           se++;
        }
    }
    if(se>0){
       N-=(se-1);
    }
    if(fo>=N/2){
       cout<<"Yes"<<endl;
    }else{
       cout<<"No"<<endl;
    }
    return(0);
}

Measured memory_bytes: 1024
n,w=map(int,input().split())
wlis=[]
vlis=[]
for i in range(n):
    a,b=map(int,input().split())
    wlis.append(a)
    vlis.append(b)

dp=[[0]*(w+1) for i in range(n+1)]

for i in range(0,n):
    for j in range(w+1):
        if j-wlis[i]>=0:
            dp[i+1][j]=max(dp[i][j],dp[i][j-wlis[i]]+vlis[i])
        else:
            dp[i+1][j]=dp[i][j]

print(dp[n][w])


Measured memory_bytes: 120300
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i = 0; i < n1; i++)
    L[i] = A[left + i];
  for(int i = 0; i < n2; i++)
    R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for(int k = left; k < right; k++){
    cnt++;
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right){
  if(left + 1 < right){
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main(){
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for(i = 0; i < n; i++)
    cin >> A[i];

  mergeSort(A, n, 0, n);

  for(i = 0; i < n; i++){
    if(i)
      cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 5064
#include <iostream>

#include <vector>

using namespace std;

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

int main() {
	int n;
	cin >> n;
	vector<int> p(4), t(4);
	REP(i, 4) cin >> p[i];
	REP(i, 4) cin >> t[i];
	int ans = 1e9;
	REP(a, n + 1) REP(b, n + 1) REP(c, n + 1) REP(d, n + 1) {
		if (t[0] * a + t[1] * b + t[2] * c + t[3] * d >= n) {
			ans = min(ans, p[0] * a + p[1] * b + p[2] * c + p[3] * d);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3104
n = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
    return b if a == 0 else gcd(b % a, a)
l = [0]
r = [0]
for i in range(n):
    l.append(gcd(l[-1], a[i]))
    r.append(gcd(r[-1], a[n - i - 1]))
ret = 0
for i in range(n):
    ret = max(ret, gcd(l[i], r[n - i - 1]))
print(ret)

Measured memory_bytes: 14060
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=1;i<=k;++i)
	{
		if(i%2)
		{
			if(a%2) --a;
			a/=2;
			b+=a;
		}
		else
		{
			if(b%2) --b;
			b/=2;
			a+=b;
		}
	}
	cout<<a<<' '<<b;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    an = list(map(int, input().split()))
    humi = 0
    maxi = an[0]
    for i in range(1, n):
        if an[i] < maxi:
            hu = maxi -an[i]
            humi += hu
        maxi = max(maxi, an[i])

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

Measured memory_bytes: 32132
#include <iostream>
#include <vector>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
//#define REPR(i, n) for(int i = n; i >= 0; i--)
//#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 1e9
// 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; }
using namespace std;

int main() { //int argc, const char * argv[]

    //input from txt ***提出時に削除***
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, ans=0;
    //double x;
    cin >> n;
    
    if (n%2 == 0){
        ans = n/2;
    } else {
        ans = (n+1)/2;
    }

    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    int n;
    std::cin >> n;
    VEC(int,a,n);
    int q;
    std::cin >> q;
    VEC(int,m,q);
    std::vector<bool> b(50000,0);
    brep(n){
        int d=0;
        rep(i,n)if(bit&(1<<i))d+=a[i];
        b[d]=1;
    }
    rep(i,q){
        if(b[m[i]])std::cout << yes << std::endl;
        else std::cout << no << std::endl;
    }
}


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

const int N = 10000100;
bool a[N];

void make_table(){
  fill(a, a+N, true);
  a[0] = false;
  a[1] = false;
  a[2] = true;
  a[3] = true;
  for(int i = 4;i < N;i+=2){
    a[i] = false;
  }
  for(int i = 3;i < N;i += 2){
    if (!a[i])continue;
    for(int j = 2*i;j < N;j+=i){
      a[j] = false;
    }
  }
}
  
int main(){
  make_table();
  int n;
  cin >> n;
  
  int ans = 0;
  if (n <= 2){
    ans = 0;
  } else {
    for(int i = 3;i <= n;i++){
      if (a[i] && a[2 + i]){
	ans++;
      }
    }
    ans = ans * 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 12864
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  vector<int> vec = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int X;
  cin >> X;
  int c = 0;
  rep(i, 9) {
    rep(j, 9) {
      if(vec.at(i) * vec.at(j) == X) {
        c++;
      }
    }
  }
  if(c == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3600
#include<cstdio>
#include<algorithm>
#include <functional>
using namespace std;
using ll = long long;

int main(){
	int N;
	scanf("%d", &N);
	int A[N], B[N];
	pair<int, int> sum[N];
	for (int i = 0; i < N; ++i){
		scanf("%d %d", A + i, B + i);
		sum[i].first = A[i] + B[i];
		sum[i].second = i;
	}
	sort(sum, sum + N, greater<pair<int, int> >());
	ll answer = 0;
	for (int i = 0; i < N; ++i){
		answer += i & 1 ? -B[sum[i].second] : A[sum[i].second];
	}
	printf("%lld\n", answer);
	return 0;
}

Measured memory_bytes: 1664
#include <fstream>
#include <map>
#include <cmath>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 1000000007
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define add(a,b) ((int) (((ll) (a) + (b))%MOD))
#define mul(a,b) ((int) (((ll) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N;
int pw2 [200001];
ll A, B;
map<pll,pii> track;

ll gcd(ll a, ll b) { // MAKE SURE NONE IS NEGATIVE
    while (a != 0 && b != 0) {
        if (a > b) a = a%b;
        else b = b%a;
    }
    if (a == 0) return b;
    else return a;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;

    pw2[0] = 1;
    FOR(i,1,N+1) pw2[i] = mul(pw2[i-1],2);

    int zz = 0;
    F0R(i,N) {
        cin >> A >> B;
        if (A == 0 && B == 0) {zz++; continue;}

        ll C = gcd(abs(A),abs(B));
        A /= C;
        B /= C;
        if (track.count(mp(-A,-B))) track[mp(-A,-B)].F++;
        else if (track.count(mp(-B,A))) track[mp(-B,A)].S++;
        else if (track.count(mp(B,-A))) track[mp(B,-A)].S++;
        else track[mp(A,B)].F++;
    }
    int ans = 1;
    for (auto it = track.begin(); it != track.end(); it++) {
        ans = mul(ans,add(add(pw2[(it->S).F], pw2[(it->S).S]), MOD-1));
    }
    cout << add(ans,MOD-1)+zz << '\n';
}

// edge: 0

Measured memory_bytes: 16796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;

  vector<char> pl(n);
  vector<int> score(n);
  for (int i = 0; i < n; i++) {
    switch (t[i]) {
      case 'r':
        pl[i] = 'p';
        score[i] = p;
        break;
      case 's':
        pl[i] = 'r';
        score[i] = r;
        break;
      case 'p':
        pl[i] = 's';
        score[i] = s;
    }
  }

  for (int i = k; i < n; i++) {
    if (pl[i] == pl[i - k]) {
      score[i] = 0;
      pl[i] = 'x';
    }
  }

  int ans = accumulate(score.begin(), score.end(), 0);

  cout << ans << endl;

  return 0;
}

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

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0)
        {
            if(a[i]%3==0||a[i]%5==0)
            continue;
            else
            {
                cout << "DENIED";
                k = 1;
                break;
            }
            
        }
    }
    if(k==0)
        cout << "APPROVED";
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3632
from collections import deque
import bisect
n = int(input())

dq = deque()
for i in range(n):
    a = int(input())
    index = bisect.bisect_left(dq, a)
    if index == 0:
        dq.appendleft(a)
    else:
        dq[index-1] = a
print(len(dq))

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

using namespace std;

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

int dp[20][50001];
int coin[20];

int main()
{
	int n, m;
	cin >> n >> m;
	rep(i, m) cin >> coin[i];
	sort(coin, coin+m);
	rep(i, n+1) dp[0][i] = i;
	reps(i, 1, m) {
		rep(j, n+1) {
			dp[i][j] = dp[i-1][j];
			if(j-coin[i] >= 0) dp[i][j] = min(dp[i][j], dp[i][j-coin[i]]+1);
		}
	}
	cout << dp[m-1][n] << endl;
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
using namespace std;
#define INF (1e9)
int N,M;
int s[15];
int d[100];
int sum[(1<<15)];
int dp[(1<<15)];
 
void init(){
  for(int i=0;i<(1<<N);i++){
    sum[i]=0;
    dp[i]=0;
  }
}
 
int solve(){
  for(int i=0;i<M;i++){
    for(int bit=0;bit<(1<<N);bit++){
      for(int j=0;j<N;j++){
        int nbit=bit|(1<<j);
        dp[nbit]=min(dp[nbit],dp[bit]);
      }
      dp[bit]+=abs(sum[bit]-d[i]);
    }
  }
  int ans=INF;
  for(int bit=0;bit<(1<<N);bit++){
    ans=min(ans,dp[bit]);
  }
  return ans;
}
 
int main(){
  while(1){
    cin>>N>>M;
    if(N==0&&M==0)break;
    init();
    for(int i=0;i<N;i++)cin>>s[i];
    for(int i=0;i<M;i++)cin>>d[i];
    sort(d,d+M);
    for(int bit=0;bit<(1<<N);bit++)
      for(int i=0;i<N;i++)
        if(bit>>i&1)sum[bit]+=s[i];
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 3376
n = int(input())
alist = list(map(int,input().split()))

plus_list = []
prev = 0
cum = 0
for i in range(n):
    if prev <= alist[i]:
        cum += 1
    else:
        cum = 0
    prev = alist[i]
    plus_list.append(cum)


stock = 0
money = 1000

for i in range(n):
    if i == n-1:
        money += stock*alist[i]
        break

    if plus_list[i+1] == 0:
        #sell
        money += stock*alist[i]
        stock = 0
    else:
        if stock != 0:
            continue
        #buy
        stock = int(money / alist[i])
        money -= stock*alist[i]

print(money)

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

N,K=map(int,input().split())

S=[0]*N
for i in range(K):
    d=int(input())
    A=input().split()
    for j in range(d):
        a=int(A[j])-1
        S[a]+=1

ans=0
for s in S:
    if s==0: ans+=1

print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
vector<ll> fac, inv, facinv;

void modcalc(int n) {
	fac.resize(n); inv.resize(n); facinv.resize(n);
	fac[0] = 1; fac[1] = 1; inv[1] = 1;
	facinv[0] = 1; facinv[1] = 1;
	for (ll i = 2; i < n; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modinv(ll a) {
	a %= mod;
	if (a == 0) abort();
	if (a < (ll)inv.size()) return inv[a];
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b, ll m = mod) {
	ll ans = 1;
	a %= m;
	while (b) {
		if (b & 1) ans = ans * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return ans;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0 || n == 0 && k > 0) return 0;
	if (n == 0 && k == 0) return 1;
	return fac[n + k - 1] * facinv[k] % mod * facinv[n - 1] % mod;
}

const int N = 200010;
vector<vector<int>> graph(N, vector<int>());
vector<int> sz(N, 1);

void dfs(int n, int p) {
	for (int i : graph[n]) {
		if (i == p) continue;
		dfs(i, n);
		sz[n] += sz[i];
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	rep(i, n - 1) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	dfs(0, -1);
	ll ans = mod * 2 - n * modinv(2) % mod - modpow(modinv(2), n) + 1;
	ans %= mod;
	for (int i = 1; i < n; i++) {
		ll x = mod + 1 - modpow(modinv(2), sz[i]);
		ll y = mod + 1 - modpow(modinv(2), n - sz[i]);
		ans += x * y % mod;
		if (ans >= mod) ans -= mod;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 26036
def f(a):
    if a>1.0:return 0
    elif a>0.5:return 1
    elif a>0.1:return 2
    else:return 3
b=[0]*8
while 1:
    try:l,r=map(float,input().split())
    except:break
    b[f(l)]+=1
    b[4+f(r)]+=1
for i in range(4):print(b[i],b[4+i])


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

using Int = int;
using namespace std;

#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; };
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; };
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
}


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

int canFight(int *next){
   int ans=0;
   for(int i=0;i<N;i++){
       if(next[i] != -1){
           ans = 1;
           break;
       }
   }
   if(ans == 0) return ans;
   else return 1;
}

int main(){
    cin >> N;
    int A[N][N];
    for(int i=0;i<N;i++){
        for(int j=0;j<N-1;j++){
            cin >> A[i][j];
        }
        A[i][N-1] = -1;
    }
    int day=0;
    int next[N], count[N];
    bool fought [N];
    for(int i=0;i<N;i++){
        next[i] = A[i][0];
        count[i] = 0;
    }
    while(1){
        if(canFight(next) == 0) break;
        for(int i=0;i<N;i++) fought[i] = false;
        for(int i=0;i<N;i++){
            if(next[i] != -1 && next[i]-1 >=0 && next[next[i]-1] == i+1 && fought[next[i]-1] == false && fought[i] == false){
                int j = next[i]-1;
                count[i]++;count[j]++;
                next[i] = A[i][count[i]];next[j] = A[j][count[j]];
                fought[i] = true;fought[j] = true;
                //cout<<i+1<<" and "<<j+1<<" fought"<<endl;
            }
        }
        day++;
        bool can = false;
        for(int i=0;i<N;i++) {if(fought[i]){
            can = true;
        }
    }
        if(!can) break;
    }
    if(canFight(next)==0) cout << day <<endl;
    else cout << -1 <<endl;
}

Measured memory_bytes: 4096
from collections import defaultdict


def solve():
    N = int(input())
    S_dict = defaultdict(int)
    S = ['' for _ in range(N)]
    for i in range(N):
        si = input()
        S[i] = si
        S_dict[si] += 1
    
    max_v = max(S_dict.values())
    tmp = [s for s in S if S_dict[s] == max_v]
    tmp.sort()
    p_ans = ''
    for ans in tmp:
        if p_ans != ans:
            print(ans)
            p_ans = ans


if __name__ == '__main__':
    solve()


Measured memory_bytes: 34016
n = int(input())
a = []
b = []
c = []

for i in range(n):
    A,B,C = map(int,input().split())
    a.append(A)
    b.append(B)
    c.append(C)
dp = [[0 for i in range(3)]for i in range(n)]
for i in range(n):
    for j in range(3):
        if j == 0:
            s = a[i]
        if j == 1:
            s = b[i]
        if j == 2:
            s = c[i]
        for k in range(3):
            if i !=0:
                if j != k:
                    dp[i][j] = max(dp[i-1][k],dp[i][j])
        dp[i][j] += s
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))


Measured memory_bytes: 36132
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(a >= b && a <= c)
        cout << b << " " << a  << " " << c <<endl;
    else if(a <= b && a >= c)
        cout << c << " "  << a << " " << b << endl;
    else if( a >= b && b >= c)
        cout << c << " " <<  b << " " << a << endl;
     else if(a >= b && b <= c )
        cout << b << " " << c << " " << a << endl;
}


Measured memory_bytes: 3088
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int main(){
    char ch[4][4] ;
    for( int i = 0 ; i < 3 ; i++ )
        for( int j = 0 ; j < 3 ; j++ )
            cin >> ch[i][j] ;
    
    cout << ch[0][0] << ch[1][1] << ch[2][2] << endl ;
    return 0 ;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,K;
	ll ans = 0;
	cin >> N >> K ;
	vector<ll> a(N),b;
	rep(i,N){
		cin >> a[i];
	}
	for(int i=0;i<N;i++){
		ll sum = a[i];
		b.push_back(sum);
		for(int j=i+1;j<N;j++){
			sum += a[j];
			b.push_back(sum);
		}
	}
	
	bool flag = 0;
	
	for(int m=40;m>=0;m--){
		ll nowbit = (1LL<<m);
		vector<ll> t;
		int cnt = 0;
		for(int i=0;i<b.size();i++){
			if(b[i]&nowbit){
				cnt++;
				t.push_back(b[i]);
			}
		}
		if(cnt>=K){
			ans += nowbit;
			b = t;
			flag = 1;
		}else{
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6512
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;
//emplace_back next_permutation tie get

typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define OUT(a) cout<<(a)<<endl;

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

    string a="CODEFESTIVAL2016",b;
    cin >> b;
    int ans=0;
    REP(i,16){
        if(a[i]!=b[i]) ans++;
    }
    cout << ans <<endl;
    return 0;
}


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

using namespace std;

typedef long long int ll;

ll M = 1e9 + 7;

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

    ll ans = 0,cc=0;
    int n;
    cin >> n;
    ll a[n];
    for(int i=0 ; i<n; i++)
    {
        cin >> a[i];
        cc = (cc + a[i])%M;
    }
    for(int i=0 ; i<n ; i++)
    {
        cc -= a[i];
        if( cc < 0)
            cc+=M;
        ans = (ans + (a[i]*cc)%M)%M;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 5256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int a=in();int b=in();int c=in();
	int k=in();
	while(k and b<=a){b*=2;k--;}
	while(k and c<=b)
	{
		c*=2;k--;
	}
	//cout<<a<<b<<c<<'\n';
	if(c>b and b>a)cout<<"Yes";
	else cout<<"No";
	
	
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define allof(a) (a).begin(),(a).end()
typedef pair< int, int > pii;

struct Edge : pii {
	Edge(int u, int v) : pii(u, v) {}
	int u() { return first; }
	int v() { return second; }
};

class UnionFind {
private:
	vector< int > data;
	int num_of_g;
	
public:
	UnionFind(int n) : data(n, -1), num_of_g(n) {}
	
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		
		if (x == y) return 0;
		
		if (data[y] < data[x]) swap(x, y);
		data[x] += data[y]; data[y] = x;
		--num_of_g;
		
		return 1;
	}
	
	bool sameSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
	int getNumOfG() { return num_of_g; }
};

#define BUCKET_SIZE 25
int n, k, id[40010], t[40010], u[40010], v[40010];
vector< multiset< int > > eset;
vector< int > vis;

bool dfs(int v, int tar, int col) {
	if (v == tar) return true;
	if (vis[v] == col) return false;
	
	vis[v] = col;
	
	for (int u : eset[v]) if (dfs(u, tar, col)) return true;
	
	return false;
}

void solve() {
	set< Edge > edges;
	
	vis.assign(n, -1);
	int cur_col = 0;
	
	for (int i = 0; i < k; i += BUCKET_SIZE) {
		// vertex setting
		vector< int > vset;
		
		for (int rep = 0; i + rep < k && rep < BUCKET_SIZE; ++rep) {
			int q = i + rep;
			vset.push_back(u[q]);
			vset.push_back(v[q]);
		}
		
		sort(allof(vset));
		vset.erase(unique(allof(vset)), vset.end());
		
		// graph construction
		int V = vset.size();
		
		for_(i,0,n) id[i] = -1;
		for_(i,0,V) id[vset[i]] = i;
		
		eset.assign(V, multiset< int >());
		
		UnionFind uf(n);
		
		for (Edge e : edges) {
			if (id[e.u()] != -1 && id[e.v()] != -1) {
				eset[id[e.u()]].insert(id[e.v()]);
				eset[id[e.v()]].insert(id[e.u()]);
			} else {
				uf.unionSet(e.u(), e.v());
			}
		}
		
		for_(i,0,V) for_(j,i+1,V) {
			int u = vset[i], v = vset[j];
			
			if (uf.sameSet(u, v)) {
				eset[i].insert(j);
				eset[j].insert(i);
			}
		}
		
		// query
		for (int rep = 0; i + rep < k && rep < BUCKET_SIZE; ++rep) {
			int q = i + rep;
			
			if (t[q] == 1) {
				eset[id[u[q]]].insert(id[v[q]]);
				eset[id[v[q]]].insert(id[u[q]]);
				edges.insert(Edge(u[q], v[q]));
			}
			
			if (t[q] == 2) {
				eset[id[u[q]]].erase(id[v[q]]);
				eset[id[v[q]]].erase(id[u[q]]);
				edges.erase(Edge(u[q], v[q]));
			}
			
			if (t[q] == 3) {
				cout << (dfs(id[u[q]], id[v[q]], cur_col) ? "YES" : "NO") << endl;
				++cur_col;
			}
		}
	}
}

int main() {
	cin >> n >> k;
	for_(i,0,k) cin >> t[i] >> u[i] >> v[i];
	solve();
}

Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin>>n;
  vector<int> cs(n);
  for(int i=0;i<n;i++) cin>>cs[i],cs[i]--;

  vector<vector<int>> G(n);
  for(int i=1;i<n;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  using ll = long long;
  ll all=0;
  vector<ll> cnt(n,0),sub(n,0);

  vector<ll> ans(n,(ll)n*(n-1)/2);
  MFP([&](auto dfs,int v,int p)->int{
    sub[v]=1;
    ll bfr=cnt[cs[v]];
    for(int u:G[v]){
      if(u==p) continue;
      ll pre=all-cnt[cs[v]];
      sub[v]+=dfs(u,v);
      ll nxt=all-cnt[cs[v]];
      ans[cs[v]]-=(nxt-pre)*(nxt-pre-1)/2;
    }
    cnt[cs[v]]=bfr+sub[v];
    all++;
    return sub[v];
  })(0,-1);

  for(int c=0;c<n;c++){
    ll pre=0,nxt=n-cnt[c];
    ans[c]-=(nxt-pre)*(nxt-pre-1)/2;
  }
  for(int c:cs) ans[c]++;

  for(ll a:ans) cout<<a<<newl;
  return 0;
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	
	while (1) {
		int x, y, s;
		int maxi = 0;
		int point = 0;

		cin >> x >> y >> s;
		if (x == 0 && y == 0 && s == 0) {
			break;
		}
		FOR(i, 1, s-1) {
			FOR(t, 1, s - 1) {
				point = 0;
				point = i * (100 + x) / 100;
				point += t * (100 + x) / 100;
				if (point == s) {
					point = 0;
					point = i * (100 + y) / 100;
					point += t * (100 + y) / 100;
					if (point > maxi) {
						maxi = point;
					}
				}
			}
		}
		cout << maxi << endl;
	}
	
}


Measured memory_bytes: 3080
function Main(input){
    input = input.split("\n");
    var N = parseInt(input[0],10);
    input.shift();
    var W = input;

    for(var i = 0;i < N;i++) {
        for(var j = i + 1;j < N;j++) {
            if(W[i] === W[j]) {
                console.log("No");
                return;
            }
        }
    }

    for (var i = 0;i < N - 1;i++) {
        if(W[i].slice(-1) !== W[i + 1].slice(0,1)) {
            console.log("No");
            return;
        }
    }

    console.log("Yes");
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 21064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n, a, b;
vector<ll> v;


ll comb(ll n, ll m){
 ll ret = 1;
 for(ll i=1;i<=m;i++) ret = ret * (n-m+i) / i;
 return ret;
}

int main(void){
 cin >> n >> a >> b;
 for(int i=0;i<n;i++) {ll tmp; cin >> tmp; v.push_back(-tmp);}
 sort(v.begin(), v.end());
 ll thesum = 0;
 for(int i=0;i<a;i++) thesum += (-v[i]);
 printf("%.7f\n",((double)(thesum)) / a);
 ll ans = 0; 
 if (v[0]==v[a-1]){
  int i;
  for(i=a-1;i<n;i++) if (v[0] != v[i]) break;
  ll m = i;
  for(ll i=a;i<=min(m,b);i++) ans += comb(m,i);
 }else{
  int mi, ma;
  for(mi=0;mi<n;mi++) if (v[mi]==v[a-1]) break;
  for(ma=a-1;ma<n;ma++) if (v[ma]!=v[a-1]) break;
  ll m = ma - mi;
  ans += comb(m, a-mi);
 }
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int n, m;
  int a[55], b[55];
  int r[55] = {0};
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < m; i++) {
    r[a[i]]++;
    r[b[i]]++;
  }
  for (int i = 0; i < n; i++) {
    cout << r[i + 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3160