akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair

static int GetDays(int y,int m,int d){
  if(m<=2){
    --y;
    m+=12;
  }
  int dy=365*(y-1);
  int c=y/100;
  int dl=(y>>2)-c+(c>>2);
  int dm=(m*979-1033)>>5;
  return dy+dl+dm+d-1;
}

int main(){
  int y1,y2,m1,m2,d1,d2;
  while(1){
    cin>>y1>>m1>>d1>>y2>>m2>>d2;
    if(y1==-1)break;
    cout<<GetDays(y2,m2,d2)-GetDays(y1,m1,d1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>

using namespace std;

#define int long long

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) begin(a), end(a)

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

template<typename T>
class UnionFind {
    public:
    vector<T> parent;
    vector<T> rank;
    UnionFind() {}
    UnionFind(T n):parent(n), rank(n){
        rep(i, n) {
            parent[i]=i;
        }
        fill(ALL(rank), 0);
    }
    T root(T x) {
        if(parent[x] == x){
            return x;
        } else {
            parent[x] = root(parent[x]);
            return parent[x];
        }
    }
    bool same(T x, T y) {
        return root(x) == root(y);
    }
    void unite(T x, T y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
};

signed main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, q;
    cin>>n>>
    q;
    UnionFind<int> uf(n);
    rep(i,q) {
        int c, x, y;
        cin>>c>>x>>y;
        if(c) {
            // same(x, y)
            cout<<uf.same(x,y)<<endl;
        } else {
            // unite(x, y)
            uf.unite(x,y);
        }
    }
	return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int n, k;
vector <int> v;

bool gd(int X) {
    int K = k;
    for (int i : v)
        K -= (i - 1) / X;
    return K >= 0;
}

int main() {
    fast_io;

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }

    int l = 1, r = 2e9;
    while (l < r) {
        int md = (l + r) >> 1;
        if (gd(md)) r = md;
            else l = md + 1;
    }

    cout << l << "\n";
}


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

int main()
{
	while (true) {
		int n, k, s;

		cin >> n >> k >> s;

		if (n == 0 && k == 0 && s == 0) {
			break;
		}

		int ans = 0;

		for (int i = 0; i < (1 << n); i++) {
			int count = 0;

			for (int j = 0; j < n; j++) {
				if ((i >> j) % 2 == 1) {
					count++;
				}
			}

			if (count == k) {
				int sum = 0;

				for (int j = 0; j < n; j++) {
					if ((i >> j) % 2 == 1) {
						sum += j + 1;
					}
				}

				if (sum == s) {
					ans++;
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

typedef pair<double, double> pd;
typedef vector<pd> vpd;


#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string s;
  IN(s);

  ll N = s.size();

  if(s[0]!='1' || s[N-1]=='1'){
    OUT(-1);
    return 0;
  }
  for(ll start=0, end=N-2; start<end; start++, end--){
    if(s[start]!=s[end]){
      OUT(-1);
      return 0;
    }
  }

  ll center = 0;
  REP(i,N-1){
    printf("%lld %lld\n", center+1, i+2);
    if(s[i]=='1'){
      center = i+1;
    }
  }

  return 0;
}


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

int main(){
  int A,B,M;
  cin>>A>>B>>M;
  vector<int> a(A),b(B);
  int amin=100000,bmin=100000;
  for(int &i:a){
    cin>>i;
    amin=min(amin,i);
  }
  for(int &i:b){
    cin>>i;
    bmin=min(bmin,i);
  }
  int ab=amin+bmin;
  for(int i=0;i<M;i++){
    int x,y,c;
    cin>>x>>y>>c;
    ab=min(ab,a[x-1]+b[y-1]-c);
  }
  cout<<ab<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

using Graph = vector< vector<int> >;

int step[100010], ans[100010];
void dfs(Graph &G, int cur, int par=-1) {
    vector<int> children;
    for(auto to : G[cur]) {
        if(to == par) continue;
        dfs(G, to, cur);
        step[cur] = max(step[cur], step[to] + 1);
    }
}

void solve(Graph &G, int cur, int d_par, int par=-1) {
    vector< pair<int, int> > children;
    children.push_back(make_pair(0, -1));
    for(auto to : G[cur]) {
        if(to == par) children.push_back(make_pair(d_par + 1, to));
        else children.push_back(make_pair(step[to] + 1, to));
    }
    sort(children.begin(), children.end(), greater< pair<int, int> >());

    ans[cur] = children[0].first;
    for(auto to : G[cur]) {
        if(to == par) continue;
        int nxt_d_par = children[children[0].second == to].first;
        solve(G, to, nxt_d_par, cur);
    }
}

int main() {
    int N; scanf("%d", &N);
    Graph G(N);
    for(int i=0; i<N-1; i++) {
        int a, b; scanf("%d%d", &a, &b);
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(G, 0);
    solve(G, 0, 0);
    for(int i=0; i<N; i++) {
        printf("%d\n", 2 * (N-1) - ans[i]);
    }
    return 0;
}


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

using namespace std;

int main(){
	int S[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int H[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int C[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int D[14]={0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int n,a;
	char b;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>b>>a;
		if (b=='S'){
			S[a]=1;	
		}
		else if(b=='H'){
			H[a]=1;
		}
		else if(b=='C'){
			C[a]=1;
		}
		else if(b==
		'D'){
			D[a]=1;
		}
	}
	for(int i=1;i<=13;i++){
		if(S[i]==0){
			cout<<"S "<<i<<endl;
		}
	}
	for(int i=1;i<=13;i++){
		if(H[i]==0){
			cout<<"H "<<i<<endl;
		}
	}
	for(int i=1; i<=13; i++){
		if(C[i]==0){
			cout<<"C "<<i<<endl;
		}
	}
	for(int i=1; i<=13; i++){
		if(D[i]==0){
			cout<<"D "<<i<<endl;
		}
	}
}



Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());

    int sum = 0;
    for (int i = 0; i < n - 1; ++i)
        sum += v[i];
    sum += v[n - 1] / 2;

    cout << sum << '\n';
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
 
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(a>0||c>0)
  {
    c-=b;
    if(c<=0)
    {
      cout<<"Yes";
      return 0;
    }
    a-=d;
    if(a<=0)
    {
      cout<<"No";
      return 0;
    }
  }
}

Measured memory_bytes: 3636
i,j=map(int,input().split())
listA=[]
for n in range(i):
    listA.append(list(map(int,input().split())))
    listA[n].append(sum(listA[n]))
listA.append([])
for n in range(j+1):
    number=0
    for m in range(i):
        number+=listA[m][n]
    listA[i].append(number)
for n in range(i+1):
    print(' '.join(map(str,listA[n])))


Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s >> t;
	int n=s.size(),ans = 0;
	map<char,vector<int>> m;
	for (int i=0; i<n; ++i){
		m[s[i]].emplace_back(i);
	}
	int ts = t.size(), crt = -1;
	for (int i=0; i<ts; ++i){
		if (!m.count(t[i])){
			cout << -1;
			return 0;
		}
		int pos = upper_bound(m[t[i]].begin(),m[t[i]].end(),crt)-m[t[i]].begin();
		if (pos >= m[t[i]].size()){
			ans += n;
			pos %= m[t[i]].size();
		}
		crt = m[t[i]][pos];
	}
	if (crt == -1) crt = 0;
	cout << ans+crt+1;
	return 0;
}


Measured memory_bytes: 1736
#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;
    if (n % 10 == 3) cout << "bon" << endl;
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
   int n,m;
   cin>>n>>m;
   cout<<(n-1)*(m-1)<<endl; 
  return 0;
}


Measured memory_bytes: 256
n=int(input())
w=[input() for _ in range(n)]
ans='Yes'
for i in range(1,n):
  if w[i-1][-1]!=w[i][0]:
    ans='No'
    break
  for j in range(i):
    if w[i]==w[j]:
      ans='No'
      break
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main()
{
	int n;
	scanf("%d", &n);
	vector<int> p(n);
	rep(i, n) scanf("%d", &p[i]);
	int count = 0;
	rep(i, n) {
		if(p[i] != i + 1) count++;
	}
	if(count <= 2) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
int main()
{
	char l[3][3],s[9],m;
	int i;
	while(scanf("%s",s)!=EOF){
		l[0][0]=s[0];
		l[0][1]=s[1];
		l[0][2]=s[2];
		l[1][0]=s[3];
		l[1][1]=s[4];
		l[1][2]=s[5];
		l[2][0]=s[6];
		l[2][1]=s[7];
		l[2][2]=s[8];
		m='d';
		for(i=0;i<3;i++){
			if(l[i][0]=='o'&&l[i][1]=='o'&&l[i][2]=='o'){
				m='o';
			}else if(l[i][0]=='x'&&l[i][1]=='x'&&l[i][2]=='x'){
				m='x';
			}
		}
		for(i=0;i<3;i++){
			if(l[0][i]=='o'&&l[1][i]=='o'&&l[2][i]=='o'){
				m='o';
			}else if(l[0][i]=='x'&&l[1][i]=='x'&&l[2][i]=='x'){
				m='x';
			}
		}
		if(l[0][0]=='o'&&l[1][1]=='o'&&l[2][2]=='o'){
			m='o';
		}
		if(l[0][0]=='x'&&l[1][1]=='x'&&l[2][2]=='x'){
			m='x';
		}
		if(l[2][0]=='o'&&l[1][1]=='o'&&l[0][2]=='o'){
			m='o';
		}
		if(l[2][0]=='x'&&l[1][1]=='x'&&l[0][2]=='x'){
			m='x';
		}
		printf("%c\n",m);
	}
	return 0;
}

Measured memory_bytes: 2624
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	int ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++){
		int u, v;
		scanf("%d %d", &u, &v);
		ans += (v - u + 1);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

const int mod = 1e9 + 7;

bool solve(int s) {
	int l = 1, r = sqrt(1e9);
	while (l <= r) {
		int m = (l + r) / 2;
		if (m * m == s) return true;
		if (m * m < s) l = m + 1;
		else r = m - 1;
	}
	return false;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, d;
	cin >> n >> d;
	int a[10][10];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < d; j++) cin >> a[i][j];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ll s = 0;
			for (int k = 0; k < d; k++) s += (a[j][k] - a[i][k]) * (a[j][k] - a[i][k]);
			ans += solve(s);
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define LL long long 
#define ULL unsigned long long 
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	for(int i=0; i<n; i++) {
		cin>>a[i];
	}
	int ost = a[n-1];
	int znak = -1;
	for(int i=0; i<n-1; i++) {
		ost+=(znak*a[i]);
		znak=-znak;
	}
	int w[n];
	ost/=2;
	w[n-1] = ost;
	for(int i=n-2; i>=0; i--) {
		w[i] = a[i] - ost;
		ost = w[i];
	}
	for(int i=0; i<n; i++)
		cout<<w[i]*2<<" ";
}


Measured memory_bytes: 2176
# ABC138D - Ki (main, dfs in main())
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    # Ai (A[i][0]) may be not a parent of Bi (A[i][1])
    def dfs(v: int, p: int) -> None:
        for u in T[v]:
            if u != p:  # p: parent -> skip
                cnt[u] += cnt[v]  # cumulative sum
                dfs(u, v)

    N, Q = tuple(map(int, input().split()))  # vertices and queues
    E = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # tree, (N+1: 1-idx -> 0-idx)
    for a, b in E:
        T[a] += [b]
        T[b] += [a]
    cnt = [0] * (N + 1)
    for p, x in P:
        cnt[p] += x  # increase vertex p by x
    dfs(1, -1)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

Measured memory_bytes: 303312
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if((a==5 && b==5 && c==7) || (a==5 && b==7 && c==5) || (a==7 && b==5 && c==5))
    puts("YES");
  else
    puts("NO");
  return 0;
}

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

int main() {
	int N;
  	cin >> N;
  
  	int top = N / 100;
  	int bottom2 = N % 100;
  
  	if(bottom2 > top * 10 + top) {
    	cout << (top + 1 ) * 100 + (top + 1) * 10 + top + 1 << endl;
    }else {
    	cout << top * 100 + top * 10 + top << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int nodes = in.nextInt();
		int edges = in.nextInt();
		ArrayList<Integer>[] g = new ArrayList[nodes];
		visited = new boolean[nodes];
		for(int i=0;i<nodes;i++) g[i] = new ArrayList<>();
		for(int i=0;i<edges;i++){
			int n = in.nextInt()-1;
			int m = in.nextInt()-1;
			g[n].add(m);
			g[m].add(n);
		}
		visited[0] = true;
		dfs(g, 0);
		System.out.println(count);
	}
	static boolean[] visited;
	static int count = 0;
	public static void dfs(ArrayList<Integer>[] g, int node){
		boolean done = true;
		for(int i:g[node]){
			if(!visited[i]){
				visited[i] = true;
				dfs(g, i);
				visited[i] = false;
				done = false;
			}
		}
		if(done){
			boolean finish = true;
			for(boolean b:visited) if(!b) finish = false;
			count += finish ? 1 : 0;
		}
	}
}


Measured memory_bytes: 11036
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextFloat() float64 {
	sc.Scan()
	i, _ := strconv.ParseFloat(sc.Text(), 64)
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a, b, c := nextFloat(), nextFloat(), nextFloat()
	s := 0.5 * a * b * math.Sin(c/180*math.Pi)
	fmt.Println(s)
	fmt.Println(math.Sqrt(a*a+b*b-2*a*b*math.Cos(c/180*math.Pi)) + a + b)
	fmt.Println(2 * s / a)
}



Measured memory_bytes: 1132
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
N=int(input())
B= list(map(int, input().split()))


A = []
A.append(B[0])
for i in range(1,N-1):
    A.append(min(B[i-1],B[i]))
A.append(max(B[N-2],A[N-2]))

print(sum(A))

Measured memory_bytes: 72908
input_line = []

while line = ARGF.gets
  input_line << line.chomp
end

N = input_line.shift.to_i
A = input_line.shift.split(" ").map(&:to_i)
count = 0;

for i in 0..(N-1)
  minj = i
  for j in i..(N-1)
    if A[j] < A[minj]
      minj = j
    end
  end
  if A[i] != A[minj]
    tmp  = A[i]
    A[i] = A[minj]
    A[minj] = tmp
    count += 1
  end
end

A.each.with_index(1) do |item,index|
  if index == A.length
    puts item
  else
    print "#{item} "
  end
end
puts count

Measured memory_bytes: 8656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans=0;
  
  
  rep(i,n-2) {
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
      ans++;
      
    
  }}
  cout << ans << endl;
  return 0;
}
      


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,q;
int sum,a[105],b[105],c[105],d[105],k[105];
void dfs(int x)
{
	if(x>n)
	{
		int res=0;
		for(int i=0;i<q;i++)
		{
			if(k[b[i]]-k[a[i]]==c[i])
				res+=d[i];
		}
		sum=max(sum,res);
		return;
	}
	for(int i=k[x-1];i<=m;++i)
	{
		k[x]=i;
		dfs(x+1);
	}
}
int main()
{
	cin>>n>>m>>q;
	for(int i=0;i<q;i++)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	k[0]=1;
	dfs(1);
	cout<<sum;

	return 0;
}

Measured memory_bytes: 3644
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 * https://qiita.com/drken/items/fd4e5e3630d0f5859067
 * @author YukihiroLocal
 *
 */
public class Main {
  public static void main(String[] args) {


    Scanner sc = new Scanner(System.in);
    // get a integer

    int N = sc.nextInt();
//    System.out.println(" integer is " + N);
    List<Integer> aList = new ArrayList<>();
    List<Integer> divideList = new ArrayList<>();
    int Y = sc.nextInt();
    int ansx = -1, ansy = -1, ansz = -1;
//    Y = 10000 * x + 5000 * y + 1000 *z;
//    N = x + y + z;
//    z = N - x - y;
//    z = (Y - (10000 * x + 5000 * y)) /1000;


    for(int x = 0; x <= N ; x++){
      // i is equal to x
      double caluculatedY = getCalY(x, N,  Y);
      double caluculatedZ = N -x - caluculatedY;
      if(validateAll(caluculatedY,caluculatedZ, N)){
        ansx = x;
        ansy = (int)caluculatedY;
        ansz = (int)caluculatedZ;
        break;
      }
    }
    System.out.println(ansx + " " + ansy + " " + ansz);

  };
  private static double getCalY(int x,int N, int Y) {
//    Y = 10000 * x + 5000 * y + 1000 * (N - x - y);
//    Y = 10000 * x + 5000 * y + 1000 *N - 1000* x - 1000* y;
//    Y = 9000*x + 4000*y + 1000*N
//
    double y = ((double)Y - 9000 * (double)x  - 1000* (double)N ) /4000;
    return y;
  }

  public static boolean validate(double a, double N) {
    if(a ==(int)a && a >= 0 && a <= N){
      return true;
    }else{
      return false;
    }
  }
  public static boolean validateAll(double y, double z, int N) {
    boolean yflag = false, zflag = false;
    if(validate(y, N)){
      yflag = true;
    };
    if(validate(z, N)){
      zflag = true;
    }
    return yflag && zflag;
  }
}


Measured memory_bytes: 22996
import math

n,m = map(int, input().split())
s = input()
t = input()
g = 1
div = []
for i in range(2,min(n,m)+1):
    if min(n,m)%i == 0:
        div.append(i)
for i in div:
    if max(n,m)%i == 0:
        g = i
G = g*(n/g)*(m/g)

ans = int(G)
i = 0
while (G/m)*i <= n-1:
    if s[int((G/m)*i)] == t[int((G/n)*i)]:
        pass
    else:
        ans = -1
        break
    i += 1
print(ans)


Measured memory_bytes: 3316
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val price = sc.nextInt()

  val wotax = Math.ceil(price / 1.08).toInt()
  val check = Math.floor(wotax * 1.08).toInt()
  if (check == price) {
    println(wotax)
  } else {
    println(":(")
  }
}

Measured memory_bytes: 29476
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 122)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
bool isect (int l1, int r1, int l2, int r2){
    pii p1,p2;
    p1 = mp(l1,r1); p2 = mp(l2,r2);
    if(p1>p2)swap(p1,p2);
    if(p2.fi <= p1.se)return true;
    else return false;
}
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1;
    else if(num2==1)return num1;
    else{
        ll temp = quickpow (num1,num2/2,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2%2==1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template
str a,b;
bool t;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin>>a>>b;
    if(b=="H") t = true;
    else t = false;

    if(a=="D") t = not t;

    if(t) cout<<"H\n";
    else cout<<"D\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <complex>
#include <cmath>
using namespace std;


int main(int argc, char const *argv[]) {
    int n;cin>>n;
    vector<long long> x(n),y(n);
    for(int i=0;i<n;++i){
        cin>>x[i]>>y[i];
    }
    for(int i=1;i<n;++i){
        if((x[i]+y[i]-x[0]-y[0])%2!=0){
            cout<<-1<<endl;
            return 0;
        }
    }
    int m=33;
    vector<long long> d(m+2);
    long long ll = 1;
    for(int i=0;i<m;++i){
        d[i] = ll;
        ll<<=1;
    }
    bool par = (x[0]+y[0])%2 == 0;
    d[m] = (1ll<<(m-1)) + par;
    d[m+1] = (1ll<<m);
    vector<string> res(n);
    for(int i=0;i<n;++i){
        string s = "";
        long long u = x[i] + y[i] + (1ll<<(m-1)) + par, v = x[i] - y[i] + (1ll<<(m-1)) + par;
        for(int i=0;i<m;++i){
            u>>=1;
            v>>=1;
            bool b=u%2,c=v%2;
            if(b){
                if(c)s+='R';
                else s+='U';
            }
            else{
                if(c)s+='D';
                else s+='L';
            }
        }
        s+="LR";
        res[i] = s;
    }
    cout << d.size() << endl;
    for(long long l:d)cout<<l<<" ";
    cout<<endl;
    for(string s:res)cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
  int h = ty - sy, w = tx - sx;

  string result = "";
  rep(i, h) result += "U"; rep(i, w) result += "R";
  rep(i, h) result += "D"; rep(i, w) result += "L";

  result += "L" ;
  rep(i, h+1) result += "U"; rep(i, w+1) result += "R";
  result += "D";

  result += "R";
  rep(i, h+1) result += "D"; rep(i, w+1) result += "L";
  result += "U";

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	 char str[10];
	 scanf("%s", str);
        switch (str[0]){
          case 'S':
          printf("Cloudy");
          break;
      
          case 'C':
            printf("Rainy");
            break;
        
          case 'R':
            printf("Sunny");
            break;
        }
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N,T,A,H,a=0.000,b=0.000,m=1000,ans;
  cin >> N >> T >> A;
  for(int i=0 ; i<N ; i++){
    cin >> H;
    a+=T-0.006*H;
    if(a<A)
      b+=A-a;
    else
      b+=a-A;
    if(b<m){
      m=b;
      ans=i+1;
    }
    a=0.000,b=0.000;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
R, C, k = map(int, input().split())
xs = [[0] * C for _ in range(R)]
for _ in range(k):
    r, c, v = map(int, input().split())
    xs[r - 1][c - 1] = v

dp = [[[0] * (C + 1) for _ in range(R + 1)] for _ in range(4)]
for i in range(R):
    for j in range(C):
        for k in range(2, -1, -1):
            dp[k + 1][i][j] = max(dp[k + 1][i][j], dp[k][i][j] + xs[i][j])
        for k in range(4):
            dp[k][i][j + 1] = max(dp[k][i][j + 1], dp[k][i][j])
            dp[0][i + 1][j] = max(dp[0][i + 1][j], dp[k][i][j])
ans = 0
for k in range(4):
    ans = max(ans, dp[k][R - 1][C - 1])
print(ans)


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

using namespace std;
int main()
{
    // 整数の入力
    int n,i=0,l,flag=1,cnt=0,max,min,temp,j,f;
    cin >> n;
    int p[50];
    while(i < n)
    {
        cin >> p[i];
        i++;
    }

    flag=1;
    i=1;
    while(i < n)
    {
        if(p[i-1] > p[i])
        {
            flag = 0;
        }
        i++;
    }

    if(flag)
    {
        cout << "YES" << endl;
    }
    else
    {
        for(f=0;f<n;f++)
        {
            min=f;
            for(j=f;j<n;j++)
            {    
                if(p[j] < p[min])
                {
                    min = j;
                }
            }
            //cout << "min " << f << " " << min << endl;
            if(min != f)
            {
                temp = p[f];
                p[f] = p[min];
                p[min] = temp;

                flag=1;
                i=1;
                while(i < n)
                {
                    //cout << f << " " << p[i] << endl;
                    if(p[i-1] > p[i])
                    {
                        flag = 0;
                    }
                    i++;
                }

                if(flag)
                {
                    cout<<"YES"<<endl;
                }
                else
                {
                    cout<<"NO"<<endl;
                }

                return 0;
            }
        }   
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,k;
    cin >> n >> k;
    if(n%k == 0) cout << 0 << endl;
    else cout << 1 << endl; 
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.search_engine", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		int n = str.length();
		rep (i, n ){
			if (str[i] == ',' || str[i] == '.' ) str[i] = ' ';
		} // end rep
		vector<string> word; word.clear();
		stringstream ss (str );
		string s = "";
		while (ss >> s ){
			word.push_back (s );
		} // end while

		string res = "";
		rep (i, word.size() ){
			if (word[i].length() >= 3 && word[i].length() <= 6 ){
				res += word[i];
				res += ' ';
			} // end if
		} // end rep
		res = res.substr (0, res.length() - 1 );
		cout << res << endl;
	} // end while
		
	return 0;
}

Measured memory_bytes: 1212
X,Y,A,B,C=map(int,input().split())
p=input().split()
P=[int(a) for a in p]
q=input().split()
Q=[int(a) for a in q]
r=input().split()
R=[int(a) for a in r]
P=sorted(P,reverse=True)
P=P[:X]
Q=sorted(Q,reverse=True)
Q=Q[:Y]
answers=P+Q+R
answers=sorted(answers,reverse=True)
answers=answers[:(X+Y)]
print(sum(answers))


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

int main() {
    int N, Y;
    cin >> N >> Y;
    int a,b;
    a = Y / 10000;
    b = Y / 5000;
    //c = Y - a*10000 - b * 5000;
    int f = 0;
    for(int i=a;i>=0;i--){
        for(int j=b;j>=0;j--){
            int p = (Y - 10000*i - 5000*j)/1000;
            if(p >=0 && (Y - 10000*i - 5000*j)%1000==0 && i + j + p == N){
                cout << i <<" " << j << " " << p <<" " <<"\n";
                f = 1;
            }
            if(f==1) break;
        }
        if(f==1) break;
    }

    if(f==0) cout <<"-1 -1 -1" <<"\n";

}

Measured memory_bytes: 256
#include "iostream"
#include "string"
#include "algorithm"
using namespace std;

int main() {
	int n, c, cake, cakeSum = 0;
	cin >> n >> c;
	for (int i = 0; i < c; i++) {
		cin >> cake;
		cakeSum += cake;
	}
	int ans = cakeSum / (n + 1);
	if (cakeSum%(n + 1) != 0) {
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3112
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d,e;
int main(){
  scanf("%d%d%d",&a,&b,&c);
  d=max(max(a,b),c);
  e=min(min(a,b),c);
  printf("%d",d-e);
}


Measured memory_bytes: 256
N=gets.to_i
H=gets.split.map(&:to_i)
ans="Yes"

p0=0
p1=H.shift

(N-1).times {
    p2=H.shift
    if p2>=p1
        p0=p1
        p1=(p2-1>=p1 ? p2-1 : p2)
        next
    else
        ans="No"
        break
    end
}

puts ans

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

string s, t;

#define N 3001
int n, m, dp[N][N];

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

        getline(cin, s);
        getline(cin, t);
        n = s.length(); m = t.length();
        for (int i = 1; i <= n; i++)
                for (int j = 1; j <= m; j++)
                        if (s[i-1] == t[j-1])
                                dp[i][j] = dp[i-1][j-1] + 1;
                        else
                                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);

        int id = dp[n][m], i = n, j = m;
        char lcs[id+1];

        while (i > 0 && j > 0) {
                if (s[i-1] == t[j-1]) {
                        lcs[id] = s[i-1];
                        i--; j--; id--;
                }
                else if (dp[i-1][j] > dp[i][j-1])
                        i--;
                else
                        j--;
        }

        for (int i = 1; i <= dp[n][m]; i++)
                cout << lcs[i];

        return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){

    int n; cin >> n;
    map<string, int> M;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        M[s]++;
    }

    int size = M.size();
    vector< pair<int, string> > P(size);
    int i = 0;
    for (auto itr = M.begin(); itr != M.end(); itr++, i++) {
        P[i] = make_pair(itr->second, itr->first);
    }
    sort(P.begin(), P.end(), greater<pair<int, string> >());
    int max_cnt = P[0].first;
    vector<string> Dic;
    for (int i = 0; i < n && P[i].first == max_cnt; i++) {
        Dic.push_back(P[i].second);
    }
    sort(Dic.begin(), Dic.end());
    for (auto d : Dic) 
        cout << d << '\n';

}


Measured memory_bytes: 30068
L,R = gets.split.map(&:to_i)

min = 2019
L.step(R) do |i|
  i.step(R) do |j|
    next if i == j
    n = i * j % 2019
    min = n if n < min
    break if min == 0
  end
  break if min == 0
end
puts min

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

def abc155b(num, s):
    b = True

    for i in range(0, num):
        if(s[i] % 2 == 0):
            if(s[i] % 3 == 0):
                continue
            elif(s[i] % 5 == 0):
                continue
            else:
                b = False

    return(b)

###
# main
if(__name__ == '__main__'):
    # input
    num = int(input())
    s = list(map(int, input().split(" ")))

    b = abc155b(num, s)

    # output
    if( True == b ):
        print("APPROVED")
    else:
        print("DENIED")
# else:
    # do nothing


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			char[] s = in.next().toCharArray();
			
			int s_10_counter = 0;
			int s_01_counter = 0;
			
			
			for (int i = 0; i < s.length; i++) {
				if (i%2 == 1) {
					if (s[i] == '1') s_10_counter++;
					else s_01_counter++;
				} else {
					if (s[i] == '0') s_10_counter++;
					else s_01_counter++;
				}
			}
			
			System.out.println(s.length - Math.max(s_10_counter, s_01_counter));
			
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}

Measured memory_bytes: 25940
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Map<Integer, Integer>map = new TreeMap<>();
		for(int i = 1; i <= n; i++){
			map.put(sc.nextInt(), i);
		}
		for(int i : map.keySet()){
			System.out.print(map.get(i));
			if(i != n){
				System.out.print(" ");
			}
		}
		
	}
}


Measured memory_bytes: 72032
#include <stdio.h>
int main(){
    int a,b,c;
    while(scanf("%d%d%d",&a,&b,&c)!=EOF){
        if(a>1989)printf("heisei %d %d %d\n",a-1988,b,c);
        else if(a==1989){
            if(b>1)printf("heisei %d %d %d\n",a-1988,b,c);
            else if(c>=8)printf("heisei %d %d %d\n",a-1988,b,c);
            else printf("showa %d %d %d\n",a-1925,b,c);
        }
        else if(a>1926)printf("showa %d %d %d\n",a-1925,b,c);
        else if(a==1926){
            if(b==12&&c>=25)printf("showa %d %d %d\n",a-1925,b,c);
            else printf("taisho %d %d %d\n",a-1911,b,c);
        }
        else if(a>1912)printf("taisho %d %d %d\n",a-1911,b,c);
        else if(a==1912){
            if(b>7)printf("taisho %d %d %d\n",a-1911,b,c);
            else if(b==7&&c>=30)printf("taisho %d %d %d\n",a-1911,b,c);
            else printf("meiji %d %d %d\n",a-1867,b,c);
        }
        else if(a>1868)printf("meiji %d %d %d\n",a-1867,b,c);
        else if(a==1868){
            if(b>9)printf("meiji %d %d %d\n",a-1867,b,c);
            else if(b==9&&c>=8)printf("meiji %d %d %d\n",a-1867,b,c);
            else printf("pre-meiji\n");
        }
        else printf("pre-meiji\n");
    }
}

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb emplace_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
int a[20][20];
int dp[(1ll<<20)];
bool used[(1ll<<20)];

int solve(int S){
    if(used[S])return dp[S];
    used[S]=true;
    int tmp=0;
    rep(i,0,N)rep(j,i+1,N)if((S&(1<<i))&&(S&(1<<j)))tmp+=a[i][j];
    for(int T=(S-1)&S;T>0;T=(T-1)&S){
        chmax(tmp,solve(T)+solve(S^T));
    }
    return dp[S]=tmp;
}
 
signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N;
    rep(i,0,N)rep(j,0,N)cin>>a[i][j];
    cout<<solve((1ll<<N)-1)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    string s[3];
    rep(i, 3) cin >> s[i];
    rep(i, 3) cout << s[i][0];

    
    cout << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main(void){
    int lng, a[30], m = 0;
    string s;
    cin >> s;
    lng = s.size();
    for (int i = 1; i <= 26; i++) a[i] = 0;
    for (int i = 0; i < lng; i++) {
        a[s[i] - 'a' + 1]++;
    }
    for (int i = 1; i <= 26; i++) {
        if (a[i] == 0) {
            cout << char('a' + i - 1);
            break;
        } else m++;
    }
    if (m == 26) cout << "None";
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().answer();
        }
    }

    class Solution
    {
        string N,M ;
        int T = 0;

        public Solution()
        {
            N = Console.ReadLine();
            M = Console.ReadLine();
            int j = Convert.ToInt32(N);      
            string[] M_split = new string[j];


            M_split = M.Split(' ');
            int i;
            for (i = 0; i < j ; i++)
            {
                if (i + 1 == Convert.ToInt32(M_split[i]))
                {
                    T++;
                    i++;
                }                         
            }
            //if (j % 2 == 1 && Convert.ToInt32(M_split[j - 1]) == j) { T++; }

        }

        public void answer()
        {
            Console.WriteLine(T.ToString());
        }
    }
}

