akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <list>
#include <tuple>
#include <queue>
#include <bitset>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

int main(){
  long long N;
  std::cin >> N;
  vector<long long> a(N-1);
  vector<long long> b(N-1);
  vector<long long> c(N);

  for (int i = 0; i < N-1; i++) {
    std::cin >> a[i] >> b[i];
  }

  for (int i = 0; i < N; i++) {
    std::cin >> c[i];
  }

  vector<list<long long>> g(N, list<long long>());

  for (int i = 0; i < N-1; i++) {
    g[a[i]-1].push_back(b[i]-1);
    g[b[i]-1].push_back(a[i]-1);
  }

  vector<pair<long long, long long>> li(N, pair<long long, long long>(-1LL, -1LL));
  li[0] = make_pair(1, 0);
  queue<long long> q;
  q.push(0);

  long long x;
  long long next;
  while(!q.empty()) {
    x = q.front();
    for (auto&& var : g[x]) {
      if (li[var] == make_pair(-1LL, -1LL)) {
        q.push(var);
        li[var] = make_pair(li[x].first+1, var);
      }
    }
    q.pop();
  }

  sort(li.begin(), li.end());
  sort(c.begin(), c.end());

  vector<long long> ans(N);

  for (int i = 0; i < N; i++) {
    ans[li[N-1-i].second] = c[i];
  }

  long long m = 0;
  for (int i = 0; i < N-1; i++) {
    m += c[i];
  }

  std::cout << m << std::endl;

  for (int i = 0; i < N; i++) {
    std::cout << ans[i];
    if (i != N-1) {
      std::cout << " ";
    }
  }

  std::cout << std::endl;

  return 0;
}


Measured memory_bytes: 1664
str = gets.to_s.chomp
words = ['dream', 'dreamer', 'erase', 'eraser']

while !str.empty?
  if words[1] == str[-words[1].length .. str.length]
    str = str[0 .. -words[1].length-1]
  elsif words[3] == str[-words[3].length .. str.length]
    str = str[0 .. -words[3].length-1]
  elsif words[0] == str[-words[0].length .. str.length]
    str = str[0 .. -words[0].length-1]
  elsif words[2] == str[-words[2].length .. str.length]
    str = str[0 .. -words[2].length-1]
  else
    puts 'NO'
    break
  end
end
puts 'YES' if str.empty?



