akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) {
    cin >> A[i];
  }
  cout << ((N - 1) + (K - 1) - 1) / (K - 1) << endl;
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
typedef long long int64;

int n, a, b;

int main()
{
    scanf("%d%d%d", &n, &a, &b);
    printf("%lld\n", std::max(0LL, (int64)(n - 2) * (b - a) + 1));
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
int main(){
  int n,m,c,b[25],a[25][25],count=0;
  std::cin>>n>>m>>c;
  for(int i=0;i<m;++i)std::cin>>b[i];
  for(int i=0;i<n;++i)for(int j=0;j<m;++j)std::cin>>a[i][j];
  for(int i=0;i<n;++i){
    int p=c;
    for(int j=0;j<m;++j)p+=a[i][j]*b[j];
    if(p>0)++count;
  }
  std::cout<<count<<std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>

using namespace std;

const int MAXN = 100000;

vector<int> g[1 + MAXN];
bool bad = false;

bool match(int node, int father) {
    int sons = 0;
    for (auto son : g[node])
        if (son != father && !match(son, node))
            sons++;
    if (sons > 1) {
        bad = true;
        return false;
    }
    if (sons == 1)
        return true;
    else {
        if (father == 0)
            bad = true;
        return false;
    }
}

int main(){
    //ifstream cin("input.in");
    int n;
    cin >> n;
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    match(1, 0);
    if (!bad)
        cout << "Second\n";
    else
        cout << "First\n";
    return 0;
}





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

using namespace __gnu_pbds;
using namespace std;

const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;

int n;
int x, y;
int edge[2007][2007];
int dis[2007][2007];
int ans[2007];

int main()
{
    scanf("%d%d%d", &n, &x, &y);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            edge[i][j] = abs(j - i);

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            dis[i][j] = min(min(edge[i][x] + 1 + edge[y][j], edge[i][y] + 1 + edge[x][j]), edge[i][j]);
        }
    }


    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            ans[dis[i][j]]++;
        }
    }


    for (int i = 1; i < n; i++)
    {
        printf("%d\n", ans[i]);
    }

    return 0;
}


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

int main() {
	int X;
	cin >> X;

	int r;
	if (X<600) r = 8;
	else if(X<800) r = 7;
	else if(X<1000) r = 6;
	else if(X<1200) r = 5;
	else if(X<1400) r = 4;
	else if(X<1600) r = 3;
	else if(X<1800) r = 2;
	else  r = 1;

	cout << r << endl;

    return 0;
}

Measured memory_bytes: 3672
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
static const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q,key;
string s,sb;
bool ok;

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

	
	cin>>n>>m; x=n/m;
	cout<<(x*x*x+((m%2)?0:((n%m>=m/2)?(x+1)*(x+1)*(x+1):x*x*x)))<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <cfenv>
using ll = unsigned long long;
using namespace std;
int gcd(int x,int y){
    if(y==0){
        return x;
    }else{
        return gcd(y,x%y);
    }
}
int lcm(int x,int y){
    return x/gcd(x,y)*y;
}
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    cin >> k;
    k--;
    for(int i=0;i<n;i++){
        if(s[i]!=s[k]){
            cout<<'*';
        }else{
            cout<<s[k];
        }
    }
    cout<<endl;
}

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

