akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	string S;
	cin >> S;

	S.at(3) = '8';
	cout << S << endl;
}

Measured memory_bytes: 3572
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# -*- coding: utf-8 -*-
'import sys'
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)


Measured memory_bytes: 5612
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define Temp template<typename T>
using namespace std;
typedef long long LL;
Temp inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}

const int maxn=100000+10;
int n,m;
int a[maxn],b[maxn],maxa;
int ans;

inline int cmp(int x,int y){return x>y;}

int main(){
	read(n);read(m);
	for(Rint i=1;i<=n;i++){
		read(a[i]);read(b[i]);
		maxa=max(maxa,a[i]);
	}
	sort(b+1,b+n+1,cmp);
	int l=0,r=n,pos;
	while(l<r){
		int mid=((l+r)>>1)+1;
//		cout<<l<<' '<<r<<' '<<b[mid]<<endl;
		if(maxa<=b[mid])l=mid;
		else r=mid-1;
	}
//	cout<<l<<endl;
	for(Rint i=1;i<=l;i++){
		m-=b[i];
		ans++;
		if(m<=0){
			printf("%d\n",ans);
			return 0;
		}
	}
	int p=m%maxa;
	ans+=(m/maxa);
	if(p)ans++;
	printf("%d\n",ans);
	return 0;
}


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

int main() {
  string s;cin>>s;
  bool ans=true;
  rep(i,s.size())for(int j=i+1;j<s.size();j++){
    if(s[i]==s[j])ans=false;
  }
  if(ans)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
int dp[10005];
int n,m;
int tot;
int minn;
int use[10]={0,2,5,5,4,5,6,3,7,6},in[10],in2[10],in3[10];
bool dfs(int res,int xx){
    if(xx>dp[n]||(res<(dp[n]-xx)*minn))return false;
    if(res==0&&xx==dp[n]){
        for(int i=tot-1;i>=0;i--){
            for(int j=0;j<in3[i];j++){
                printf("%d",in2[i]);
            }
        }
        printf("\n");
        return true;
    }
    for(int i=tot-1;i>=0;i--){
        if(res-use[in2[i]]>=0){
                in3[i]++;
                if(dfs(res-use[in2[i]],xx+1))return true;
                in3[i]--;
        }
    }
    return false;
}
int main(){
    cin>>n>>m;
    set<int>ss;
    while(m--){
        int a;
        scanf("%d",&a);
        ss.insert(use[a]);
        in[use[a]]=max(in[use[a]],a);
    }
        set<int>::iterator it=ss.begin();
        minn=(*it);
        for(it;it!=ss.end();it++){
            in2[tot++]=in[(*it)];
        }
        sort(in2,in2+tot);
    for(int i=0;i<=n;i++){
        set<int>::iterator it=ss.begin();
        for(it;it!=ss.end();it++){
            if((*it)<=i&&(dp[i-(*it)]||(i==(*it)))){
                dp[i]=max(dp[i],dp[i-(*it)]+1);
            }
        }
    }
   // cout<<dp[n]<<endl;
    dfs(n,0);
    return 0;
}


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

int main(){
    string a,b,c; cin>>a>>b;
    c = a+b;
    int num = stoi(c);

    for(int i=1; i<=100000; i++){
        if(i*i == num){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;

    return 0;
}

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

const ll MAXN = 200000;

ll N, M, ans=0, tmp=0;
vector<vector<pair<ll, ll>>> F;

void dfs(ll id, vector<ll> v) {
    if(id==N) {
        for(int i=0;i<N;i++) {
            if(v[i]==1) {
                for(int j=0;j<F[i].size();j++) {
                    if(v[F[i][j].first]!=F[i][j].second) {
                        return;
                    }
                }
            }
            /*
            else {
                for(int j=0;j<F[i].size();j++) {
                    if(v[F[i][j].first]==F[i][j].second) {
                        return;
                    }
                }
            }
            */
        }
        ll vc=0;
        for(int i=0;i<N;i++) {
            if(v[i]==1) vc++;
        }
        ans = max(ans, vc);
        return;
    }
    dfs(id+1, v);
    v[id]=1;
    dfs(id+1, v);
}

signed main(){
    cin >> N;
    F.resize(N);
    vector<ll> TF(N, 0);
    for(int i=0;i<N;i++) {
        cin >> M;
        for(int j=0;j<M;j++) {
            ll x, y;
            cin >> x >> y;
            x--;
            F[i].push_back(make_pair(x, y));
        }
    }
    dfs(0, TF);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  int a[200000];
  rep(i,n) cin>>a[i];
  int f[200000];
  rep(i,n) cin>>f[i];
  sort(a,a+n);sort(f,f+n,greater<int>());
  int mn=0,mx=1000000000000;
  int mid=(mn+mx)/2;
  int cnt;
  while(mn<mx){
    cnt=0;
    rep(i,n){
      cnt+=max((int)0,(f[i]-1+(a[i]*f[i]-mid))/f[i]);
    }
    if(cnt > k) mn=mid+1;
    else mx=mid;
    mid=(mn+mx)/2;
  }
  cout<<mid<<endl;

  return 0;
}


Measured memory_bytes: 3456
import java.util.Scanner;

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

        int N = sc.nextInt();
        int L = sc.nextInt();
        int sum = calcSum(L, L + N - 1);

        if (L > 0)
            System.out.println(sum - L);
        else if (N + L <= 0 && L <= 0)
            System.out.println(sum - (L + N - 1));
        else
            System.out.println(sum);
        
    }

    static int calcSum(int a, int b) {
        return (a + b) * (b - a + 1) / 2;
    }
}


Measured memory_bytes: 21844
#!/usr/bin/env python

def main():
    n, k = map(int, input().split())
    d = []
    a = []
    for i in range(k):
        d.append(int(input()))
        a.append(list(map(int, input().split())))

    cnt = [1 for _ in range(n)]
    for i in range(k):
        for b in a[i]:
            cnt[b-1] = 0

    print(sum(cnt))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9220
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	char S[50];
	scanf("%s", S);
	int len = strlen(S);
	
	char *A="AKIHABARA";
	char *B="KIHABARA";
	char *C="AKIHBARA";
	char *D="AKIHABRA";
	char *E="AKIHABAR";
	char *F="KIHBARA";
	char *G="AKIHBRA";
	char *H="AKIHABR";
	char *I="AKIHBR";
	char *J="KIHABR";
	char *K="KIHBAR";
	char *L="KIHBRA";
	char *M="KIHBR";
	char *N="KIHABRA";
	char *O="AKIHBAR";
	char *P="KIHABAR";
	
	if(len>=10) printf("NO");
	else{
		if( strncmp(S,A,9)==0 || strncmp(S,B,8)==0 || strncmp(S,C,8)==0 || strncmp(S,D,8)==0 || strncmp(S,E,8)==0 || strncmp(S,F,7)==0 || strncmp(S,G,7)==0 || strncmp(S,H,7)==0 || strncmp(S,I,6)==0 || strncmp(S,J,6)==0 || strncmp(S,K,6)==0 || strncmp(S,L,6)==0 || strncmp(S,M,5)==0 ||  strncmp(S,N,7)==0 || strncmp(S,O,7)==0 || strncmp(S,P,7)==0) printf("YES");
		else printf("NO");
	}
	return 0;
	
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	REP(i, w + 2)cout << '#';
	cout << endl;
	REP(i, h) {
		cout << '#';
		string s;
		cin >> s;
		cout << s << '#' << endl;
	}
	REP(i, w + 2)cout << '#';
	cout << endl;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int a;
    cin >> a;
    n -= a;
  }

  cout << max(n, -1) << endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 30
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