Measured memory_bytes: 53144
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));
struct Unionfind{
    vector<int> data;
    Unionfind(int size):data(size, -1) {}
    bool unite(int x, int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x!=y;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int root(int x){
        return (data[x] < 0) ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int m; cin >> m;
    Unionfind uni(n);
    vector<ll> num(n,0);
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        num[a]++;
        if(!uni.same(a,b)) uni.unite(a,b);
    }
    vector<bool> v(n,0);
    ll ans=0;
    rep(i,n){
        int rt=uni.root(i);
        if(!v[rt]){
            v[rt]=1;
            ans++;
        }
    }
    cout << ans-1 << endl;
    
}




Measured memory_bytes: 4516
import sys

s_args = sys.stdin.read().splitlines()

s_args = s_args[0].split(' ')

a = int(s_args[0])
b = int(s_args[1])
c = int(s_args[2])

eo = []
res = 0

if a % 2 == 0:
    eo.append('a')
if b % 2 == 0:
    eo.append('b')
if c % 2 == 0:
    eo.append('c')

if len(eo) != 0 and len(eo) != 3:
    res += 1
    if len(eo) == 1:
        if not 'a' in eo:
            a += 1
        if not 'b' in eo:
            b += 1
        if not 'c' in eo:
            c += 1
    elif len(eo) == 2:
        if 'a' in eo:
            a += 1
        if 'b' in eo:
            b += 1
        if 'c' in eo:
            c += 1

n = [a, b, c]
n.sort()
res += (n[2] - n[0]) // 2
res += (n[2] - n[1]) // 2

print(res)


Measured memory_bytes: 3064
def debug_print(maze):
    for xx in maze:
        print(xx)
#        for yy in xx:
#            print(yy)

def clear_maze(h,w,sx, sy, gx, gy, maze):
#    debug_print(maze)
    INF = 100000000
    distance = [[INF for _ in range(w)] for _ in range(h)]
    def bfs():
        queue = []
        queue.insert(0, (sy, sx))
        distance[sy][sx] = 0
        while len(queue):
            y, x = queue.pop()
            if x == gx and y == gy:
                break
            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
                if (0<= nx <w and 0<= ny <h and maze[ny][nx] != '#' and distance[ny][nx] == INF):
                    queue.insert(0, (ny, nx))
                    distance[ny][nx] = distance[y][x] + 1
        return distance[gy][gx]
    return bfs()
###########################################

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')

H, W = LI()
cur = int(0)
S = [list(str(input().rstrip('\n'))) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            cur +=1
#print (clear_maze(H,W,0,0,W-1,H-1,S))
ans = H*W - (clear_maze(H,W,0,0,W-1,H-1,S) + 1 + cur)
if ans<0:
    ans = -1
print(ans)

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int ar[n+1],ptr[n+1];
    for(int i=0;i<n;i++){
        cin>>ar[i];
        ptr[i] = ar[i];
    }
    sort(ptr,ptr+n);
    for(int i = 0;i<n;i++){
        if(ar[i] == ptr[n-1]){
            cout<<ptr[n-2]<<endl;
        }
        else{
            cout<<ptr[n-1]<<endl;
        }
    }

}


Measured memory_bytes: 3200
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;


int main(){
    int N,K;
    cin>>N>>K;
    int x[1000];
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>x[i];
        int a=min(x[i]-0,abs(x[i]-K));
        ans+=a*2;
    }
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define pb push_back
#define si second
#define int unsigned long long
#define mod 1000000007
#define debug(x) cout << #x << " " << x <<endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define double long double
#define all(o) o.begin(),o.end()
using namespace std;
int power(int x, int y)
{
    int res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1; // y = y/2
        x = (x*x) % mod;
    }
    return res%mod;
}
int inv(int  n)
{
    return power(n,mod-2)%mod;
}


int a[2000005],p[1000006];
int32_t main(){

    fast
    int n,i,j;
    int ans=0;
    cin>>n;
    for(i=1;i<=1000;i++)
        p[i*i]=1;
    for(i=2;i<=1e6;i++)
    {
        if(a[i]==0){
            for(j=i;j<=1e6;j+=i)
                if(a[j]==0)
                    a[j]=i;
        }
    }
    for(i=1;i<n;i++){
        int rem=n-i;
        int per=p[rem];
        map<int,int> mp;
        
        while(rem>1)
        {
            mp[a[rem]]++;
            rem/=a[rem];
        }
        int c=1;
        for(auto x:mp)
            c*=(x.si+1);
        ans+=c;
    }
    cout<<ans<<"\n";
}




 

Measured memory_bytes: 14956
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const int INF=1001001001;
const int MOD=1000000007;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}



int main() {
  int n,m;
  cin>>n>>m;
  vector<ll>x(m);
  priority_queue <int> q;;
  rep(i,m){
    cin>>x[i];
  }
  sort(x.begin(),x.end());
rep(i,m-1){
  q.push(x[i+1]-x[i]);
}
int ans=x[m-1]-x[0];
rep(i,n-1){
  if (q.empty())break;
  ans-=q.top();
  q.pop();

}
cout<<ans;

  }


Measured memory_bytes: 1660
import sys


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


input = sys.stdin.readline

N = int(input())

arr = [LIST() for _ in range(N)]

dp = [[0 for _ in range(3)] for _ in range(N + 1)]

for i in range(0, N):
    for j in range(3):
        for k in range(3):
            if j == k: continue
            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + arr[i][k])

print(max([dp[N][j] for j in range(3)]))


Measured memory_bytes: 47328
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll a, b, c, d;
	ll cnt, ccnt, dcnt, cdcnt;
	cin >> a >> b >> c >> d;
	cnt = b - a + 1LL;
	ccnt = (b / c) - ((a-1LL) / c);
	dcnt = (b / d) - ((a-1LL) / d);
	cdcnt = (b / lcm(c,d)) - ((a-1LL) / lcm(c,d));
	cout << cnt + cdcnt - (ccnt + dcnt) << endl;
	return 0;
}


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

