akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    if( s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
struct edge{int to,cost;};

struct State{
    int d,o,y,x,l,r;
    bool operator<(const State& right) const{
        return d == right.d ? o < right.o : d > right.d;
    }
};

const int dx[] = {-1,1,0};
const int dy[] = {0,0,1};
int field[10][10];
int d[51][10][10][10][10];

int main(){
    while(1){
        int W,H;
        scanf("%d%d",&W,&H);
        if(!W)break;

        int f,m,o;
        scanf("%d%d%d",&f,&m,&o);
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                scanf("%d",&field[i][j]);
            }
        }

        for(int i=0;i<51;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    for(int l=0;l<10;l++){
                        fill(d[i][j][k][l],d[i][j][k][l]+10,INF);
                    }
                }
            }
        }

        priority_queue<State> que;
        for(int i=0;i<W;i++){
            int no = o-1, nd = 0;
            if(no<=0) continue;
            if(field[0][i]<0) nd -= field[0][i];
            else no = min(m, no+field[0][i]);
            d[no][0][i][i][i] = nd;
            que.push((State){nd,no,0,i,i,i});
        }

        int ans = -1;
        while(que.size()){
            State p = que.top(); que.pop();
            if(d[p.o][p.y][p.x][p.l][p.r]<p.d) continue;
            if(p.d>=f)break;
            if(p.y==H-1){
                ans = p.d;
                break;
            }

            for(int i=0;i<3;i++){
                int nx = p.x + dx[i], ny = p.y + dy[i];
                if(nx<0||W<=nx||ny<0||H<=ny) continue;
                int nl = min(p.l, nx), nr = max(p.r, nx);
                int no = p.o - 1;
                int nd = p.d;
                if(no <= 0) continue;
                if(i==2){
                    nl = nx; nr = nx;
                }
                if(i==2 || nx < p.l || p.r < nx){
                    if(field[ny][nx]<0) nd -= field[ny][nx];
                    else no = min(m, no+field[ny][nx]);
                }
                if(d[no][ny][nx][nl][nr] > nd){
                    d[no][ny][nx][nl][nr] = nd;
                    que.push((State){nd, no, ny, nx, nl, nr});
                }
            }
        }
        if(ans==-1) cout << "NA" << endl;
        else cout << ans << endl;
    }

    return 0;
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();   
    int n; cin >> n;
    vector<ll> v(n);
    for(auto &x : v){
        cin >> x;
    }
    int ans = 0, cur = 0;
    for(int i = 0; i < n - 1; ++i){
        if(v[i] >= v[i + 1]){
            ++cur;
        }else{
            cur = 0;
        }
        ans = max(cur, ans);
    }
    return cout << ans << '\n', 0;
}


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

ans1 = 10000000000000000000

# a勝ち続け, & b負け続けで会える場合
if abs(a-b)%2==0:
    ans1 = (b-a)//2

# 1 or n テーブルで会える場合
ans2 = min(b-1, n-a)


# 17, 2, 7 とか, 一旦どちらかが端に行ってから途中で会う場合
c = 0
ans3 = 10000000000000000000
if (b-a)%2 == 1:
    if a-1 <= n-b:
        c = a - 1
        a, b = 1, b-c
        ans3 = c + (b-2)//2 + 1
    else:
        c = n - b
        a, b = a + c, n
        ans3 = c + (n-(a+1))//2 +1
print(min(ans1, ans2, ans3))

Measured memory_bytes: 38384
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


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

def tansaku(already, paths, cur, n):
    global ans
    aim = [i for i in paths[cur] if i not in already]
    #print(cur,aim,already,ans)
    if aim == []:
        if len(already) == n-1:
            #print("here")
            ans += 1
        return

    for a in aim:
        tansaku(already+[cur], paths, a, n)

N, M = getNM()
paths = [[] for i in range(N)]
ans = 0
for i in range(M):
    a, b = getNM()
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)

tansaku([], paths, 0, N)
print(ans)



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

using namespace std;


