akhauriyash/Code-Regression huggingface dataset:
N,M,X = [int(hoge) for hoge in input().split()]
CE = [[int(hoge) for hoge in input().split()] for n in range(N)]
curmin = 100000000000000000
ans = -1
for i in range(2**12):
    A = [0]*M
    cost = 0
    for n,CA in enumerate(CE):
        if (i >> n) & 1:
            cost += CA[0]
            for m in range(M):
                A[m] += CA[m+1]
    if all([x >= X for x in A]):
        curmin = min(curmin,cost)
        ans = curmin
print(ans)

Measured memory_bytes: 69232
#include <iostream>
#include <cstdio>
#include <string>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
#define P 1000000007
using namespace std;

int powmp(long long x,long long n){
	const long long p = 1000000007;
	if(n==0) return 1;
	long long y = x%p;
	if(n==1) return y;
	long long tmp = (powmp(y,n/2))%p;
	if(n%2==0) return (tmp*tmp)%p;
	else return (powmp(y,n-1)*y)%p;
}

int main(int argc, char const *argv[])
{
	int n = 16;
	char b[16] = {'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
	string a;
	int ans = 0;
	
	cin >> a;
	REP(i,16){
		if(b[i]!=a[i]) ans++;
	}
	cout << ans <<"\n";
	return 0;
}	

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

int main(){
    int n, number, v1_max1 = 0, v1_max2 = 0, v2_max1 = 0, v2_max2 = 0, ans;
    cin >> n;
    int v1[100001] = {}, v2[100001] = {};
    for(int i=0;i<n;i++){
        cin >> number;
        if(i%2 == 0)
            v1[number]++;
        else
            v2[number]++; 
    }
    //1番目
    for(int i=0;i<100001;i++){
        if(v1[v1_max1] < v1[i])
            v1_max1 = i;
        if(v2[v2_max1] < v2[i])
            v2_max1 = i;
    }
    //2番目
    for(int i=0;i<100001;i++){
        if(v1[v1_max2] < v1[i] && v1_max1 != i)
            v1_max2 = i;
        if(v2[v2_max2] < v2[i] && v2_max1 != i)
            v2_max2 = i;
    }
    //cout << v1_max1 << ' ' << v1_max2 << ' ' << v2_max1 << ' ' << v2_max2 << endl;
    //降順ソート
    sort(v1, v1 + 100001, greater<int>());
    sort(v2, v2 + 100001, greater<int>());
 
    if(v1_max1 != v2_max1){
        ans = n - (v1[0] + v2[0]);
    }else if(v1_max2 == 0 && v2_max2 == 0){
        ans = n/2;
    }else if(v1_max2 == 0){
        ans = n - (v1[0] + v2[1]);
    }else if(v2_max2 == 0){
        ans = n - (v1[1] + v2[0]);
    }else {
        ans = n;
        if(v1_max1 != v2_max2)
            ans = min(ans, n - (v1[0] + v2[1]));
        if(v2_max1 != v1_max2)
            ans = min(ans, n - (v1[1] + v2[0]));
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m;
    cin >> n >> m;
    vint ht(n);
    fr(i, 0, n)
    {
        cin >> ht[i];
    }
    vector<vint> adj(n);
    fr(i, 0, m)
    {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    int tot = 0;
    fr(i, 0, n)
    {
        int ans = 1;
        for (int u : adj[i])
        {
            if (ht[u] >= ht[i])
            {
                ans = 0;
            }
        }
        tot += ans;
    }
    cout << tot << "\n";
    return 0;
}

Measured memory_bytes: 8740
s=input()
q=int(input())
keep=1
mae=""
ato=""
for i in range(q):
  lis=list(map(str,input().split()))
  if lis[0]=="1":
    keep*=-1
  elif lis[1]=="1":
    if keep==1:
      mae=lis[2]+mae
    else:
      ato+=lis[2]
  else:
    if keep==1:
      ato+=lis[2]
    else:
      mae=lis[2]+mae

if keep==1:
  print(mae+s+ato)
else:
  print(ato[::-1]+s[::-1]+mae[::-1])
  

Measured memory_bytes: 4468
#include "bits/stdc++.h"
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

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

const ll MOD = 1000000007;

void Main() {
  ll n;
  cin >> n;
  vector<ll> C(n);
  rep(i, n) cin >> C[i];
  sort(C.begin(), C.end());
  rep(i, n - 1)(C[i + 1] += C[i]) %= MOD;
  ll ans = C[n - 1];
  rep(i, n)(ans += C[i]) %= MOD;
  rep(i, 2 * n - 2)(ans *= 2) %= MOD;
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
using namespace std;
double dist(double x1, double y1, double x2, double y2) {
    double x = x2-x1;
    double y = y2-y1;
    return sqrt(x*x + y*y);
}
int main() {
    double x1, y1, x2, y2;
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
    printf("%f\n", dist(x1, y1, x2, y2));
}


Measured memory_bytes: 2756
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		string s = GetString();
		Console.WriteLine(s.Substring(0, 4) + " " + s.Substring(4, 8));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13140
xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;
inner(xp1,yp1,xp2,yp2,xp3,yp3,x0,y0){
	double o1,o2,o3;
	xp1-=x0,yp1-=y0;
	xp2-=x0,yp2-=y0;
	xp3-=x0,yp3-=y0;
	o1=(double)xp1*yp2-(double)yp1*xp2;
	o2=(double)xp2*yp3-(double)yp2*xp3;
	o3=(double)xp3*yp1-(double)yp3*xp1;
	return o1*o2>0&&o2*o3>0;
}
main(){
	scanf("%*d");
	for(;~scanf("%d%d%d%d%d%d%d%d%d%d",&xp1,&yp1,&xp2,&yp2,&xp3,&yp3,&xk,&yk,&xs,&ys);){
		puts(inner(xp1,yp1,xp2,yp2,xp3,yp3,xk,yk)^inner(xp1,yp1,xp2,yp2,xp3,yp3,xs,ys)?"OK":"NG");
	}
}

Measured memory_bytes: 0
#include"iostream"
#include"vector"
#include"string"
#include"map"
using namespace std;
int main(){
	string s,t,u;
	int a, b;
	cin >> s>>t;
	cin >> a;
	cin >> b;
	cin >> u;
	map<string, int>mp;
	mp[s] = a;
	mp[t] = b;
	if (mp.find(u) == mp.end()){
		cout << a << " " << b << endl;
	}
	else{
		mp[u]--;
		cout << mp[s] << " " << mp[t] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println(Math.max(0, b - a - W));
		} else {
			System.out.println(Math.max(0, a - b - W));
		}
	}
}


Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BTrickOrTreat solver = new BTrickOrTreat();
        solver.solve(1, in, out);
        out.close();
    }

    static class BTrickOrTreat {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), k = in.nextInt();
            HashSet<Integer> bad = new HashSet<>();
            for (int i = 0; i < k; i++) {
                int d = in.nextInt();
                for (int j = 0; j < d; j++) {
                    bad.add(in.nextInt());
                }
            }

            out.println(n - bad.size());
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 26824
import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Data.Array
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:xs)=jst.lookup 2$f n as 1 1 where as=listArray(1,n)xs
f n as c i|c>n=[]
f n as c i=(i',c):f n as(c+1)i' where i'=as!i
jst(Just i)=i
jst _ = -1

Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  int Q,T,F;
  char C;
  cin >> S >> Q;
  
  int SwapCnt;
  vector<char> Stack1(0),Stack2(0);
  
  for(int i=0;i<Q;i++){
    cin>>T;
    if(T==1){
      SwapCnt = (SwapCnt + 1) % 2;
    }else{
      cin>>F>>C;
      if((F==1 & SwapCnt==0) | (F==2 & SwapCnt==1))
        Stack1.push_back(C);
      else
        Stack2.push_back(C);
    }
  }
  for(int i=(SwapCnt ? Stack2 : Stack1).size()-1;i>=0;i--)
    cout<<(SwapCnt ? Stack2 : Stack1).at(i);
  if(SwapCnt)
    reverse(S.begin(),S.end());
  cout<<S;
  for(int i=0;i<(SwapCnt ? Stack1 : Stack2).size();i++)
    cout<<(SwapCnt ? Stack1 : Stack2).at(i);
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    int g=0,p=0,ans=0;
    rep(i,n){
        if(p==g){
            g++;
            if(s[i]=='p')ans--;
        }else{
            p++;
            if(s[i]=='g')ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();

	if(a<b&& b<c) {
		System.out.println("Yes");
	}else {
		System.out.println("No");
	}
	}
}


Measured memory_bytes: 26100
main :: IO()
main = do
    n <- getLine {-nは使わない-}
    numbers <- fmap (map read . words) getLine
    putStrLn $ solve numbers

solve :: [Int] -> String
solve nums = show $ f nums 0

{-第一引数のリストが2で割れる回数を第二引数に加えて返却する。-}
f :: [Int] -> Int -> Int
f [] x = x
f nums x = if (dividable nums) then f nums' x+1 else x
    where nums' = map ((flip div) 2) nums

{-整数のリストの中のすべての整数が偶数の時Trueを返しそれ以外の時False-}
dividable :: [Int] -> Bool
dividable = and . map ((0==) . (flip mod) 2)


Measured memory_bytes: 1020
N = gets.to_i
S = gets.chomp
r = S.count("R")
g = S.count("G")
b = S.count("B")
count = r * g * b

N.times do |i|
   t = 1
   while i + 2 * t < N do
      count -= 1 if S[i] != S[i + t] && S[i] != S[i + 2 * t] && S[i + t] != S[i + 2 * t]
      t += 1
   end
end
 
puts count

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  int sum=0;
  rep(i,0,M){
    int X; cin>>X;
    sum+=X;
  }
  int ans=N-sum;
  ans=max(-1ll,ans);
  cout<<ans<<endl;
  }


Measured memory_bytes: 3632
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
#define sz(x) (int)x.size()
int d[1000 * 100 + 5];
int32_t main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, m, a, b;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		a--, b--;
		d[a]++;
		d[b]++;
	}
	for(int i = 0; i < n; i++){
		if(d[i] % 2){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1532
N,K = map(int, input().split())
P = list(map(int, input().split()))

#期待値 : (p+1)//2
range_total = sum(P[:K]) + K
max_value = range_total
for i in range(N-K):
    range_total += P[K+i] - P[i]
    max_value = max(max_value, range_total)
print(max_value / 2)

Measured memory_bytes: 32032
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();

		String firstS = S.substring(0, K-1);
		char s = Character.toLowerCase(S.charAt(K-1));
		String lastS = S.substring(K, S.length());
		System.out.println(firstS + s + lastS);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 21332
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<queue>
#include<map>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mp make_pair
#define case_for(n) for(int i = 1 ; i <= n ; i ++) { cout<<"Case "<<i<<": "<<endl; solve();}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll power(ll a, ll b, ll p) { ll ans = 1; while (b) { if (b & 1) ans = ans * a % p; a = a * a % p, b /= 2; }return ans; }
int hw_check(string a, int l, int r) { int ans = r - l + 1; for (l, r; l < r; l++, r--)if (a[l] != a[r]) return 0; return ans; }
string movesubstr(string a, int l, int r) { string s = "";	for (int i = l; i <= r; i++) s.push_back(a[i]);	return s; }

ull mod = 212370440130137957ll;
int base = 233;
/*ull hashs(string a)
{
	ull ans = 0;
	for (int i = 0; i < a.size(); i++)
	{
		ans = ans * base + a[i];
	}
	return ans;
}*/

int main()
{
	std::ios::sync_with_stdio(false);
	//cin.tie(nullptr),cout.tie(0);
	cin.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int res = 0;
	if (k > 0) res += min(a, k), k -= min(a, k);
	if (k > 0) k -= min(b, k);
	if (k > 0) res -= min(c, k), k -= min(c, k);
	cout << res << endl;
	return 0;
}
/*

*/

Measured memory_bytes: 3656
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a;
	cin>>a;
	if(a==3||a==5||a==7)yes;
	else no;
}






Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import java.io.*;
import java.math.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		char[] c = sc.next().toCharArray();
		if(c[2] == c[3] && c[4] == c[5])
			out.println("Yes");
		else
			out.println("No");

		out.close();
	}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}

Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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


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

