akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		if(a.equals(b)){
			System.out.print("H");
		}else{
			System.out.print("D");
		}
	}
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);

    for (auto i = 0; i < n; i++)
    {
        int ai;
        cin >> ai;
        ai -= 1;
        a[i] = ai;
    }

    for (auto i = 0; i < n; i++)
    {
        int bi;
        cin >> bi;
        b[i] = bi;
    }

    for (auto i = 0; i < n-1; i++)
    {
        int ci;
        cin >> ci;
        c[i] = ci;
    }

    int sum = b[a[0]];

    for (auto i = 1; i < n; i++)
    {
        sum += b[a[i]];
        if (a[i] - a[i - 1] == 1)
        {
            sum += c[a[i-1]];
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define N_MAX 100001
#define MOD 1000000007

void solv()
{
	long long int T1, T2, A1, A2, B1, B2;
	scanf("%lld%lld%lld%lld%lld%lld", &T1, &T2, &A1, &A2, &B1, &B2);

	if (T1*A1 + T2*A2 == T1*B1 + T2*B2){
		printf("infinity");
		return;
	}

	if (T1*A1 + T2*A2 > T1*B1 + T2*B2){
		swap(A1, B1);
		swap(A2, B2);
	}

	long long int diff = (T1*B1 + T2*B2) - (T1*A1 + T2*A2);

	long long int ret = 0;
	if (A1 > B1){
		ret = 1 + ((T1*A1 - T1*B1) / diff) * 2;
		if (0 == (T1*A1 - T1*B1) % diff){
			ret--;
		}
	}

	printf("%lld", ret);


	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------

def check(a0, a1):
    b0,b1 = a0,a1
    Ans = a1
    for i in range(N):
        # 羊
        if a1 == "S":
            # 両隣が同じ
            if S[i] == "o":
                a2 = a0
            else:
                a2 = B[a0]
        # 狼
        else:
            # 両隣が異なる
            if S[i] == "o":
                a2 = B[a0]
            else:
                a2 = a0
        Ans += a2
        a0,a1 = a1,a2
    if Ans[0] == Ans[N] and Ans[0] == b1 and Ans[N-1] == b0:
        return Ans[0:N]
    else:
        return -1

# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
S = input().rstrip()

B = {"S":"W", "W":"S"}
S0S1 = [("S","S"), ("S","W"), ("W","S"), ("W","W")]

for s0,s1 in S0S1:
    Ans = check(s0,s1)
    if Ans != -1:
        print(Ans)
        sys.exit()

print(-1)



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

int N, M;
int a[50], b[50];

int main() {
    cin >> N >> M;
    rep(i, M) cin >> a[i] >> b[i]; 

    map<int, vector<int>> ans;
    rep(i, M) {
        ans[a[i]].push_back(b[i]);
        ans[b[i]].push_back(a[i]);
    }

    rep(i, N) {
        cout << ans[i + 1].size() << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
static const int INFTY = (1<<21);

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,m[MAX][MAX];
int prim(void);


int main()
{
  int i,j,a,e;
  
  scanf("%d",&n);

  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&a);
      if(a==-1) m[i][j]=INFTY;
      else m[i][j]=a;
    }
  }

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


  return 0;
}
int prim()
{
  int x,min,i,j,res=0;
  int d[MAX],p[MAX],color[MAX];
  for(i=0;i<n;i++)
    {
      d[i] =INFTY;           /*d[n]重み最小のへんの重み p[n]にMSTにおける頂点の親記録*/
      p[i] =-1;               /*color[n] white,black,gray 記録*/
      color[i] =WHITE;

    }
  d[0]=0;


  while(1)
    {
      min =INFTY;
      x= -1;
      for(i=0;i<n;i++)
	{
	  if(min> d[i] && color[i]!=BLACK)
	    {
	      x=i;
	      min=d[i];
	    }
	}
      if(x==-1) break;
      color[x]=BLACK;
      for(j=0;j<n;j++)
	{
	  if(color[j]!=BLACK && m[x][j]!= INFTY)
	    {
	      if(d[j]> m[x][j])
		{
		  d[j]=m[x][j];
		  p[j] =x;
		  color[j] =GRAY;
		}
	    }
	}
    }
  for(i=0;i<n;i++)
    {
      if(p[i]!=-1)res+=m[i][p[i]];
    }
  return res;
}

			       





Measured memory_bytes: 1992
import java.util.*;

public class Main {
	
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int n = sc.nextInt();
		int c = sc.nextInt();
		int k = sc.nextInt();
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = sc.nextInt();
		}
		Arrays.sort(t);
		
		int result = 0;
		int j = 1;
		int i = 0;
		while(i < n){
			if(j < n){
				if (t[j] <= t[i] + k && (j - i) < c ) {
					j++;
					continue;
				}
				result++;
				i = j;
				j = i + 1;
			}
			else {
				result++;
				break;
			}
		}
		System.out.println(result);
	}

}