int main(){
  
  string s;
  cin >> s;
  
  int num =0;
  
  if(s[0] == '1') ++num;
  if(s[1] == '1') ++num;
  if(s[2] == '1') ++num;
  cout << num << endl;
}


Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){
    vector<pair<T,T>> out(input.size()-1);
    rep(i,input.size()-1){
        out[i].first =input[i  ];
        out[i].second=input[i+1];
    }
    return(out);
}
vector<char> String_to_vector_char(const string& input){
    vector<char> out(input.size());
    rep(i,input.size()){
        out[i]=input[i];
    }
    return out;
}

long double w ,h,x,y;
vector<ll> D,L;
void input(){
    cin>>w>>h>>x>>y;
}
void src(){
    cout<<setprecision(10)<<fixed<<w*h/2<<" ";
    cout<<(x==w/2 and y==h/2? 1:0);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define LL long long int
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define PI pair<int,int>
#define mem(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define scan(t) scanf("%d",&t)
#define N 200005
const int inf=0x3f3f3f3f;
struct node{
    int v,c,next; //公司c
}e[N*2];
int head[N];
int cnt=0;
int ans[N];
set<int>cmp[N]; //记录公司
void add(int u,int v,int c){
    e[cnt].v=v;
    e[cnt].next=head[u];
    e[cnt].c=c;
    head[u]=cnt++;
}
void bfs(int s,int t){
    priority_queue<pair<int,int> >q;
    q.push({0,1});
    ans[s]=0;
    int i,u,v,c1,c2;
    while(!q.empty()){
        u=q.top().se;
        c1=-q.top().fi;  //花费
        q.pop();
        if(ans[u]<c1)
            continue;
        for(i=head[u];i!=-1;i=e[i].next){
            v=e[i].v;
            c2=c1+(!cmp[u].count(e[i].c));
            if(ans[v]>c2){
                ans[v]=c2;
                q.push({-c2,v});
                cmp[v].clear();
                cmp[v].insert(e[i].c);
            }
            else if(ans[v]==c2){
                cmp[v].insert(e[i].c);
            }
        }
    }
    if(ans[t]==inf) ans[t]=-1;
    cout<<ans[t]<<endl;
}
int main()
{
    int n,m,u,v,c;
    scanf("%d%d",&n,&m);
    mem(head,-1);
    mem(ans,inf);
    rep(i,0,m){
        scanf("%d%d%d",&u,&v,&c);
        add(u,v,c);
        add(v,u,c);
    }
    bfs(1,n);
    return 0;
}


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        b[i]--;
    }
    vector<int> ans(n);
    for (int j = 0; j < n; j++)
    {
        int pos = -1;
        for (int i = (int)b.size() - 1; i >= 0; i--)
        {
            if (b[i] == i)
            {
                pos = i;
                break;
            }
        }
        if (pos == -1)
        {
            cout << -1;
            return 0;
        }
        ans[n - 1 - j] = pos;
        for (int i = pos; i < (int)b.size() - 1; i++)
            b[i] = b[i + 1];
        b.pop_back();
    }
    for (int e : ans)
        cout << e + 1 << "\n";
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

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

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    PRINT(max(a * 10 + b + c, max(b * 10 + c + a, c * 10 + a + b)));
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
count = 0
b = []
c = []

for i in range(n):
    b.append(a[i]+i)
    c.append(i-a[i])
t = Counter(c) 
for s in b:
    count += t[s]

print(count)