const ll MOD = 1000000007;
const ll INF = 1000000000;


int main(void){
    int n;
    int ans = 0, p = 0;
    int a[300000];
    int num[3] = { 3, 5, 7 };
    cin >> n;
    queue<int> que;
    que.push(0);
    bool f = false;
    while (que.size()!=0){
        int s = que.front();
        que.pop();
        for (int i = 0; i < 3; i++){
            int m = 10 * s + num[i];
            if (m <= n){
                a[p++] = m;
                que.push(m);
                //cout << p << endl;
                //cout << m << endl;
            }
            else{
                f = true;
            }
        }
        if(f) break;
        
    }
    
    bool flag[10];

    for (int i = 0; i < p; i++){
        for(int j=0;j<10;j++) flag[j] = false;
        int s = a[i];
        //cout << s << ":"<<' ';
        while (s > 0){
            //cout << s%10<< ' ';
            flag[s%10] = true;
            s /= 10;
        }
        if (flag[3] && flag[5] && flag[7] && (a[i] <= n)) ans++;
    }

    cout << ans << endl;
    

}



Measured memory_bytes: 640
from math import sqrt,ceil
n=int(input())
a=ceil(sqrt(n))
l=[]
p=[]
for i in range(1,a+1):
    if n%i==0:
        l.append([i,n//i])
        x=len(str(i))
        y=len(str(n//i))
        p.append(max(x,y))

print(min(p))


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong A, B, K;
	cin >> A >> B >> K;

	cout << max(0ll, A - K) << " " << max(0ll, B - max(0ll, K - A)) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
  public static void main(String args[]){
  	Scanner Sc=new Scanner(System.in);
    int N=Sc.nextInt();
    int K=Sc.nextInt();
    int dp[]=new int[N+1];
    dp[0]=1;
    for(int i=1;i<=N;i++){
    	dp[i]=Math.min((dp[i-1]*2),(dp[i-1]+K));
    }
    System.out.println(dp[N]);
  }
}

Measured memory_bytes: 35608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b!=c){
    cout<<"Yes"<<endl;
  }
   if(a==c&&b!=c){
    cout<<"Yes"<<endl;
  }
  if(b==c&&c!=a){
    cout<<"Yes"<<endl;
  }
  if(a==b&&b==c){
    cout<<"No"<<endl;
  }
  if(a!=b&&b!=c&&c!=a){
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
int n,c[10000];
int no(int i,int color){
    int ue=i-1,shita=i+1,x=1,y=n;
    if (c[ue]==color) {
        ue--;
        x++;
    }
    if (c[shita]==color) {
        shita++;
        x++;
    }
    if (x==1) {
        return n;
    }
    while (ue!=-1&&shita!=n) {
        while (ue!=-1&&c[ue]==color) {
            ue--;
            x++;
        }
        while (shita!=n&&c[shita]==color) {
            shita++;
            x++;
        }
        if (x>=4) {
            y-=x;
            x=0;
            if (c[ue]!=c[shita]) {
                return y;
            }
            color=c[ue];
        }else{
            return y;
        }
    }
    return y;
}

int main(){
    while (1) {
        int i,j,ans;
        scanf("%d",&n);
        if (n==0) {
            return 0;
        }
        ans=n;
        for (i=0; i<n; i++) {
            scanf("%d",&c[i]);
        }
        for (i=0; i<n; i++) {
            for (j=1; j<=3; j++) {
                ans=min(ans, no(i,j));
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 636
N = int(input())

a = list(map(int, input().split()))

ans = False
b = [0]*N


for i in range(N, 0 ,-1):
    b_sum = 0
    for j in range(i, N+1, i):
        b_sum += b[j-1]
    if b_sum % 2 != a[i-1]: b[i-1] = 1
if b==[0]*N:print(0)      
else:
    print(sum(b))
    print(*[k+1 for k, l in enumerate(b) if l==1])

Measured memory_bytes: 15156
#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<string,ll> a,pair<string,ll> b)
{
	if(a.first<b.first)
		return 1;
	else if(a.x==b.x)
	{
		return a.y<b.y;
	}
	return 0;
}
bool cmp(ll a,ll b)
{
	return a>b;
}
void solve()
{
	ll n;
	cin>>n;
	unordered_map<ll,ll> a,b;
	ll x;
	rep(i,0,n)
	{
		cin>>x;
		if(i%2==0)
		{
			a[x]++;
		}
		else
			b[x]++;
	}	
	ll fma=0,sma=-1,fmb=0,smb=-1,p,q,ans=0;
	for(auto i:a)
	{
		if(fma<i.second)
		{
			sma=fma;
			fma=i.second;
			p=i.first;
		}
		else if(i.second>sma)
		{
			sma=i.second;
		}
	}
	for(auto i:b)
	{
		if(fmb<i.second)
		{
			smb=fmb;
			fmb=i.second;
			q=i.first;
		}
		else if(i.second>smb)
		{
			smb=i.second;
		}
	}
	ans=n;
	if(p==q)
	{
		cout<<min(n-fma-smb,n-sma-fmb);
	}
	else
	{
		cout<<n-fma-fmb;
	}
	
}	
int main()
{
	IOS
	ll t;
	t=1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 6296
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    string s;
    cin>>s;
    string y=s;
    reverse(all(y));
    if(y==s)cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}






Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 3005
#define F first
#define S second
using namespace std;

int n, t, mx, d[N][N];
pair<int,int> a[N];

int f(int p, int q) {
	if(p==n || q>=t) return 0;
	if(d[p][q] != -1) return d[p][q];
	return d[p][q] = max(f(p+1, q), a[p].S + f(p+1, q+a[p].F));
}

int main() {
	int i;
	cin >> n >> t;
	for(i=0; i<n; i++) cin >> a[i].F >> a[i].S;
	sort(a, a+n);
	memset(d, -1, sizeof(d));
	cout << f(0, 0);
	return 0;
}


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

typedef long long ll;

ll t = 1e18;
ll a[100005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	ll res = 1;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort(a+1,a+1+n);
	for (int i = 1; i <= n; i++)
	{
		if( a[i] == 0 )
		{
			cout << 0 << '\n';
			return 0;
		}
		if( t / a[i] < res )
		{
			cout << -1 << '\n';
			return 0;
		}
		res *= a[i];
	}
	if( res <= t ) cout << res << '\n';
	else cout << -1 << '\n';
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll h, w;
  cin >> h >> w;
  if (w == 1 || h == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ans = h * w / 2;
  if (h * w % 2 == 1) ans++;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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;
  set<string> st;
  rep(i,n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 19192
def z_algo(S):
    '''
    Input: a string S
    Output: an array Z[0..|S| - 1]
            Z[i] = l: the length of the longest prefix of S[i..|S| - 1] which is also a prefix of S,
            i.e.,
                S[j] = S[i + j] for all 0 <= j < l (l != 0),
                S[0] != S[i] (l == 0)
    Time complexity: O(|S|) time
    '''
    N = len(S)
    Z = [-1] * N
    Z[0] = N
    L = 0; R = 0 # algorithm invariant: S[L..R] is always set to be the longest common prefix of S[L..|S| - 1]
    for i in range(1, N):
        if i > R: # naive calculation
            j = 0
            while i + j < N and S[j] == S[i + j]: j += 1
            Z[i] = j
            if j > 0: L = i; R = i + j - 1
        else: # i in [L, R]
            k = i - L
            if Z[k] < R - i + 1: Z[i] = Z[k]
            else:
                L = i
                while R < N and S[R - L] == S[R]: R += 1
                Z[i] = R - L
                R -= 1
    return Z

N = int(input())
S = input()
ans = 0
for i in range(N-1):
    Z = z_algo(S[i:])
    for j, z in enumerate(Z):
        ans = max(ans, min(z, j))
print(ans)

Measured memory_bytes: 50396
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> T(N), A(N);
	for (int i = 0; i < N; i++)cin >> T[i] >> A[i];
	long long x = T[0], y = A[0];
	for (int i = 1; i < N; i++) {
		long long k = max((x-1) / T[i] + 1, (y-1) / A[i] + 1);
		x = k * T[i]; y = k * A[i];
	}
	cout << x + y << endl;
}



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

const ll mod = 1e9 + 7;

int main() {
  ll a, b;
  cin >> a >> b;
  if (abs(a-b) != 1 && a != b) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  if (a == b) {
    for (ll i = 1; i <= a; i++) {
      ans = (ans * i) % mod;
    }
    ans = (ans * ans) % mod;
    ans = (ans * 2) % mod;
  } else {
    if (a > b) swap(a, b);
    for (ll i = 1; i <= a; i++) {
      ans = (ans * i) % mod;
    }
    ans = (ans * ans) % mod;
    ans = (ans * b) % mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

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

  vector<int> a(n),b(n);
  int cnt=0;
  for(int i=1;i<n;i++){
      if(s.at(i-1)=='W')cnt++;
      a.at(i)=cnt;
      //cout<<a.at(i);
  }
  //cout<<endl;
  cnt=0;
  for(int i=n-2;i>=0;i--){
    if(s.at(i+1)=='E')cnt++;
    b.at(i)=cnt;
    //cout<<b.at(i);
  }
  //cout<<endl;
  int mini=n;
  r(i,n){
    mini=min(mini,a.at(i)+b.at(i));
  }

  cout<<mini<<endl;


  return 0;
}


Measured memory_bytes: 3076
#include <ext/rope>
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long

const int N = 2e5 + 5;
int n , x , y , cnt[N] , q;
vector<vector<int>> v(N);

void dfs(int u , int p)
{
    for(auto i : v[u])
        if(i != p)
            cnt[i] += cnt[u] , dfs(i , u);
}

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

    cin >> n >> q;
    for(int i = 0 ; i < n - 1 ; i++) cin >> x >> y , v[x].push_back(y) , v[y].push_back(x);

    while(q--)
    {
        cin >> x >> y;
        cnt[x] += y;
    }
    dfs(1 , 0);

    for(int i = 0 ; i < n ; i++) cout << cnt[i + 1] << " ";

    return 0;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 100000 + 100;
int A[Maxn], P[Maxn];
int N;
int main()
{
	scanf("%d", &N);
	int Sum = 0;
	for (int i = 1; i <= N; ++i)
	{
		scanf("%d", &A[i]);
		if (A[i] == i)P[i] = 1, ++ Sum;
	}
	if (Sum == 0)
	{
		puts("0");
		return 0;
	}
	for (int i = 1; i < N; ++i)
		if (P[i] && P[i + 1]) -- Sum, ++ i;
	cout<<Sum<<endl;
	return 0;
}

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

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

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=1000000007
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarize_list(sl):

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append(c)
      a=x
      c=1
  res.append(c)

  return res
# Summarize count of factor within list --- END ---

def main():
  n,k=LI()
  s=list(S())

  l=summarize_list(s)
  # print(l)

  # 1 0 1 0... の形にする
  if s[0]=='0':
    l=[0]+l

  # ...0 1 0 1 の形にする
  if s[-1]=='0':
    l+=[0]

  # 累積和
  for i in range(len(l)-1):
    l[i+1]+=l[i]

  l=[0]+l

  # print(l)

  ans=0
  left=0
  while True:
    right=min(len(l)-1,left+2*k+1)
    if left>=len(l):
      return ans

    # print(right,left)
    ans=max(ans,l[right]-l[left])

    left+=2

# main()
print(main())


Measured memory_bytes: 10564
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

ll k, i, j, act, base, nxt;

ll sum(ll x) {
    ll ans = 0;
    while (x > 0) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%lld", &k);

    base = 1;
    act = 1;


    while (k > 0) {
        while (true) {
            nxt = act + base;
            if (act * sum(nxt) > nxt * sum(act)) {
                act -= base;
                break;
            }

            printf("%lld\n", act);
            if (--k == 0) return 0;
            act = nxt;
        }

        base *= 10LL;
        act += base;
    }


    return 0;
}


Measured memory_bytes: 256
/*#include<stdio.h>
#include<string.h>
int panduan(int i)
{
	int a[5], b[5];
	a[0] = i % 10;
	i = i / 10;
	a[1] = i % 10;
	i = i / 10;
	i = i / 10;
	b[0] = i % 10;
	i = i / 10;
	b[1] = i % 10;

	if (a[0] == b[1] && a[1] == b[0])
	{
		printf("%d %d %d %d\n", a[0], a[1], b[0], b[1]);
		return 1;
	}
	return 0;
}
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	int i,sum=0;
	for (i = a; i <= b; i++)
		if (panduan(i))
			sum++;
	printf("%d", sum);
	getchar(); getchar();
	return 0;
}
*/

#include<stdio.h>
int main()
{

	char a[3][3];
	scanf("%s%s%s", a[0], a[1], a[2]);
	printf("%c%c%c", a[0][0], a[1][1], a[2][2]);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int i, n, x, m[100], min = 1000, cnt=0;
	
	scanf("%d %d", &n, &x);
	
	for (i = 0; i < n; i++) {
		scanf("%d", &m[i]);
		x -= m[i];
		cnt++;
		min = m[i] < min ? m[i] : min;
	}
	
	while (x >= min) x -= min, cnt++;
	
	printf("%d\n", cnt);
	
	return 0;
}

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

Measured memory_bytes: 596
package main

import "fmt"

const inf = 1 << 60

func main() {
	var n int
	fmt.Scan(&n)

	dist := make([][]int, n)
	edges := make([][]int, n)
	for i := 0; i < n; i++ {
		dist[i] = make([]int, n)
		edges[i] = make([]int, n)
		for j := 0; j < n; j++ {
			var weight int
			fmt.Scan(&weight)
			dist[i][j] = weight
			edges[i][j] = weight
		}
	}

	ok := true
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			for j := 0; j < n; j++ {
				if k == i || k == j || i == j {
					continue
				}
				via := dist[i][k] + dist[k][j]
				if via < dist[i][j] {
					ok = false
				} else if via == dist[i][j] {
					edges[i][j] = inf
				}
			}
		}
	}

	if !ok {
		fmt.Println(-1)
		return
	}

	sum := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if edges[i][j] == inf {
				continue
			}
			sum += edges[i][j]
		}
	}
	fmt.Println(sum / 2)
}


Measured memory_bytes: 4864
s = input()
n = len(s)
ruiseki = [0]*(n+1)

for i in range(n):
  if s[i]=="S":
    ruiseki[i+1] = ruiseki[i]-1
  else:
    ruiseki[i+1] = ruiseki[i]+1
print(max(ruiseki)*2)

Measured memory_bytes: 11144
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for key_i,i in enumerate(l):
    for key_j,j in enumerate(l[key_i+1:]):
        key_j += key_i + 1
        ans += bisect.bisect_left(l, i+j) - key_j - 1
print(ans)

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String x = sc.next();
        String y = sc.next();
        
        System.out.println(x.substring(0,1).equals(y.substring(2,3)) && x.substring(1,2).equals(y.substring(1,2)) && x.substring(2,3).equals(y.substring(0,1))?"YES":"NO" );
    }
}


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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = 998244353;
const string COL = "RGB";

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

	ll ans = 1;
	for (int i = 1; i <= N; ++i) {
		ans = ans * i % MOD;
	}
	N *= 3;

	vi cnt(3);

	rep(i, N) {
		int c = -1;
		rep(j, 3) if (s[i] == COL[j]) c = j;
		vi vec;

		rep(j, 3) if (j != c) {
			vec.pb(cnt[j]);
		}
		if (vec[0] > vec[1]) swap(vec[0], vec[1]);

		//cerr << cnt[c] << " " << vec[1] << endl;
		if (cnt[c] < vec[0]) {
			ans = ans * (vec[0] - cnt[c]) % MOD;
		} else if (cnt[c] < vec[1]) {
			ans = ans * (vec[1] - cnt[c]) % MOD;
		}

		cnt[c]++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 900
import re

while True:
    n = int(raw_input())
    if n == 0:
        break
    l = [0] * (24*60*60+1)
    for _ in range(n):
        h1,m1,s1,h2,m2,s2 = map(int, re.split(':| ', raw_input()))
        l[h1*60*60 + m1*60 + s1] += 1
        l[h2*60*60 + m2*60 + s2] -= 1
    r = 0
    for i in range(24*60*60):
        l[i+1] += l[i]
        r = max(r, l[i+1])
    print r

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef int64_t ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

void solve(const vector<int> &a) {
  int N = a.size();
  vector<int> cnt(N + 1, 0);
  vector<int> b(N + 1, 0);
  for(int i = N; i >= 1; i--) {
    if (cnt[i] % 2 != a[i - 1]) {
      b[i] = 1;
      for (int j = 1; j * j <= i; j++) {
        if (i % j) continue;
        cnt[j]++;
        if (j * j != i) cnt[i / j]++;
      }
    }
  }

  int M = accumulate(ALL(b), 0);
  cout << M << endl;
  if (M) {
    bool flag = false;
    REP(i, N) {
      if (b[i + 1] == 0) continue;
      if (flag) cout << " ";
      flag = true;
      cout << (i + 1);
    }
    cout << endl;
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i, N) cin >> a[i];

  solve(a);
  return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#define eps 1e-6
#define MAX 100100
typedef  long long LL;
using namespace std;
int main() {
	LL a,c;
	char b[10];
	scanf("%lld%s", &a, b);
	c = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
	cout << LL(a*c/100) << endl;
	return 0;
}

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

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

    int N, M, C;
    cin >> N >> M >> C;
    int B[M], A[N][M];
    rep(i, 0, M) cin >> B[i];
    rep(i, 0, N) rep(j, 0, M) cin >> A[i][j];
    int rsl = 0;
    rep(i, 0, N) {
        int tmp = C;
        rep(j, 0, M) tmp += A[i][j] * B[j];
        if(tmp > 0) rsl++;
    }
    cout << rsl << endl;
}


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

ll scc(ll s, ll c) {
  return min(s * 2, c) / 2;
}

int main() {
  ll S, C;
  cin >> S >> C;

  ll t, ans = 0;

  t = scc(S, C);
  ans += t;
  S -= t, C -= t * 2;

  if (0 < C) {
    S = C / 4;
    C = C / 2;
    ans += scc(S, C);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3560
int main(int argc, char const *argv[])
{
	int a, b, c;
	char s[101];

//	scanf("%d", &a);
//	scanf("%d", &b);
//	scanf("%d", &c);
	scanf("%s", &s);

//	printf("%d ", a+b+c);
//	printf("%s\n", s);

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

	printf("%d\n", a);



	return 0;
}

Measured memory_bytes: 128