akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

struct Node {
  int x, y, z;
  int64 sum;
  bool operator <(const Node& rhs) const {
    if (sum != rhs.sum) return sum > rhs.sum;
    return make_tuple(x, y, z) < make_tuple(rhs.x, rhs.y, rhs.z);
  }
};

int main() {
  int X, Y, Z, k;
  scanf("%d%d%d%d", &X, &Y, &Z, &k);
  vector<int64> a(X), b(Y), c(Z);
  for (int i = 0; i < X; ++i) scanf("%lld", &a[i]);
  for (int i = 0; i < Y; ++i) scanf("%lld", &b[i]);
  for (int i = 0; i < Z; ++i) scanf("%lld", &c[i]);
  sort(a.begin(), a.end(), greater<int64>());
  sort(b.begin(), b.end(), greater<int64>());
  sort(c.begin(), c.end(), greater<int64>());
  set<Node> A;
  A.insert(Node{0, 0, 0, a[0] + b[0] + c[0]});
  vector<int64> ret;
  while (k--) {
    auto it = A.begin();
    ret.push_back(it->sum);
    int x = it->x, y = it->y, z = it->z;
    if (x + 1 < X) {
      Node cur = Node{x + 1, y, z, a[x + 1] + b[y] + c[z]};
      A.insert(cur);
    }
    if (y + 1 < Y) {
      Node cur = Node{x, y + 1, z, a[x] + b[y + 1] + c[z]};
      A.insert(cur);
    }
    if (z + 1 < Z) {
      Node cur = Node{x, y, z + 1, a[x] + b[y] + c[z + 1]};
      A.insert(cur);
    }
    A.erase(it);
  }
  for (auto& it : ret) {
    printf("%lld\n", it);
  }
  return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;
LL N;
std::string s, t;
std::vector<std::vector<LL>>memo;

LL dp(LL i, char j)
{
	if (i == N - 1)
	{
		if (t[i] == j) return 1;
		else return 0;
	}
	if (memo[i][j - 'a'] != -1) return memo[i][j - 'a'];

	LL res;
	if (t[i] != j) res = dp(i + 1, j);
	else res = dp(i + 1, s[i]) + dp(i + 1, j);
	return memo[i][j - 'a'] = res % mod;
}

int main()
{
	in >> N >> s >> t;

	memo.resize(N, std::vector<LL>(30, -1));
	out << dp(1, s[0]) << std::endl;
}



Measured memory_bytes: 36620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

#define pi 3.141592653589

int main(){
	int H, W;
	while (cin >> H >> W)
	{
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if ((i + j) % 2 == 0) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include <queue>
#include<utility>
using namespace std;

typedef pair<string, int> process;

int main(){
    int n, q, total = 0;
    queue<process> Q;
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        process P;
        cin >> P.first >> P.second;
        Q.push(P);
    }
    while(!Q.empty()){
        process P = Q.front();
        Q.pop();
        if(P.second <= q){
            total += P.second;
            cout << P.first << " " << total << endl;
        }else{
            total += q;
            P.second -= q;
            Q.push(P);
        }
    }
}

Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}
//dp
int main(){
    string S;
    cin >> S;
    int s=S.size();
    vector<ll> sum(s+1,1);
    rep(i,s){
        sum[i+1]=sum[i];
        if (S[i]=='?'){
            sum[i+1]*=3;
            sum[i+1]%=MOD;
        }
    }
    vector<vector<ll>> dp(s+1,vector<ll>(3,0));
    dp[0][0]=dp[0][1]=dp[0][2]=0;
    rep(i,s){
        if (S[i]=='A'){
            dp[i+1][0]+=sum[i];
        }
        else if (S[i]=='B'){
            dp[i+1][1]+=dp[i][0];
        }
        else if (S[i]=='C'){
            dp[i+1][2]+=dp[i][1];
        }
        else {
            dp[i+1][0]+=sum[i]+dp[i][0]*2;
            dp[i+1][1]+=dp[i][0]+dp[i][1]*2;
            dp[i+1][2]+=dp[i][1]+dp[i][2]*2;
        }
        rep(j,3){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=MOD;
        }
    }
    cout << dp[s][2] << endl;
}

Measured memory_bytes: 6656
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))


def calc_imos(arr):
    imos = [0] * (N + 1)
    for i, a in enumerate(arr):
        l = max(0, i - a)
        r = min(N - 1, i + a)
        imos[l] += 1
        imos[r + 1] -= 1
    imos = list(accumulate(imos))
    return imos[:-1]