Measured memory_bytes: 50760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    int N;
    cin >> N;
    if(N % 10 == 3){
        cout << "bon" << endl;
    }
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main()
{
    int n, a, b;
    int distance;
    
    scanf("%d %d %d", &n, &a, &b);

    distance = b - a;

    if ((distance % 2) == 0)
    {
	printf("Alice\n");
    }
    else
    {
	printf("Borys\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    string s; cin >> s;
    Rep(i, 0, s.size()-2){
        if(s[i] == 'A' && s[i+1] == 'C'){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

    solve();
    return 0;
}
 


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int N;
int a[3333];

int calc(int m) {
   int ret = 0;
   rep (i, N) {
      ret += m % a[i];
   }
   return ret;
}

int main() {
   cin >> N;
   int sum = 0;
   rep (i, N) {
      cin >> a[i];
      sum += a[i];
   }

   cout << sum - N << endl;
   // dbg(calc(sum))

   return 0;
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int A[100];
  for (int i = 0; i < M; i++) cin >> A[i];

  int cost1 = 0, cost2 = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < M; j++) {
      if (i >= 0 && i <= X && A[j] == i) cost1++;
      else if (A[j] == i) cost2++;
    }
  }

  cout << min(cost1, cost2) << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        PrintWriter out = new PrintWriter(System.out);
        int N = scan.nextInt();
        String X = scan.next();
        char[] data = X.toCharArray();
        int count_original = 0;
        for (int j = 0; j < N; j++) {
            if (data[j] == '1') {
                count_original += 1;
            }
        }
        long initial = 0;
        long initial_negative = 0;
        for (int i = 0; i < N; i++) {
            if (data[i] == '1') {
                initial += pow(2, N - 1 - i, count_original+1);
                initial %= (count_original+1);
            }
        }
        if (1 < count_original) {
            for (int i = 0; i < N; i++) {
                if (data[i] == '1') {
                    initial_negative += pow(2, N - 1 - i, count_original-1);
                    initial_negative %= (count_original-1);
                }
            }
        }
        for (int i = 0; i < N; i++) {
            long current = 0;
            if (data[i] == '0') {
                current = initial;
                current += pow(2, N - 1 - i, (count_original+1));
                current %= (count_original+1);
            } else {
                if (count_original == 1) {
                    out.println(0);
                    continue;
                }
                current = initial_negative;
                current -= pow(2, N - 1 - i, (count_original-1));
                current += (count_original-1);
                current %= (count_original-1);
            }
            long ans = 1;
            while (current != 0) {
                char[] x = Long.toBinaryString(current).toCharArray();
                int len = x.length;
                int c = 0;
                for (int j = 0; j < len; j++) {
                    if (x[j] == '1') {
                        c += 1;
                    }
                }
                current = 0;
                for (int j = 0; j < len; j++) {
                    if (x[j] == '0') {
                        continue;
                    }
                    current += pow(2, len - 1 - j, c);
                    current %= c;
                }
                ans += 1;
            }
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    private long pow(int base, int count, long mod) {
        if (count == 0) {
            long t = 1 % mod;
            return t;
        }
        if (count % 2 == 1) {
            long t = base * pow(base, count - 1, mod);
            t %= mod;
            return t;
        }
        long t = pow(base, count / 2, mod);
        t *= t;
        t %= mod;
        return t;
    }
}


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

using namespace std;
const int maxn=110;
int a[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    int flag=0;
    for(int i=1;i<=n;i++)
    {
        int t;
        scanf("%d",&t);
        if(t%2==0)
        {
            if(t%3==0||t%5==0)
            {
                continue;
            }
            else
            {
                flag=1;
                break;
            }
        }
    }
    if(flag)
    {
        printf("DENIED\n");
    }
    else
        printf("APPROVED\n");
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

int main(){

	int n,a,b;
	cin>>n>>a>>b;

	int x=0,y=0;

	string s;
	cin>>s;

	for(int i=0;i<s.size();i++){
		if(s[i]=='a' && x<a+b){
			x++;
			cout<<"Yes"<<endl;
		}else if(s[i]=='b' && x<a+b && y<b){
			x++; y++;
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}

	}

}


Measured memory_bytes: 896
#include <iostream>

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

  std::string t = s;
  t = t.erase(t.size()/2);

  if(s.substr(s.size()/2) == t)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin>>a>>b;
  int gcd;
  
    for(int i=1;i<=a;i++){
      if(a%i==0 &&b%i==0){
        gcd=i;
      }
    }
  
  ll ans=ll(a)*b/gcd;
  cout<<ans<<endl;
}

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

using namespace std;

int ModAtoi(string_view sv, int d) {
  int r = 0;
  for (char c : sv) {
    r *= 2;
    r %= d;
    r += c - '0';
  }
  return r;
}

inline int popcount(int x) { return __builtin_popcount(x); }

int f(int x) { return x == 0 ? 0 : f(x % popcount(x)) + 1; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int pc0 = 0;
  for (char c : s) pc0 += c - '0';
  vector<int> ans(n);
  for (int b : {0, 1}) {
    const int pc = b == 0 ? pc0 + 1 : pc0 - 1;
    if (pc <= 0) continue;
    const int r0 = ModAtoi(s, pc);  // X0 % popcount(X0)

    int k = 1;
    for (int i = n - 1; i >= 0; --i) {
      const int x = s[i] - '0';
      if (x == b) {
        int r = r0;
        if (b == 0) {
          r = (r + k) % pc;
        } else {
          r = (r - k + pc) % pc;
        }
        ans[i] = f(r) + 1;
      }
      k = (2 * k) % pc;
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(int x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

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

static const int mod = 1e9+7;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H+1, vector<int> (W, 0));
  dp[0][0] = 1;
  rep(i, 0, H) {
    rep(j, 0, W) {
      rep(k, 0, (1 << (W-1))) {
        bool flag = true;
        rep(l, 0, W - 2) {
          if (((k >> l) & 1) && ((k >> (l+1)) & 1)) {
            flag = false;
          }
        }

        if (flag) {
          if (j >= 1 && ((k >> (j - 1)) & 1)) {
            // 左方向に横線をたどる
            dp[i+1][j-1] += dp[i][j];
            dp[i+1][j-1] %= mod;
          } else if (j <= W - 2 && ((k >> j) & 1)) {
            // 右方向に横線をたどる
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1] %= mod;
          } else {
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= mod;
          }
        }
      }
    }
  }

  cout << dp[H][K-1] << endl;
  return 0;
};


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
 
int main() {
 
  char ch[1200];
  int i,n;
  n=0;
  char a[1200];
 
  while(1) {
    scanf("%c",&a[n]);
    if(a[n] == '\n') {
      break;
    }
    ch[n] = a[n];
    if('A' <= a[n] && a[n] <= 'Z') {
      ch[n] = a[n] + 32;
    } else if(a[n] >= 'a' && a[n] <= 'z') {
      ch[n] = a[n] - 32;
 
    }
     
     
    n = n +1;
     
  }
   
  for(i=0; i<n ; i++) {
    printf("%c" ,ch[i]);
  }
  printf("\n"); 
  return 0;
   
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0) 

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }
    
    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int main() {
	int n = ri();
	int k = ri();
	int a[n];
	INPUT(a);
	
	s64 s[n];
	FOR(i,n) s[i] = i?s[i-1]+a[i]:a[i];
	
	s64 ss[n];
	FOR(i,n) ss[i] = i?ss[i-1]+(a[i]<0?0:a[i]):(a[i]<0?0:a[i]);
	
	s64 res = -LINF;
	FOR(i,n) {
		if (i+k > n) break;
		s64 base = max((s64)0,s[i+k-1]-(i?s[i-1]:0));
		if (i) base += ss[i-1];
		base += ss[n-1]-ss[i+k-1];
		res = max(res,base);
	}
	cout << res << endl;
	
	return 0;
}




Measured memory_bytes: 2176
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a < b){
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
        scan.close();
        }
    }


Measured memory_bytes: 26320
#!/usr/bin/env python3
import sys, bisect


def solve(A: int, B: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):
    s = [-1e18] + s + [1e18]
    t = [-1e18] + t + [1e18]
    for q in x:
        sRight = bisect.bisect_left(s, q)
        tRight = bisect.bisect_left(t, q)
        sLeft = sRight - 1
        tLeft = tRight - 1

        rr = max(s[sRight]-q, t[tRight]-q)
        ll = max(q-s[sLeft], q-t[tLeft])

        rl = min(
            2 * (s[sRight]-q) + (q-t[tLeft]),
            2 * (t[tRight]-q) + (q-s[sLeft]),
            2 * (q-s[sLeft]) + (t[tRight]-q),
            2 * (q-t[tLeft]) + (s[sRight]-q),
        )
        print(min(rr, ll, rl))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(A) ]  # type: "List[int]"
    t = [ int(next(tokens)) for _ in range(B) ]  # type: "List[int]"
    x = [ int(next(tokens)) for _ in range(Q) ]  # type: "List[int]"
    solve(A, B, Q, s, t, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18356
/*
 * atcoder/abc126/e.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * 1 2 1
 * 2 3 2
 * 1 3 3
 * 4 5 4
 * 5 6 5
 *
 * 1: 奇数 0 + 1 or 1 + 0 <=> xor = 1
 * 0: 偶数 1 + 1 or 0 + 0 <=> xor = 0
 * ? ? ? ? ? ?
 * 1 1
 *   0 0
 * 1   1
 *       0 0
 *         1 1
 *
 * もしかして単純に非連結成分数に帰着される?
 */
const int MAX = 100001;
int N, M;
vector<int> G[MAX];
vector<bool> done(MAX, false);

void dfs(int n) {
  done[n] = true;
  for (auto&&u: G[n]) {
    if (done[u]) continue;
    dfs(u);
  }
}
void solve() {
  cin >> N >> M;
  int a, b, c;
  loop(n,0,M) {
    cin >> a >> b >> c;
    a--;b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int count = 0;
  loop(n,0,N) {
    if (done[n]) continue;
    dfs(n);
    count++;
  }
  cout << count << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 8832
/*
	For the part of BIT's binary search see below.
	http://hos.ac/slides/20140319_bit.pdf
*/
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

template<class T> class bit{
public:
	vector<T> dat;
	int N, M;
	
	bit(){}
	bit(int _N): N(_N){
		dat.assign(_N,0);
		M = 0;
		int p = 0;
		while(_N >= (1<<p)){
			M = (1<<p);
			++p;
		} // end while
	}
	
	// sum [0,i)
	T sum(int i){
		T ret = 0;
		for (--i; i >= 0; i = (i & (i + 1)) - 1){
			ret += dat[i];
		} // end for
		return ret;
	}

	// sum [i,j)
	T sum(int i, int j){
		return sum(j) - sum(i);
	}

	// add x to i
	void add(int i, T x){
		for (; i < N; i |= i + 1) dat[i] += x;
	}

	// return w-th smallest index (0-indexed)
	int lowerBound(int w){
		if (w < 0) return -1;
		int x = 0;
		for (int k = M; k > 0; k /= 2){
			if (x + k < N && dat[x + k - 1] <= w){
				w -= dat[x + k - 1];
				x += k;
			} // end if
		} // end for
		return x;
	}
};

bit<int> bs;
map<int,int> id;
int q, lim, l, r, vs[400010];
bool done[400010];

void normalize(void){
	if (bs.sum(r) > lim){
		while(done[l]) ++l;
		done[l] = 1;
		bs.add(l++, -1);
	} // end if
}

void solve(void){
	memset(vs, 0, sizeof(vs));
	memset(done, false, sizeof(done));

	id.clear();
	l = r = 0;

	bs = bit<int>(q);
	while(q--){
		int v, x, p;
		cin >> v >> x;
		switch(v){
			case 0:
				id[x] = r;
				vs[r] = x;
				bs.add(r++, 1);
				break;
			case 1:
				p = bs.lowerBound(x-1);
				bs.add(p, -1);
				done[p] = true;
				break;
			case 2:
				p = bs.lowerBound(x-1);
				cout << vs[p] << endl;
				break;
			case 3:
				p = id[x];
				bs.add(p, -1);
				done[p] = true;
				break;
		} // end switch
		normalize();
	} // end while 
}

bool input(void){
	cin >> q >> lim;
	return (q || lim);
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	for(; input(); ){
		solve();
		cout << "end" << endl;
	} // end for

	return 0;
}

Measured memory_bytes: 25168
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, A: int, B: int):
    d, m = divmod(N, A+B)
    ans = d*A + min(m, A)
    print(ans)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int a, b; cin >> a >> b;
	cout << max(max(2*a-1, 2*b-1), a+b) << endl;
}


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

int main(){
	int n;
	cin >> n;
	
	int w[110];
	for(int i=0; i<n; i++) cin >> w[i];
	
	int ans=100000;
	for(int i=0; i<n-1; i++){
		int s1=0, s2=0, d=0;
		for(int j=0; j<=i; j++){
			s1 += w[j];
		}
		for(int j=i+1; j<n; j++){
			s2 += w[j];
		}
	d = s1-s2;
	d = sqrt(d*d);
	if(d<ans) ans=d;
	}
	cout << ans << endl;
}

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

#include <algorithm>
#include <vector>
using namespace std;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

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

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

bool check(vector<pair<int, int>> s) {
    int h = 0;
    for (auto p : s) {
        int b = h + p.first;
        if (b < 0) return false;
        h += p.second;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> ls, rs;
    int total = 0;
    rep(i, n) {
        string s;
        cin >> s;
        int h = 0, b = 0;
        for (char c : s) {
            if (c == '(')
                ++h;
            else
                --h;
            b = min(b, h);
        }
        if (h > 0)
            ls.emplace_back(b, h);
        else
            rs.emplace_back(b - h, -h);
        total += h;
    }
    sort(ls.rbegin(), ls.rend());
    sort(rs.rbegin(), rs.rend());
    if (check(ls) && check(rs) && total == 0) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }

    return 0;
}


Measured memory_bytes: 18968
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'
 

const int N = 1e7+ 5;
vlli a(N,1),ans(N,0);

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

    rep(i,N,2){
        for(int j = i; j <  N; j+= i)a[j]++;
    }

    ans[1] = 1;
    
    rep(i,N,2){
        ans[i] += ans[i - 1];
        ans[i] += i*1LL*a[i];
    }

    cout<<ans[n]<<endl;
}