int main(){
  int h, w; cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; i++){
    cin >> s.at(i);
  }
  vector<vector<int>> a(h,vector<int>(w)), b(h,vector<int>(w));
  for (int i = 0; i < h; i++){
    if (s.at(i).at(0) == '#') a.at(i).at(0) = 0;
    else  a.at(i).at(0) = 1;
  }
  for (int i = 0; i < w; i++){
    if (s.at(0).at(i) == '#') b.at(0).at(i) = 0;
    else b.at(0).at(i) = 1;
  } 
  for (int i = 0; i < h; i++){
    for (int j = 1; j < w; j++){
      if (s.at(i).at(j) == '#') a.at(i).at(j) = 0;
      else a.at(i).at(j) = a.at(i).at(j-1) + 1;
    }
  }
  for (int i = 0; i < h; i++){
    for (int j = w-2; j >= 0; j--){
      if (s.at(i).at(j) == '.' && s.at(i).at(j+1) == '.') a.at(i).at(j) = a.at(i).at(j+1); 
    }
  }
  for (int i = 0; i < w; i++){
    for (int j = 1; j < h; j++){
      if (s.at(j).at(i) == '#') b.at(j).at(i) == 0;
      else b.at(j).at(i) = b.at(j-1).at(i) + 1;
    }
  }
  for (int i = 0; i < w; i++){
    for (int j = h-2; j >= 0; j--){
      if (s.at(j).at(i) == '.' && s.at(j+1).at(i) == '.') b.at(j).at(i) = b.at(j+1).at(i);
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      ans = max(ans, a.at(i).at(j) + b.at(i).at(j));
    }
  }
  cout << ans-1 << endl;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define VA AnhNguyenProV2
#define pb push_back
#define FOR(i, a, b) for(int i = int(a); i <= int(b); i++)
#define FORD(i, a, b) for(int i = int(a); i >= int(b); i--)
#define REP(i, r) for(int i = 0; i < r; i++)
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define READFILE freopen("input.txt", "r", stdin)
#define WRITEFILE freopen("output.txt", "w", stdout);
#define ii pair<int, int>
#define ll long long
#define fi first
#define se second
#define MAX ??? 
using namespace std;
 
int tmp,n,a[11],k;

bool Ok(int n)
{
	while (n>0)
	{
		int tmp=n%10; if (a[tmp]) return false;
		n/=10;
	}
	return true;
}