int main() {
  int k, x;
  cin >> k >> x;

  for (int i = x - k + 1; i <= x + k - 1; i++) {
    cout << i;
    if (i != x + k - 1) { cout << " "; }
  }
  cout << endl;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    string S; cin>>S;
    reverse(all(S));
    int K = S.size();
    int pcnt=0;
    rep(i,K)if(S[i]=='1') pcnt++;
    int X = pcnt-1;
    int Y = pcnt+1;
    vi dp1(N+1,1), dp2(N+1,1);
    if (X>0){
        rep(i,N){
            dp1[i+1]=dp1[i]*2;
            dp1[i+1]%=X;
        }
    }
    rep(i,N){
        dp2[i+1]=dp2[i]*2;
        dp2[i+1]%=Y;
    }
    vi a(N);
    int A=0,B=0;
    if (X>0){
        rep(i,N){
            if (S[i]=='1'){
                A+=dp1[i];
                A%=X;
            }
        }
    }
    rep(i,N){
        if (S[i]=='1'){
            B+=dp2[i];
            B%=Y;
        }
    }
    rep(i,N){
        if (S[i]=='1' && X>0){
            a[i] = A;
            a[i] -= dp1[i];
            a[i] += X;
            a[i] %= X;
        }else{
            a[i] = B;
            a[i] += dp2[i];
            a[i] %= Y;
        }
    }
    RFOR(i,N-1,0){
        if (X==0 && S[i]=='1'){
            cout<<"0\n";
            continue;
        }
        int ans=1;
        while(a[i]){
            a[i]%=__builtin_popcount(a[i]);
            ans++;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Measured memory_bytes: 5988
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b){
  return a < b ? a : b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;

  while( head != tail){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if( u.t > 0 ) enqueue(u);
    else{
      printf("%s %d\n", u.name, elaps);
    }
  }

  return 0;
}

Measured memory_bytes: 10756
#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[],int n,int left,int mid,int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	int i = 0, j = 0;
	for(int k = left; k < right; k++){
		cnt++;
		if(L[i] <= R[j]){
			A[k] = L[i++];
		}
		else{
			A[k] = R[j++];
		}
	}
}

void mergeSort(int A[],int n,int left,int right)
{
	if(left+1 < right)
	{
		int mid = (left + right) / 2;
		mergeSort(A,n,left,mid);
		mergeSort(A,n,mid,right);
		merge(A,n,left,mid,right);
	}
}


int main()
{
	int A[MAX],n,i;
	cnt = 0;
	
	cin >> n;
	for(i = 0; i < n; i++) cin >> A[i];
	
	mergeSort(A,n,0,n);
	
	for(i = 0; i < n; i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 6980
def resolve():
    N, M = map(int, input().split())
    arr = sorted(list(map(int, input().split())), reverse=True)
    s = sum(arr)
    th = s / 4 / M
    ans = 'Yes'
    for i in range(M):
        if arr[i] < th:
            ans = 'No'
            break
    print(ans)

resolve()

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

typedef long long ll;

typedef pair<ll,ll> ii;
typedef pair<ii, ll > iii;

const int kn = 2e5 + 5, N = 1e5+5;
const ll mod = 1e9 + 7, inf = 1e18 ;

#define x first
#define y second

#define ff(i,n) for(int i=1;i<=n;i++)

ll n,m,k,a[kn];

int main() {
	cin >> n >> k;
	k = k*2 + 1;
	if(n%k==0) cout << n/k;
	else cout <<n/k + 1;	
	
}
//hahahahahahahahahhahahahahahaahahahahhahahahahahahah


Measured memory_bytes: 256
H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
for i in range(H):
    for j in range(W):
        count = 0
        if(S[i][j]!="#"):
            for k in [-1,0,1]:
                for l in [-1,0,1]:
                    if(i+k>=H or i+k<0 or j+l>=W or j+l<0):
                        continue
                    elif(S[i+k][j+l]=="#"):
                        count += 1
            S[i][j] = str(count)
for i in range(H):
    print("".join(S[i]))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b;cin>>a>>b;
    cout<<(a+b)%24<<endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <ctype.h>
const int bufSize = 1e6;
using namespace std;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
const int maxn = 3e5 + 100;
int n, m, k;
int row[maxn], col[maxn];
bool vis[maxn];
bitset<maxn> bs;
vector<int> v[maxn];
int main()
{
    read(n), read(m), read(k);
    for (int i = 1; i <= k; ++i) 
    {
        int x, y;
        read(x), read(y), row[x]++, col[y]++, v[x].push_back(y);
    }
    int maxx = 0,maxy = 0;
    for (int i = 1; i <= n; ++i) maxx = std::max(maxx, row[i]);
    for (int i = 1; i <= m; ++i) maxy = std::max(maxy, col[i]);
    for (int i = 1; i <= m; ++i) if (col[i] == maxy) bs.set(i);
    int ans = maxx + maxy - 1;
    for (int i = 1; i <= n; ++i)
        if (row[i] == maxx)
        {
            bitset<maxn> ts;
            for (vector<int>::iterator it = v[i].begin(); it != v[i].end(); ++it) ts.set(*it);
            ts.flip();
            if ((ts & bs).any())
            {
                ans = maxx + maxy;
                break;
            }
        }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 22904
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cerr<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;


void solve(long long N, long long K){
    ll val = 0;
    val = K * pow(K-1, N-1);
    cout << val << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
	char a[20];
	cin>>a;
	if(a[0]=='S'&&a[1]=='u'&&a[2]=='n'&&a[3]=='n'&&a[4]=='y')
	cout<<"Cloudy";
	if(a[0]=='C'&&a[1]=='l'&&a[2]=='o'&&a[3]=='u'&&a[4]=='d'&&a[5]=='y')
	cout<<"Rainy";
	if(a[0]=='R'&&a[1]=='a'&&a[2]=='i'&&a[3]=='n'&&a[4]=='y')
	cout<<"Sunny";
	return 0;
}

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

void solve(long long X) {
    cout << 8 - (X - 400) / 200 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3756
N = int(input())
P = list(map(int, input().split()))
T = []

def check_abc(T):
    c = 0
    a = 0
    for t in T:
        if t < a:
            c += 1
        a = t
    if c == 0:
        print('YES')
        exit()

check_abc(P)
for i in range(N - 1):
    for j in range(i + 1, N):
        T = []
        for p in P:
            T.append(p)
        T[i] = P[j]
        T[j] = P[i]
        check_abc(T)

print('NO')

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

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

// chmax, chmin
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;
}

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  for(int i = 0 ; i < 10 ; i++){
    x = x * r - D;
    cout << x << endl;
  }
  // Failed to predict input format
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=[0]+list(map(int,input().split()))+[0]

ANS=0
while max(A)>0:
    for i in range(1,N+2):
        if A[i-1]<=0 and A[i]>0:
            ANS+=1

    A=[a-1 for a in A]

print(ANS)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

struct point{
     double x, y;
};

void renritu(point p1, point p2, double *a, double *b, double *c){
    *a=2*(p2.x-p1.x);
    *b=2*(p2.y-p1.y);
    *c=p1.x*p1.x+p1.y*p1.y-(p2.x*p2.x+p2.y*p2.y);
}

int main(void){
    int i,n;
    point p1,p2,p3;
    cin >> n;
    for(i=0;i<n;i++){
        double a1,b1,c1,a2,b2,c2,r;
        cin >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y;
        renritu(p1,p2,&a1,&b1,&c1);
        renritu(p1,p3,&a2,&b2,&c2);
        p3.x=-(b2*c1-b1*c2)/(a1*b2-a2*b1);
        p3.y=-(a1*c2-a2*c1)/(a1*b2-a2*b1);
        r=sqrt((p3.x-p1.x)*(p3.x-p1.x)+(p3.y-p1.y)*(p3.y-p1.y));
        printf("%.3lf %.3lf %.3lf\n",round(p3.x*1000)/1000,round(p3.y*1000)/1000, round(r*1000)/1000);
    }
    return 0;
}

Measured memory_bytes: 3212
n = int(input())
s = input()
nw = len(s.replace('R',''))
nr = n - nw

if (nr ==0) or (nw==0):
    print(0)
else:
    tmp_w = 0
    ret = n
    w_left = 0
    for i, c in enumerate(s):
        if c == 'W':
            w_left += 1
        r_right = nr + w_left - i - 1
        ret = min(ret, max(r_right, w_left))
    print(ret)


Measured memory_bytes: 9484
#![allow(unused_macros)]

// cf. [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita](https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8)
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
    }

    use std::collections::{VecDeque, HashSet};
    let mut queue = VecDeque::new();
    let mut visited = HashSet::new();

    queue.push_back((A, B, C, 0));

    while let Some((a, b, c, depth)) = queue.pop_front() {
        if a == b && b == c {
            println!("{}", depth);
            return;
        }
        if visited.contains(&(a,b,c)) {
            continue;
        }

        visited.insert((a,b,c));

        let n = depth + 1;

        queue.push_back((a+1,b+1,c,n));
        queue.push_back((a+1,b,c+1,n));
        queue.push_back((a,b+1,c+1,n));
        queue.push_back((a+2,b,c,n));
        queue.push_back((a,b+2,c,n));
        queue.push_back((a,b,c+2,n));
    }

    ()
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
  if(b==0)
    return a;
  return gcd(b,a%b);

}
int  main()
{
  int x;
  cin>>x;
  int ans=(360*x)/gcd(360,x);
  cout<<(ans/x)<<endl;
  

  
}

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

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

int main(){
    int n;cin>>n;
    long long x = 1;
    for(int i=0;i<n;i++){
        long long y;
        cin>>y;
        x = 1ll*x/gcd(x,y)*y;
    }
    cout<<x<<endl;
}


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

typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll x, t;
    cin >> x >> t;
    
    if (x >= t)
        cout << x - t;
    else
        cout << 0;
    
        
    
    return 0;
}



Measured memory_bytes: 256
n,m,i,j,a[100][100],b[100],c;
main(){
    for(i=0,scanf("%d%d",&n,&m);i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(j=0;j<m;j++){
        scanf("%d",&b[j]);
    }
    for(i=0;i<n;i++){
        for(j=c=0;j<m;j++){
            c+=a[i][j]*b[j];
        }
        printf("%d\n",c);
    }
}

Measured memory_bytes: 1860
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
	int n,t,ans=INF;
	cin >> n >> t;
	int cost,tim;
	for(int i=0; i<n; i++){
		cin >> cost >> tim;
		if(t>=tim)ans=min(ans,cost);
	}
	if(ans==INF){
		cout << "TLE" << endl;
		return 0;
	}
	cout << ans << endl;
	return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a;
	cin>>a;
	int number[a];
	for(int i=0;i<a;i++){
		cin>>number[i];
	}
	int n=0;
	for(int i=0;i<a;i++){
		if(number[i]%2==0){
			if(number[i]%3!=0){
				if(number[i]%5!=0){
					break;
				}
			} 
		}
		if(i==a-1){
			cout<<"APPROVED"<<endl;
			return 0;
		}
	}
	cout<<"DENIED"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 300000
#define INF 2140000000
#define MOD 1000000007

int bfs(vector<vector<int> > &adj, int s, int t) {
	vector<int> d(adj.size(), MAX);
	int flag[MAX] = {0};
	queue<int> q;
	flag[s] = 1;
	d[s] = 0;
	q.push(s);

	while(!q.empty()) {
		int u = q.front();
		if (u == t) {
			return d[u] / 3;
		}
		q.pop();

		for (int i = 0; i < adj[u].size(); ++i) {
			int v = adj[u][i];
			
			if(!flag[v]) {
				flag[v] = 1;
				d[v] = d[u] + 1;
				q.push(v);
			}
		}
	}

	return -1;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int> > adj(3*n);
	int u, v;

	for (int i = 0; i < m; ++i) {
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v + n);
		adj[u + n].push_back(v + 2*n);
		adj[u + 2*n].push_back(v);
	}

	int s, t;
	cin >> s >> t;
	cout << bfs(adj, s - 1, t - 1) << endl;

	return 0;
}

Measured memory_bytes: 18944
n = int(input())
xl_lis = [list(map(int,input().split())) for i in range(n)]
tempx = -(10**10)
ans = 0
xl_lis.sort()
# print(xl_lis)
for i in xl_lis:
    if tempx > i[0] - i[1] and tempx < i[0] + i[1]:
        ans += 1
    
    elif tempx > i[0] - i[1] and tempx >= i[0] + i[1]:
        ans += 1
        tempx = i[0] + i[1]
    else:
        tempx = i[0] + i[1]
print(n-ans)


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

#define o(output) cout << output << endl
#define priolity_queue pq
#define push p
#define top t

using namespace std;

string s;
int a,b,c,d;
char A,B;
map<char,int> mp;

int main(){
  cin>>s;
  for(int i=0;i<s.size();i++)if(mp.count(s[i])==0)mp.insert(make_pair(s[i],0));
  for(char i='a';i<='z';i++)if(mp.count(i)==0){
    o(i);
    return 0;
    }
  o("None"); 
}                                                           


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long
#define MOD 1e9+7
#define MAX_V
const double PI=3.14159265358979323846;

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain; 

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(){
#ifdef LOCAL
    ifstream in("../in.txt"); cin.rdbuf(in.rdbuf());
#endif
    int N, K;
    cin >> N >> K;
    vector<pair<ll, ll>> point(N);
    vector<pair<ll, ll>> x_ascend(N);
    vector<pair<ll, ll>> y_ascend(N);
    REP(i, N){
        cin >> point[i].first >> point[i].second;
        x_ascend[i] = point[i];
        y_ascend[i] = point[i];
    } 

    sort(x_ascend.begin(), x_ascend.end());  
    sort(y_ascend.begin(), y_ascend.end(), compare_by_b);

    ll answer = 1LL * (x_ascend[N-1].first - x_ascend[0].first) * (y_ascend[N-1].second - y_ascend[0].second);

    for(int i=0; i<N; i++){
        for(int j=i+1; j<N; j++){
            for(int l=0; l<N; l++){
                for(int m=l+1; m<N; m++){
                    ll internal_point = 0;
                    ll x_left = x_ascend[i].first;
                    ll x_right = x_ascend[j].first;
                    ll y_down = y_ascend[l].second;
                    ll y_up = y_ascend[m].second;

                    for(int n=0; n<N; n++){
                        if(x_left <= point[n].first && point[n].first <= x_right){
                            if(y_down <= point[n].second && point[n].second <= y_up){
                                internal_point++;
                            }
                        }
                    }

                    if(internal_point >= K){
                        answer = min(answer, 1LL*(x_right - x_left)*(y_up - y_down));
                    }
                }
            }
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
#define endl "\n"
using namespace std ; 

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

	int n , d ; 	
	cin >> n >> d ; 
	int cnt =0  ;
	int v = d*d ; 
	for(int i = 0 ; i < n ; ++i)
        {
		int a , b ;	
		cin >> a >> b ; 
		if(a*a + b*b <= v)
			cnt++ ; 
	}
	cout << cnt << endl ;
}              













Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll n;
    string s;
    cin >> n;
    s = to_string(n);
    
    int sum = 0;
    for (int i = 0; i < s.length(); i++) {
        sum += s[i] - '0';
    }
    if (n % sum == 0) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
x = [0 for i in range(N)]
A = False
for i in range(len(S)):
    c = S[i]
    if c == 'A':
        A = True
    elif A and c == 'C':
        x[i] += 1
        A = False
    else:
        A = False
s = [0 for i in range(N+1)]
for i in range(N):
    s[i+1] = s[i]+x[i]
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    if s[l] != s[l+1]:
        print(s[r]-s[l]-1)
    else:
        print(s[r]-s[l])


Measured memory_bytes: 8540
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m,ac,wa;
    cin>>n>>m;
    int p;
    string s;
    vector<bool> aced(n+1);
    vector<int> waed(n+1);
    ac=0;
    wa=0;
    rep(i,m)
    {
        cin>>p>>s;
        if(aced.at(p))
            continue;
        if(s=="AC")
        {
            aced.at(p)=true;
            wa+=waed.at(p);
            ac++;
        }
        else
            waed.at(p)+=1;
    }
    cout<<ac<<" "<<wa<<endl;
 }

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int n;
#define MAX_N 8
int F[MAX_N][MAX_N];

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

void debug();

bool finished() {
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < n; j++) 
            if (F[i][j] != 0) 
                return false;
    return true;
}

void debug() {
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            printf("%4d", F[i][j]);
        }
        printf("\n");
    }
}