Measured memory_bytes: 159376
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n,nn;
    while(~scanf("%d",&n))
    {
        if(n%2==0)
            printf("%d\n",n);
        else
            printf("%d\n",n*2);
    }
    return 0;
}


Measured memory_bytes: 128
n,k = map(int,input().split())
if n == 2 and k == 0:
  print(1)
  print(1,2)
  exit()
  
if k > (n-1)*(n-2)//2 or n == 2:
  print(-1)
  exit()
  
if n == 3:
  if k == 1:
    print(2)
    print(1,2)
    print(2,3)
  elif k == 0:
    print(3)
    print(1,2)
    print(2,3)
    print(3,1)
  else:
    print(-1)
  exit()
    
m = (n-1)*(n-2)//2+(n-1)-k
print(m)
for i in range(n-1):
  print(1,2+i)
for i in range(min(n-1,m-n+1)):
  if 3+i > n:
    print(2+i,2)
  else:
    print(2+i,3+i)
    
if m > (n-1)*2:
  cnt = m-(n-1)*2
  for i in range(2,n-2):
    if cnt == 0:
        break
    for j in range(2,n-i+1):
      print(j,j+i)
      cnt -= 1
      if cnt == 0:
        break

Measured memory_bytes: 3644
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<int>cnt(N+1);
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    sort(cnt.begin(),cnt.end());
    int ans = 0;
    auto itr = lower_bound(cnt.begin(),cnt.end(),1);
    while(distance(itr,cnt.end()) > K){
        ans += *itr;
        itr++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]