for k in range(min(50, K)):
    A = calc_imos(A)
print(*A, sep=' ')


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

using namespace std;

typedef long long int64;

const int mod = 1e9 + 7;

int main()
{
  int64 N;
  int dp[62][3] = {{}};

  cin >> N;

  dp[0][0] = 1;
  for(int i = 0; i < 61; i++) {
    for(int j = 0; j < 3; j++) {
      for(int x = 0; x < 2; x++) {
        for(int y = x; y < 2; y++) {
          int64 b = (N >> i & 1) - x - y - j;
          (dp[i + 1][(1 - b) >> 1] += dp[i][j]) %= mod;
        }
      }
    }
  }

  cout << dp[61][0] << endl;
}

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M;
  cin >> N;
  
  VLL D(N);
  
  REP(i,N){
    cin >> D.at(i);
  }
  
  cin >> M;
  
  VLL T(M);
  
  REP(i,M){
    cin >> T.at(i);
  }
  
  SORT(D);
  SORT(T);
  
  int j=0;
  
  bool ans = false;
  
  REP(i,M){
    if(j > N-1){
      break;
    }
    
    if(T.at(i) == D.at(j)){
      if(i == M-1){
        ans = true;
        break;
      }
      j++;
      continue;
    }
    i--;
    j++;
  }
  
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    
    cout << N-K+1 << endl;
    
        return 0;
    }
    


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  LL x[n], y[m];
  ARRIN(x, n);
  ARRIN(y, m);

  LL xsum=0, ysum=0, w;
  for(LL i=0; i<n-1; ++i){
    w = (x[i+1]-x[i])*(i+1)%MOD;
    w = w*(n-i-1)%MOD;
    xsum =(xsum+w)%MOD;
  }
  for(LL i=0; i<m-1; ++i){
    w = (y[i+1]-y[i])*(i+1)%MOD;
    w = w*(m-i-1)%MOD;
    ysum =(ysum+w)%MOD;
  }

  LL ans = xsum*ysum;
  ans%=MOD;
  ECHO(ans);

  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a, b, c, k;
	scanf("%d %d %d %d", &a, &b, &c, &k);
	if (k < a)
		printf("%d\n", k);
	else if (k < a + b)
		printf("%d\n", a);
	else
		printf("%d\n", a - k + a + b);
	return 0;
}

Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>

using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll mod=1e9+7;



int main(void){
    int N,K;
    cin>>N>>K;
    if(K==1) N=1;
    cout<<N-K<<endl;
    return 0;
}


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

class Main{
    static int D;
    static int G;
    static int[] p;
    static int[] c;
    static int[] a;
    static int ans = Integer.MAX_VALUE;
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        D = sc.nextInt();
        G = sc.nextInt();
        p = new int[D];
        c = new int[D];
        a = new int[D];
        for (int i=0;i<D;i++){
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        sc.close();
        dfs(0);
        System.out.println(ans);
    }

    public static void dfs(int pos){
        if (pos==D){
            func();
        } else {
            a[pos] = 0;
            dfs(pos+1);
            a[pos] = 1;
            dfs(pos+1);
        }
    }

    public static void func(){
        int point = 0;
        int cnt = 0;
        for (int i=0;i<D;i++){
            if (a[i]==1){
                point += (i+1)*100*p[i]+c[i];
                cnt += p[i];
            }
        }
        for (int i=D-1;i>=0;i--){
            if (a[i]==1){
                continue;
            }
            for (int j=0;j<p[i]-1;j++){
                if (point>=G){
                    break;
                }
                point += (i+1)*100;
                cnt++;
            }
            if (point>=G){
                break;
            }
        }
        if (point<G){
            return;
        }
        ans = Math.min(ans,cnt);
    }
}

Measured memory_bytes: 22228
import sys
 
S = sys.stdin.readline().rstrip()
T = sys.stdin.readline().rstrip()
 
def checkValid(S, i, T):
    try:
        if S[i] == T[0]:
            for j in range(0, len(T)):
                if S[i+j] == T[j] or S[i+j] == '?':
                    pass
                else:
                    return False
        else:
            return False
        return True
    except Exception as e:
        return False
 
def checkValid2(S, i, T):
    try:
        for j in range(0, len(T)):
            if S[i+j] == T[j] or S[i+j] == '?':
                pass
            else:
                return False
        return True
    except Exception as e:
        return False
def getResult(S, i, T):
    res = ""
    for k in range(0, len(S)):
        if k < i:
            res = res + S[k]
        elif k >= i and k < i+len(T):
            res = res + T[k-i]
        else:
            res = res + S[k]
    S = res.replace('?', 'a')
    return S
 