bool dfs(int y, int x, int c) {
    //printf("c: %d\n", c);
    if (c > 0) return false;
    if (c == 0) {
        if (finished()) return true;
        for (int i = 0; i < n; i++) 
            for (int j = 0; j < n; j++) 
                if (F[i][j] < 0) {
                    bool ans;
                    int f = F[i][j];
                    F[i][j] = 0;
                    ans = dfs(i, j, f);
                    F[i][j] = f;
                    return ans;
                }
        return false;
    }

    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (0 <= nx && nx < n && 0 <= ny && ny < n && F[ny][nx] > 0) {
            int f = F[ny][nx];
            F[ny][nx] = 0;
            if (dfs(ny, nx, c+f)) return true;
            else F[ny][nx] = f;
        }
    }
    return false;
}

bool solve() {
    bool ans;
    for (int i = 0; i < n; i++) 
        for (int j = 0; j < n; j++) 
            if (F[i][j] < 0) {
                int f = F[i][j];
                F[i][j] = 0;
                ans = dfs(i, j, f);
                return ans;
            }
}
 
int main() {
    while (scanf("%d", &n), n) {
        for (int i = 0; i < n; i++) 
            for (int j = 0; j < n; j++) 
                scanf("%d", &F[i][j]);
       puts(solve() ? "YES" : "NO");
    }
    return 0;
}