ABC = str(input()).split()
A = int(ABC[0])
B = int(ABC[1])
C = int(ABC[2])
ans = "No"

if(A==B):
    if not(A==C):
        ans = "Yes"
elif(A==C):
    ans = "Yes"
elif(B==C):
    ans = "Yes"

print(ans)


Measured memory_bytes: 21268
local UnionFind={}

UnionFind.create=function(self,n)
    self.par={}
    self.rank={}
    self.size={}
    for i=1,n do
        self.par[i]=i
        self.rank[i]=1
        self.size[i]=1
    end
end

UnionFind.getroot=function(self,x)
    local nx=x
    while self.par[x]~=x do
        x=self.par[x]
    end
    while self.par[nx]~=x do
        self.par[nx],nx=x,self.par[nx]
    end
    return x
end

UnionFind.same=function(self,x,y)
    return self:getroot(x)==self:getroot(y)
end

UnionFind.unite=function(self,x,y)
    x=self:getroot(x)
    y=self:getroot(y)
    if x==y then
        return
    end
    if self.rank[x]>self.rank[y] then
        x,y=y,x
    elseif self.rank[x]==self.rank[y] then
        self.rank[x]=self.rank[x]+1
    end
    self.par[x]=y
    self.size[y]=self.size[y]+self.size[x]