int main()
{
    #ifndef ONLINE_JUDGE
        //READFILE;
    #endif
    FAST;
    
 	cin >> n >> k;
 	FOR(i,1,k) cin >> tmp, a[tmp]=true;

 	while (!Ok(n))
 	{
 		n++;
 	}
 	cout<<n;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 1e5 + 5;
const int Mod = 1e9 + 7;


int main()
{
    LL r, D, x;
    cin >> r >> D >> x;
    for(int i = 1; i <= 10; i++){
        LL tmp = x * r - D;
        cout << tmp << endl;
        x = tmp;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include<random>
using namespace std;
#define int long long
#define double long double
//typedef unsigned long long ulong;
typedef pair<int, int> pii;
typedef pair<int, pii > piii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 61ll)
#define mod 1000000007

int X, Y;

signed main(){
    cin >> X >> Y;
    int ans = 0;
    if(X == 1 && Y == 1){
        ans += 400000;
    }
    if(X == 1){
        ans += 300000;
    }
    if(X == 2){
        ans += 200000;
    }
    if(X == 3){
        ans += 100000;
    }
    if(Y == 1){
        ans += 300000;
    }
    if(Y == 2){
        ans += 200000;
    }
    if(Y == 3){
        ans += 100000;
    }
    cout << ans << endl;

    
    

    return 0;
}

/*

*/

Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int[] ans = new int[n];
    for(int i=1;i<n;i++){
      ans[nextInt()-1]++;
    }
    for(int i=0;i<n;i++){
      System.out.println(ans[i]);
    }




    //System.out.println();

  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

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

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

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 60552
#include<stdio.h>
int e(int a){return a<0?-a:a;}
int main(){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  printf("%s",e(a-c)>d&&(e(a-b)>d||e(b-c)>d)?"No":"Yes");
}


Measured memory_bytes: 1684
/*
ID: rajiv
TASK: test
LANG: C++14
*/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>
#include<iterator>
#include<random>
#include<chrono>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ONLINE_JUDGE

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
int rnd(int a, int b){ // including a and b
	return a+(rng()%(b-a+1));
}
#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sortr(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb push_back
#define endl '\n'

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

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

void solve(){
	int w,h,n; cin>>w>>h>>n;
	int xb=0, xe=w, yb=0, ye=h;
	int xi,yi,a;
	rep(i,n){
		cin>>xi>>yi>>a;
		if(a==1){
			xb=max(xb, xi);
		}else if(a==2){
			xe=min(xe, xi);		
		}else if(a==3){
			yb=max(yb, yi);
		}else{
			ye=min(ye, yi);
		}
	}
	//deb(xb, xe, yb, ye)
	if(yb<=ye and xb<=xe){
		cout<<((xe-xb)*(ye-yb))<<endl;
	}else if(yb >ye or xb>xe){
		cout<<0<<endl;
	}	
}

int main(){
	fast_io
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
	#endif 
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}
/*
5 4 2
2 1 1
3 3 4

5 4 3
2 1 1
3 3 4
1 4 2

10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3
*/

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

int main(){
  ll n, m;
  cin >> n >> m;
  vector<vector<ll>> ps(m, vector<ll>(2));
  for(ll i=0; i<m; ++i){
    cin >> ps.at(i).at(0);
    string s; cin >> s;
    if(s == "AC") ps.at(i).at(1) = 1;
    else ps.at(i).at(1) = 0;
  }
  
  vector<int> acornot(n, 0);
  vector<ll> penalty(n, 0);
  for(ll i=0; i<m; ++i){
    ll index = ps.at(i).at(0) - 1;
    int result = ps.at(i).at(1);
    if(acornot.at(index) == 0){
      if(result == 1) acornot.at(index) = 1;
      else ++penalty.at(index);
    }
  }
  for(ll i=0; i<n; ++i){
    if(acornot.at(i)==0 && penalty.at(i)!=0) penalty.at(i) = 0;
  }
  
  ll acnum = accumulate(acornot.begin(), acornot.end(), 0);
  ll penum = accumulate(penalty.begin(), penalty.end(), 0);
  cout << acnum << " " << penum << endl;
  
  return 0;
}

Measured memory_bytes: 6912
a, b = map(int, input().split())

n = 0

if b == 100:
    n = a * 1000 + b
elif b >= 10:
    n = a * 100 + b
else:
    n = a * 10 + b

for i in range(10000):
    if i * i == n:
        print("Yes")
        exit(0)

print("No")


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  int w[10];
  int k[10];
  int aw = 0, ak = 0;

  REP(i, 2) {
    REP(j, 10) {
      if(!i) cin >> w[j];
      else cin >> k[j];
    }
  }

  stable_sort(w, w+10, greater<int>());
  stable_sort(k, k+10, greater<int>());
    
  REP(i, 3) {
    aw += w[i];
    ak += k[i];
  }
  cout << aw << ' ' << ak << endl;
}

Measured memory_bytes: 1220
#include <stdio.h>

int main(void) {
    int N;
    int X;
    
    scanf("%d %d",&N,&X);
    
    int m[N-1];
    for(int i = 0; i < N; i++){
        scanf("%d", &m[i]);
    }
    int min = m[0];
    for(int i = 0;i < N-1;i++){
        if(min>m[i+1]){
            min = m[i+1];
        }
    }
    for(int i=0;i<N;i++){
        X=X-m[i];
    }
    int c = 0;
    while(X>=0) {
        X = X-min;
        c++;
    }
    printf("%d\n",c-1+N);
}


Measured memory_bytes: 128
from collections import deque

def main():
    k = int(input())
    l = list(range(1, 10))
    Q = deque(l)
    for _ in range(k):
        q = Q.popleft()
        # 基準-1
        if q % 10 != 0:
            Q.append(10*q+q%10-1)
        # 基準
        Q.append(10*q+q%10)
        # 基準 + 1
        if q % 10 != 9:
            Q.append(10*q+q%10+1)
    print(q)

if __name__ == '__main__':
    main()


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

int main(){
    string s,t; cin >> s >> t;
    for(int i = 0; i < s.size(); i++) {
        if(s==t) {
            cout << "Yes" << endl;
            return 0;
        } else {
            s = s.back() + s.substr(0, s.size()-1);
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
r = 1000000007
N = 100000
l = [1]*N

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

for i in range(1,N):
    l[i] = l[i-1]+modinv(i+1,r)

N = int(input())
A = list(map(int,input().split()))

exp = 0
for i in range(N):
    exp += (l[i]+l[N-i-1]-1)*A[i]%r

ans = exp
for i in range(1,N+1):
    ans = ans*i%r
print(ans)

Measured memory_bytes: 18988
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		double total = 0;
		for (int i = 1; i <= n; i++) {
		    int x = i;
		    double base = 1.0 / n;
		    while (x < k) {
		        x *= 2;
		        base /= 2;
		    }
		    total += base;
		}
		System.out.println(total);
   }
}


Measured memory_bytes: 20820
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin>>n;
	cout<<n/3<<endl;
	return 0;
}


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

using namespace std;
int main()
{
	int N,X,T;
	cin >> N>>X>>T;
	if (N%X == 0) {
		cout << (N / X * T);
	}
	else {
		cout << ((N / X+1) * T);

	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
map<long,long>mp;
int main()
{
    long i,j,t,a,b,n,c,y,m,prev,sum,ans=1;
    t=1;
    // cin>>t;
    while(t--)
    {
       int arr[3];
       cin>>arr[0]>>arr[1]>>arr[2];
       sort(arr,arr+3);
       if(arr[0]!=arr[1])cout<<arr[0];
       else cout<<arr[2];
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
bool ss(pii &a,pii &b)
{
	return a.F+a.S<b.F+b.S;
}
ll fact[200005],inv_fact[200005];
ll inv_fac(ll x)
{
	return mod_Expo(x,mod-2,mod);
}
ll nCr(ll x,ll y)
{
	if(y>x || x<0 || y<0)
	return 0;
	return (fact[x]*((inv_fact[y]*inv_fact[x-y])%mod))%mod;
}
ll ways(ll x,ll y)
{
	return nCr(x+y,y);
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,n,total,h,w;
    	cin>>h>>w>>n;
    	vector<pii> in(n+1);
    	rep(i,0,n)
    	cin>>in[i].F>>in[i].S;
    	in[n]={mod,mod};
    	sort(all(in),ss);
    	in[n]={h,w};
    	fact[0]=1; inv_fact[0]=1;
    	repi(i,1,200004)
    	{
    		fact[i]=(fact[i-1]*i)%mod;
    		inv_fact[i]=inv_fac(fact[i]);
		}
    	vector<ll> dp(n+1,0);
    	repi(i,0,n)
    	{
    		k=ways(in[i].F-1,in[i].S-1);
    		rep(j,0,i)
    		{
    			if(in[j].F<=in[i].F && in[j].S<=in[i].S)
    			k=(k-((ways(in[i].F-in[j].F,in[i].S-in[j].S)*dp[j])%mod)+mod)%mod;
			}
			dp[i]=k;
		}
    	cout<<dp[n];
    } 
	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    int ans=0;

    rep2(i,1,n+1){
        string a=to_string(i);
        if(a.size()%2!=0){
            ans++;
        }
    }
    cout<<ans<<endl;
}


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

const int MAXN = 2e5+5;

bitset<4000005> b;
int n, a[2005];

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

	b[0] = 1; ll s = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		s += a[i];
		b |= (b << a[i]);
	}

	for (int i = (s+1)/2; i < 4000005; ++i) {
		if (b[i]) {
			cout << i << endl;
			return 0;
		}
	}
}

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

typedef pair<int, int> P;
vector<vector<char>> field;
vector<vector<int>> dist;

int main() {

  int h, w;
  cin >> h >> w;
  field.resize(h, vector<char>(w));
  dist.resize(h, vector<int>(w, -1));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> field[i][j];
    }
  }
  queue<P> que;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (field[i][j] == '#') { 
        que.push(P(i, j)); 
        dist[i][j] = 0;
      }
    }
  }
  int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
  int ans = 0;
  while(!que.empty()) {
    P p = que.front(); que.pop();
    int y = p.first, x = p.second;
    for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < h && nx >= 0 && nx < w && dist[ny][nx] == -1) {
        dist[ny][nx] = dist[y][x] + 1;
        que.push(P(ny, nx));
        ans = max(ans, dist[ny][nx]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 13456
N=int(input())
S=list(input())
#print(S)

S_orig=list(S)
while True:
  update=False
  
  remove_flg=[False]*len(S)
  for i in range(1,len(S)):
    if S[i-1]=='(' and S[i]==')':
      remove_flg[i-1]=remove_flg[i]=True
      update=True      
  if not update:
    break
      
  new_S=[]
  for i in range(len(S)):
    if not remove_flg[i]:
      new_S.append(S[i])      
  S=new_S
  
cnt_l=cnt_r=0
for i in range(len(S)):
  if S[i]=='(':
    break
  else:
    cnt_l+=1
for i in reversed(range(len(S))):
  if S[i]==')':
    break
  else:
    cnt_r+=1
#print(cnt_l,cnt_r)

answer_S=['(']*cnt_l+S_orig+[')']*cnt_r
print("".join(answer_S))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long ll;
#define int ll
const ll mod=998244353;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll dp[305][90005]={0};
ll dp2[305][90005]={0};
signed main(){
  ll n,sum=0;
  cin>>n;
  dp[0][0]=1;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    if(i==0) dp2[1][a]=1;
    sum+=a;
    for(int j=0;j<90005;j++){
      dp[i+1][j]+=dp[i][j]*2;
      dp[i+1][j+a]+=dp[i][j];
      dp[i+1][j]%=mod;
      dp[i+1][j+a]%=mod;

      dp2[i+1][j]+=dp2[i][j];
      dp2[i+1][j+a]+=dp2[i][j];
      dp2[i+1][j]%=mod;
      dp2[i+1][j+a]%=mod;
    }
  }
  ll ans=pow(3,n);
  for(int i=(sum+1)/2;i<=sum;i++){
    ans+=mod;
    ans-=(dp[n][i]*3)%mod;
    ans%=mod;
  }
  if(sum%2==0) {
    ans+=mod;
    ans+=(dp2[n][sum/2]*6)%mod;
    ans%=mod;
  }
  cout<<ans<<endl;
}


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

A = []

for i in range(N):

    a = int(input())
    A.append(a)

A.sort()

ans = 0
las = 0

for i in range(N):

    if (A[i] - las) % 2 != 0:
        ans ^= N - i

    las = A[i]

if ans == 0:
    print ("second")
else:
    print ("first")



Measured memory_bytes: 50264
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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 main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);

    int H, W, N;
    cin >> H >> W >> N;

    cout << (N + (max(H, W)) - 1) / (max(H, W)) << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