res_list = []
 
res = False
for i in range(0, len(S)):
    if S[i] != '?':
        if checkValid(S, i, T) == True:
            res_list.append(getResult(S, i, T))
            res = True
    else:
        if checkValid2(S, i, T) == True:
            res_list.append(getResult(S, i, T))
            res = True
 
if res == False:
    print("UNRESTORABLE")
else:
    smallest = res_list[0]
    for i in range(0, len(res_list)):
        if smallest > res_list[i]:
            smallest = res_list[i]
    print (smallest)

Measured memory_bytes: 3064
n = int(input())
s = [list(map(str,input().split())) for i in range(n)]
m = int(input())
t = [list(map(str,input().split())) for i in range(m)]


c=0
for i in range(n):
    c=max(c,s.count(s[i])-t.count(s[i]))

print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a;
    cin>>a;

    cout<<3*a*a<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

int main() {
  string s,t,ss;
  cin >> s >> t;
  ss = s;
  for(int i = 1;i < s.size()+1;i++){
    if(i%2 == 1){
      for(int j = 0;j < s.size()-1;j++){
        ss.at(j+1) = s.at(j);
      }
      ss.at(0) = s.at(s.size()-1);
      if(ss == t){
        cout << "Yes" << endl;
        goto end;
      }
    }
    else{
      for(int j = 0;j < s.size()-1;j++){
        s.at(j+1) = ss.at(j);
      }
      s.at(0) = ss.at(s.size()-1);
      if(s == t){
        cout << "Yes" << endl;
        goto end;
      }
    }
  }
  cout << "No" << endl;
  end:;
}

Measured memory_bytes: 256
const fs = require('fs')
const stdin = fs.readFileSync('/dev/stdin', 'utf8')

const [a, b, c, d, e, k] = stdin.split('\n').map(Number)

const antennas = [a, b, c, d, e]
const max = Math.max(...antennas)
const min = Math.min(...antennas)

const res = max - min > k ? ':(' : 'Yay!'
console.log(res)


Measured memory_bytes: 7372
n = int(input())
t = [1,2,3,4,5,6,7,8,9]
if n < 10:
    print(n)
else:
  i = 0
  while len(t) < n:
    a = t[i]
    b = a % 10
    if b == 0:
        c = a*10
        t.append(c)
        c += 1
        t.append(c)
    elif b == 9:
        c = a*10+8
        t.append(c)
        c += 1
        t.append(c)
    else:
        c = a*10 + b -1
        t.append(c)
        c += 1
        t.append(c)
        c += 1
        t.append(c)
    i += 1
  print(t[n-1])

Measured memory_bytes: 7172
#include <iostream>
#include <algorithm>
using namespace std;
int n, q, xa, ya, xb, yb, xc[5555], yc[5555], xd[5555], yd[5555]; pair<int, int> p1[5555], p2[5555];
int main() {
	scanf("%d%d", &n, &q);
	for(int i = 0; i < n; i++) scanf("%d%d", &p1[i].first, &p1[i].second), p2[i] = make_pair(p1[i].second, p1[i].first);
	sort(p1, p1 + n); sort(p2, p2 + n);
	for(int i = 0; i < n; i++) xc[i] = p1[i].first, yc[i] = p1[i].second, xd[i] = p2[i].second, yd[i] = p2[i].first;
	for(int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &xa, &ya, &xb, &yb);
		int l1 = lower_bound(xc, xc + n, xa) - xc;
		int r1 = lower_bound(xc, xc + n, xb + 1) - xc;
		int l2 = lower_bound(yd, yd + n, ya) - yd;
		int r2 = lower_bound(yd, yd + n, yb + 1) - yd;
		int c = 0;
		if(r1 - l1 <= r2 - l2) {
			for(int j = l1; j < r1; j++) {
				if(ya <= yc[j] && yc[j] <= yb) c++;
			}
		}
		else {
			for(int j = l2; j < r2; j++) {
				if(xa <= xd[j] && xd[j] <= xb) c++;
			}
		}
		printf("%d\n", c);
	}
}

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