end

UnionFind.getsize=function(self,x)
    return self.size[self:getroot(x)]
end

UnionFind.new=function(self,n)
    local obj={}
    setmetatable(obj,{__index=UnionFind})
    obj:create(n)
    return obj
end

----------

local n,m=io.read("n","n")
local uf=UnionFind:new(n)
for i=1,m do
    local a,b=io.read("n","n")
    uf:unite(a,b)
end

local max=0
for i=1,n do
    max=math.max(max,uf:getsize(i))
end
print(max)

Measured memory_bytes: 14708
# Nこの商品の中からM個選ぶ
N, M = list(map(int, input().split()))
# 商品iの得票数はA_i
A = list(map(int, input().split()))

A = sorted(A, reverse=True)

if A[M-1] >= sum(A)/(4*M):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9024
from collections import deque
n, q = [int(i) for i in input().split()]
g = [[] for i in range(n)]

for i in range(n-1):
    a, b = [int(_) for _ in input().split()]
    g[a-1].append(b)
c = [0 for i in range(n)]
for i in range(q):
    p, x = [int(_) for _ in input().split()]
    c[p-1] += x

q = deque([[1, c[0]]])
while len(q) != 0:
    p = q.popleft()
    for i in g[p[0]-1]:
        c[i-1] += p[1]
        q.append([i, c[i-1]])