vector<int> V[210];
int color[210];

//二部グラフならtrueを返す
bool dfs(int x,int c){
  color[x]=c;
  for(int i=0;i<V[x].size();i++){
    //隣接している頂点が同じ色ならfalse
    if(color[V[x][i]]==c) return false;
    //隣接している頂点がまだ塗られていないなら-cで塗る
    if(color[V[x][i]]==0 && !dfs(V[x][i],-c)) return false;
  }
  return true;
}

ll d[210][210]; //d[u][v]は辺e=(u,v)のコスト(存在しない場合はINF，d[i][i]=0)
int N;
//(V^3)
void warshall_floyd(){
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++) d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}

void init(){
  for(int i=0;i<210;i++){
    for(int j=0;j<210;j++){
      if(i==j) d[i][j]=0;
      else d[i][j]=INF;
    }
  }
}


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

    cin>>N;
    init();
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            char c;
            cin>>c;
            if(c=='1'){
                V[i].push_back(j);
                d[i][j]=1;
            } 
        }
    }

    if(dfs(0,1)==false){
        cout<<-1<<endl;
        return 0;
    }
    warshall_floyd();
    int ans=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            chmax(ans,d[i][j]);
        }
    }
    cout<<ans+1<<endl;
}


Measured memory_bytes: 768
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>

typedef int32_t i32;
typedef int64_t i64;

typedef struct directed_edge {
  int32_t vertex;
  int32_t next;
} graph_edge;

typedef struct directedGraph {
  graph_edge *edge;
  int32_t *start;
  int32_t pointer;
  int32_t vertex_num;
  int32_t edge_max_size;
} graph;

