akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
typedef vector <ll> vi;                 // Vector of long long
typedef vector <vi> vvi;                // Vector of vi
typedef vector <pair<ll,ll>> ii;        // Vector of pairs
#define ff first                        // For pairs
#define ss second                       // For pairs
#define sz(a) int((a).size())           // Function to determine size of any container
#define pb push_back                    // Pushback to vector
#define mp make_pair                    // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()   // Mainly used by me in sorting
// ordered_set adds two new functions to set - (set).find_by_order([kth element based on zero indexing]) and order_of_key()
// order_of_key returns number of elements less that parameter. If element exists, that order is its index
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
#define MAX (ll)(1e5 + 10)
ll dp[MAX][3];
ll n;
ll arr[MAX][3];

ll solve(ll i, ll p)
{
    if (i == 0)
        return arr[0][p];

    if (dp[i][p] == -1)
        dp[i][p] = max(solve(i - 1, (((p - 1) % 3) + 3) % 3), solve(i - 1, (p + 1) % 3)) + arr[i][p];
    return dp[i][p];
}

int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 3; j++)
            cin >> arr[i][j];

    memset(dp, -1, sizeof(dp));

    cout << max(solve(n - 1, 0), max(solve(n - 1, 1), solve(n - 1, 2))) << "\n";
}


Measured memory_bytes: 9600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include <functional>

using namespace std;
typedef unsigned long long ll;
typedef pair<int,int>P;

int main()
{
	string S;
	ll K;
	cin>>S>>K;
	if(K==1)
	{
		cout<<S[0]<<endl;
	}
	else
	{
		for(ll i=0;i<K;i++)
		{
			if(S[i]!='1')
			{
				cout<<S[i]<<endl;
				return 0;
			}
		}
		cout<<S[K-1]<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;

	if (A == B) co(A + B);
	else co(max(A, B) * 2 - 1);

	Would you please return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

int main() {

more:
  int n; cin >> n;
  if (!n) return 0;

  vector<string> occur[30];
  Dictionary ps;

  rep (i, n) {
    string name; cin >> name;
    ps[name] = 0;
    int m; cin >> m;
    rep (j, m) {
      int d; cin >> d;
      occur[d].push_back(name);
    }
  }

  rep (d, 30) {
    int p = n - occur[d].size() + 1;
    for (string name : occur[d]) {
      ps[name] += p;
    }
  }

  int min_p = INF;
  for (auto&pr : ps) min_p = min<int>(min_p, cdr(pr));

  vector<string> anses;
  for (auto&pr : ps)
    if (cdr(pr) == min_p)
      anses.push_back(car(pr));

  sort(all(anses));

  cout << min_p << ' ' << anses[0] << endl;

  goto more;
}

Measured memory_bytes: 1236
//当其中有一个数不符，往后退，直到退到末尾，输出UNSTORABLE，若相符，将剩下问好替换为？; 
#include<bits/stdc++.h>
using namespace std;
string s,t,sss="";
int i,j,r;
int main()
{
    cin>>s>>t;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE";
        return 0;
    }
    for(i=0;i<=s.size()-t.size();i++)
	{
        int k=i;
        string ss=s;
        j=0;
        while(j<t.size())
		{
            if(ss[k]=='?')
                ss[k]=t[j];
            else if(s[k]!=t[j])
                break;
            k++;
            j++;
        }
        if(j==t.size())
		{
            for(r=0;r<ss.size();r++)
			{
                if(ss[r]=='?')
                {
            		ss[r]='a';
				}

            }
            if(sss=="")
                sss=ss;
            else sss=min(sss,ss);
        }
    }
    if(sss=="")
        cout<<"UNRESTORABLE";
    else cout<<sss;
    return 0;
}

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

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

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

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

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

void IN(void){
  return;
}

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

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

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

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

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

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

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

ll N;
vll a;

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

  IN(N);
  string str;
  IN(str);
  a.resize(N);
  REP(i,N) a[i] = (str[i]-'0')-1;

  ll one_count=0;
  REP(i,N) if(a[i]==1) one_count++;

  if(one_count==0){
    REP(i,N) a[i]/=2;
  }

  ll tmp2=2;
  vll P2(N+1, 0);
  while(tmp2<=N){
    for(ll i=tmp2; i<=N; i+=tmp2) P2[i]++;
    tmp2<<=1;
  }

  REP(i,N) P2[i+1] += P2[i];

  //vec_print(P2);

  REP(i,N) a[i] &= 1;

  ll ans = 0;
  REP(i,N){
    if(P2[N-1]-P2[i]-P2[N-1-i]==0) ans += a[i];
    ans %= 2;
  }

  if(one_count==0){ans*=2;}
  OUT(ans);

  return 0;
}

Measured memory_bytes: 17052
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
int main(){
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else if(s == "Rainy") cout << "Sunny" << endl;

    return 0;
}


Measured memory_bytes: 256
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# N = int(readline())
# D = [int(d) for d in readline().split()]