print(*c)

Measured memory_bytes: 55892
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(A,B) :
    if A%2 == 1 and B%2 == 1:
        return 'Yes'
    else :
        return 'No'
    
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
x,n=map(int,input().split())
if n!=0:
  li=list(map(int,input().split()))
else:
  li=[]
z=0

while True:
  if x-z not in li:
    print(x-z)
    break
  if x+z not in li:
    print(x+z)
    break
  z+=1

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
int main() {
	long long n, i, a[222222], ans = 0,t[222222],k;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		t[a[i]] = i;
	}
	set<long long> p{ -1,n };
	for (i = 1; i <= n; i++) {
		auto r = p.insert(t[i]);
		r.first++;
		k = *r.first - t[i];
		r.first--;
		r.first--;
		k *= t[i] - *r.first;
		ans += k*i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13056
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Long,Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            long k = sc.nextLong();
            if(map.containsKey(k)){
                map.put(k,map.get(k) + 1);
            }else{
                map.put(k,1);
            }
        }
        int ans = 0;
        for(Map.Entry<Long,Integer> e : map.entrySet()){
            long k = e.getKey();
            int v = e.getValue();
            if(v - k >= 0){
                ans += v-k;
            }else{
                ans += v;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 62900
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAX = 1e9;

int main()
{
	lld n,a,b;
	vector<lld> h;

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

	lld up = MAX , low = -1;
	lld mid = 0;

	while(up - low > 1)
	{
		mid = (up + low) / 2;
		//cout << "mid = " << mid << endl;
		lld t = 0;
		for(int i = 0; i < n; i++)
		{
			lld x = h[i];
			x -= b * mid;
			if (x > 0)
			{
				t += ceil((double)x / (a-b));
			}
		}


		if (t <= mid)
		{
			up = mid;
		}else
		{
			low = mid;
		}
	}

	cout << up << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX(a,b) (((a)>(b))?(a):(b))
using namespace std;

int gcd(int a, int b) {
    if(a > b)
        swap(a, b);
    while(1) {
        int t = a % b;
        if(t == 0)
            break;
        a = b;
        b = t;
    }
    return b;
}

int main() {
    int n, i;
    cin >> n;
    int a[n], l[n], r[n];
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    l[0] = a[0];
    for(i = 1; i < n; i++) {
        l[i] = gcd(l[i - 1], a[i]);
    }
    r[n - 1] = a[n - 1];
    for(i = n - 2; i >= 0; i--) {
        r[i] = gcd(r[i + 1], a[i]);
    }
    int maxgcd = r[1];
    for(i = 1; i < n - 1; i++) {
        int m = gcd(l[i - 1], r[i + 1]);
        maxgcd = MAX(maxgcd, m);
    }
    maxgcd = MAX(maxgcd, l[n - 2]);
    cout << maxgcd << endl;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int, input().split()))
newa = [abs(a[i]) for i in range(n)]

neg = 0
zeros = 0
for i in range(n):
    if a[i] < 0:
        neg += 1 
    elif a[i] == 0:
        zeros += 1 

res = 0 
for i in range(n):
    res += newa[i]
        
if neg%2 == 0:
    print(res)
else:
    if zeros > 0:
        print(res)
    else:
        res -= 2*min(newa)
        print(res)

Measured memory_bytes: 64928
import sys
h,w,n=map(int,input().split())
obj=set()
hor=[0]*(h+1)
ver=[0]*(w+1)
for i in range(n):
  x,y=map(int,input().split())
  obj.add((x-1)+(y-1)*h)
  hor[x]+=1
  ver[y]+=1
maxh=max(hor)
maxv=max(ver)
maxhct=0
maxvct=0
hs=[]
vs=[]
for i in range(1,h+1):
  if hor[i]==maxh:
    maxhct+=1
    hs.append(i)
for i in range(1,w+1):
  if ver[i]==maxv:
    maxvct+=1
    vs.append(i)
if maxhct*maxvct>n:
  print(maxh+maxv)
  sys.exit()
for i in hs:
  for j in vs:
    if not (((i-1)+(j-1)*h) in obj):
      print(maxh+maxv)
      sys.exit()
print(maxh+maxv-1)

Measured memory_bytes: 169156
n, a, b = map(int, input().split())
MOD = 1000000007
def pow(d, n):
  ps = [d]
  for i in range(64):
    ps.append(ps[-1]*ps[-1]%MOD)
  r = 1
  for i in range(64):
    if n&(1<<i) != 0:
      r = r*ps[i]%MOD
  return r
def perm(n, a):
  r = 1
  for i in range(a):
    r = r*(n-i)%MOD
  return r
def comb(n, a):
  r = perm(n, a)*pow(perm(a, a), MOD-2)%MOD
  return r
r = (pow(2, n)-1-comb(n, a)-comb(n, b))%MOD
print(r)


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

const int maxn = 3e5 + 3;

vector<array<int, 2>> v;

int a[maxn];
int tree[maxn << 2];

struct seg_tree {
    int combine(int x, int y)  {
        return max(x, y);
    }
    int query(int l, int r, int ql, int qr, int node) {
        if (qr < l || r < ql)
            return 0;
        if (ql <= l and r <= qr) {
            return tree[node];
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        return combine(query(l, mid, ql, qr, lc), query(mid + 1, r, ql, qr, rc));
    }
    void update(int l, int r, int pos, int val, int node) {
        if (pos < l || r < pos)
            return;
        if (l == r and l == pos) {
            tree[node] += val;
            return;
        }
        int mid = l + r >> 1, lc = node + node, rc = 1 + lc;
        update(l, mid, pos, val, lc);
        update(mid + 1, r, pos, val, rc);
        tree[node] = combine(tree[lc], tree[rc]);
    }
};

int ask(vector<array<int,2>> v) {
    sort(v.begin(), v.end());
    memset(tree, 0, sizeof tree);
    seg_tree ins;

    const int N = v.size();

    for (int i = 0; i < N; ++i) {
        ins.update(1, maxn - 1, v[i][1], 1, 1);
    }

    int ret = 0;
    for (int i = 0; i < N; ) {
        int cur = v[i][0], cnt = 0;
        int index = i;
        while (i < N && v[i][0] == cur) {
            ins.update(1, maxn - 1, v[i][1], -1, 1);
            ++i;
            ++cnt;
        }
        int ans = cnt + tree[1];
        ret = max(ret, ans);
        i = index;
        while (i < N && v[i][0] == cur) {
            ins.update(1, maxn - 1, v[i][1], 1, 1);
            ++i;
        }
    }
    return ret;
}

void solve() {
    int n, m, q;
    cin >> n >> m >> q;
    v.resize(q);
    for (int i = 0; i < q; ++i) {
        cin >> v[i][0] >> v[i][1];
    }
    int ans = ask(v);
    for (auto &it: v) {
        swap(it[0], it[1]);
    }
    ans = max(ans, ask(v));
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

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

main() {
    int A,B; cin >> A >> B;
    cout << (A+B)%24 << endl;
 
    return 0;
}


Measured memory_bytes: 256