#define MOD_1_000_000_007 (1000000007LL)
#define LINF (1LL<<60)
#define rep(i, n)   for (long long i = 0; i <  (long long)(n); i++)
#define rep1(i, n)  for (long long i = 1; i <  (long long)(n); i++)
#define rep2(i, n)  for (long long i = 2; i <  (long long)(n); i++)
#define rep0c(i, n) for (long long i = 0; i <= (long long)(n); i++)
#define rep1c(i, n) for (long long i = 1; i <= (long long)(n); i++)
#define rep2c(i, n) for (long long i = 2; i <= (long long)(n); i++)
#define repc0(n, i) for (long long i = (long long)(n); i >= 0; i--)
#define repc1(n, i) for (long long i = (long long)(n); i >= 1; i--)
#define repc2(n, i) for (long long i = (long long)(n); i >= 2; i--)

namespace solver {
  using namespace std;
  typedef long long ll;

  ll N, K, A[200020];

  void init() {
    scanf("%lld %lld", &K, &N);
    rep(i, N) scanf("%lld", &A[i]);
    A[N] = K+A[0];
  }

  void solve() {
    ll maxv = 0ll;
    rep(i, N) maxv = max(maxv, abs(A[i+1]-A[i]));
    printf("%lld\n", K-maxv);
  }
}

int main() {
  solver::init();
  solver::solve();
  return 0;
}

Measured memory_bytes: 1792
//raja1999

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define int ll

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