graph* new_graph (const int vertex_num) {
  graph *g = (graph *) calloc (1, sizeof (graph));
  g->edge = (graph_edge *) calloc (1, sizeof (graph_edge));
  g->start = (int32_t *) calloc (vertex_num, sizeof (int32_t));
  g->pointer = 0;
  g->vertex_num = vertex_num;
  g->edge_max_size = 1;
  for (int32_t i = 0; i < vertex_num; ++i) {
    g->start[i] = -1;
  }
  return g;
}

void add_edge (graph *g, int32_t from, int32_t to) {
  if (g->pointer == g->edge_max_size) {
    g->edge_max_size *= 2;
    g->edge = (graph_edge *) realloc (g->edge, sizeof (graph_edge) * g->edge_max_size);
  }
  g->edge[g->pointer] = (graph_edge) {to, g->start[from]};
  g->start[from] = g->pointer++;
}

void BFS_graph (graph *g, int32_t src, i32 *q) {
  uint8_t *used = (uint8_t *) calloc (g->vertex_num, sizeof (uint8_t));
  int32_t front = 0;
  int32_t last = 0;
  used[src] = 1;
  q[last++] = src;
  while (front < last) {
    const int32_t v = q[front++];
    for (int32_t p = g->start[v]; p != -1; p = g->edge[p].next) {
      const int32_t u = g->edge[p].vertex;
      if (!used[u]) {
	used[u] = 1;
	q[last++] = u;
      }
    }
  }
  free(used);
}

void fill (graph *g, i32 v, i32 *ok) {
  if (ok[v]) return;
  ok[v] = 1;
  for (i32 p = g->start[v]; p != -1; p = g->edge[p].next) {
    i32 u = g->edge[p].vertex;
    fill (g, u, ok);
  }
}

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, a + i);
    a[i]--;
  }
  graph *g = new_graph (n);
  for (i32 i = 1; i < n; ++i) {
    add_edge (g, a[i], i);
  }
  i32 *q = (i32 *) calloc (n, sizeof (i32));
  BFS_graph (g, 0, q);
  i32 *ok = (i32 *) calloc (n, sizeof (i32));
  i32 ans = a[0] == 0 ? 0 : 1;
  a[0] = 0;
  ok[0] = 1;
  for (i32 i = n - 1; i > 0; --i) {
    i32 v = q[i];
    if (ok[v]) continue;
    i32 t = k - 1;
    while (t > 0 && !ok[v]) {
      v = a[v];
      t--;
    }
    if (v == 0) break;
    if (a[v] != 0 && !ok[v]) {
      ans++;
      a[v] = 0;
    }
    fill (g, v, ok);
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  int a, b; cin >> a >> b;
  if(min(a,b) <= 0 && max(a,b) >= 0){
    cout << "Zero" << endl;
  }else if(min(a,b) < 0){
    if(b%2 == a%2){
      cout << "Negative" << endl;
    }else{
      cout << "Positive" << endl;
    }
  }else{
      cout << "Positive" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int prime[100010] = {};
    rep(i,2,100001){
        prime[i] = 1;
        for(int j = 2;j * j <= i;j++){
            if(i % j == 0){
                prime[i] = 0;
                break;
            }
        }
    }
    int accum[100010] = {};
    for(int i = 3;i <= 100000;i += 2){
        accum[i] = accum[i-2] + ( (prime[i] && prime[(i+1)/2]) ? 1 : 0);
    }
    rep(i,0,30){
        //cout << i << " " << accum[i] << endl;
    }
    int Q;
    cin >> Q;
    rep(i,0,Q){
        int l,r;
        cin >> l >> r;
        cout << accum[r] - (l == 1 ? 0 : accum[l-2]) << endl;
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--) 
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    ll N,A,B;
    cin >> N >> A >> B;

    cout << min(N*A,B) <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

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

#define MOD 1000000007
#define PI 3.14159265359

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

    int h, w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> a[i][j];
        }
    }

    char b[h + 2][w + 2];
    for (int i = 0; i < h + 2; i++){
        for (int j = 0; j < w + 2; j++){
            b[i][j] = '#';
        }
    }

    for (int i = 1; i < h + 1; i++){
        for (int j = 1; j < w + 1; j++){
            b[i][j] = a[i - 1][j - 1];
        }
    }

    for (int i = 0; i < h + 2; i++){
        for (int j = 0; j < w + 2; j++){
            cout << b[i][j];
        }
        cout << endl;
    }
}

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

using namespace std;

int main()
{
    int a,b,c,d;
    string A,B;
    cin >> a >> b;
    c = max(a,b);
    d = min(a,b);
    int e = c;
    c--;
    c = max(c,d);
    e += c;
    
    cout <<e<<endl;

    return 0;
}

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

const int mn=1e7+7;
int f[mn],p[mn],n,t[mn];
long long ans;