import numpy as np

N, K = map(int, readline().split())
h = [int(x) - K for x in readline().split()]
ha = np.array(h)

print(np.count_nonzero(ha >= 0))


Measured memory_bytes: 19488
s = gets.split("").map(&:to_s)
white_number = s.count("W")
before_distance_sum = 0
after_distance_sum = 0

white_number.times do |num|
  after_distance_sum += num
end

s.each_with_index do |str, index|
  if str == "W"
    before_distance_sum += index
  end
end

puts before_distance_sum - after_distance_sum

Measured memory_bytes: 18172
#include<stdio.h>
int main(){
  int a,b,x,y,z;
  scanf("%d%d",&a,&b);
  x=a+b;
  y=a*b;
  z=a-b;
  int max=x;
  if(y>max){
    max=y;
  }
  if(z>max){
    max=z;
  }
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 128
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    ################
    class UnionFind():
        """
        parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
        find(x):要素xの属するグループの根を返す
        size(x):要素xの属するグループの要素数を返す
        same(x,y):x,yが同じグループに属しているか返す
        members(x):要素xが属するグループに属する要素をリストで返す
        roots:全ての根の要素を返す
        group_count():グループの数を返す
        all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
        """
        def __init__(self, n):
            self.n = n
            self.parents = [-1] * n

        def find(self, x):
            #根を探す&つなぎかえる
            if self.parents[x] < 0:
                return x
            else:
                self.parents[x] = self.find(self.parents[x])
                return self.parents[x]

        def union(self, x, y):
            x = self.find(x)
            y = self.find(y)

            if x == y:
                return

            if self.parents[x] > self.parents[y]:
                x, y = y, x

            self.parents[x] += self.parents[y]
            self.parents[y] = x

        def size(self, x):
            return -self.parents[self.find(x)]

        def same(self, x, y):
            return self.find(x) == self.find(y)

        def members(self, x):
            root = self.find(x)
            return [i for i in range(self.n) if self.find(i) == root]

        def roots(self):
            return [i for i, x in enumerate(self.parents) if x < 0]

        def group_count(self):
            return len(self.roots())

        def all_group_members(self):
            return {r: self.members(r) for r in self.roots()}

        def __str__(self):
            return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
        
    ################

    H,W=MI()
    S=[]
    for i in range(H):
        s=input()
        S.append(s)
    uf=UnionFind(H*W)
    
    dx=[0,1]
    dy=[1,0]
    
    def make(ii,jj):
        return ii*W+jj
    

    
    for i in range(H):
        for j in range(W):
            for k in range(2):
                ni=i+dx[k]
                nj=j+dy[k]
                if 0<=ni<H and 0<=nj<W:
                    if S[i][j]!=S[ni][nj]:
                        uf.union(make(i,j),make(ni,nj))
                        
    ans=0
    from collections import defaultdict
    ddb = defaultdict(int)
    ddh = defaultdict(int)
    
    for i in range(H):
        for j in range(W):
            v=make(i,j)
            root=uf.find(v)
            if S[i][j]=="#":
                ddb[root]+=1
            else:
                ddh[root]+=1
                
    for k,v in ddb.items():
        ans+=v*ddh[k]

        
        
    print(ans)
            
    
        
main()


Measured memory_bytes: 116780
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A = nextInt(); // 窓
		int B = nextInt(); // カーテン

		int res = A - (B * 2);
		if(res <= 0) res = 0;
		out.println(res);
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 23252
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

struct Node{
 int key;
 Node *right,*left,*parent;
 };
 
 Node *root,*NIL;
 
 Node * find(Node *u,int k){
 while(u!=NIL && k!=u->key){
 if(k<u->key) u=u->left;
 else u= u->right;
 }
 return u;
 }
 
 void insert(int k){
Node *y=NIL;
 Node *x=root;
 Node *z;
 
 z=(Node *)malloc(sizeof(Node));
 z->key=k;
 z->left=NIL;
 z->right=NIL;
 
 while(x!=NIL){
 y=x;
 if(z->key < x->key){
 x=x->left;
 }else{
 x=x->right;
 }
 }
 
 z->parent=y;
 if(y==NIL){
 root=z;
 }else{
 if(z->key < y->key){
 y->left=z;
 }else{
  y->right=z;
 }
 }
 }
 
 void inorder(Node *u){
  if(u==NIL) return;
 inorder(u->left);
 printf(" %d",u->key);
 inorder(u->right);
 }
 void preorder(Node *u){
  if(u==NIL) return;
 printf(" %d",u->key);
 preorder(u->left);
 preorder(u->right);
}
 
 int main(){
 int n,i,x;
 string com;
 
 scanf("%d",&n);
 
 for(i=0;i<n;i++){
 cin >> com;
 if(com[0]=='f'){
 scanf("%d",&x);
 Node *t=find(root,x);
 if(t!=NIL) printf("yes\n");
 else printf("no\n");
 }else if(com=="insert"){
  scanf("%d",&x);
  insert(x);
  }else if(com=="print"){
  inorder(root);
  printf("\n");
   preorder(root);
  printf("\n");
  }
  }
  
  return 0;
  }
  
  /*
10
insert 30
insert 88
insert 12
insert 1
insert  20
find 12
insert 17
insert 25
find 16
print
*/
  
  


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

using namespace std;

const int N = 3e3;
const int T = 3e3;

pair<int, int> a[N + 7];

int dp[N + 7][T + 7];

int n;

int dpf (int i, int t) {
	int &d = dp[i][t];

	if (d != -1) {
		return d;
	}

	if (i > n) {
		return d = 0;
	}

	if (t == 0) {
		return d = 0;
	}

	d = a[i].second;

	d = max(d, dpf(i + 1, t));
	
	if (t - a[i].first >= 0) {
		d = max(d, a[i].second + dpf(i + 1, t - a[i].first));
	}

	return d;
}

int main () {
	memset(dp, -1, sizeof dp);
	int t;
	cin >> n >> t;

	for (int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}

	sort(a + 1, a + n + 1, [] (pair<int, int> a, pair<int, int> b) {
		if (a.first == b.first) {
			return a.second > b.second;
		}
		
		return a.first < b.first;
	});

	cout << dpf(1, t) << "\n";

	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;

int main() {
  int64_t N,K;
  cin>>N>>K;
  int64_t ans=0;
  for(int b=1;b<=N;b++){
    ans+=(N+1)/b*max((int64_t)0,b-K);
    ans+=max((int64_t)0,(N+1)%b-K);
  }
  if(K==0){ans-=N;}
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3612
n = int(input())

if 400<=n<=599:
    print(8)
elif 600<=n<=799:
    print(7)
elif 800<=n<=999:
    print(6)
elif 1000<=n<=1199:
    print(5)
elif 1200<=n<=1399:
    print(4)
elif 1400<=n<=1599:
    print(3)
elif 1600<=n<=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,m;
int a[maxn],b[maxn],id[maxn];
struct edge{int v,nxt;}e[maxn<<1];
int head[maxn],ecnt=0,vis[maxn];
void add(int u,int v)
{
	e[++ecnt]=(edge){v,head[u]},head[u]=ecnt;
	e[++ecnt]=(edge){u,head[v]},head[v]=ecnt;
}
bool cmp(const int &x,const int &y){return a[x]<a[y];}
vector<int>G[maxn];
int fa[maxn];
long long sum[maxn],dp[maxn];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void dfs(int u,int pre)
{
	
	for(int i=head[u];~i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(v==pre)continue;
		dfs(v,u);
		sum[u]+=sum[v];
	}
	sum[u]+=b[u];
	dp[u]=sum[u]+a[u];
	for(int i=head[u];~i;i=e[i].nxt)
	{
		int v=e[i].v;
		if(v==pre)continue;
		dp[u]=min(dp[u],sum[u]-sum[v]+max(dp[v],a[u]*1LL));
	}
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),a[i]=max(0,a[i]-b[i]),id[i]=i;
	sort(id+1,id+1+n,cmp);
	for(int i=1;i<=n;i++)fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
	{
		int u=id[i];
		vis[u]=1;
		for(auto v:G[u])
		if(vis[v]&&find(u)!=find(v))
		{
			add(u,find(v));
			fa[find(v)]=u;
		}
	}
	dfs(id[n],0);
	printf("%lld\n",dp[id[n]]);
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;



int main() {
  intll n,a,b,c,d,e ;
  cin >> n >> a >> b >> c >> d >> e ;
  
  intll MIN = min(a,(min(min(b,c),min(d,e)))) ;
  intll ans = 4 ;
  
  ans += n /MIN ;
  if(n%MIN) ans++ ;
  
  cout << ans ;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, k);
  out(k / 2 * (k - k / 2));
}


Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, d;
    cin >> n >> d;
    d = d * 2 + 1;

    int ans = n / d;
    if (n % d > 0) ans++;

    cout << ans << "\n";
    return 0;
}

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

const int MAXN = 200010;

int a[MAXN];

int main(){
	int N, x, cnt;
	scanf("%d %d", &N, &x);
	if (x == 1 || x == (N << 1) - 1){
		printf("No");
		return 0;
	}
	if (x == 2){
		a[N - 2] = 4, a[N - 1] = 1, a[N] = 2, a[N + 1] = 3;
		for (int i = 1; i < N - 2; ++i)
			a[i] = i + 4;
		for (int i = N + 2; i <= (N << 1) - 1; ++i)
			a[i] = i;
	}
	else if (x == (N << 1) - 2){
		a[N - 1] = (N << 1) - 3, a[N] = (N << 1) - 2, a[N + 1] = (N << 1) - 1, a[N + 2] = (N << 1) - 4;
		for (int i = 1; i < N - 1; ++i)
			a[i] = i;
		for (int i = N + 3; i <= (N << 1) - 1; ++i)
			a[i] = i - 4;
	}
	else {
		a[N - 2] = x + 2, a[N - 1] = x - 1, a[N] = x, a[N + 1] = x + 1, a[N + 2] = x - 2;
		cnt = 1;
		for (int i = 1; i < N - 2; ++i, ++cnt){
			if (cnt == x - 2)
				cnt = x + 3;
			a[i] = cnt;
		}
		for (int i = N + 3; i <= (N << 1) - 1; ++i, ++cnt){
			if (cnt == x - 2)
				cnt = x + 3;
			a[i] = cnt;
		}
	}
	printf("Yes\n");
	for (int i = 1; i <= (N << 1) - 1; ++i)
		printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 2480
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define ALL(n) begin(n),end(n)

int main(){
    vector<int> v(3);
    REP(i,3){
        cin>>v[i];
    }
    
    sort(ALL(v));
    
    REP(i,2){
        cout<<v[i]<<" ";    
    }
    
    cout<<v[2]<<endl;

}


Measured memory_bytes: 3124
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))