A = list(map(int, input().split()))
under = A[0] ** 2
total = under * A[1]
if A[2] >= total // 2:
  b = (total - A[2]) * 2 / under
  print(90 * np.arctan(b / A[0]) / np.pi * 2)
else:
  under = A[2] * 2 / A[1]
  a = under / A[0]
  print(90 * np.arctan(A[1] / a) / np.pi * 2)
  

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

	ll ans = 0;
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ans += min(a, k);
	k -= min(a, k);

	k -= min(b, k);
	ans += -1 * min(c, k);

	cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    string S;
    cin >> S;
    cout << S.substr(0, 4) << " " << S.substr(4, 8) << endl;
}

Measured memory_bytes: 256
/*
ITP1_11_D
Dice 4

*/

#include<stdio.h>
#include<string.h>

int compdice(int*, int*);

struct DICE
{
  int *state;
  int *label;
};

int main(){
  int label[100][6] = {};
  int i,j,n,ans=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<6;j++){
      scanf("%d",&label[i][j]);
    }
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      ans += compdice(label[i],label[j]);
    }
  }
  if (ans == 0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;
}



int compdice(int *a,int *b){
  int inistate[6][6] = {{1,3,4,2,5,6},{4,1,6,2,5,3},{6,4,3,2,5,1},
  {3,6,1,2,5,4},{6,2,5,3,4,1},{6,5,2,4,3,1}};
  ///{上,E,W.S,N,下}
  int label_0[6] = {a[0],a[1],a[2],a[3],a[4],a[5]};
  int label[6] = {b[0],b[1],b[2],b[3],b[4],b[5]};
  int staticstate[6] = {1,3,4,2,5,6};
  struct DICE dice_0 = {staticstate,label_0};
  struct DICE dice = {inistate[0],label};
  int i,j,ans=0,temp;
  for(i=0;i<6;i++){
    dice.state = inistate[i];
    for (j=0;j<4;j++){
      temp = dice.state[0];
      dice.state[0] = dice.state[4];
      dice.state[4] = dice.state[5];
      dice.state[5] = dice.state[3];
      dice.state[3] = temp;
      if (dice_0.label[dice_0.state[0]-1]==dice.label[dice.state[0]-1]
        && dice_0.label[dice_0.state[1]-1]==dice.label[dice.state[1]-1]
        && dice_0.label[dice_0.state[2]-1]==dice.label[dice.state[2]-1]
        && dice_0.label[dice_0.state[3]-1]==dice.label[dice.state[3]-1]
        && dice_0.label[dice_0.state[4]-1]==dice.label[dice.state[4]-1]
        && dice_0.label[dice_0.state[5]-1]==dice.label[dice.state[5]-1]){
        ans = 1;
      }
    }
  }
  return ans;
}


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

