akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

// N: ??¬?????°
// M: ????????°
// P: ????????°
int N, M, P, A, B;
VI ts;
VVI es;

struct State {
	int v;
	int used;
	double cost;

	State () {}
	State (int v_, int used_, double cost_) : 
		v(v_), used(used_), cost(cost_) {}

	bool operator < (const State &s) const {
		return cost < s.used;
	}

	bool operator > (const State &s) const {
		return cost > s.used;
	}
};

double solve() {
	// dist[v][used] = min_cost
	VVD dist(M, VD(1 << N, DINF));
	dist[A][0] = 0;

	priority_queue<State, vector<State>, greater<State>> q;
	q.push(State(A, 0, 0));

	while (q.size()) {
		State cur = q.top();
		q.pop();

		if (__builtin_popcount(cur.used) == N) continue;

		if (cur.v == B) continue;

		if (dist[cur.v][cur.used] > cur.cost) continue;

		for (int i = 0; i < N; i++) {
			int next_used = (1 << i) | cur.used;
			if (cur.used == next_used) continue;

			for (int j = 0; j < M; j++) {
				if (es[cur.v][j] == -1) continue;

				State next;
				next.v = j;
				next.used = next_used;
				next.cost = cur.cost + 1. * es[cur.v][j] / ts[i];

				if (dist[next.v][next.used] > next.cost) {
					dist[next.v][next.used] = next.cost;
					q.push(next);
				}
			}
		}
	}

	double ans = *min_element(ALL(dist[B]));
	if (ans == DINF) {
		return -1;
	} else {
		return ans;
	}
}