//std::ios::sync_with_stdio(false);
int a[200005],gg[1000010],cnt[1000010];
main(){
	std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,i,ans=0,j;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		cnt[a[i]]++;
	}
	//return 0;
	f(i,1,1000005){
		for(j=i;j<1000005;j+=i){
			gg[j]+=cnt[i];
		}
	}
	rep(i,n){
		if(gg[a[i]]==1){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
} 


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

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

int main() {
  ll n, ans = 0;
  cin >> n;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll m = n / i - 1;
      if (m != 0 && n / m == n % m) ans += m;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  string s,t;
  cin >> s >> t;
  
  bool f = true;
  REP(i,3)
    if(s[i] != t[2-i]) f = false;
  
  if(f) cout << "YES" << endl;
  else  cout << "NO" << endl;
  
 return 0;
}

Measured memory_bytes: 256
#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 pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,a,b;

int main(){
	cin >> n >> a >> b;
	
	int c=0;
	REP(i,1,n+1){
		string s=to_string(i); int pos=0;
		REP(j,0,s.size()) pos+=s[j]-'0';
		if(a<=pos and pos<=b) c+=i;
	}
	
	cout << c << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,k;
  cin>>n>>k;
  int res=n-k+1;
  out(res);
  
  
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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 ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n,a;
  cin >> n >> a;

  cout << (n%500<=a ? "Yes" : "No") << endl;
  return 0;
} 

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

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define nfor(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define fore(i, l, r) for (int i = int(l); i < int(r); i++)
#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define pb(a) push_back(a)
#define mp(x, y) make_pair((x), (y))
#define x first
#define y second

using namespace std;

typedef long long li;
typedef long double ld;
typedef pair<int, int> pti;

template<typename X> inline X abs(const X& a) { return a < 0? -a: a; }
template<typename X> inline X sqr(const X& a) { return a * a; }

template<typename A, typename B> inline ostream& operator<< (ostream& out, const pair<A, B>& p) { return out << "(" << p.x << ", " << p.y << ")"; }
template<typename T> inline ostream& operator<< (ostream& out, const vector<T>& a) { out << "["; forn(i, sz(a)) { if (i) out << ','; out << ' ' << a[i]; } return out << " ]"; }
template<typename T> inline ostream& operator<< (ostream& out, const set<T>& a) { return out << vector<T>(all(a)); }
template<typename X, typename Y> inline ostream& operator<< (ostream& out, const map<X, Y>& a) { return out << vector<pair<X, Y>>(all(a)); }
template<typename T> inline ostream& operator<< (ostream& out, const pair<T*, int>& a) { return out << vector<T>(a.x, a.x + a.y); }

inline ld gett() { return ld(clock()) / CLOCKS_PER_SEC; }

const int INF = int(1e9);
const li INF64 = li(1e18);
const ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;

#ifdef SU1
//#define GEN
#ifndef GEN
#define LOG
#endif
#endif

int r;

bool read() {
  return !!(cin >> r);
}

void solve() {
  if (r < 1200) puts("ABC");
  else if (r < 2800) puts("ARC");
  else puts("AGC");
}

int main() {
#ifdef SU1
  assert(freopen("input.txt", "rt", stdin));
  //assert(freopen("output.txt", "wt", stdout));
#endif

  cout << setprecision(10) << fixed;
  cerr << setprecision(5) << fixed;

  while (read()) {
    ld stime = gett();
    solve();
#ifdef SU1
    cerr << "Time: " << gett() - stime << endl;
#endif
    //break;
  }

  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

cri = 0
for i in range(n-1):
    if h[i] <= h[i+1]:
        continue
    else:
        cri = max(cri, h[i+1])
        if h[i] - h[i+1] > 1 or cri > h[i+1]:
            print("No")
            exit()
else:
    print("Yes")

Measured memory_bytes: 63856
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=list(map(int,input().split()))
b.sort()
c=list(map(int,input().split()))
c.sort()
def binary_search1(x,sortedlist):
  left=-1
  right=len(sortedlist)
  while abs(right-left)>1:
    mid=(left+right)//2
    if sortedlist[mid]<=x:
      left=mid
    else:
      right=mid
  return right
def binary_search2(x,sortedlist):
  left=-1
  right=len(sortedlist)
  while abs(right-left)>1:
    mid=(left+right)//2
    if sortedlist[mid]>=x:
      right=mid
    else:
      left=mid
  return left
ans=0
for i in range(len(b)):
  ans+=(len(c)-binary_search1(b[i],c))*(binary_search2(b[i],a)+1)
print(ans)

Measured memory_bytes: 23372
#include <stdio.h>

int make3(int num){
    return num * num * num ;
}

int main(void){
    int num;
    do{
    scanf("%d", &num);
    }while(num < 1 || num > 100);
    
    int x = make3(num);
    
    printf("%d\n", x);
    
    return 0;

}


Measured memory_bytes: 2048
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <vector>

long fffff(long x)
{
  return x * x * x * x * x;
}

std::tuple<long, long> solve2(long x, long aa, long bb)
{
  long a = aa;
  long b = bb;
  long a5 = fffff(aa);
  long b5 = fffff(bb);
  do {
    if (a5 - b5 == x) return {a, b};
    a += 1;
    b += 1;
    a5 = fffff(a);
    b5 = fffff(b);
  } while (a5 - b5 <= x);

  a = aa - 1;
  b = bb - 1;
  a5 = fffff(a);
  b5 = fffff(b);
  bool flag = false;
  do {
    if (a5 - b5 == x) return {a, b};
    if (!flag && a5 - b5 <= x) flag = true;
    a -= 1;
    b -= 1;
    a5 = fffff(a);
    b5 = fffff(b);
  } while (!flag || a5 - b5 <= x);

  return {0, 0};
}

std::tuple<long, long> solve(long x)
{
  if (x == 1) return {0, -1};
  for (long i = 1; i < std::ceil(std::sqrt(x)); ++i) {
    if (x % i) continue;

    long a, b;
    std::tie(a, b) = solve2(x, i, 0);
    if (a != 0) return {a, b};

    std::tie(a, b) = solve2(x, x / i, 0);
    if (a != 0) return {a, b};
  }

  throw 1;
}

int main()
{
  long x;
  std::cin >> x;

  long a, b;
  std::tie(a, b) = solve(x);

  std::cout << std::setprecision(20);
  std::cout << a << " " << b << std::endl;
}


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

int main(){
    int c=0;
    string a,b;
    cin >> a;
    b = a;
    for(int i=0;i<a.size()-1;i++){
        if(c==1)break;
        for(int j=i+1;j<a.size();j++){
            if(a[i]==b[j]){
                c=1;
                break;
            }
        }
    }
    if(c==0)cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

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

#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;

ll n, w;
ll tb[105][100005];
vll peso, val;

ll dp(int i, ll p) {
    if(i == n or p == w) return 0;
    if(tb[i][p] != -1) return tb[i][p];

    ll ans = dp(i+1, p);
    if(p + peso[i] <= w) ans = max(ans, dp(i+1, p + peso[i]) + val[i]);

    tb[i][p] = ans;
    return ans;
}

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

    peso.resize(n+5);
    val.resize(n+5);
    for(int i = 0; i < n; i++)
    {
        scanf("%lld %lld", &peso[i], &val[i]);
    }
    memset(tb, -1, sizeof tb);
    printf("%lld\n", dp(0, 0));



    return 0;
}

Measured memory_bytes: 82304
while (line = gets)
  as = line.chop.split(" ").map { |s| s.to_i }
  bs = gets.chop.split(" ").map { |s| s.to_i }

  h = 0
  b = 0

  for i in (0..3)
    for j in (0..3)
      if as[i] == bs[j]
        if i == j
          h += 1
        else
          b += 1
        end
      end
    end
  end

  puts [h, b].join(" ")
end

Measured memory_bytes: 6104
N = int(input())
n = int(N**(1/2))

ans_list = [0]*(N)

for i in range(1,n):
    for j in range(1,n):
        for k in range(1,n):
            index = i**2+j**2+k**2+i*j+j*k+k*i

            if index>N:
                break

            ans_list[index-1] += 1

for i in ans_list:
    print(i)



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

long long N, L;
int main(){
	cin >> N >> L;
	long long sum = N*L - N + ((N)*(N+1))/2;
	long long mini = INT_MAX;
	long long ans = 0;

	for(long long i = 0; i < N; i++){
		long long tmp = L + i;
		long long p = abs(sum - (sum - tmp));
		if(p < mini){
			mini = p;
			ans = sum - tmp;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100LL
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
#define FILEIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
	int a,b;
	sd(a);sd(b);
	int n=(b-a);
	ll temp=(1LL*n*(n+1))/2;
	temp-=b;
	plldn(temp);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void) {
    char b;
    scanf("%c", &b);

    if ( b == 'A' ) {
        printf("T\n");
    }
    else if ( b == 'T' ) {
        printf("A\n");
    }
    else if ( b == 'G' ) {
        printf("C\n");
    }
    else if ( b == 'C' ) {
        printf("G\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int h,w;
    cin >> h >> w;
    int math[h][w];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> math[i][j];
        }
    }    
    vector<pair<pair<int,int>,pair<int,int>>> ans;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(math[i][j]%2 == 1){
                if(j == w-1 && i == h-1) continue;
                else if(j == w-1 && i < h-1){
                    math[i][j]--;
                    math[i+1][j]++;
                    ans.push_back({{i+1,j+1},{i+2,j+1}});
                }
                else{
                    math[i][j]--;
                    math[i][j+1]++;
                    ans.push_back({{i+1,j+1},{i+1,j+2}});
                }
            }
        }
    }
    cout << ans.size() << endl;
    for(auto p:ans){
        cout << p.first.first << " " << p.first.second << " " << p.second.first << " " << p.second.second << endl;
    }
}

Measured memory_bytes: 5232
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  string s;
  cin >> s;
  map<int, string> m;
  int v = (int) s[0] - (int) '0';
  m[v] = s[0];
  // cout << m[0] << endl;
  for(int i=1; i<4; i++){
    map<int, string> temp;
    for(auto x: m){
      int v = (int) s[i] - (int) '0';
      temp[x.first+v] =  x.second + "+" + s[i];
      // cout << x.first+v << " " << temp[x.first+v] << endl;
      temp[x.first-v] =  x.second + "-" + s[i];
    }
    m = temp;
  }
  cout << m[7] + "=7" << endl;


}

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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n & 1 ==1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n=n>>1;
    }
    return result;
}