int n, k;
vector<int> a;

int solve() {
  int ans = (n - 1) / (k - 1);

  if ((n - 1) % (k - 1) != 0) {
    ans++;
  }

  return ans;
}

int main() {
  int i;

  cin >> n >> k;

  a.resize(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }

  cout << solve() << "\n";

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

void solve(){
    int n;
    ll W;
    cin>>n>>W;
    vector<ll>w(n),v(n);
    rep(i,n)cin>>w[i]>>v[i];
    vector<vector<ll>>dp(n+1,vector<ll>(W+5));
    rep(i,n){
        rep(j,W+1){
            if(j<w[i])dp[i+1][j]=dp[i][j];
            else dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout<<dp[n][W]<<"\n";
}
 
signed main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 80256
#include<iostream>

using namespace std;

int main(){

    int a,b;
    int flag=0;

    cin>>a>>b;

    if((a*b)%2!=0){
        flag=1;
    }
    if((a*b*2)%2!=0){
        flag=1;
    }
    if((a*b*3)%2!=0){
        flag=1;
    }
    if(flag==1)cout<<"Yes"<<endl;
    if(flag==0)cout<<"No"<<endl;


    return 0;
}

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

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

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

int main(void){
    int a, b, c; cin >> a >> b >> c;
    string res;

    if(a == b && b == (c ? 0:1)) res = "Open";
    else res = "Close";

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(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==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);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
ll ketawa(ll a){ll r=0;while(a){r+=a%10;a/=10;}return r;}


bool no_need(vector<int> &a,int n,int k,int i){
  const int S = 5010;
  bitset<S> bits;
  bits[0] = 1;
  FOR(j,0,n){
    if(j==i)continue;
    if(k < a[j])break;
    bits = bits<<a[j] | bits;
  }
  int first=MOD;
  FOR(j,max(0,k-a[i]),k){
    if(bits[j]){
      first = j;
      break;
    }
  }
  if(first==MOD)return true;
  return false;
}

 
int main(){

  int N,K;
  cin >> N >> K;

  vector<int> a(N);
  for(auto &&x:a)cin>>x;
  SORT(a);
  
  int l=-1,r=N;

  while(r-l>1){
    int mid = (r+l)/2;
    if(no_need(a,N,K,mid)){
      l = mid;
    }else{
      r = mid;
    }
  }

  cout << l+1 << endl;
}

/*
  任意 -> すべて

  a[i]を含む集合Siで
  K<= sum(Si) < K+a[i]
  のものがあればa[i]は必要

  a[j] > a[i] について
  先ほどのSiにa[j]が含まれていればa[j]は必要
  Siにa[j]が含まれていなくてもa[i]と交換することでa[j]は必要とわかる


  a[i]が不必要　-> K<=sum(S)<K+a[i] となるa[i]を含む集合Sがない
  
  a[j] < a[i]について
  if(a[j] in S){
    K+a[j] < K+a[i]より
    K<=sum(S)<K+a[j] もない
  }else{
    K <= sum(S) < K+a[i] がない
    K-a[i]+a[j] <= sum(S)-a[i]+a[j] < K+a[j]　もない
    K <= sum(S') < K+a[j]　もない
  }
*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n, m;
int p[1001];
int arr[1000001];

int main(int argc, char const* argv[])
{
	while(true){
			cin >> n >> m;
			if(n == 0)break;
			for(int i = 0; i < n; i++){
					cin >> p[i];
			}
			vector<int> vec;
			vec.pb(0);
			for(int i = 0; i < n - 1; i++){
					if(p[i] <= m)vec.pb(p[i]);
					else continue;
					for(int j = i; j < n; j++){
							if(p[i] + p[j] <= m)vec.pb(p[i] + p[j]);
					}
			}
			sort(vec.begin(), vec.end());
			int ind = 1;
			for(auto itr = vec.begin(); itr != vec.end(); ++itr){
					arr[vec.size() - ind] = *itr;
					ind++;
			}
			int res = 0;
			for(auto itr = vec.begin(); itr != vec.end(); ++itr){
					int index = lower_bound(arr, arr+vec.size(), m-*itr, greater<int>()) - arr;
					if(index >= 0 && index < vec.size()){
							res = max(res, arr[index] + *itr);
					}
			}
			cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 8704
#include <stdio.h>
#include <string.h>

int main()
{
    int sl, pl;
    char s[256], p[128];
    scanf("%s %s", s, p);
    sl=strlen(s);
    pl=strlen(p);
    pl=pl;
    memcpy(s+sl, s, sl);
    sl+=sl;
    s[sl]='\0';

    int i, ans=0;
    for(i=0; i<=sl-pl; i++) {
        if( (ans=strncmp(s+i, p, pl))==0) break;;
    }
    puts(ans?"No":"Yes");
    return 0;
}

Measured memory_bytes: 544
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

const MOD: u64 = 1_000_000_007;

fn main() {
    let nm: Vec<usize> = read_vec();
    let mut a: Vec<u64> = Vec::new();

    for i in 0..nm[1]
    {
        let ai: u64 = read();
        a.push(ai);
    }

    // 動的計画法
    let mut dp = vec![0_u64; nm[0] + 1];
    dp[0] = 1;

    // 崖崩れフラグ用変数
    let mut collapsed = 0_usize;

    for i in 1..dp.len() as usize
    {
        if collapsed < nm[1] && a[collapsed] == (i as u64)
        {
            // 崩壊している場合、この足場にたどり着くパターンは存在しない
            dp[i] = 0;
            collapsed += 1;
            continue;
        }

        if i == 1 { dp[1] = 1; continue; }

        dp[i] = (dp[i - 1] + dp[i - 2]) % MOD;
    }
    println!("{}", dp[nm[0]]);
}


Measured memory_bytes: 6396
#include <iostream>
#include <cstdio>
#include <stack>
using namespace std;

#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int main() {
	stack<int> s;
	int n;
	while(1) {
		if(scanf("%d", &n) == EOF) break;
		if(n > 0) {
			s.push(n);
		} else if(n == 0) {
			if(!s.empty()) {
				cout << s.top() << endl;
				s.pop();
			}
		}
	}
}

Measured memory_bytes: 1212
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost::multiprecision;  
//using namespace boost::math;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

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

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

    int n, m, k;
    cin >> n >> m >> k;

    vector<int> a(n+1), b(m+1), cum(m+1);

    reps(i,n){
        cin >> a[i];
    }

    reps(i,m){
        cin >> b[i];
        cum[i] += cum[i-1] + b[i];
    }

    int maxv = 0, sum = 0;

    for(int i = 0; i <= n; ++i){
        sum += a[i];
        int ok = -1, ng = m+1;
        while(ng - ok > 1){
            int mid = (ok + ng) / 2;
            if(sum + cum[mid] <= k) ok = mid;
            else ng = mid;
        }
        if(ok != -1){
            chmax(maxv, i + ok);
        }
    }

    cout << maxv << '\n';

    return 0;
}




Measured memory_bytes: 7940