int main(void) {
	while (cin >> N >> M >> P >> A >> B, N) {
		--A; --B;

		ts.clear();
		ts.resize(N);
		for (auto &t : ts) cin >> t;

		es.clear();
		es.resize(M, VI(M, -1));
		for (int i = 0; i < P; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			--a; --b;
			es[a][b] = c;
			es[b][a] = c;
		}

		double ans = solve();
		
		if (ans == -1) {
			cout << "Impossible" << endl;
		} else {
			cout << fixed << setprecision(6) << ans << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 1728
n, p = map(int, raw_input().split())
a = map(int, raw_input().split())
dp = [[0]*5500 for _ in xrange(n + 1)]
dp[0][0] = 1
for i in xrange(n):
    for j in xrange(5001):
        dp[i + 1][j + a[i]] += dp[i][j]
        dp[i + 1][j] += dp[i][j]
ans = 0
for j in xrange(5001):
    if j % 2 == p:
        ans += dp[n][j]
print ans


Measured memory_bytes: 6020
#include <stdio.h>

int main(void)
{
    int num;
    int a,b;
    scanf("%d",&num);
    if (num==1)
    {
        printf("Hello World");
    }
    else
    {
        scanf("%d",&a);
        scanf("%d",&b);
        printf("%d",a+b);

    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int A, B;
void solve(string state="", int a=0, int b=0){
  if (a > A || b > B) return;
  if (a == A && b == B){
    cout << state << endl;
    return;
  }
  if (max(a, b) == 5 && min(a, b) < 4) return;
  if (a == 5 && b == 5) return;
  solve(state + 'A', a + 1, b);
  solve(state + 'B', a, b + 1);
}
int main()
{
  scanf("%d %d", &A, &B);
  solve();
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int Ans=1;
  for(int i=1; i<N; i++){
    if(vec.at(i)!=vec.at(i-1)){
      Ans=Ans+1;
    }
    else{}
  }
  cout << Ans << endl;
}


Measured memory_bytes: 256
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    n = ii()
    tmp = 26
    cnt = 1
    while n > tmp:
        n-=tmp
        tmp*=26
        cnt+=1
    cnt-=1
    tmplist = []
    while cnt > 0:
        tmptmp = 26**cnt

        if n%tmptmp == 0:
            tmplist.append(n//tmptmp-1)

        else:
            tmplist.append(n//tmptmp)
        n%=tmptmp
        cnt-=1
    if n%26 == 0:
        tmplist.append(25)
    else:
        tmplist.append(n-1)

    ans = ''
    for i in tmplist:
        ans+=l[i]

    print(ans)



main()




Measured memory_bytes: 10024
# solution
import io
from scipy.misc import comb

def inpl(): return [int(i) for i in input().split()]

nim,mike,kite = inpl()
inf = float('inf')
H = {(0,0): 0}
for i in range(nim):
    a, b, c = inpl()
    for (ia, ib), ic in H.copy().items():
        H[(ia+a,ib+b)] = min(H.get((ia+a, ib+b), inf),ic+c)

ans = min(H.get((i*mike, i*kite), inf) for i in range(1,401))
print(-1 if ans == inf else ans)    

Measured memory_bytes: 18064
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>n>>x;
    vector<ll> v(n);
    rep(i,n){
        cin>>v[i];
        sum++;
        x-=v[i];
    }
    sort(all(v));
    sum+=x/v[0];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  // 入力
  int A, B;
  cin >> A >> B;

  int result = -1;
  for (int i=1; i<=10000; i++) {
    if (floor(i*0.08) == A && floor(i*0.1) == B) {
      result = i;
      break;
    }
  }


  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

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

	sum := 0
	for i := 0; i <= n; i++ {
		if !(i%3 == 0 || i%5 == 0) {
			sum += i
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1756
import bisect

N,M=map(int,input().split())
lists=[list(map(int,input().split())) for _ in range(M)]
dict={}

for l in lists:
    if l[0] not in dict.keys():
        dict[l[0]]=[l[1]]
    else:
        dict[l[0]].append(l[1])

for d in dict.values():
    d.sort()

for l in lists:
    print(str(l[0]).zfill(6)+str(bisect.bisect_right(dict[l[0]],l[1])).zfill(6))

Measured memory_bytes: 42136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin>>S;
  bool a=0;
  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
  a=1;
  }
  if(a==0){
  cout<<"No"<<endl;
  }
  if(a==1){
  cout<<"Yes"<<endl;
  }
  }

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

#define ll long long

ll dp[100005], n, m, u, v;
vector<ll> *edges;

ll dfs (ll u) {
	if (dp[u] != -1) {
		return dp[u];
	}

	dp[u] = 0;
	for (auto it : edges[u]) {
		dp[u] = max (dp[u], 1 + dfs(it));
	}
	return dp[u];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	cin >> n >> m;
	edges = new vector<ll>[n + 1];
	memset (dp, -1, sizeof dp);

	for (ll i = 0; i < m; i++) {
		cin >> u >> v;
		edges[u].push_back(v);
	}

	ll ans = INT_MIN;

	for (ll i = 1; i <= n; i++) {
		if (dp[i] == -1) {
			dfs (i);
		}
		ans = max (ans, dp[i]);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 7936
primes :: [Int]
primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]

log':: Int -> Int -> Int
log' b n = fst $ helper (0, n)
  where helper (i, n') = if n' `mod` b == 0
                         then helper (i + 1, n' `div` b)
                         else (i, n')

factoring :: Int -> [Int]
factoring n = map (`log'` n) primes

count :: [Int] -> Int
count fs =
  let g2s = length $ filter (2 <=) fs
      g4s = length $ filter (4 <=) fs
      g14s = length $ filter (14 <=) fs
      g24s = length $ filter (24 <=) fs
      g74s = length $ filter (74 <=) fs
  in g74s +
     g24s * (g2s - 1) +
     g14s * (g4s - 1) +
     g4s * (g4s - 1) * (g2s - 2) `div` 2

main = do
  n <- read <$> getLine :: IO Int
  let fs = foldr1 (zipWith (+)) $ map factoring [1..n]
  print $ count fs


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main(){
  int n;
  cin>>n;
  
  vector<ll> p(n+1);
  vector<ll> q(n+1);
  vector<ll> r(n+1,INF);
  rep(i,n+1){
    cin>>p[i];
  }


  q[n]=p[n];
  for(int i=n-1;i>=0;i--){
    q[i]=q[i+1]+p[i];
  }

  ll ans=0;
  r[0]=1;
  rep(i,n+1){
    ans+=min(r[i],q[i]);
    r[i]-=p[i];
    if((i!=n && r[i]<=0)||(i==n && r[i]<0)) {
      cout << -1 << endl;
      return 0;
    }
    if(i!=n && r[i]<=q[i]) r[i+1]=2*r[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 5572
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        Set<String> set = new HashSet<>();

        for(int i = 0 ; i < n ; i++){
            set.add(scanner.next());
        }

        System.out.println(set.size());
    }

}

Measured memory_bytes: 77216
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();  //動物総数
    int y = sc.nextInt();  //足の総数
    boolean flag = false;


    int num = 0;
    for(int i=0; i<=x; i++){
      num = 2 * i + 4 * (x-i);
      if(num==y){
        flag = true;
      }
    }

    if(flag){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }



  }

}

Measured memory_bytes: 35668
#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 = 1001001001;

ll n,k;

double win(int i){
  double p = 1;
  while(i < k) {
    p /= 2;
    i *= 2;
  }
  return p;
}

int main(){
  cin >> n >> k;

  double ans = 0;
  for(int i = 1; i <=n; i++){
    ans += win(i)/n;
  }
  printf("%.12f\n",ans);
}


Measured memory_bytes: 3756
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main()
{
	int n;
	cin >> n;
	map<string, int> dic;
	vector<string> s(n);
	rep(i,n) {
		cin >> s[i];
		dic[s[i]]++;
	}
	int m;
	cin >> m;
	vector<string> t(m);
	rep(i,m) {
		cin >> t[i];
		dic[t[i]]--;
	}
	int ans = 0;
	for(auto d : dic){
		// cout << d.fi << ": " << d.se << endl;
		ans = max(ans, d.se);
	}
	cout << ans << endl;
	return;
}

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

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

typedef long long ll;
const ll INF = 1LL << 60;

int main(void){
    ll N;
    cin >> N;
    
    vector<ll> dp(110000,INF);
    dp[0] = 0;
    int num;
    
    for(int i = 1; i <= N; i++){
        num = 1;
        while(num <= i){
            dp[i] = min(dp[i], dp[i-num]+1);
            num *= 6;
        }
        
        num = 1;
        while(num <= i){
            dp[i] = min(dp[i], dp[i-num]+1);
            num *= 9;
        }
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4032
#include<iostream>
#include<cmath>
#include<string.h>
using namespace std;
int dp[100005];
int h[100005];
int frog1(int n)
{ if(n==1)
  return 0;
  if(n==2)
    return abs(h[1]-h[0]);
  if(dp[n-1]!=-1)
    return dp[n-1];
 
  dp[n-1] = min(frog1(n-1)+abs(h[n-1]-h[n-2]),frog1(n-2)+abs(h[n-1]-h[n-3]));
   return dp[n-1];
}
int main()
{ int n;
  cin>>n;
 for(int i=0;i<n;i++)
   cin>>h[i];
 memset(dp,-1,sizeof(dp));
 cout<<frog1(n);
 return 0;
}
 

Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<queue>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

int ma;
int n;
int d[252];
std::vector<int> G[252], rG[252];
bool reach[252], rev[252];

void dfs( int v )
{
	rev[v] = true;

	rep( i, rG[v].size() )
		if( !rev[rG[v][i]] )
			dfs( rG[v][i] );

	return;
}

void dfs2( int v )
{
	reach[v] = true;

	rep( i, G[v].size() )
		if( !reach[G[v][i]] )
			dfs2( G[v][i] );

	return;
}

int main()
{
	while( scanf( "%d", &ma ), ma )
	{
		rep( i, 252 )
			G[i].clear(), rG[i].clear();

		scanf( "%d", &n );

		repi( i, 1, n+1 )
			scanf( "%d", d+i );
		d[0] = d[n+1] = 0;

		rep( i, n+1 )
		{
			rep( j, ma )
			{
				int t = std::min( i+j+1, n+1 );
				int to = std::max( 0, std::min( t+d[t], n+1 ) );
				G[i].push_back( to );
				rG[to].push_back( i );
			}
		}

		memset( reach, false, sizeof( reach ) );
		memset( rev, false, sizeof( rev ) );
		dfs( n+1 );
		dfs2( 0 );

		bool fl = true;
		rep( i, n+2 )
			if( reach[i] && !rev[i] )
				fl = false;

		puts( fl ? "OK" : "NG" );
	}

	return 0;
}

Measured memory_bytes: 1100
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hs = readLine()!!.split(' ').map { it.toInt() }

    val dp = Array(n) { Int.MAX_VALUE }

    (0 until n).forEach {
        if (it == 0) {
            dp[it] = 0
            return@forEach
        }

        if (it == 1) {
            dp[it] = Math.abs(hs[it] - hs[it - 1])
            return@forEach
        }

        val a = dp[it - 1] + Math.abs(hs[it] - hs[it - 1])
        val b = dp[it - 2] + Math.abs(hs[it] - hs[it - 2])

        dp[it] = Math.min(a, b)
    }

    println(dp.last())
}

Measured memory_bytes: 50584
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    string s;
    cin>>s;
    int n = s.length();
    int k;
    cin>>k;
    char min = 'z';
    char smin = 'z';
    vector<int> p;
    vector<int> sp;
    map<string,int> po;
    vector<string> T;
    if(n<=100){
    for(int i=0;i<n;i++){
        for(int j=1;j<=n-i;j++){
        string t = s.substr(i,j);
        po[t]++;
        if(po[t]==1){
            T.push_back(t);
        }
        //cout<<t<<endl;
        }
    }
    all(T);
    cout<<T[k-1]<<endl;
    }
    else{
    rep(i,n){
        if(s[i]<min){
            smin = min;
            min = s[i];
        }
    }
    //cout<<min<<endl;
    rep(i,n){
        if(s[i]==min){
            p.push_back(i);
        }
        if(s[i]==smin){
            sp.push_back(i);
        }
    }
    for(int i=0;i<p.size();i++){
        for(int j=1;j<=5;j++){
            if(p[i]+j>n)break;
            string t = s.substr(p[i],j);
            po[t]++;
            if(po[t]==1){
                T.push_back(t);
            }
        }
    }
    for(int i=0;i<sp.size();i++){
        for(int j=1;j<=5;j++){
            if(sp[i]+j>n)break;
            string t = s.substr(sp[i],j);
            po[t]++;
            if(po[t]==1){
                T.push_back(t);
            }
        }
    }
    all(T);
    cout<<T[k-1]<<endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define INF 1000000009
#define INFL 1000000000000000018
#define mod 1000000007
#define pb push_back
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int> >PQG;
#define fi first
#define sf second.first
#define ss second.second

int n, c, d[50][50], x[550][550], sum[3][50], color[3], ans = INF;

signed main()
{
    cin >> n >> c;
    for(int i = 1; i <= c; i++){
        for(int j = 1; j <= c; j++){
            cin >> d[i][j];
        }
    }
    //printf("%d\n", __LINE__);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> x[i][j];
        }
    }
    //printf("%d\n", __LINE__);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            sum[(i + j) % 3][x[i][j]]++;
            //printf("sum[%lld][%lld] %lld\n", (i + j) % 3, x[i][j], sum[(i + j) % 3][x[i][j]]);
        }
    }
    //printf("%d\n", __LINE__);
    //printf("%\n");
    for(int i = 1; i <= c - 2; i++){
    for(int j = i + 1; j <= c - 1; j++){
    for(int k = j + 1; k <= c; k++){
        color[0] = i;
        color[1] = j;
        color[2] = k;
        for(int ii = 0; ii < 3; ii++){
        for(int jj = 0; jj < 3; jj++){
        for(int kk = 0; kk < 3; kk++){
            int res = 0;
            if(ii == jj || jj == kk || ii == kk)continue;
            for(int r = 1; r <= c; r++){
                res += d[r][color[ii]] * sum[0][r] + d[r][color[jj]] * sum[1][r] + d[r][color[kk]] * sum[2][r];
                //printf("res += (d[%lld][%lld]) %lld * %lld (sum[%lld][%lld])\n", rr, color[r], d[rr][color[r]], sum[r][rr], r, rr);
            }
            //printf("%lld\n", res);
            ans = min(ans, res);
        }
        }
        }
    }
    }
    }
    cout << ans << endl;



    return 0;
}


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

int main() {
  int X,Y;
  cin >> X >> Y;
  vector<int> a(X);
  for (int i = 0; i < X; i++) {
    cin >> a.at(i);
  }
  double all = 0;
  for (int i = 0; i < X; i++) {
    all += a.at(i);
  }
  
  double s = all/(4*Y);
  
  int ans = 0;
  for (int i = 0; i < X; i++) {
    if (a.at(i) >= s) {
      ans++;
    }
  }
  
  if (ans < Y) {
    cout << "No" <<endl;
  }
  else {
    cout << "Yes" <<endl;
  }
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[200010], b[200010], n;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	sort(b, b+n);
	for (int i = 0; i < n; i++)
	{
		if (a[i] <= b[n/2-1]) printf("%d\n", b[n/2]);
		else printf("%d\n", b[n/2-1]);
	}
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	const int mod=1000000007;
	int N,W;
	cin >> N >> W;
	
	vector<int> v(N);
	REP(i,0,N) cin >> v[i];
	sort(v.begin(),v.end());

	static vector<vector<ll>> dp(N,vector<ll>(W+1));
	ll ans=0,sum=0;
	REP(i,0,N){
		if(sum>W) break;
		dp[i][sum]=1;
		REP(j,i+1,N){
			REP(k,sum,W+1){
				dp[j][k]=dp[j-1][k];
				if(k-v[j]>=0) dp[j][k]=(dp[j][k]+dp[j-1][k-v[j]])%mod;
			}
		}
		//W-w<v[i] <-> w>W-v[i]
		REP(w,W-v[i]+1,W+1) ans=(ans+dp[N-1][w])%mod;
		fill(dp.begin(),dp.end(),vector<ll>(W+1));
		sum+=v[i];
	}
	if(sum<=W) ++ans;
	
	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

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

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


ll a,b;


int main(){
  cin>>a>>b;
  ll k1,k2,k3,k4,k5;
  ll ans=0,j;
  for(ll i=a;i<=b;i++){
    j=i;
    k1=j%10;
    j-=k1;
    k2=(j%100)/10;
    j-=k2*10;
    k3=j%1000/100;
    j-=k3*100;
    k4=j%10000/1000;
    j-=k4*1000;
    k5=j%100000/10000;
    if(i==10000*k1+1000*k2+100*k3+10*k4+k5){
//      cout<<i<<" "<<(10000*k1+1000*k2+100*k3+10*k4+k5)<<endl;
      ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}


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

int main() {
     int nums[5];
     cin >> nums[0] >> nums[1] >> nums[2] >> nums[3] >> nums[4];
     sort(nums, nums+5, greater<int>());
     cout <<  nums[0] << " " <<nums[1] << " " << nums[2] << " " << nums[3] << " " << nums[4] << endl;
     return 0;
}

Measured memory_bytes: 1184
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
// #include<boost/multiprecision/cpp_int.hpp>
// namespace multiprecisioninteger = boost::multiprecision;
// using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool ff=0;for(auto outi:v){cout<<(ff?" ":"")<<outi;ff=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
int main(){
  startupcpp();
  int i,j=0,N;
  ll ans=1;
  cin>>N;
  vector<int> v(N);
  rep(i,N)cin>>v[i];
  rep(i,N){
    while(j<N-1&&v[j]>(j-i)*2)++j;
    (ans*=j-i+1)%=mod;
  }
  print(ans);
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
long long lcm(long long  a,long long  b){
	long long x = a * b;
	
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    long long tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  long long r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  
  return x/b;
}
int main(){
	long long A,B,C,D;
	cin>>A>>B>>C>>D;
	long long a,b;
	long long CD=lcm(C, D);
	A--;
	a=A-(A/C + A/D - A/CD);
	b=B-(B/C + B/D - B/CD);
	cout<<b-a;
	
	
	
}


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

 using namespace std;
 typedef long long ll;

 int main() {
   int N, M, K;
   cin >> N >> M >> K;

   string ans = "No";

   for (int i = 0; i <= N; i++) {
     for (int j = 0; j <= M; j++) {
       if (K == i * M + j * N - 2 * i * j) {
         ans = "Yes";
         break;
       }
     }
     if (ans == "Yes") break;
   }
   cout << ans << endl;
 }


Measured memory_bytes: 256
#include <cstdio>

int main(){
//  freopen("in.in", "r", stdin);
//  freopen("out.out", "w", stdout);
  char ch;
  ch = fgetc(stdin);
  if(ch == 'A')
    printf("T");
  else  if(ch == 'T')
    printf("A");
  else  if(ch == 'C')
    printf("G");
  else
    printf("C");
  return 0;
}


Measured memory_bytes: 128
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	long long a;scanf("%lld",&a);
	long long ret=(a-1)*a/2;
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll dp[100099],n,k,a[100099];
    cin >> n >> k;
    for(int i=1; i<=n; i++)cin >> a[i];
    dp[0]=0;
    for(int i=1; i<=k; i++){
        bool z=0;
        for(int j=1; j<=n; j++){
            if(i-a[j]>=0){
                if(dp[i-a[j]]==0){
                    z=1;
                    break;
                }
            }
        }
        if(z)dp[i]=1;
        else dp[i]=0;
    }
    string s[2]={"Second\n","First"};
    cout << s[dp[k]];
    
}

Measured memory_bytes: 1024
seed = [i for i in range(1,14)]
deck = {}
for s in ['S','H','C','D']:
    deck[s] = seed[:]

n = int(input())
for i in range(n):
    s,v = input().split()
    deck[s][int(v)-1] = 0

for s in ['S','H','C','D']:
    for i in deck[s]:
        if i != 0:
            print(s,i)

Measured memory_bytes: 7608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

using namespace std;

int main(void){
    int N, val, lat, tot=0;
    cin >>N;
    rep(i, N-1){
        cin >> val;
        if(i == 0){
            tot += val;
        } else{
            tot += min(lat, val);
        }
        lat = val;
        //cout << tot  <<" " << lat << " "  << val<< endl;
    }
    tot += lat;
    cout << tot << endl;
    return 0;
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll a,b;
  	ci(a>>b);
  st s;
  	ci(s);
  ch now;
  ll count=0;
  FOR(i,0,a+b+1){
    now=s[i];
    if(i==a){
      if(now!='-'){
        co("No")
          count=0;
          break;
      }
    }
      else{
        if(now=='-'){
          co("No")
            count=0;
            break;
        }
      }
        count++;
      }
  
  if(count==a+b+1){
    co("Yes")
  }      
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main(){
  vector<int> a(32);
  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 b = 0;
  cin >> b;
  cout << a[b - 1] << endl;
  return 0;
}

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

using namespace std;

string s, t;
map<char, char> m1, m2;

void solve() {
  bool same = true;
  for (int i=0;i<s.size();i++) {
    if (m1.find(s[i]) == m1.end() && m2.find(t[i]) == m2.end()) {
      m1[s[i]] = t[i];
      m2[t[i]] = s[i];
    } else {
      if (m1[s[i]] != t[i] || m2[t[i]] != s[i]) {
        same = false;
        break;
      }
    }
  }
  cout << (same ? "Yes" : "No") << endl;
}

int main() {
  cin >> s >> t;
  solve();
}


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

int main(void){
    int r,c;
    cin >>r>>c;
    int mat[r][c];
    
    for(int i=0;i<r;i++){
        int r_s=0;
        for(int j=0;j<c;j++){
            cin >> mat[i][j];
            r_s+=mat[i][j];
            cout << mat[i][j] << " ";
        }
        cout << r_s << endl;
    }
    
    int r_c_s = 0;
    for(int j=0;j<c;j++){
        int c_s=0;
        for(int i=0;i<r;i++){
            c_s+=mat[i][j];
        }
        r_c_s += c_s;
        cout << c_s << " ";
    }
    cout << r_c_s << endl;

    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

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

    int cntR=0;
    for(auto &c:S){
        if(c=='R'){
            cntR++;
        }
    }

    int ans=0;
    for(int i=0; i<cntR; i++){
        if(S[i]=='W'){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
///////////////////////////////////////////////////////////////////////////////

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

///////////////////////////////////////////////////////////////////////////////

void intin(int *a)
{
        cin >> *a;
}

void intinl1(auto *v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a;
                cin >> a;
                v->push_back(a);
        }
}

void intinl2(auto *v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b;
                cin >> a >> b;
                v->push_back({a, b});
        }
}

void intinl3(auto *v, int count)
{
        for (int i = 0; i < count ; ++i) {
                int a, b, c;
                cin >> a >> b >> c;
                v->push_back({a, b, c});
        }
}

void intina(auto *v, int count)
{
        intinl1(v, count);
}

///////////////////////////////////////////////////////////////////////////////

int main()
{
        int n;
        vector<int> hlist;

        intin(&n);
        intina(&hlist, n);

        int hmax = 0;
        int ans = 0;

        for (int i = 0; i < n; ++i) {
                if (hlist[i] >= hmax) {
                        ans += 1;
                        hmax = hlist[i];
                }
        }

        cout << ans;

        return 0;
}

///////////////////////////////////////////////////////////////////////////////


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

int main() {
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int i=0; i<=K; i++) {
        for (int j=0; j<=K; j++) {
            int k = S - i - j;
            if (0<=k and k<=K) {
                count++;
            }
        }
    }
    cout << count << endl;
}


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

template<class Type>
Type Pow(Type a, Type n)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a;
		}
		a = a * a;
		n >>= 1;
	}
	return res;
}

int main()
{
	ll x;
	cin >> x;
	for (ll i = -118; i < 120; i++) {
		for (ll j = -118; j < 120; j++) {
			if (x == Pow(i, 5LL) - Pow(j, 5LL)) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	cout << fixed << setprecision(15) << 6.28318530717958623200 * N << endl;
}

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

int main()
{
	int n, T;
	cin >> n >> T;
	int t[n];
	long long ans = 0;
	for (int i = 0; i < n; i++) cin >> t[i];
	for (int i = 1; i < n; i++){
		ans += min(t[i]-t[i-1], T);
	}
	ans += T;

	cout << ans << endl;
}




Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define rep(i,l,r) for(int i=l;i<r;i++)

typedef long long ll;

ll max(ll a, ll b) { return a > b ? a : b; }

int main() {
    ll n, a[3][100001];
    scanf("%lld", &n);
    rep(i, 0, n) {
        rep(j, 0, 3) {
            scanf("%lld", &a[j][i]);
        }
    }
    ll dp[3][100001];
    rep(i, 0, 3) dp[i][0] = a[i][0];
    rep(i, 1, n) {
        rep(j, 0, 3) {
            dp[j][i] = max(dp[(j + 1) % 3][i - 1] + a[j][i], dp[(j + 2) % 3][i - 1] + a[j][i]);
        }
    }
    ll ans = max(dp[0][n - 1], max(dp[1][n - 1], dp[2][n - 1]));
    
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 6792
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

slices _ [] = []
slices n s = (take n s:slices n (drop n s))

hit as bs = length $ filter (uncurry (==)) $ zip as bs
blow as bs = subtract (hit as bs) $ length $ intersect as bs

hitAndBlow [as,bs] = unwords . map show $ [hit as bs, blow as bs] 

main = slices 2 . map (map readInt . words) . lines <$> getContents >>= mapM_ (putStrLn . hitAndBlow)

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 30
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define FORALL(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef valarray<int> Array;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cout<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}

char solve(string s)
{
  REP(i,3)
  {
    if(s[i*3]==s[i*3+1]&&s[i*3]==s[i*3+2]&&s[i*3]!='s') return s[i*3];
    if(s[i]==s[i+3]&&s[i]==s[i+6]&&s[i]!='s') return s[i];
  }
  if(s[0]==s[4]&&s[4]==s[8]&&s[4]!='s') return s[4];
  if(s[2]==s[4]&&s[4]==s[6]&&s[4]!='s') return s[4];
  return 'd';
}

int main()
{
  string s;
  while(cin >> s) cout << solve(s) << endl;
  return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int N, A, B, C;
vec(L);
int ans = INT_MAX;
void search(int i, int a, int b, int c, int sum) {

	if (i==N) {
		if (a == 0 || b == 0 || c == 0) { return; }
		ans = min(ans, sum + abs(a - A)+ abs(b - B)+ abs(c - C));
		return;
	}

	search(i + 1, a + L[i], b, c, sum + (a == 0 ? 0 : 10));
	search(i + 1, a, b + L[i], c, sum + (b == 0 ? 0 : 10));
	search(i + 1, a , b, c + L[i], sum + (c == 0 ? 0 : 10));
	search(i + 1, a , b, c, sum );

}

int main()
{

	cin >> N >> A >> B >> C;


	fx(N) {
		vecp(L);
	}

	search(0, 0, 0, 0, 0);
	
	ce(ans)
    return 0;
}



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

bool comp(int h1, int w1, int h2, int w2) {
	const double d1 = h1 * h1 + w1 * w1, d2 = h2 * h2 + w2 * w2;
	if(d1 != d2)
		return d1 > d2;
	else
		return h1 > h2;
}

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

	for(int h, w; cin >> h >> w, h;) {
		int ans_h = 200, ans_w = 200;
		for(int i = 1; i <= 150; ++i) {
			for(int j = i + 1; j <= 150; ++j) {
				if(comp(i, j, h, w) && comp(ans_h, ans_w, i, j)) {
					ans_h = i;
					ans_w = j;
				}
			}
		}

		cout << ans_h << " " << ans_w << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, m, p;
signed main() {
    int q; cin >> q;
    int a, b, cnt = 0; char c;
    rep(i,0,q) {
        cin >> a >> c >> b;
        c == '(' ? cnt += b : cnt -= b;
        cout << (!cnt ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 3104
f,h=range,input
R,C,K=map(int,h().split())
G=[-~C*[0]for i in f(R+1)]
for i in'_'*K:r,c,v=map(int,h().split());G[r][c]=v
F=[[-~C*[0]for i in f(R+1)]for i in f(4)]
for r in f(1,R+1):
	for x in f(1,4):
		for c in f(1,C+1):F[x][r][c]=max(F[x-1][r][c],max(F[x-1][r][c-1],(x<2)*F[3][r-1][c])+G[r][c],F[x][r][c-1])
print(F[3][R][C])

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

public class Main {
	public static char[] c = {'a','b','c','d','e','f','g','h','i','j'}; 
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		outHyojun(n, 1, 0, "");
	}
	public static void outHyojun(int n,int currentDepth,int currentMaxC,String currentString) {
		int cm = currentMaxC;
		
		if(currentDepth <= n) {
			for(int i = 0 ; i < currentMaxC+1 ; i++) {
				if(i < currentMaxC) {
					outHyojun(n, currentDepth+1, currentMaxC, currentString+ c[i]);
				}else {
					outHyojun(n, currentDepth+1, currentMaxC+1, currentString + c[i]);
				}
			}
		}else {
			System.out.println(currentString);
		}
	}
}


Measured memory_bytes: 45364
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N; cin >> N;
    map<string,int> mp;
    auto nc2 = [](const ll x) {return x*(x-1)/2;};

    REP(i,N) {
        string s; cin >> s;
        sort(ALL(s));
        mp[s]++;
    }

    ll ans = 0;
    for(auto p:mp) {
        ans += nc2(p.second);
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

void sol()
{
	string s;
	cin >> s;
	
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout << "Yes" << endl;
	}
	
	else
	{
		cout << "No" << endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	sol();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll A, B, V, W,T;
    cin >> A >> V >> B >> W >> T;
    ll d = V - W;
    if(d <= 0){
        cout << "NO" << endl;
        return 0;
    }
    ll diff = abs(A - B);
    ll t = (diff + d - 1) / d;
    if(t <= T){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;

int main() {
    int N;
    cin >> N;
    long double sum = 0;
    for(int i = 0; i < N; i++) {
        long double x;
        cin >> x;
        sum += 1 / x;
    }
    cout << fixed << setprecision(10) << 1 / sum;
}

Measured memory_bytes: 256