Measured memory_bytes: 1012
"use strict"

function main(arg) {
    var nums = arg.trim().split(" ").map((item)=> parseInt(item));
    var result = nums[0] * nums[1];
    if(result % 2 == 0){
        console.log("Even");
    } else {
        console.log("Odd");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> pl,mi;
  rep(i,n){
    cin >> a[i];
    if(a[i]>=0){
      pl.emplace_back(a[i]);
    } else {
      mi.emplace_back(a[i]);
    }
  }
  sort(pl.rbegin(),pl.rend());
  sort(mi.begin(),mi.end());
  if(mi.empty()){
    mi.emplace_back(pl.back());
    pl.pop_back();
  }
  if(pl.empty()){
    pl.emplace_back(mi.back());
    mi.pop_back();
  }

  vector<pair<ll,ll>> act;
  ll ans = mi[0];
  int plsz = pl.size();
  rep(i,plsz-1){
    act.emplace_back(ans,pl[i]);
    ans -= pl[i];
  }
  act.emplace_back(pl[plsz-1],ans);
  ans = pl[plsz-1]-ans;

  int misz = mi.size();
  REP(i,1,misz){
    act.emplace_back(ans,mi[i]);
    ans -= mi[i];
  }

  cout << ans << endl;
  for(auto it:act){
    cout << it.F << " " << it.S << endl;
  }
  return 0;
}

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

int main(){

  int n,m; cin >> n >> m;
  int a[n],b[n];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  int c[m],d[m];
  for(int i=0;i<m;i++){
    cin>>c[i]>>d[i];
  }
  long long min=10000000000;
  int ans_index=0;
  for(int i=0;i<n;i++){
    int k=0;
    while(k<m){
      if(min>(abs(a[i]-c[k])+abs(b[i]-d[k]))){
        min=(abs(a[i]-c[k])+abs(b[i]-d[k]));
        ans_index=k+1;
      }
      k++;
    }
    cout << ans_index << endl;
    ans_index=0;
    min=1000000000;
  }  
  return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int result = 0;

		for (int i = 1; i <= n; i++) {
			List<Integer> list = new ArrayList<>();
			int cnt = i;
			while(cnt > 0) {
				list.add(cnt%10);
				cnt /= 10;
			}
			
			int lcnt = 0;
			for (int l : list) {
				lcnt += l;
			}
			
			if (lcnt >= a && lcnt <= b) {
				result += i;
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 36872
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=2000000001;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n,m;
  while(cin >> n >> m && (n||m)) {
    int a[n][m];
    rep(i,n) {
      rep(j,m) cin >> a[i][j];
    }
    int ans=0;
    rep(k,(1<<n)) {
      int sum=0;
      rep(j,m) {
	int cnt=0;
	rep(i,n) {
	  bool x=a[i][j];
	  if((k&(1<<i))!=0) x=!x;
	  if(x) cnt++;
	}
	sum+=max(cnt,n-cnt);
      }
      ans=max(ans,sum);
    }
    pr(ans);
  }
  return 0;
}


Measured memory_bytes: 1548
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
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...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int mod = 1000000007;
signed main(){
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	vector<int> s(n+1);
	rep(i,n)s[i+1] = (s[i] + a[i])%mod;
	s[0] = 1;
	int ret = 0;
	rep(i,n){
		if(i == 0)continue;
		int tmp = (a[i]*s[i])%mod;
		ret = (ret + tmp)%mod;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 6424
const MOD: i64 = 1_000_000_007;

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let a: Vec<i64> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let mut cs = vec![0; n + 1];
    for i in 0..n {
        cs[i + 1] = (cs[i] + a[i]) % MOD;
    }

    let mut ans = 0;
    for i in (0..n).rev() {
        ans = (ans + cs[i] * a[i] % MOD) % MOD;
    }
    println!("{}", ans);
}

Measured memory_bytes: 5848
def main():
    import sys
    input = sys.stdin.readline

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

    cs = [0] * (N+1)
    for i in range(N):
        cs[i+1] = cs[i] + A[i]

    B = []
    for i in range(N):
        for j in range(i, N):
            B.append(cs[j+1] - cs[i])

    tmax = cs[-1].bit_length()
    ans = 0
    for t in range(tmax-1, -1, -1):
        k = 0
        tmp = []
        for b in B:
            if b >> t & 1:
                k += 1
                tmp.append(b)
        if k >= K:
            B = tmp
            ans += 2**t

    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
   char A[1000005];
	scanf("%s", A);
  
  	if ((A[0] == A[1]  && A[1] ==A[2]) || (A[1] == A[2] && A[2] == A[3]))
      	printf("Yes\n");
  	else
      	printf("No\n");
  return 0;
}


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

long long int gcd(long long int a, long long int b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

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

    vector<long long int> left(n), right(n), total(n);
    left[0] = a[0];
    right[n-1] = a[n-1];
    for(int i=1; i<n; i++){
        left[i] = gcd(left[i-1],a[i]);
    }
    for(int i=n-2; i>=0; i--){
        right[i] = gcd(a[i], right[i+1]);
    }
    total[0] = right[1];
    total[n-1] = left[n-2];
    for(int i=1; i<n-1; i++){
        total[i] = gcd(left[i-1],right[i+1]);
    }
    sort(total.begin(),total.end());
    cout << total[n-1] << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include "atcoder/all"
typedef long long int ll;
using namespace std;
using namespace atcoder;
#define MAXN 101
#define MAXM 101
bool wall[MAXN][MAXM];
char grid[MAXN][MAXM];
int main() {
    int n, m;
    cin >> n >> m;
    mf_graph<int> graph(n * m + 2);
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++) {
            grid[i][j] = s[j];
            if (s[j] == '#') {
                wall[i][j] = true;
            }
            else {
                wall[i][j] = false;
                if ((i + j) % 2) {
                    graph.add_edge(m * n, i * m + j, 1);
                }
                else {
                    graph.add_edge(i * m + j, m * n + 1, 1);
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if ((i >= 1) && (!wall[i][j]) && (!wall[i - 1][j])) {
                if ((i + j) % 2) {
                    graph.add_edge(i * m + j, (i - 1) * m + j, 1);
                }
                else {
                    graph.add_edge((i - 1) * m + j, i * m + j, 1);
                }
            }
            if ((j >= 1) && (!wall[i][j]) && (!wall[i][j - 1])) {
                if ((i + j) % 2) {
                    graph.add_edge(i * m + j, i * m + j - 1, 1);
                }
                else {
                    graph.add_edge(i * m + j - 1, i * m + j, 1);
                }
            }
        }
    }
    cout << graph.flow(m * n, m * n + 1) << endl;
    auto edges = graph.edges();
    for (auto e: edges) {
        if ((e.from == m * n) || (e.to == m * n + 1) || e.flow == 0) {
            continue;
        }
        int i0 = e.from / m;
        int j0 = e.from % m;
        int i1 = e.to / m;
        int j1 = e.to % m;
        if (i0 == i1) {
            if (j0 < j1) {
                grid[i0][j0] = '>';
                grid[i1][j1] = '<';
            }
            else {
                grid[i0][j0] = '<';
                grid[i1][j1] = '>';
            }
        }
        else {
            if (i0 < i1) {
                grid[i0][j0] = 'v';
                grid[i1][j1] = '^';
            }
            else {
                grid[i0][j0] = '^';
                grid[i1][j1] = 'v';
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5488
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 18];
int cnt[1 << 20];
vector<int> X[1 << 20];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; cnt[A[i]]++; }
	for (int i = 1; i <= 1000000; i++) {
		for (int j = i; j <= 1000000; j += i) X[j].push_back(i);
	}
	int cnts = 0;
	for (int i = 1; i <= N; i++) {
		bool flag = false;
		for (int j = 0; j < X[A[i]].size(); j++) {
			int r = cnt[X[A[i]][j]];
			if (X[A[i]][j] == A[i]) r--;
			if (r >= 1) flag = true;
		}
		if (flag == false) cnts++;
	}
	cout << cnts << endl;
	return 0;
}

Measured memory_bytes: 123736
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
s = [INT() for _ in range(N)]

ans = sum(s)

if ans%10:
	print(ans)
	exit()

for x in sorted(s):
	if (ans-x)%10:
		print(ans-x)
		break
else:
	print(0)

Measured memory_bytes: 13680
from collections import Counter

n = int(input())
xs = [None] + [int(input())-1 for _ in range(n-1)]

count_win = Counter(xs)
q = [i for i in range(n) if not i in count_win]
children = [[] for i in range(n)]

qi = 0
while not q[qi]==0:
    i, qi = q[qi], qi+1
    children[i].sort(reverse=True)
    children[i] = max(v+w for v, w in  enumerate([0]+children[i]))
    j = xs[i]
    children[j].append(children[i])
    if count_win[j] <= 1:
        q.append(j)
    else:
        count_win[j] -= 1

children[0].sort(reverse=True)
children[0] = max(v+w for v, w in  enumerate([0]+children[0]))

print(children[0])

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

using namespace std;

int dpm[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  int aend, bend;
  cin >> aend >> bend;

  int result = 0;
  for (int a = 1; a <= aend; a++) {
    for (int b = 1; b <= dpm[a]; b++) {
      if (a==b) result++;
      if (a == aend && b == bend) {
        cout << result << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int num=1,i;
  for(i=1;i<=n;i++)
  {
    if(floor(i*1.08) == n)
    {
      num=0;
      cout<<i;
      break;
    }
  }
  if(num ==1)
    cout<<":(" ;
  return 0;
            }


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
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; }

ll dp[2010][2010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    VI s(n), t(m);
    dp[0][0] = 1;
    FOR(i, 0, n) {
        cin >> s[i];
        dp[i + 1][0] = 1;
    }
    FOR(i, 0, m) {
        cin >> t[i];
        dp[0][i + 1] = 1;
    }

    FOR(i, 0, n)FOR(j, 0, m) {
        if (s[i] != t[j])dp[i + 1][j + 1] -= dp[i][j];
        dp[i + 1][j + 1] += dp[i][j + 1];
        dp[i + 1][j + 1] += dp[i + 1][j];
        dp[i + 1][j + 1] = (dp[i + 1][j + 1] + mod) % mod;
    }

    cout << dp[n][m] << "\n";
}

Measured memory_bytes: 31744
integer N
integer,allocatable,dimension(:)::A
integer color(8),over
read*,N
allocate(A(N))
read*,A
color=0;over=0
do i=1,N
  select case (A(i))
    case(1:399)
      color(1)=1
    case(400:799)
      color(2)=1
    case(800:1199)
      color(3)=1
    case(1200:1599)
      color(4)=1
    case(1600:1999)
      color(5)=1
    case(2000:2399)
      color(6)=1
    case(2400:2799)
      color(7)=1
    case(2800:3199)
      color(8)=1
    case default
      over=over+1
  end select
end do
print"(i0,A,i0)",merge(sum(color),1,sum(color)/=0.or.over==0)," ",sum(color)+over
end

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

int main(){
    int n; cin >>n;
    vector<int> edge(n);
    for(int i=0; i<n; i++) cin >> edge[i];
    sort(edge.begin(), edge.end());
    int ans = 0;

    for(int i=n-1; i>=0; i--){
        for(int j=i-1; j>=0; j--){
            auto iter = lower_bound(edge.begin(), edge.end(), edge[i]+edge[j]);
            ans += n-1-i - (edge.end()-iter);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    string s;
    int n;

    cin >> s;
    cin >> n;

    string command, p;
    int a, b;
    for (int i = 0; i < n; i++) {
        cin >> command;
        cin >> a >> b;
        if (command == "replace") {
            cin >> p;
            string s1 = s.substr(0, a);
            string s2 = s.substr(b + 1);
            s = s1 + p + s2;
        }
        else if (command == "reverse") {
            while (a < b) {
                char t = s[a];
                s[a] = s[b];
                s[b] = t;
                a++;
                b--;
            }
        }
        else if (command == "print") {
            for (int i = a; i <= b; i++)
                cout << s[i];
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3172