Measured memory_bytes: 49892
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <unordered_set>

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
3
abc
arc
agc
)");
#define cin input
#endif

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

	unordered_set<string> dict;

	char last = '\0';
	REP (i, n)
	{
		string s;
		cin >> s;
		if (last && s.front() != last || dict.count(s))
		{
			cout << "No" << endl;

			return 0;
		}
		last = s.back();
		dict.insert(s);
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

    String w = sc.nextLine();

    int count = 0;

    while (true) {
        String[] t = sc.nextLine().split(" ");

        if (t.length > 0 && "END_OF_TEXT".equals(t[0])) break;

        for (String s : t) {
            count += s.toLowerCase().equals(w) ? 1 : 0;
        }
    }

    System.out.println(count);
  }
}


Measured memory_bytes: 26272
#include <stdio.h>

int main() {
int N;
scanf("%d",&N);
int a[N+1];
int count=0;
for(int i=0;i<N;i++){
  scanf("%d",&a[i]);
}
 for(int j=0;a[j]!='\0';j++){
 if(a[j]%2==1&&j%2==0){
   count++;
 }
 }
printf("%d",count);
}

Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<string>
#include<math.h>
#include<map>
#include<deque>
#include<unordered_map>
using namespace std;

int main(){
    int n;
    cin>>n;
    int ar[n+1][3];
    for(int i=1;i<=n;i++){
        cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
    }
    int dp[n+1][3];
    dp[1][0] = ar[1][0];
    dp[1][1] = ar[1][1];
    dp[1][2] = ar[1][2];
    
    for(int i=2;i<=n;i++){
        dp[i][0] = ar[i][0] + max(dp[i-1][1],dp[i-1][2]);
        dp[i][1] = ar[i][1] + max(dp[i-1][0],dp[i-1][2]);
        dp[i][2] = ar[i][2] + max(dp[i-1][0],dp[i-1][1]);
    }

    int res = max(dp[n][0],max(dp[n][1],dp[n][2]));
    cout<<res;
    
}


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