int32_t main()
{
    IOS

    ll n,w;
    cin>>n>>w;

    ll v[n],wt[n];

    for(ll i=0;i<n;i++)
    {
    	cin>>wt[i]>>v[i];
    }

    ll dp[w][n];

    for(ll i=0;i<=w;i++)
    {
    	for(ll j=0;j<=n;j++)
    	{
    		if(i==0||j==0)
    			dp[i][j]=0;

    		else if(wt[j-1]>i)
    			dp[i][j]=dp[i][j-1];

    		else
    			dp[i][j]=max(v[j-1]+dp[i-wt[j-1]][j-1],dp[i][j-1]);
    	}
    }

    cout<<dp[w][n]<<endl;

    
    return 0;
}


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

using namespace std;

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int ac = 0, tle = 0, wa = 0, re = 0;

    int n;
    cin >> n;

    while(n--){
    	string v;
    	cin >> v;
    	if(v == "AC") ac++;
    	if(v == "WA") wa++;
    	if(v == "RE") re++;
    	if(v == "TLE") tle++;
    }
    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
    
	return 0;
}

Measured memory_bytes: 3656
#ABC156 - Virtual
sel='C'

#C
if sel=='C':
    def ceilT(a,b): #ceil(a/b)
        return (a+b-1)//b

    N=int(input())
    X=[int(i) for i in input().split()]
    p=ceilT(sum(X),N)
    ans=sum((x-p)**2 for x in X)
    p-=1
    ans=min(ans,sum((x-p)**2 for x in X))
    print(ans)






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

bool table[1000][1000];