int main()
{
    scanf("%d",&n);
    f[1]=1;
    for(int i=2;i<=n;++i) {
        if(!p[i]) p[++p[0]]=i,f[i]=2,t[i]=1;
        for(int j=1;j<=p[0]&&i*p[j]<=n;++j) {
            p[i*p[j]]=1;
            if(i%p[j]==0) {
                f[i*p[j]]=f[i]/(t[i]+1)*(t[i]+2);
                t[i*p[j]]=t[i]+1;
                break;
            }
            t[i*p[j]]=1;
            f[i*p[j]]=f[i]*2;
        }
    }
    for(int i=1;i<=n;++i) ans+=1ll*i*f[i];
    cout<<ans;
}

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

int main() {
  ll k,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};
  cin >> k;
  cout << a[k-1] << endl;

  return 0;
}

Measured memory_bytes: 256
A = int(input())
a=[A]
a.append(A)
def div(x):
	if x % 2 == 1:
		return x*3+1
	else:
		return x//2
n = div(a[0])
while not n in a:
	a.append(n)
	n = div(n)
print(len(a))

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;

int main(){
    
    int N,K;cin>>N>>K;
    vector<ll> S[N],A,B;
    
    for(int i=0;i<N;i++){
        ll t,d;cin>>t>>d;
        t--;
        S[t].push_back(d);
    }
    
    for(int i=0;i<N;i++){
        if(S[i].size()){
            sort(S[i].rbegin(),S[i].rend());
            for(int j=0;j<S[i].size();j++){
                if(j) B.push_back(S[i][j]);
                else A.push_back(S[i][j]);
            }
        }
    }
    sort(A.rbegin(),A.rend());
    sort(B.rbegin(),B.rend());
    
    for(int i=0;i<A.size();i++){
        if(i) A[i]+=A[i-1];
    }
    
    for(int i=0;i<B.size();i++){
        if(i) B[i]+=B[i-1];
    }
    
    ll ans=0;
    
    for(ll i=1;i<=A.size();i++){
        if(K-i>B.size()) continue;
        if(K<i) continue;
        ll sum=i*i;
        if(K>i) sum+=A[i-1]+B[K-i-1];
        else sum+=A[i-1];
        ans=max(ans,sum);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 6904
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	W, a, b := getInt(), getInt(), getInt()
	if a > b {
		a, b = b, a
	}
	out(max(0, b-(a+W)))
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
int main() {
	string A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;

	int flag = 0;
	char first = A[0];
	A.erase(0, 1);
	while (flag < 300) {
		if (first == 'a') {
			if (A.empty()) {
				cout << "A" << endl;
				return 0;
			}
			first = A[0];
			A.erase(0, 1);
			flag++;
		}
		
		if (first == 'b') {
			if (B.empty()) {
				cout << "B" << endl;
				return 0;
			}
			first = B[0];
			B.erase(0, 1);
			flag++;
		}

		if (first == 'c') {
			if (C.empty()) {
				cout << "C" << endl;
				return 0;
			}
			first = C[0];
			C.erase(0, 1);
			flag++;
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#pragma warning(disable:4996)

int main()
{
    int a, h, b, c;
    scanf("%d %d", &h, &a);
    b = h % a;
    c = h / a;
    if (b != 0) {
        printf("%d", c + 1);
    }
    else {

        printf("%d", c);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
int main()
{
    Hello
    string a;
    cin >> a;
    if(a == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#define LINF (1LL << 60)
using namespace std;
typedef long long Int;

Int n, W;
Int UV = 110000;
Int w[110], v[110], dp[110000];

int main() {
  cin >> n >> W;
  for (int i = 0; i < n; i++) cin >> w[i] >> v[i];

  for (int j = 1; j < UV; j++) dp[j] = LINF;
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    Int weight = w[i];
    Int val = v[i];
    for (int j = UV - 1; 0 < j; j--) {
      if (0 <= j - val) {
        dp[j] = min(dp[j - val] + weight, dp[j]);
      }
    }
  }
  for (int i = UV - 1; 0 <= i; i--) {
    if (dp[i] <= W) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl

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

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

    int dp[n][3];
    dp[0][0] = arr[0][0]; dp[0][1] = arr[0][1]; dp[0][2] = arr[0][2];
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + arr[i][0];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + arr[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + arr[i][2];
    }
    
    cout << *max_element(dp[n - 1], dp[n - 1] + 3) << endl;

    return 0;
}

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

m = {5: 0, 7: 0}
m[a] = m[a] + 1
m[b] = m[b] + 1
m[c] = m[c] + 1
if m[5] == 2 and m[7] == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9056
import java.util.*; class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); while(true) { int a = sc.nextInt(); String d = sc.next(); int b = sc.nextInt(); if(d.equals("?")) break; if(d.equals("+")) System.out.println(a + b); if(d.equals("-")) System.out.println(a - b); if(d.equals("*")) System.out.println(a * b); if(d.equals("/")) System.out.println(a / b); } } } 


Measured memory_bytes: 26520
import java.util.Scanner;

class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int time = scan.nextInt();
		int h = time / 3600;
		int m = time % 3600 / 60;
		int s = time % 3600 % 60;
		System.out.println(h + ":" + m + ":" + s);
	}
}

Measured memory_bytes: 26224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ll i,j,n;
    ll h,w,m;
    cin>>h>>w>>m;
    vector<ll> r(m),c(m);
    unordered_map<ll,ll> rm,cm;
    unordered_map<ll, unordered_map<ll,bool>> mp;
    ll mxrc = 0, mxcc = 0;
    for(i=0;i<m;i++)
    {
        cin>>r[i]>>c[i];
        rm[r[i]]++;
        mxrc = max(mxrc, rm[r[i]]);
        cm[c[i]]++;
        mxcc = max(mxcc, cm[c[i]]);
        mp[r[i]][c[i]]=1;
    }
    vector<ll> rows,cols;
    for(auto p : rm) 
    {
        if(p.second == mxrc) rows.push_back(p.first);
    }
    for(auto p : cm)
    {
        if(p.second == mxcc) cols.push_back(p.first);
    }
    ll ans = 1;
    for(i=0;i<rows.size();i++)
    {
    ll cur = rm[rows[i]];
    int f = 0;
    for(j=0;j<cols.size();j++)
    {
        ll val = cur + cm[cols[j]];
        if(mp[rows[i]][cols[j]]) 
        {
            val--;
        }
        else f++;
        ans = max(ans,val);
        if(f==1) break;
    }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 95256
import java.util.Scanner;

public class Main{
	public  static void main(String[] args) {
    	try (Scanner sc = new Scanner(System.in)) {
    		int n=sc.nextInt();
    		int m=sc.nextInt();
    		int[] c=new int[m+1];
    		for(int i=1; i<=m; i++) {
    			c[i]=sc.nextInt();
    		}
    		int[] dp=new int[n+1];
    		for(int i=1; i<=n; i++) {
    			dp[i]=n+1;
    		}
    		dp[0]=0;
    		for(int i=1; i<=n; i++) {
    			for(int j=1; j<=m; j++) {
    				if(c[j]<=i) {
    					dp[i]=Math.min(dp[i-c[j]]+1, dp[i]);
    				}
    			}
    		}
    		System.out.println(dp[n]);
    	}
    }
}


Measured memory_bytes: 26932
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <math.h>

int main(int argc, char *argv[])
{
    int n, m, c;
    int a[20][20];
    int b[20];
    int i, j;
    int ans;
    int count;

    scanf("%d %d %d", &n, &m, &c);

    for (i = 0; i < m; i++) {
        scanf("%d", &b[i]);
    }

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

    count = 0;

    for (i = 0; i < n; i++) {
        ans = c;
        for (j = 0; j < m; j++) {
            ans += a[i][j] * b[j];
        }
        if (ans > 0) {count++;}
    }

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

    return 0;
}


Measured memory_bytes: 128
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n,m,x] = spi[0].split(' ').map(e => Number(e));

    const cArray = new Array(n), aArray = new Array(n);
    for (let i = 1; i < n + 1; i++) {
        const work = spi[i].split(' ').map(e => BigInt(e));
        cArray[i - 1] = work[0];
        const wArray = new Array(n);
        for (let j = 1; j < m + 1; j++) {
            wArray[j - 1] = work[j];
        }
        aArray[i - 1] = wArray;
    }

    const MAX = 1000000000000000n;
    let ans = MAX;
    for (let bit = 0; bit < (1 << n); bit++) {
        let row = new Array(m);
        let sum = 0n;
        for (let i = 0; i < m; i++) row[i] = 0n;
        for (let i = 0; i < n; i++) {
            if (bit & (1 << i)) {
                for (let j = 0; j < m; j++) {
                    row[j] += aArray[i][j];
                }
                sum += cArray[i];
            }
        }

        let c = 0;
        for (let i = 0; i < m; i++) {
            if (row[i] >= x) c++;
        }

        if (c === m) {
            if (ans > sum) ans = sum;
        }
    }

    if (ans === MAX) console.log(-1);
    else console.log(ans.toString());
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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


int main() {
  string S, T;
  cin >> S >> T;

  if (S.length() != T.length()) {
    printf("No\n");
    return 0;
  }

  vector<int> pos_S[26], pos_T[26];
  for (int i = 0; i < S.length(); ++i) {
    pos_S[S[i] - 'a'].push_back(i);
    pos_T[T[i] - 'a'].push_back(i);
  }

  bool bCheck = true;

  // S -> T
  for (int i = 0; i < 26; ++i) {
    if (pos_S[i].size() >= 2) { // 同じ文字が２つ以上ある場合
      char s = T[pos_S[i][0]];
      for (int j = 1; j < pos_S[i].size(); ++j) {
        if (s != T[pos_S[i][j]]) bCheck = false;
      }
    }
  }

  // T -> S
  for (int i = 0; i < 26; ++i) {
    if (pos_T[i].size() >= 2) { // 同じ文字が２つ以上ある場合
      char s = S[pos_T[i][0]];
      for (int j = 1; j < pos_T[i].size(); ++j) {
        if (s != S[pos_T[i][j]]) bCheck = false;
      }
    }
  }

  if (bCheck) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

vector<bool> solution;
ll n, res = -10000000000000;

void solve2(vector<vector<bool>> &stores, vector<vector<ll>> &prices) {
    ll result = 0;
    for (ll i=0; i<n; i++) {
        ll counts = 0;
        for (ll j=0; j<10; j++) if (solution[j] && stores[i][j]) counts++;
        result+=prices[i][counts];
    }
    res = max(res,result);
    return;
}

void solve(vector<vector<bool>> &stores, vector<vector<ll>> &prices) {
    if (solution.size()==10) {
		ll counts = 0;
		for (auto i : solution) if (i) counts++;
        if (counts>0) solve2(stores,prices);
        return;
    }
    solution.push_back(0);
    solve(stores,prices);
    solution.pop_back();
    solution.push_back(1);
    solve(stores,prices);
    solution.pop_back();
    return;
}

int main() {
    cin >> n;
	bool temp;
    vector<bool> srow(10,0);
    vector<vector<bool>> stores(n,srow);
    vector<ll> prow(11,0);
    vector<vector<ll>> prices(n,prow);
    for (ll i=0; i<n; i++) for (ll j=0; j<10; j++) {
		cin >> temp;
		stores[i][j] = temp;
	}
    for (ll i=0; i<n; i++) for (ll j=0; j<11; j++) cin >> prices[i][j];
    solve(stores,prices);
    cout << res;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        StringBuilder answer = new StringBuilder();
        answer.append("No");
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if ((i * j) == n) {
                    answer.setLength(0);
                    answer.append("Yes");
                    break;
                }
            }
        }
        System.out.println(answer);
        sc.close();
    }
}

Measured memory_bytes: 35616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int D = in.nextInt();
            int[][] X = new int[N][D];
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < D; j++) {
                    X[i][j] = in.nextInt();
                }
            }

            int count = 0;
            for (int i = 0; i < N; i++) {
                for (int j = i + 1; j < N; j++) {
                    double len = 0;
                    for (int k = 0; k < D; k++) {
                        len += Math.pow(Math.abs(X[i][k] - X[j][k]), 2);
                    }
                    len = Math.sqrt(len);
                    if (len == (int) len) {
                        count++;
                    }
                }
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 22996
N = int(input())
A = list(map(int,input().split()))
odd = 0
even = 0
eveneven = 0
for a in A:
    if a % 4 == 0:
        eveneven += 1
    elif a % 2 == 0:
        even += 1
    else:
        odd += 1
        
if even == 0:
    #間に挟み込む
    if eveneven +1 >= odd:
        print('Yes')
    else:
        print('No')
else:
    #２を後ろに固める
    if odd <= eveneven:
        print('Yes')
    else:
        print('No') 

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

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> P(N);
  REP(i, 0, N) cin >> P[i];

  ll g = 0;
  REP(i, 0, N) g = gcd(g, abs(P[i] - X));
  cout << g << endl;
}