Measured memory_bytes: 17376
#define R(i,n) for(i=0;i<n;i++)
t,l,b,a,I,J,s;main(n){while(scanf("%d%d%d%d",&n,&t,&l,&b),n){float d[101][101]={{}},o=0;int f[101]={};R(s,l)scanf("%d",&a),f[a]=1;R(s,b)scanf("%d",&a),f[a]=2;d[0][0]=1;R(l,t+1){o+=d[l][n];d[l][n]=0;R(b,n+1){I=l+(f[b]-1?1:2);if(I<=t)R(s,6){J=b+s+1;if(J>n)J=2*n-J;J=f[J]-2?J:0;d[I][J]+=d[l][b]/6;}}}printf("%f\n",o);}}

Measured memory_bytes: 1884
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int i = ((A + B) % 24);
		System.out.print(i);
	}
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k,s=0,t;cin>>n>>k;
	for(ll i=0;i<k;i++){
		cin>>t;
		s += t;
	}
	if(s>=n)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                int[] a = new int[3];
                for(int i = 0 ; i < 3 ; i++){
                        a[i] = sc.nextInt();
                }
                sc.close();
                Arrays.sort(a);
                if(a[0] + a[1] == a[2]){
                        System.out.println("Yes");
                }else{
                        System.out.println("No");
                }
        }
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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; }




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




void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


int main() {


  cout<<fixed<<setprecision(10);

  ll a,b,k; cin>>a>>b>>k;
  vint v;

  repf(i,1,min(a,b)+1){
    if(a%i == 0 && b%i==0){
      v.push_back(i);
    }
  }

  cout<<v[v.size()-k]<<endl;


}

//


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

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,p=0,q=0,r=0;
    cin >>n;

    for (int i = 0; i < n; i++){
        int ai;
        cin >>ai;

        if(ai%4 == 0){
            ++p;
        }else if(ai % 2 == 0){
            ++q;
        }else{
            ++r;
        }
    }
    
    if(r <= p)flag=true;
    else if(q == 0 && r == p+1)flag = true;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

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


Measured memory_bytes: 256
import functools
import math

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


k = inp()
print((k // 2) * math.ceil(k / 2))


Measured memory_bytes: 3700
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
       long X =sc.nextLong();
      
      long total = 100;
      long a =0;
      while(total<X){
        total *=1.01;
        a = a+1;
      }
      System.out.println(a);
    }
}

Measured memory_bytes: 35568