int main() {

    int c,n;

    int count = 0;

    int ans = 0;

    cin >> c >> n;

    char ch;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            scanf(" %c",&ch);
            if(ch=='0'){
                table[i][j] = false;
            }
            else{
                table[i][j] = true;
            }
        }
    }

    for(int i=0;i<n/2;i++){
        for(int j=0;j<n/2;j++){
            if(table[i][j] != table[i][n-1-j] || table[i][j] != table[n-1-i][j] || table[i][j] != table[n-1-i][n-1-j]){
                count++;
            }
        }
    }

    if(count == 0){
        ans++;
    }

    for(int i=0;i<c-1;i++){
        int d;
        scanf(" %d",&d);

        for(int j=0;j<d;j++){
            int r,x;
            scanf(" %d %d",&r,&x);
            r--;x--;
            bool check = true;
            if(table[r][x] != table[r][n-1-x] || table[r][x] != table[n-1-r][x] || table[r][x] != table[n-1-r][n-1-x]){
                check = false;
            }
            table[r][x] = !table[r][x];
            if(table[r][x] != table[r][n-1-x] || table[r][x] != table[n-1-r][x] || table[r][x] != table[n-1-r][n-1-x]){
                if(check){
                    count++;
                }
            }
            else{
                count--;
            }
        }
        if(count == 0){
            ans++;
        }

    }

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 4128
import java.util.*;

public class Main{
    private static final int mx = 10000000;

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

	int n;
	boolean[] prime = (new boolean[mx]);
	Arrays.fill(prime, true);
	prime[0] = prime[1] = false;

	for(int i = 2; i < mx; ++i)
	    if(prime[i])
		for(int j = i+i; j < mx; j+=i)
		    prime[j] = false;
	
	while(sc.hasNext()){
	    n = sc.nextInt();
	    if(n == 0) break;

	    for(int i = n; i >= 13; --i)
		if(prime[i-8] && prime[i-6] && prime[i-2] && prime[i]){
		    System.out.println(i);
		    break;
		}
	}
    }
}

Measured memory_bytes: 34932
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
	for(int i=0;i<=5;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<5;i++)
	{
		for(int j=i+1;j<5;j++)
		{
			if(abs(a[i]-a[j])>a[5])
			{
				printf(":(");
				return 0;
			}
		}
	}
	printf("Yay!");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int h, w, i, j, tmp, max = 0;
    scanf("%d %d", &h, &w);
    char s[h][w];
    int l[h][w], r[h][w], d[h][w], u[h][w];
    for(i = 0; i < h; ++i){
        scanf("%s", s[i]);
    }
    for(i = 0; i < h; ++i){
        for(j = 0; j < w; ++j){
            if(s[i][j] == '#'){l[i][j] = 0;}
            else if(j == 0){l[i][j] = 1;}
            else{l[i][j] = l[i][j-1] + 1;}
        }
    }
    for(i = 0; i < h; ++i){
        for(j = w-1; j >= 0; --j){
            if(s[i][j] == '#'){r[i][j] = 0;}
            else if(j == w-1){r[i][j] = 1;}
            else{r[i][j] = r[i][j+1] + 1;}
        }
    }
    for(j = 0; j < w; ++j){
        for(i = h-1; i >= 0; --i){
            if(s[i][j] == '#'){d[i][j] = 0;}
            else if(i == h-1){d[i][j] = 1;}
            else{d[i][j] = d[i+1][j] + 1;}
        }
    }
    for(j = 0; j < w; ++j){
        for(i = 0; i < h; ++i){
            if(s[i][j] == '#'){u[i][j] = 0;}
            else if(i == 0){u[i][j] = 1;}
            else{u[i][j] = u[i-1][j] + 1;}
        }
    }
    for(i = 0; i < h; ++i){
        for(j = 0; j < w; ++j){
            if(s[i][j] == '.'){
                if( (tmp = l[i][j] + r[i][j] + d[i][j] + u[i][j] - 3) > max){max = tmp;}
            }
        }
    }
    printf("%d\n", max);
    return 0;
}

Measured memory_bytes: 66560
package main

import (
	"fmt"
	"os"
	"strconv"
)

var Cal = []int64{1, -1}

func main() {
	var num string
	fmt.Scanf("%s\n", &num)
	fmt.Println(f(num, 0, ""))
}

func f(s string, sum int64, ss string) (int64, string) {
	if s == "" {
		return sum, ss
	}
	var av int64
	var bs, ws string
	for _, v := range Cal {
		if ss == "" {
			bs = s[:1]
		} else {
			bs = ss + toCalc(v) + s[:1]
		}
		av, ws = f(s[1:], sum+toNum(s[:1])*v, bs)
		if av == 7 {
			fmt.Println(ws + "=7")
			os.Exit(0)
		}
	}
	return sum, ws
}