Measured memory_bytes: 1024
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

func parseProblem() int {
	str := scanString(sc)
	min := math.MaxInt64
	for i := 0; i+2 < len(str); i++ {
		i, _ := strconv.Atoi(str[i : i+3])
		if v := abs(int(i) - 753); min > v {
			min = v
		}
	}
	return min
}

func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func resolve(n int) int {
	return n
}

// snip-scan-funcs
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <climits>
using namespace std;
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForLong(i, n) for (int64 i = 0; i < (n); ++i)
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) > (b) ? (a) : (b))



int main()
{
	auto comparer = [](pair<int, int> x, pair<int, int> y) { return x.second < y.second; };

	int n, m;
	cin >> n >> m;
	priority_queue<int, vint, greater<int>> a;
	ForInt(i, n)
	{
		int tmp;
		cin >> tmp;
		a.push(tmp);
	}

	priority_queue<pair<int, int>, vector<pair<int, int>>, decltype(comparer)> tasks(comparer);
	ForInt(i, m)
	{
		int b, c;
		cin >> b >> c;
		tasks.emplace(b, c);
	}

	while (!tasks.empty())
	{
		pair<int, int> task = tasks.top();
		tasks.pop();
		ForInt(i, task.first)
		{
			int target = a.top();
			if (target >= task.second) break;
			a.pop();
			a.push(task.second);
		}
	}

	int64 sum = 0;
	while (!a.empty())
	{
		int val = a.top();
		a.pop();
		sum += val;
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1784
//
//  main.cpp
//  project for C++
//
//  Created by 伊藤博隆 on 2020/04/17.
//  Copyright © 2020 伊藤博隆. All rights reserved.
//

#include <iostream>

using namespace std;
 


int main(){
   int N;
    long long int ans=0;
    
  
  cin >> N;
  
    for (int i=0; i<= N; i++){
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
        
    }
    cout<<ans;
    return 0;
    
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) x.begin(),x.end()
#define db(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  string S;
  cin>>S;

  char c0=S[0];

  char c1=S[S.length()-1];

  cout << ( S.length()%2 xor (c0==c1)  ? "First": "Second") <<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 512
use proconio::input;

fn main() {
    input!(n: u64, k: u64);
    println!(
        "{}",
        if k == 0 {
            n * n
        } else {
            let mut ans = 0;
            for b in k + 1..=n {
                ans += n / b * (b - k);
                ans += (n % b + 1).saturating_sub(k);
            }
            ans
        }
    );
}


Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define N 100010
char s[N];
int S[N],ne[N][4],f[N],ans;
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1); bool flag=1;
	for (int i=2;i<=n && flag;i++) if (s[i]==s[i-1]) flag=0;
	if (flag) {puts("1"); return 0;}
	for (int i=1;i<=n;i++) S[i]=(S[i-1]+s[i]-'a'+1)%3;
	ne[n][0]=ne[n][1]=ne[n][2]=n+1;
	for (int i=n-1;i>=0;i--){
		for (int j=0;j<3;j++) ne[i][j]=ne[i+1][j];
		ne[i][S[i+1]]=i+1;
	}
	f[0]=1;
	for (int i=0;i<n;i++){
		if (!f[i]) continue;
		for (int k=0;k<3;k++){
			if (S[i]==k) continue;
			if (ne[i][k]>n) continue;
			(f[ne[i][k]]+=f[i])%=M;
		}
		if (i && S[i]==S[n]) (ans+=f[i])%=M;
	}
	(ans+=f[n])%=M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2688
using System;
using System.Collections.Generic;
namespace 私が灰コーダーです{
    class Inonoa{
        static void Main(){
            string[] r_d_x = Console.ReadLine().Split();
            int r = int.Parse(r_d_x[0]);
            int d = int.Parse(r_d_x[1]);
            int x = int.Parse(r_d_x[2]);
            for(int i=0;i<10;i++){
                x = x * r - d;
                Console.WriteLine(x);
            }
         }
    }
}

Measured memory_bytes: 11092
/*

Bismillah_hir_rahmanir_rahim

*/

#include <bits/stdc++.h>
using namespace std;

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


#define bug cout <<"--------------------------\n"



#define inf ( ll  )( 1e18 + 100 )

#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define PI          2*acos(0.0)
#define MOD         1000000007
#define endl        '\n'
#define yes         cout << "yes" << endl
#define no          cout << "no" << endl
#define YES         cout << "YES" << endl
#define NO          cout << "NO" << endl
#define LCM(a, b)   ((a)*(b)) / __gcd(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;


int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
/// const int fx[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
/// const int fy[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move



/// int dx[] = {0, 0, +1, -1};
/// int dy[] = {+1, -1, 0, 0};   //4 Direction Array

///  int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};   //8 Direction Array

///int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1}; //Knight Moves

///int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; ///Hexagonal Direction


bool isPallindrome(string s)
{
    string r=s;
    reverse(s.begin(),s.end());
    if(s==r)
        return true;
    return false;
}


template <typename T>
std::string NumberToString ( T Number )
{
    std::ostringstream ss;
    ss << Number;
    return ss.str();
}



int main()
{
    FIO;

    string str ;

    cin >> str ;

    if(str.length()==6 and str[3-1]==str[4-1] and str[5-1]==str[6-1] )
    {
        cout <<"Yes"<<endl;
    }
    else
    {

        cout <<"No"<<endl;

    }

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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

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

	if ((a-1 + d)/d >= (c-1 + b)/b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
    string s;
    cin>>s;
    map<char,int> mp;
    for(int i=0;i<s.size();++i){
        mp[s[i]]+=1;
    }
    if(mp.size()==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  ll a,b,x;
  cin>>a>>b>>x;
  ll ans = 0;
  ans += (b-a) / x;
  if(a % x == 0 || a % x > b % x) ans++;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
s = 0
x = []
y = []
for i in range(n + 1):
    s += abs(a[i] - a[i + 1])
    x.append(abs(a[i] - a[i + 1]))
for i in range(n):
    y.append(abs(a[i] - a[i + 2]))
for i in range(n):
    print(s + y[i] - x[i] - x[i + 1])


Measured memory_bytes: 15892
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n)-1)
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL ans=(1ll<<62)-1;
    vector< LL > a(3);
    REP(i,3){
        cin >> a[i];
    }
    REP(i,3){
        //cout << ans << endl;
        LL t=abs(a[i%3]*a[(i+1)%3]*(a[(i+2)%3]/2)-a[i%3]*a[(i+1)%3]*(a[(i+2)%3]-a[(i+2)%3]/2));
        ans=min(ans,t);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define make_unique(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define Sort(vec) sort(vec.begin(),vec.end())
#define RSort(vec) sort(vec.rbegin(),vec.rend())
#define endl "\n"
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define vvi vector<vector<int> > 
#define vvl vector<vector<ll> >
#define all(st) st.begin(),st.end()
#define vpl vector<pair<ll,ll> >
#define vpi vector<pair<int,int> >
#define pi pair<int,int>
#define pl pair<ll,ll>
#define al vector<list<int> >
#define vs vector<string>
#define vb vector<bool>
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ull unsigned long long int
#define eb emplace_back
#define pb push_back
#define ll long long int
#define minf -9223372036854775807
#define inf 9223372036854775807
#define f first
#define se second
#define mod 1000000007
#define mx 100001
using namespace std;
ll mi(ll n,ll m){ll pw=n%m;ll ex=m-2;ll ans=1;while(ex){if(ex&1) ans = ans*pw%m;pw = pw*pw%m;ex>>=1;}return ans%mod;}
ll pw(ll a,ll n){ll pw=a%mod;ll ex=n;ll ans=1;while(ex){if(ex&1) ans = ans*pw%mod;pw = pw*pw%mod;ex>>=1;}return ans%mod;}
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
void show(ll x){cout<<x<<" ";}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
ll Abs(ll x){return x>0?x:(-x);}
ll Ceil(ll a,ll b){return a/b+(a%b!=0);}
#define to_low(s) for_each(s.begin(), s.end(), [](char & c) {c = ::tolower(c);})
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mkp make_pair
//#define d double
void solve(){
	int n,m;
	cin>>n>>m;
	string s=string(n,'#');
	bool ok=true;
	map<int,int> mp;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;
		if(mp.count(a)==0) mp[a]=b;
		else{
			if(mp[a]!=b){
				ok=false;
			}
		}
	}
	if(!ok) cout<<"-1"<<endl;
	else{
		if(n>1 && mp.count(0) && mp[0]==0) cout<<"-1"<<endl;
		else{
			string s=string(n,'0');
			if(n==1){
				if(mp.count(0)) s[0]=mp[0]+'0';
				else s[0]='0';
			}
			else if(n==2){
				if(mp.count(0)) s[0]=mp[0]+'0';
				else s[0]='1';
				if(mp.count(1)) s[1]=mp[1]+'0';
				else s[1]='0';
			}
			else{
				if(mp.count(0)) s[0]=mp[0]+'0';
				else s[0]='1';
				if(mp.count(1)) s[1]=mp[1]+'0';
				else s[1]='0';
				if(mp.count(2)) s[2]=mp[2]+'0';
				else s[2]='0';
			}
			cout<<s<<endl;
		}
	}
 
}
int32_t main(){
FIO;
int t=1;
//cin>>t;
while(t--){
	solve();
}
}

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

int main() 
{
  int N;
  cin >> N;
  int a = N / 1000;
  int b = (N - a * 1000) / 100;
  int c = (N - a * 1000 - b * 100) / 10;
  int d = N - a * 1000 - b * 100 - c * 10;
  
  if (a == b)
  {
    if (b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  else 
  {
    if (b == c && c == d) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}


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

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

    int* b = new int[m];
    for(int i = 0; i < m; ++i) {
        cin >> b[i];
    }

    int** a = new int*[n];
    // a[0] = new int[n*m];

    for(int ni = 0 ; ni < n; ++ni){
        a[ni] = new int[m];
    for(int mi = 0; mi < m; ++mi) {
        cin >> a[ni][mi];
    }
    }

    int cnt = 0;
    for (int ni = 0; ni < n; ++ni) {
        // ip
        int wx =0;
        for(int mi = 0; mi < m; ++mi) {
            wx += a[ni][mi] * b[mi];
        }

        if (wx+c >0) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256