#define task "B"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 102;
int n, a[N];
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    int ans = 0;
    rep(i, 1, n - 2) rep(j, i + 1, n - 1) rep(k, j + 1, n) if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
    {
        if (a[i] + a[j] > a[k] && a[k] > abs(a[i] - a[j])) ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

struct edge { int to, cost; };
typedef pair<int, int> P;

int N, M;
vi A, B;
vector<vector<edge>> G;


int main() {
    cin >> N >> M;
    A.resize(M); B.resize(M);
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }

    G.resize(N);
    rep(i, M) {
        G[A[i]].push_back(edge{B[i], 1});
        G[B[i]].push_back(edge{A[i], 1});
    }

    vi pre(N);
    vi d(N, INF);

    priority_queue<P, vector<P>, greater<P>> pq;
    d[0] = 0;
    pq.push(P{0, 0});

    while (!pq.empty()) {
        P p = pq.top(); pq.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i, G[v].size()) {
            edge e = G[v][i];

            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                pq.push(P{d[e.to], e.to});
                pre[e.to] = v;
            }
        }
    }

    bool ok = true;
    rep(i, N) {
        if (d[i] == INF) ok = false;
    }

    if (ok) {
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) {
            cout << (pre[i] + 1) << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 15208
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;

int main(){
    int H, N;
    cin >> H >> N;
    vector<pair<int, int>> skills;
    int a, b;
    int max_a = 0;
    REP(i, 0, N){
        cin >> a >> b;
        // first -> ダメージ, second -> コスト
        skills.emplace_back(make_pair(a, b));
        if(max_a <= a){ max_a = a;}
    }

    vector<int> dp(H + max_a, 0);

    for(int i = 1; i < H + max_a; i++){
        vector<int> tmp(N, INF);
        for(int j = 0; j < N; j++){
            if(i >= skills[j].first) {
                tmp[j] = dp[i - skills[j].first] + skills[j].second;
            }
        }
        dp[i] = *min_element(tmp.begin(), tmp.end());
    }

    int ans = INF;
    for(int i = H; i < H + max_a; i++){
        if(ans >= dp[i]){ ans = dp[i];}
    }
    p(ans);

}

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

using namespace std;

int main(){
  int n;

  cin >> n;

  string taro,hanako;
  int tarop=0,hanakop=0;

  for(int i=0;i<n;i++){
    cin >> taro >> hanako;
    if(taro>hanako){
      tarop+=3;
    }
    else if (taro<hanako){
      hanakop+=3;
    }
    else{
      tarop++;
      hanakop++;
    }
  }

  cout << tarop << " " << hanakop << endl;
  return 0;
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int H,W;
int A[2222][2222];
int ma;

int idx[2222];

bool C(int d){
    int lim=ma-d;

    for(int i=0;i<H;i++){
        idx[i]=0;
        for(int j=0;j<W;j++){
            if(A[i][j]<lim)break;
            idx[i]++;
        }
        if(i)chmin(idx[i],idx[i-1]);
        int latte=-1;
        rep(j,W)if(A[i][j]==ma)latte=j+1;
        if(latte>idx[i])return false;
    }

    int l=INT_MAX,r=0;
    rep(i,H){
        for(int j=idx[i];j<W;j++){
            chmin(l,A[i][j]);
            chmax(r,A[i][j]);
        }
    }
    return r-l<=d;
}

int ans;

void solve(){
    int lb=-1,ub=1000000000;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }
    chmin(ans,ub);
}

signed main(){
    scanf("%lld%lld",&H,&W);
    rep(i,H)rep(j,W)scanf("%lld",&A[i][j]),chmax(ma,A[i][j]);

    ans=INT_MAX;
    rep(i,2){
        rep(j,2){
            solve();
            rep(k,H)reverse(A[k],A[k]+W);
        }
        rep(l,W){
            for(int k=0;k<H/2;k++)swap(A[k][l],A[H-1-k][l]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 37876
# B
N = int(input())

value = []
for _ in range(N):
    tmp1, tmp2 = map(int, input().split())
    
    a = max(0, tmp1-tmp2)
    b = tmp1+tmp2
    value.append([a,b])

value = sorted(value, key=lambda x: x[1])

pre_right = value[0][1]

count = 1
for i in range(1, N):
    left = value[i][0]
    right = value[i][1]
    
    if left >= pre_right:
        count+=1
        pre_right = right      

print(count)




Measured memory_bytes: 22104
#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define co(i) cout<<i<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
    int n; cin>>n;
    int a[200001];
    FOR(i,0,n) cin>>a[i];
    int st=0,en=1;
    int nowxor=a[0],nowsum=a[0];
    LLI ans=1;
    while(en<n){
        int newxor=nowxor^a[en];
        int newsum=nowsum+a[en];
        if(newxor==newsum){
            nowxor^=a[en];
            nowsum+=a[en];
            en++;
            ans+=en-st;
        }else{
            nowxor^=a[st];
            nowsum-=a[st];
            st++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
char *s[2] = {"YES", "NO"};
char c[6], f, i;
int main(){
  c[0] = getchar();
  c[1] = getchar();
  c[2] = getchar();
  getchar();
  c[3] = getchar();
  c[4] = getchar();
  c[5] = getchar();
  for(i=0; i<3; i++){
    if(c[i] != c[5-i]){f=1;}
  }
  puts(s[f]);
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int n = nextInt();
        int k = nextInt();
        int res = 0;
        int[] arr = nextIntArr(n);
        Arrays.sort(arr);
        for (int i = 0; i < k; i++) {
            res += arr[i];
        }
        outln(res);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 33240
require 'prime'

n = gets.to_i
divisors = Prime.prime_division(n)

def f(a, b)
  [a.to_s.size, b.to_s.size].max
end

products = Array.new(divisors.size + 1) { Array.new }

products[0] << 1

divisors.each_with_index do |(divisor, number), index|
  (0..number).each do |num|
    products[index].each do |product|
      if num == 0
        products[index + 1] << product
      else
        products[index + 1] << product * divisor ** num
      end
    end
  end
end

ans = []
products.last.each do |a|
  b = n / a
  ans << f(a, b)
end
puts ans.min


Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll x,y,cnt=0,ans;
	cin>>x>>y;
	if(x>y) swap(x,y);
	ans=x;
	while(ans<=y)
	{
		cnt++;
		ans=ans*2;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cfenv>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    vector<double> val(n);
    rep(i, n) cin >> val[i];

    double x = 0;
    double y = 0;

    for(int i = 0; i < n-1; ++i){
        sort(val.rbegin(), val.rend());
        x = val.back();
        val.pop_back();
        y = val.back();
        val.pop_back();
        val.push_back((x+y)/2);
    }

    cout << val[0] << endl;
}


Measured memory_bytes: 888
#include<iostream>
    #include <bits/stdc++.h>
    #include<cmath>
    using namespace std;
    int main()
    {
        int n,k,count=0;
        cin>>n>>k;
        int arr[n];
        for(int i=0; i<n; i++)
        cin>>arr[i];
      sort(arr, arr+n);
       for(int j=0;j<k;j++)
       count=count+arr[j];
       cout<<count;
    }

Measured memory_bytes: 3580
def main():
    N = int(input())
    flag = True
    tascs = []
    for _ in range(N):
        a, b = map(int, input().split(" "))
        tmp = [a, b]
        tascs.append(tuple(tmp))
    tascs.sort(key=lambda x: x[1])
    passed_time = 0
    for tasc in tascs:
        passed_time += tasc[0]
        if passed_time > tasc[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 31872
N, Y = [int(x) for x in input().split()]

for i in range(N + 1):
    for j in range(N + 1):
        k = N - i - j
        if k < 0:
            continue
        if i * 1000 + j * 5000 + k * 10000 == Y:
            print(k, j, i)
            exit()

print("-1 -1 -1")


Measured memory_bytes: 66204
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int>memo(10001, 0);
    for (int x=1; x<=100; x++) {
        for (int y=1; y<=100; y++) {
            for (int z=1; z<=100; z++) {
                int m = pow(x, 2.0) + pow(y, 2.0) + pow(z, 2.0) + (x * y) + (y * z) + (z * x);
                if (m > 10000) {
                    break;
                }

                memo[m] = memo[m] + 1;
            }
        }
    }

    for (int i=1; i<=N; i++) {
        cout << memo[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll h,w;
	cin >> h >> w;
	string s[h];
	FOR(i,0,h){
		cin >> s[i];
	}
	ll ans = 0;
	queue<P> a;
	FOR(i,0,h){
		FOR(j,0,w){
			if(s[i][j]=='#'){
				a.push({i,j});
			}
		}
	}
	while(!a.empty()){
		ans++;
		queue<P> b;
		while(!a.empty()){
			ll x = a.front().first;
			ll y = a.front().second;
			a.pop();
			if(x>0&&s[x-1][y]=='.'){
				b.push({x-1,y});
				s[x-1][y] = '#';
			}
			if(x<(h-1)&&s[x+1][y]=='.'){
				b.push({x+1,y});
				s[x+1][y] = '#';
			}
			if(y>0&&s[x][y-1]=='.'){
				b.push({x,y-1});
				s[x][y-1] = '#';
			}
			if(y<(w-1)&&s[x][y+1]=='.'){
				b.push({x,y+1});
				s[x][y+1] = '#';
			}
		}
		a = b;
	}
	cout << ans-1 << endl;
}


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

int main(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    int max = 0;
    rep(i, k){
        vector<char> a;
        for(int j = i; j < n; j+=k){
            a.push_back(t[j]);
        }
        // rep(j, a.size()) cout << a[j];
        // cout << endl;
        if(a[0] == 'r') max += p;
        if(a[0] == 's') max += r;
        if(a[0] == 'p') max += s;
        for(int j = 1; j < a.size(); j++){
            if(a[j] == a[j-1]){
                a[j] = 'a';
            }else{
                if(a[j] == 'r') max += p;
                if(a[j] == 's') max += r;
                if(a[j] == 'p') max += s;
            }
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 640
from fractions import gcd
import math
a, b, c, d = [int(item) for item in input().split()]
a = abs(a - c)
b = abs(b - d)
if a > b:
    a, b = b, a
g = gcd(a, b)
a //= g; b //= g

print((a + b - 1) * g)

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

const int mod = 1e9+7;

ll dp[100100];

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

    if (abs(n-m) > 1) {
        cout << 0 << endl;
        return 0;
    }

    dp[0] = 0;
    dp[1] = 1;
    for (int i=2; i<=max(n,m); ++i) {
        dp[i] = dp[i-1] * i % mod;
    }

    if (n == m) {
        cout << (dp[n]*dp[n]%mod) * 2 % mod << endl;
    }
    else {
        cout << dp[max(n, m)] * dp[min(n, m)] % mod << endl;
    }


}


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

int main() {
	// your code goes here
    int x,y,c=0,d=0;
    int a[7]={1,3,5,7,8,10,12};
    int b[4]={4,6,9,11};
    cin>>x>>y;
    if(x==2||y==2){cout<<"No"<<endl;return 0;}
    for(int i=0;i<7;++i){
    	if(x==a[i])c++;
    	if(y==a[i])c++;
    }
    for(int i=0;i<4;++i){
    	if(x==b[i])d++;
    	if(y==b[i])d++;
    }
    if((d==0&&c==2)||(d==2&&c==0))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
	return 0;
}

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

const int MAX=100001;
int N;
vector<int> S(MAX,0);
vector<bool> T(MAX,false);
void DP(int u){
    for(int i=1;i<u;i++){
        for(int j=0;j<N;j++){
            if(i-S[j]<0) break;
            else if(T[i-S[j]]==false){
                T[i]=true;
                break;
            }
        }
    }
}

int main(){

    int K;
    cin>>N>>K;
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    DP(K+1);
    if(T[K]==true) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();
        int l = input.nextInt();

        int sum = 0;
        int ex = 0;

        for (int i = 1; i <= n; i++) {
        	sum += i;
        }

        if (l - 1 >= 0) {
        	ex = 1;
        } else if (l - 1 <= n * (-1)) {
        	ex = n;
        } else {
        	ex = 1 - l;
        }

        sum -= ex;

        int ans = (n - 1) * (l - 1) + sum;

        System.out.println(ans);

    }
}


Measured memory_bytes: 23252
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N, R = map(int, input().split())
    if N >= 10:
        print(R)
    else:
        print(R + 100 * (10 - N))


if __name__ == '__main__':
    main()

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

int a, b, c;

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

    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final Scanner sc  = new Scanner(System.in);
    static final int MOD = (int) 1E9 + 7;
    static final int INF = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        String s = nstr();
        if (s.equals("Sunny")) {
            System.out.println("Cloudy");
        } else if (s.equals("Cloudy")) {
            System.out.println("Rainy");
        } else if (s.equals("Rainy")) {
            System.out.println("Sunny");
        }
    }
    
    
    private static int nint() {
        return sc.nextInt();
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static double ndouble() {
        return sc.nextDouble();
    }
    
    private static double[] ndoubles(int n) {
        return ndoubles(n, 0, 0);
    }
    
    private static double[] ndoubles(int n, int padL, int padR) {
        double[] d = new double[n + padL + padR];
        for (int i = 0; i < n; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }
    
    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0, 0);
    }

    private static char[][] nchars2(int h, int w, int padLU, int padRD) {
        char[][] a2 = new char[h + padLU + padRD][w + padLU + padRD];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, w);
        return a2;
    }
    
    private static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }
    
    private static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }
    
    private static long abs(long a, long b) {
        return Math.abs(a - b);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N+1,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }

    N = N + 1;


  vector<int> cnt_vec(100001,0);
  vector<int> out_vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cnt_vec[vec[i]]++;
  }
  for (int i = 0; i <=100000; i++)
  {
    cnt_vec[i+1] += cnt_vec[i];
  }

  for (int i = N-2   ; i >= 0; i--)
  {
    int target = vec[i];
    int suf = cnt_vec[target];
    out_vec[suf-1] = target;
    cnt_vec[target]--;
  }

  for (int i = 1; i < N; i++)
  {
    if(i - 1)cout<<" ";
    cout<<out_vec[i];
  }

  cout<<endl;
  
  
  
  
  

  return;  
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(8);

  solve();

 
  return 0;
}


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

int main()
{
  int a, p;
  cin >> a >> p;
  int apple = 0;
  apple = a*3;
  int pie = 0;
  pie = (apple + p)/2;
  cout << pie << endl;

}


Measured memory_bytes: 256
N = int(input())
dic = {}

for _ in range(N):
    S = input()
    if S in dic.keys():
        dic[S] += 1
    else:
        dic[S] = 1

dic = sorted(dic.items(), key=lambda x:x[1])

v = dic[-1][1]
ans = []

for d in dic:
    if d[1] == v:
        ans.append(d[0])

for a in sorted(ans):
    print(a)
    


Measured memory_bytes: 43228
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;

int n,m,k,ans=0;
int jc[200005];

int quick_power(int a,int b)
{
	a%=mod;
	
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod;
	}
	return res%mod;
}

int ny(int a)
{
	return quick_power(a,mod-2)%mod;
}

int C(int nn,int kk)
{
	if (kk==0||nn==kk)  return 1;
	else return ((jc[nn]*ny(jc[kk]%mod))%mod*ny(jc[nn-kk]%mod))%mod;
}

signed main()
{
	cin>>n>>m>>k;
	jc[0]=1;
	
	for (int i=1;i<=200000;i++)  jc[i]=(jc[i-1]*i)%mod;
	for (int t=n-k;t<=n;t++)
	{
		int first=(C((n-1)%mod,t-1)%mod),second=(m*quick_power((m-1)%mod,t-1))%mod;
		ans=(ans+((first*second)%mod))%mod;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 5204
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] s = new String[N];
		for(int i = 0;i < N;i++) {
			s[i] = sc.next();
		}
		sc.close();

		int cnt = 0;
		int lastA = 0;
		int firstB = 0;
		int lastA_And_firstB = 0;
		for(int i = 0;i < N;i++) {
			for(int j = 0;j < s[i].length()-1;j++) {
				if(s[i].substring(j,j+2).equals("AB")) {
					cnt++;
				}
			}
		}
		for(int i = 0;i < s.length;i++) {
			if(s[i].startsWith("B") && s[i].endsWith("A")) {
				lastA_And_firstB++;
			}else if(s[i].startsWith("B") && !s[i].endsWith("A")) {
				firstB++;
			}else if(!s[i].startsWith("B") && s[i].endsWith("A")) {
				lastA++;
			}
		}
		if(lastA_And_firstB == 0) {
			cnt += Math.min(lastA, firstB);
		}else{
			if(lastA + firstB > 0) {
				cnt += (lastA_And_firstB + Math.min(lastA, firstB));
			}else {
				cnt += (lastA_And_firstB - 1);
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 32488
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
C = Counter(A)

MAXN = max(A)
B = [False]*(MAXN+1)
for c in C.most_common():
    B[c[0]] = True
ans = 0
for i in range(MAXN + 1):
    if B[i]:
        if C[i]==1:
            ans += 1
        B[i::i] = [False]*(MAXN//i)
print(ans)

Measured memory_bytes: 52196
n,m = map(int,input().split())
lstpy = [list(map(int,input().split()))+[i] for i in range(m)]

lstpy.sort(key=lambda x:(x[0],x[1]))
pref = 0

for i in range(m):
    if  pref != lstpy[i][0]:
        pref = lstpy[i][0]
        cnt = 1
    else:
        cnt += 1
    num = "0"*(6-len(str(pref)))+str(pref)+"0"*(6-len(str(cnt)))+str(cnt)
    lstpy[i].append(num)

lstpy.sort(key=lambda x:x[2])
for i in range(m):
    print(lstpy[i][3])

Measured memory_bytes: 34740
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N, Y;
    cin >> N >> Y;
    for(int x = 0; x <= N; x++) {
        for(int y = 0; 5000 * y <= Y - 1000 * x; y++) {
            if((Y - 1000 * x - 5000 * y) / 10000 == N - x - y &&
               (Y - 1000 * x - 5000 * y) % 10000 == 0) {
                cout << N - x - y << " " << y << " " << x << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
S = raw_input()

if S == 'SUN':
    print 7
elif S == 'MON':
    print 6
elif S == 'TUE':
    print 5
elif S == 'WED':
    print 4
elif S == 'THU':
    print 3
elif S == 'FRI':
    print 2
elif S == 'SAT':
    print 1


Measured memory_bytes: 2568
package main

import (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	if len(b) == 0 {
		test()
	} else {
		solve(bytes.NewReader(b), os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n int // number of participants
	var m int // number of languages
	fmt.Fscanln(r, &n, &m)

	g := make(map[int][]int)

	for i := 0; i < n; i++ {
		var langs int
		fmt.Fscan(r, &langs)
		g[i] = make([]int, 0, langs)
		for j := 0; j < langs; j++ {
			var lang int
			fmt.Fscan(r, &lang)
			langi := n + lang - 1
			g[i] = append(g[i], langi)
			g[langi] = append(g[langi], i)
		}
	}

	seen := make([]bool, n+m)
	q := []int{0}
	for len(q) > 0 {
		v := q[0]
		q = q[1:]
		if !seen[v] {
			seen[v] = true
			q = append(q, g[v]...)
		}
	}

	for i := 0; i < n; i++ {
		if !seen[i] {
			fmt.Fprintln(w, "NO")
			return
		}
	}
	fmt.Fprintln(w, "YES")
	return
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `4 6
3 1 2 3
2 4 2
2 4 6
1 6`,
			want: `YES
`,
		},
		{
			in: `4 4
2 1 2
2 1 2
1 3
2 4 3`,
			want: `NO
`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(tt.in), buf)
		if got := buf.String(); got != tt.want {
			fmt.Printf("%d: got %v, want %v\n", i, got, tt.want)
		}
	}
}


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

int main() {
  string S;
  cin >> S;
  int price = 700;
  for(int i=0;i<3;i++){
    if(S.at(i)=='o'){
      price = price + 100;
    }
  }
  cout << price;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class BHomework {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int m = in.readInt();
            int[] a = new int[m];
            long sum = 0;

            for (int i = 0; i < m; i++) {
                a[i] = in.readInt();
                sum += a[i];
            }

            System.out.println(sum > n ? -1 : n - sum);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32660
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] arr = new int[3];
    arr[0]=sc.nextInt();
    arr[1]=sc.nextInt();
    arr[2]=sc.nextInt();
    Arrays.sort(arr);
    System.out.println(arr[2]-arr[0]);
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <functional>
using namespace std;

int min_val = 99999;

template<class T>
void combination(const vector<T>& seed, int target_size, bool (*callback)(const vector<T>&)) {
    vector<int> indices(target_size);
    const int seed_size = seed.size();
    int start_index = 0;
    int size = 0;

    while (size >= 0) {
        for (int i = start_index; i < seed_size; ++i) {
            indices[size++] = i;
            if (size == target_size) {
                vector<T> comb(target_size);
                for (int x = 0; x < target_size; ++x) {
                    comb[x] = seed[indices[x]];
                }
                if (callback(comb)) return;
                break;
            }
        }
        --size;
        if (size < 0) break;
        start_index = indices[size] + 1;
    }
}

///////////////// How to use

bool my_callback(const vector<int>& comb) {
    int n = comb.size();
	int sum=0;
    for (int i=0; i<n; ++i)
        sum+=comb[i];
    if(sum < min_val)
		min_val=sum;
    return false;
}

int main()
{
	int n,tmp;
	vector<int> v;

	n=3;

	for (int i = 0; i < n; i++) {
		scanf("%d", &tmp);
		v.push_back(tmp);
	}
	
	combination(v, 2, my_callback);
	cout << min_val << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	int a,b,c;

	cin >> a >> b >> c;


	if (c == 1)
	{
		cout << "Open" << endl;
	}
	else if (b == 1 && a == 1)
	{
		cout << "Open" << endl;
	}
	else
	{
		cout << "Close" << endl;
	}
}



Measured memory_bytes: 3092
s = input()

n = len(s)

kai = str()
for i in range(n):
    kai = kai + s[n-1-i]

strong = 0

if kai == s:
    strong = strong + 1

nf = int(((n-1)/2)-1)

kaif = str()
for i in range(nf):
    kaif = kaif + s[nf-i]

if kaif == s[0:nf]:
    strong = strong + 1

ns = int((n+3)/2)

kais = str()
for i in range(n-ns):
    kais = kais + s[n-i-1]

if kais == s[ns-1:n-1]:
    strong = strong + 1

if strong == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
 
string vbString(int Number,string Character){
        string res="";
        for(int i=0;i<Number;i++) res+=Character;
        return res;
}
string checksnake(string s){
        string t;
        for(int i=1;i<100;i++){
                t=">'"+vbString(i,"=")+"#"+vbString(i,"=")+"~";
                if(t==s) return "A";
        }
 
        for(int i=1;i<100;i++){
                t=">^"+vbString(i,"Q=")+"~~";
                if(t==s) return "B";
        }
       return "NA";
 
}
int main(){
        int n;
        cin >> n;
        while(n--){
		string s;
                cin >> s;
                cout << checksnake(s) << endl;
         }
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#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 rep_rev(i, n) for (int i = n-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

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

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}

template<class... T>
void debug_print(T... args){
    vector<lint> tmp = initializer_list<lint>{args...};
    print_vec(all(tmp));
}
template<class T>
void print(T a){ cout << a << endl;}

vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

int ord(char x){ return (int)(x - 'a');}
char chr(lint x){ return (char)(x + (lint)('a'));}
lint mod = 1e9+7;
// lint mod = 

lint sum(vlint a){lint ret = 0; for(auto&& v:a) ret += v; return ret;}
int main(){
    INT(n);
    vlint ans9(n+1, 0), ans6(n+1, 0);
    ans9[1] = 1; ans6[1] = 1;
    vlint exp9(20, 1); rep(i, 19) exp9[i+1] = exp9[i]*9;
    vlint exp6(21, 1); rep(i, 20) exp6[i+1] = exp6[i]*6;
    for (int i = 2; i <= n; ++i){
        ans9[i] = 1 + ans9[i - exp9[ub(exp9, i)-1]];
        ans6[i] = 1 + ans6[i - exp6[ub(exp6, i)-1]];
    }
    lint ans = LLONG_MAX;
    rep(i, n+1){
        chmin(ans, ans6[i] + ans9[n-i]);
    }
    print(ans);

    
    
}


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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int x, n;
    cin >> x >> n;
    set<int> p;
    int bf;
    rep(i, n) {
        cin >> bf;
        p.insert(bf);
    }

    int i = 0;
    while(1) {
        if(!p.count(x - i)) {
            cout << x - i << endl;
            return 0;
        } else if(!p.count(x + i)) {
            cout << x + i << endl;
            return 0;
        }
        i++;
    }
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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

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


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

int main(){
  vector<char>a(10);
  for(int i=0;i<10;i++)
    cin >> a.at(i);
  vector<char>b(0);
  for(int i=0;i<10;i++){
    if(a.at(i)=='1')
      b.push_back('1');
    if(a.at(i)=='0')
      b.push_back('0');
    if(a.at(i)=='B'){
      if(b.size()>0)
        b.pop_back();
    }
  }
  for(int i=0;i<b.size();i++)
    cout << b.at(i);
  cout << endl;
}

Measured memory_bytes: 3616