func toCalc(n int64) string {
	if n == 1 {
		return "+"
	}
	return "-"
}

func toNum(s string) int64 {
	if s == "" {
		return 0
	}
	n, _ := strconv.ParseInt(s, 10, 64)
	return n
}


Measured memory_bytes: 512
/*
    Ujjawal Pabreja
*/
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
using ll = long long;
using ld = long double;
#define speed_cubing    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define nl              "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;

// ====== int_1024t begins ======
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// ====== int_1024t ends ======

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

// ====== Useful functions begin ======
inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}
ll pwr(ll x,ll n){
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
ll modinv(ll n){ 
    return pwr(n,mod - 2); 
}
// ====== Useful functions end ======
 
// ====== Variables begin ======

// ====== Variables end ======
void speed_solve(){
    ll n, m;
    cin >> n >> m;
    cout << (n * (n - 1))/2 + (m * (m - 1))/2 << nl;
}
int main()
{
    speed_cubing;
    ll test_cases = 1;
    // cin >> test_cases;
    rep(i,test_cases){
        // cout << "Case #" << i + 1 << ": ";
        speed_solve();
    }
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
c = [False for i in range(200000)]
d = [False for i in range(200000)]
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        c[b] = True 
    if b == n:
        d[a] = True
        
flag = False
for i in range(200000):
    if c[i] and d[i]:
        flag = True
        break
if flag:
    print("POSSIBLE")
    
else:
    print("IMPOSSIBLE")



Measured memory_bytes: 6320
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <map>
#include <algorithm>
#include <math.h>
#include <iostream>     // std::cout, std::fixed
#include <iomanip>
#include<queue>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <iostream>
#include <sstream>
typedef long long ll;
using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<vector<int>> dist(10,vector<int>(10));
    for(int i=0;i<10;i++)
        for(int j=0;j<10;j++)
            cin>>dist[i][j];
    for(int k=0;k<10;k++)
        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
            {
                if(dist[i][j]>dist[i][k]+dist[k][j])
                    dist[i][j]=dist[i][k]+dist[k][j];
            }
    ll ans=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        {
            int x;
            cin>>x;
            if(x==-1)continue;
            ans+=dist[x][1];
            
        }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
d = {chr(i):i-96 for i in range(97,123)}
D = {val:key for key,val in d.items()}
N = int(input())
x = ""
while N>0:
    a = N%26
    if a!=0:
        x += D[a]
        N = N//26
    else:
        x += "z"
        N = N//26
        N -= 1
print(x[::-1])

Measured memory_bytes: 61724
#include <bits/stdc++.h>
#define MAX 105
using namespace std;

typedef long long ll;

int adjMat[MAX][MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, k;

    cin>>n>>k;

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            adjMat[i][j] = 1;
        }
    }
    int MX = (n - 1) * (n - 2);
    MX /= 2;

    if(k > MX){
        cout<<-1<<endl;
        return 0;
    }

    int cnt = (n * (n - 1)) / 2 - k;
    cout<<cnt<<endl;

    for(int i = 2; i <= n; i++){
        cout<<1<<" "<<i<<endl;
        cnt--;
    }

    for(int i = 2; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            if(cnt <= 0){
                return 0;
            }
            else{
                cout<<i<<" "<<j<<endl;
                cnt--;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 384
n, p = map(int, input().split())

count = {0: 0, 1: 0}
for a in input().split():
    count[int(a) % 2] += 1

if count[1] == 0:
    if p == 0:
        print(pow(2, n))
    else:
        print(0)
else:
    print(pow(2, n - 1))

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

bool p(string s){
    string t = s;
    reverse(t.begin(), t.end());
    return s == t;
}

int main(){
    int n;
    cin >> n;
    for(int i = 0;;i++){
        for(int j : {-1, 1}){
            if(p(to_string(n+i*j))){
                cout << n+i*j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 3288
#include <iostream>
#include <string>
#include <vector>

using namespace std;

bool dfs(int d, string num, int result, string exp)
{
  if (d == num.size()) {
    if (result == 7) {
      cout << exp << "=7" << endl;
      return true;
    }
    return false;
  }

  if (dfs(d + 1, num, result + (num[d] - '0'), exp + '+' + num[d]))
    return true;
  if (dfs(d + 1, num, result - (num[d] - '0'), exp + '-' + num[d]))
    return true;
  return false;
}

int main()
{
  string num;
  cin >> num;
  dfs(1, num, num[0] - '0', ""s + num[0]);

  return 0;
}


Measured memory_bytes: 256