def main():
    n=I()
    a=[]
    b=[]
    c=[]
    for i in range(n):
        tmp=L()
        a.append(tmp[0])
        b.append(tmp[1])
        c.append(tmp[2])
    dp=[[0]*3 for i in range(n)]
    dp[0][0]=a[0]
    dp[0][1]=b[0]
    dp[0][2]=c[0]
    for i in range(n-1):
        dp[i+1][0]=max(dp[i+1][0],dp[i][1]+a[i+1],dp[i][2]+a[i+1])
        dp[i+1][1]=max(dp[i+1][1],dp[i][0]+b[i+1],dp[i][2]+b[i+1])
        dp[i+1][2]=max(dp[i+1][2],dp[i][0]+c[i+1],dp[i][1]+c[i+1])
    print(max(dp[n-1]))
        
        
    
    
if __name__ == '__main__':
    main()

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

int main() {

	int n; cin >> n;

	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	ll ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < n; j++) {
			ll tmp = abs(a[i] - a[j]);
			ans = max(ans, tmp);
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >> k;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout<<a[k-1]<<endl;
  
}


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



using ull = unsigned long long;

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

	if (n >= m) 
		std::cout << "0\n";
	
	else {
		std::vector<int> xi;
		xi.resize(m);

		for (auto&e : xi)
			std::cin >> e;

		std::sort(std::begin(xi), std::end(xi));


		std::vector<ull> dist;
		dist.resize(m - 1, 1000'000);// > 10^5

		for (int i{ 1 }; i < m; ++i)
			dist[i - 1] = xi[i] - xi[i - 1];

		std::sort(std::begin(dist), std::end(dist));


		auto ans = std::accumulate(
			std::begin(dist)
			, std::end(dist) - (n - 1)
			, ull{}
		);

		std::cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;

const ll MAX_N = ll(1e16) + 1000;

bool check(const vector<ll>& a) {
    for (ll x : a) {
        if (x < 0 || x > MAX_N) return false;
    }
    return true;
}

int main() {
#if __APPLE__
    // freopen("D.in", "r", stdin);
    // freopen("D.out", "w", stdout);
#endif

    ll k;
    scanf("%lld", &k);

    for (ll n = 50; n >= 2; --n) {
        vector<ll> a(n);
        ll cnt = k / n;
        ll rem = k % n;
        for (int i = 0; i < rem; ++i) {
            a[i] = n - 1 + (cnt + 1) * n - ((n - 1) * cnt + rem - 1);
        }
        for (int i = rem; i < n; ++i) {
            a[i] = n - 1 + cnt * n - ((n - 1) * cnt + rem);
        }
        if (check(a)) {
            printf("%d\n", int(n));
            for (ll x : a) {
                printf("%lld ", x);
            }
            puts("");
            return 0;
        }
    }
}


Measured memory_bytes: 256
#import pysnooper
#import numpy
#import os,re,sys,operator
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time

setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
a=[int(i) for i in input().split()]

b=Counter(a).most_common()
ans=0
for i in b:
    if i[0]==i[1]:
        continue
    if i[0]>i[1]:
        ans+=i[1]
    else:
        ans+=i[1]-i[0]
print(ans)

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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)

const int INF = 1000000000;

int main(){
    int n, m; cin >> n >> m;
    dsu d(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        d.merge(a - 1, b - 1);
    }
    auto vec = d.groups();
    cout << vec.size() - 1 << endl;
}

Measured memory_bytes: 8876
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
  int N;
  cin>>N;
  int H[N];
  rep(i,N){
      cin>>H[i];
  }
  int MAX=0;
  int cnt=0;
  
  rep(i,N){
      MAX=max(MAX,H[i]);
      if(H[i]==MAX){
          cnt++;
      }
  }
 
  cout<<cnt<<endl;
  
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong X, K, D;
  cin >> X >> K >> D;

  if (X > 0) {
    llong sho = X / D;
    if (sho >= K) {
      cerr << "a";
      cout << abs(X - K * D) << endl;
    }
    else {
      cerr << "b";
      cout << abs(X - (sho + (K - sho) % 2) * D) << endl;
    }
  }
  else {
    llong sho = -X / D;
    if (sho >= K) {
      cerr << "c";
      cout << abs(X + K * D) << endl;
    }
    else {
      cerr << "d";
      cout << abs(X + (sho + (K - sho) % 2) * D) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

  int n, x; cin >> n >> x;
  vector<int> l(n);
  rep(i, n) cin >> l[i];

  int cnt = 1;
  int dist = 0;
  for(int i = 0; i < n; i++) {
    dist += l[i];
    if(dist <= x) cnt++;
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
def main(N,M,sc):
    if (N,M) == (1,0) or ((N,M) == (1,1) and (sc[0][0] == 1 and sc[0][1] == 0)):
        print(0)
        return
    ans=[-1]*N
    for x in sc:
        if (ans[x[0]-1] != -1 and ans[x[0]-1] != x[1]) or (x[0] == 1 and x[1] == 0):
            print(-1)
            return
        else:
            ans[x[0]-1] = x[1]
    if ans[0] == -1:
        ans[0] = 1
    for i,x in enumerate(ans):
        if x == -1:
            ans[i] = 0
    print(*ans, sep='')

N,M = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(M)]
main(N,M,sc)

Measured memory_bytes: 3064
const [n, ...ss] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const result = {AC: 0, WA: 0, TLE: 0, RE: 0}
for (const s of ss) {
  result[s] += 1
}
console.log(`AC x ${result['AC']}`)
console.log(`WA x ${result['WA']}`)
console.log(`TLE x ${result['TLE']}`)
console.log(`RE x ${result['RE']}`)


Measured memory_bytes: 45236
#include <bits/stdc++.h>
using namespace std;
int main() {
  int H,W;
  cin >> H >> W;
  char f[H+2][W+2] = {'q'};
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> f[i+1][j+1];
    }
  }
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      if (f[i][j] == '.') {
        int cnt = 0;
        for (int x = -1; x <= 1; x++) {
          for (int y = -1; y <= 1; y++) {
            if (f[i+x][j+y] == '#') {
              cnt++;
            }
          }
        }
        f[i][j] = cnt + '0';
      }
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << f[i+1][j+1];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n,k;
const LL mof=1e9+7;
LL p=mof;
const LL maxn=1000007;
inline LL pow_mod(LL a,LL k,LL mo)
{
    LL ans=1;
    while(k)
    {
        if(k%2) ans=ans*a%mo;
        a=a*a%mo;
        k>>=1;
    }
    return ans%mo;
}
LL jc[maxn+7];
inline LL inv(LL x)
{
    return pow_mod(x,mof-2,mof);
}
LL Inv[maxn+7];
LL C(LL N,LL k)
{
    if(k>N||k<0)return 0;
    if(k==0||k==N)return 1;
    LL ans=1;
    ans=ans*jc[N]*Inv[k]%mof*Inv[N-k]%mof;
    return ans;
}
void init()
{
    jc[1]=jc[0]=1;
    for(LL i=2; i<=maxn; ++i) jc[i]=jc[i-1]*i%mof;
    for(int i=0; i<=maxn; ++i) Inv[i]=inv(jc[i]);
}
int main()
{
    init();
    int x,y;
    cin>>x>>y;
    if((2*x-y)%3 || (2*y-x)%3)
    {
        cout<<0<<endl;
        return 0;
    }
    int a = (2*x-y)/3;
    int b = (2*y-x)/3;
    
    cout<<C(a+b,a)<<endl;
}

Measured memory_bytes: 15872
// Coded by- Rad0n

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())
#define forn(i,n) for(ll i=0;i<ll(n);i++)
#define forr(i,n) for(ll i=ll(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define test int t,o;cin>>o;for(t=1;t<=o;t++)
#define kickstart int t,o;cin>>o;for(t=1;t<=o;t++){cout<<"Case #"<<t<<": ";solve();}
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define o_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define o_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll=long long int;
#define mod 1000000007
mt19937 rng(time(NULL));
double p=3.1415926535897;
void solve()
{
	
	int n,k;
	cin>>n>>k;
	ll s=0;
	forn(i,k)
	{
		ll a;
		cin>>a;
		s+=a;
	}

	if(n-s<0)cout<<-1<<endl;
	else cout<<n-s<<endl;
	

}

int main()
{
	
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    solve();
}


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

ll gcd(ll a, ll b) {
    while ( b != 0 ) {
        ll t = b;
        b = a % b;
        a = t;
    }
    return a;
}

ll solve() {
    ll N, t, a, ct = 1, ca = 1, k;
    cin >> N;
    for ( int i = 0; i < N; i++ ) {
        cin >> t >> a;
        k = max(( ct + t - 1 ) / t, ( ca + a - 1 ) / a);
        ct = k * t;
        ca = k * a;
    }
    return ct + ca;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  priority_queue<ll> pq;
  for(int i=0;i<n;i++){
    cin >> a[i];
    pq.push(a[i]);
  }
  for(int i=1;i<=m;i++){
    ll c=pq.top();
    pq.pop();
    pq.push(c/2);
  }
  ll sum=0;
  while(!pq.empty()){
    sum+=pq.top();
    pq.pop();
  }
  cout<< sum << endl;
}

Measured memory_bytes: 2168
from itertools import product
import numpy as np
a = int(input())
b = int(input())
c = int(input())
x = int(input())

a = sum([sum(el)==x for el in 
               product(
                   np.arange(a+1)*500, np.arange(b+1)*100, np.arange(c+1)*50
               )])
print(a)


Measured memory_bytes: 13788
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
const ll nmax = 1e9 + 7;
const ll MOD = 998244353;
const double PI = 2 * asin(1);

int main(){
  int H, W; cin >> H >> W;
  char S[H][W]; bool visited[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> S[i][j];
      visited[i][j] = false;
    }
  }

  ll ans = 0;
  queue < pair<int, int> > que;
  que.push(make_pair(0, 0)); visited[0][0] = true;
  int di[4] = {-1, 0, 1, 0}, dj[4] = {0, -1, 0, 1};
  int nowi = 0;
  ll B = 0, Wh = 0;
  while (!que.empty()){
    pair <int, int> P = que.front(); que.pop();
    if (S[P.first][P.second] == '#') B++;
    else Wh++;

    for (int k = 0; k < 4; k++){
      int I = P.first + di[k], J = P.second + dj[k];

      if (0 <= I && I < H && 0 <= J && J < W){
        if (visited[I][J] == false && S[P.first][P.second] != S[I][J]){
          visited[I][J] = true;
          que.push(make_pair(I, J));
        }
      }
    }

    if (que.empty()){
      ans += B * Wh; B = 0; Wh = 0;

      for (int i = nowi; i < H; i++){
        for (int j = 0; j < W; j++){
          if (visited[i][j] == false){
            nowi = i;
            visited[i][j] = true;
            que.push(make_pair(i, j));
            break;
          }
        }
        if (!que.empty()) break;
      }
    }
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
import queue
import math
import copy
"""
N = int(input())
#S = input()
# (N,M) = (int(i) for i in input().split(" "))
# A = [int(i) for i in input().split()]
A = []
for i in range(N):
	A.append(int(input()))

print(A)

"""

N = int(input())
M = int(input())
print(6-N-M)

Measured memory_bytes: 4336
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 1005

int r,c;
int fx[]={-1,1,0,0};
int fy[]={0,0,1,-1};

bool valid(int x,int y){
   return x>=1&&x<=r&&y>=1&&y<=c;
}

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,m,k,sx,sy,dx,dy;
   cin>>n>>m>>k>>sx>>sy>>dx>>dy;
   r=n,c=m;
   char s[n+5][m+5];
   int dis[n+5][m+5];
   for(int i=1;i<=n;i++){
      for(int j=1;j<=m;j++){
         cin>>s[i][j];
         dis[i][j]=INT_MAX;
      }
   }
   queue<pi>q;
   if(s[sx][sy]=='.') q.push({sx,sy}),dis[sx][sy]=0;
   while(!q.empty()){
      pi u=q.front();q.pop();
      for(int i=0;i<4;i++){
         for(int j=1;j<=k;j++){
            int nx=u.F+fx[i]*j;
            int ny=u.S+fy[i]*j;
            if(!valid(nx,ny)||s[nx][ny]=='@'||dis[nx][ny]<=dis[u.F][u.S]) break;
            if(dis[nx][ny]>dis[u.F][u.S]+1){
               dis[nx][ny]=dis[u.F][u.S]+1;
               q.push({nx,ny});
            }
         }
      }
   }
   int ans=(dis[dx][dy]==INT_MAX)?-1:dis[dx][dy];
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 9148
N=int(input())
A=list(map(int,input().split()))

D={}
for a in A:
    if a in D:
        D[a]+=1
    else:
        D[a]=1
        
S=[0,0]
for a in D:
    for _ in range(D[a]//2):
        S.append(a)
        
x=max(S)
del S[S.index(x)]
y=max(S)
print(x*y)


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=924844033;

int dp[2222][2222][2];

int N,K;

int fact[2222];

int tmp[2222];
int dp2[2222];

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

signed main(){
    cin>>N>>K;
    fact[0]=1;
    for(int i=1;i<2222;i++)fact[i]=fact[i-1]*i%mod;

    dp2[0]=1;
    for(int i=0;i<2*K&&i<N;i++){
        int n=(N-i)/(2*K)+1;
        if((N-i)%(2*K)==0)n--;

        int flag1=0,flag2=0;
        if(i-K>=0)flag1=true;
        if(i+(n-1)*2*K+K<N)flag2=true;
        rep(j,n+1)rep(k,n+1)rep(l,2)dp[j][k][l]=0;
        dp[0][0][1-flag1]=1;
        rep(j,n){
            rep(k,n+1){
                rep(l,2){
                    add(dp[j+1][k][0],dp[j][k][l]);
                    add(dp[j+1][k+1][1],dp[j][k][l]);
                    if(l==0)add(dp[j+1][k+1][0],dp[j][k][l]);
                }
            }
        }
        memset(tmp,0,sizeof(tmp));
        rep(j,N+1){
            rep(k,n+1){
                if(j+k<=N)add(tmp[j+k],dp2[j]*(dp[n][k][0]+dp[n][k][1]*flag2)%mod);
            }
        }
        rep(j,N+1)dp2[j]=tmp[j];
    }

    rep(j,N+1)dp2[j]=dp2[j]*fact[N-j]%mod;

    int ans=0;
    rep(i,N+1){
        if(i&1)ans=(ans-dp2[i]+mod)%mod;
        else ans=(ans+dp2[i])%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 34176
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
	typedef pair<int,int>P;
	typedef vector<P>V;
	int N,M,r,q,t,n,m,s,e,i,j;
	while(scanf("%d%d",&N,&M),N)
	{
		P p;
		vector<V>S(M+1);
		V T(M+1);
		scanf("%d",&r);
		for(i=0;i<r;++i)
		{
			scanf("%d%d%d%d",&t,&n,&m,&s);
			if(s){if(!T[m].second++)T[m].first=t;}
			else{if(!--T[m].second)S[m].push_back(P(T[m].first,t));}
		}
		scanf("%d",&q);
		for(i=0;i<q;++i)
		{
			scanf("%d%d%d",&s,&e,&m);
			for(r=j=0;j<S[m].size();++j)
			{
				p=S[m][j];
				p.first=max(p.first,s);
				p.second=min(p.second,e);
				if(p.first<p.second)r+=p.second-p.first;
			}
			printf("%d\n",r);
		}
	}
	return 0;
}

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

using namespace std;

bool check(int n){
  if(n==1||n==0)return 0;
  for(int i=2;i*i<=n;i++) if(n%i==0)return 0;
  return 1;
}

int main(){
  int n;
  
  while(cin>>n,n){
    int cnt=0;
    for(int i=0;i<n;i++)
      if(check(i)&&check(n-i)&&i<=n-i)cnt++;
    cout <<cnt<<endl;
        }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> A(3);
  cin >>A.at(0)>>A.at(1)>>A.at(2);
  
  sort(A.begin(),A.end());
  int ans=A.at(2)-A.at(0);
  
  cout<<ans<<endl;

}
  
  

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

def check(y,x):
    if 0<=y<=h-1 and 0<=x<=w-1:
        return True
    return False

def dfs(y,x):
    dx=[1,0,-1,0]
    dy=[0,1,0,-1]
    color[y][x]=1
    for i in xrange(4):
        nextx=x+dx[i]
        nexty=y+dy[i]
        if not check(nexty,nextx):continue
        if g[nexty][nextx]==g[y][x] and color[nexty][nextx]==0:
            dfs(nexty,nextx)
    color[y][x]=2
    return 1
while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    g=[raw_input() for _ in xrange(h)]
    cnt=0
    color=[[0]*w for _ in xrange(h)]
    for i in xrange(h):
        for j in xrange(w):
            if color[i][j]==2:continue
            cnt+=dfs(i,j)
    print(cnt)

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

int main() {

  int N = 0;
  int A = 0;
  int B = 0;

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

  int Plan1 = A * N;
  int Plan2 = B;

  if (Plan1 < Plan2) {
    cout << Plan1 << endl;
  } else {
    cout << Plan2 << endl;
  }
}



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

int main(){
  long long int n, k;
  long long int mod = 1000000007;
  cin >> n >> k;
  if(n+1==k){
    cout << 1 << endl;
    return 0;
  }
  long long int fw[n+2],bw[n+2];
  fw[0]=0; bw[0]=0;
  fw[1] = 0;
  bw[1] = n;
  for(int i=1; i<=n; i++){
    fw[i+1] = fw[i]+i;
    bw[i+1] = bw[i]+(n-i);
  }
  long long int ans=0;
  for(int i=k; i<=n+1; i++){
    ans += (bw[i] - fw[i] + 1)%mod;
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


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

int gcd(int x,int y){
    if(x%y==0){
        return y;
    }else{
        return gcd(y,x%y);
    }
}
int main(){
    int W,H,C;
    cin>>W>>H>>C;

    cout<<W*H/gcd(W,H)/gcd(W,H)*C<<endl;

    return 0;
}


Measured memory_bytes: 3096
def main():
    N = int(input())
    A = [input() for i in range(N)]
    from collections import Counter
    c = Counter(A[0])
    for a in A[1:]:
        d = Counter(a)
        c = c & d
    print("".join(sorted(c.elements())))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  
  for (int i=0; i<=N-3; i++){
    string sub = S.substr(i,3);
    if (sub == "ABC"){
      ans += 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ 2 * g - r where [r, g] = fmap read (lines s) :: [Int]

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
//=========================================c++
/* ===========================================
// 20.03.21 AtCoder Beginner Contest 155, C - Poll (unordered map hash)
// 
// 
=========================================== */
/* ===========================================

問題文
N
 枚の投票用紙があり、i(1≤i≤N) 枚目には文字列 Si が書かれています。
書かれた回数が最も多い文字列を全て、辞書順で小さい順に出力してください。

test input:
7
beat
vet
beet
bed
vet
bet
beet

=========================================== */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>
#define UQ unique_ptr
#define MQ make_unique
const ll INF = 1LL << 50;
const int mini = 10e5+5;



int main(){
    
    int n; cin >> n;
    
    map<string, int> hash;
    
    rez(i,n){
        string s_find; cin >> s_find;
        
        if (hash.find(s_find) != hash.end()){
            hash[s_find]++;
        }
        else{
            hash[s_find] = 1;
        }
    }
    
    int max_cnt = 0;
    for(auto &fd : hash){
        max_cnt = max(max_cnt, fd.second);
    }
    for(auto &fd : hash){
        if (fd.second == max_cnt){
            cout << fd.first << ET;
        }
    }
    
    
    
}








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

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  int ans = 1LL << 40;
  for (int i = 0; i+3 <= s.size(); i++) {
    string t = s.substr(i, 3);
    ans = min(ans, abs(stoll(t)-753));
  }
  cout << ans << endl;

  return 0;
}

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

public class Main {

	private static Scanner in;
	private static String s, t;
	private static long[][] dp;
	private static int n, m;
	
	public static void main(String[] args) {
		in = new Scanner(System.in);
		s = in.next();
		t = in.next();
		n = s.length();
		m = t.length();
		dp = new long[n+1][m+1];
		
		for(int i=0; i<dp.length; i++) {
			Arrays.fill(dp[i], -1);
		}
//		System.out.println(solve(0, 0));
		
		for(int i=0; i<n; i++) {
			for(int j=0; j<m; j++) {
				solve(i, j);
			}
		}
		
		int i = 0;
		int j = 0;
		
		while(i!=n && j!=m) {
			if (s.charAt(i)==t.charAt(j)) {
				System.out.print(s.charAt(i));
				i++;
				j++;
			} else {
				if (dp[i][j]==dp[i][j+1]) {
					j++;
				} else {
					i++;
				}
			}
		}

	}
	
	private static long solve(int i, int j) {
		if (i==n || j==m) return 0;
		
		if (dp[i][j]!=-1) return dp[i][j];
		
		if (s.charAt(i)==t.charAt(j)) {
			return dp[i][j]=1+solve(i+1, j+1);
		} else {
			return dp[i][j] = Math.max(solve(i+1, j), solve(i, j+1));
		}
	}

}


Measured memory_bytes: 131016
import numpy as np

temp = input()
H,W = temp.split()
H = int(H)
W = int(W)
pref = np.zeros((H,W))
for i in range(H):
    row = input()
    for j in range(W):
        if row[j] == ".":
            pref[i][j] = 1
        else:
            pref[i][j] = 0
totalw = np.count_nonzero(pref)

a = np.zeros((H,W))     

quere = []
quere.append(0)
while quere != []:
    locas = quere[0]
    tempscore = (H+1)*(W+1)
    if locas % W > 0 :
        left = locas - 1
        if a[(left // W)][(left % W)] == 0 and pref[(left // W)][(left % W)] == 1:
            if left not in quere:
                quere.append(left)
        elif a[(left // W)][(left % W)] > 0:
            tempscore = min(tempscore,a[(left // W)][(left % W)])
    if locas % W < W-1:
        right = locas + 1
        if a[(right // W)][(right % W)] == 0 and pref[(right // W)][(right % W)] == 1:
            if right not in quere:
                quere.append(right)
        elif a[(right // W)][(right % W)] > 0:
            tempscore = min(tempscore,a[(right // W)][(right % W)])
    if locas // W > 0 :
        up = locas - W
        if a[(up // W)][(up % W)] == 0 and pref[(up // W)][(up % W)] == 1:
            if up not in quere:
                quere.append(up)
        elif a[(up // W)][(up % W)] > 0:
            tempscore = min(tempscore,a[(up // W)][(up % W)])
    if (locas // W) < (H - 1):
        down = locas + W
        if a[(down // W)][(down % W)] == 0 and pref[(down // W)][(down % W)] == 1:
            if down not in quere:
                quere.append(down)
        elif a[(down // W)][(down % W)] > 0:
            tempscore = min(tempscore,a[(down // W)][(down % W)])
    
    if locas == 0:tempscore=0
    
    a[(locas // W)][(locas % W)] = tempscore + 1
    quere.pop(0)
    

leng = a[H-1][W-1]
if leng > 0 and leng < (H+1)*(W+1):
    score = totalw-leng
    print(int(score))
else:print(-1)


Measured memory_bytes: 20884