akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MX = 100005;

pair<int, int> A[MX];

int main()
{
	int n;
	ignore = scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) ignore = scanf("%d", &A[i].first);
	for (int i = 1; i <= n; i++) ignore = scanf("%d", &A[i].second);
	sort(A + 1, A + 1 + n, [](pair<int, int> a, pair<int, int> b) {
		return a.second < b.second;
	});
	
	{
		multiset<int> S;
		for (int i = 1; i <= n; i++) S.insert(A[i].first);
		for (int i = 1; i <= n; i++) {
			if (*S.begin() > A[i].second) {
				printf("No\n");
				return 0;
			}
			S.erase(S.begin());
		}
	}
	
	set<pair<int, int>> S;
	
	for (int i = 1; i <= n; i++) {
		S.insert({A[i].first, i});
	}
	
	for (int i = 1; i <= n - 1; i++) {
		if (S.begin()->first > A[i].second) {
			printf("No\n");
			return 0;
		}
		if (next(S.begin())->first <= A[i].second) {
			printf("Yes\n");
			return 0;
		}
		if (S.begin()->second == i) {
			printf("Yes\n");
			return 0;
		}
		
		int x = i;
		int y = S.begin()->second;
		S.erase({A[x].first, x});
		S.erase({A[y].first, y});
		swap(A[x].first, A[y].first);
		S.insert({A[y].first, y});
	}
	
	printf("No\n");
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N;
    cin >> N;
    vl a(N);
    in(N,a);
    
    ll sum = a[0];
    ll ans = 0;
    if(a[0] == 0) sum = 1,ans = 1;
    reps(i,1,N){
        if((sum <= 0 && sum+a[i] <= 0)||(sum >= 0 && sum+a[i] >= 0)){
            if(sum <= 0) ans += (1-sum-a[i]),sum = 1;
            else ans += (sum+a[i]+1),sum = -1;
        }else{
            sum += a[i];
        }
    }
    
    ll an = 0;
    if(a[0] == 0) sum = -1,an = 1;
    else{
        if(a[0] > 0) sum = -1,an = a[0]+1;
        else sum = 1, an = 1-a[0];
    }
    reps(i,1,N){
        if((sum <= 0 && sum+a[i] <= 0)||(sum >= 0 && sum+a[i] >= 0)){
            if(sum <= 0) an += (1-sum-a[i]),sum = 1;
            else an += (sum+a[i]+1),sum = -1;
        }else{
            sum += a[i];
        }
    }
    
    
    cout << min(an,ans) << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 1024
/**
 * auther: moririn_cocoa
 */
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define fi first
#define se second
#define ll long long
#define pll pair<ll,ll>
#define pq priority_queue
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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 argc, const char * argv[]) {
  
  int X;
  int A;
  int B;
  
  cin >> X;
  cin >> A;
  cin >> B;
  
  int n = ( X - A ) / B;
  
  cout << X - A - ( B * n ) << endl;
  
  return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
	int h,w,cnt;
	cin>>h>>w;
	char S[h][w];
	char buf[30];
	int i,j;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>S[i][j];
		}
	}

	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cnt=0;
			//cout<<"aaa"<<endl;
			if(S[i][j]=='.'){
				if(i!=0&&j!=0){
					if(S[i-1][j-1]=='#')cnt++;
				}
				if(i!=0){
					if(S[i-1][j]=='#')cnt++;
				}
				if(i!=0&&j!=w-1){
					if(S[i-1][j+1]=='#')cnt++;
				}
				if(j!=0){
					if(S[i][j-1]=='#')cnt++;
				}
				if(j!=w-1){
					if(S[i][j+1]=='#')cnt++;
				}
				if(i!=h-1&&j!=0){
					if(S[i+1][j-1]=='#')cnt++;
				}
				if(i!=h-1){
					if(S[i+1][j]=='#')cnt++;
				}
				if(i!=h-1&&j!=w-1){
					if(S[i+1][j+1]=='#')cnt++;
				}
				cout<<cnt;
			}else{
				cout<<S[i][j];
			}
		}
		cout<<endl;
	}
	/*for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cout<<S[i][j];
		}
		cout<<endl;
	}*/

}


Measured memory_bytes: 256
h, w = map(int, input().split())
c = []
a = []

for _ in range(10):
    c.append(list(map(int, input().split())))

for _ in range(h):
    a.append(list(map(int, input().split())))

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j] = min(c[i][j], c[i][k] + c[k][j])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += c[a[i][j]][1]  # 1までの最短コスト

print(ans)

Measured memory_bytes: 3444
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    py = sorted([LI() + [i] for i in range(m)], key=lambda x: [x[1], x])
    d = collections.defaultdict(int)
    rd = {}
    for p,y,i in py:
        d[p] += 1
        rd[i] = '{:06d}{:06d}'.format(p,d[p])

    return '\n'.join(map(lambda x: rd[x], range(m)))


print(main())


Measured memory_bytes: 48564
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    string s;cin>>s;
    if(s.size()<4)return cout<<"No" , 0;
    cout<<(s.substr(0,4)=="YAKI"?"Yes":"No");
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long double PI = (acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int ctoi(char c)
{
    switch (c)
    {
    case '0':
        return 0;
    case '1':
        return 1;
    case '2':
        return 2;
    case '3':
        return 3;
    case '4':
        return 4;
    case '5':
        return 5;
    case '6':
        return 6;
    case '7':
        return 7;
    case '8':
        return 8;
    case '9':
        return 9;
    default:
        return 0;
    }
}
int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> A(m);
    vector<int> L(n, 0);
    int leftsum = 0, rightsum = 0;
    rep(i, m)
    {
        cin >> A[i];
        if(A[i]<x){
            leftsum++;
        }else{
            rightsum++;
        }
    }
    
    cout << min(leftsum, rightsum) << endl;

}

Measured memory_bytes: 256
import java.util.*;
import static java.util.Comparator.*;
import java.math.BigInteger;

public class Main {
    private static BigInteger MOD = BigInteger.valueOf(1000000007L);
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        List<BigInteger> numList = new LinkedList<>();
        for(int i=0;i<N;i++){
            numList.add(BigInteger.valueOf(Long.parseLong(sc.next())));
        }
        BigInteger lcmNum = numList
                    .stream()
                    .sorted(reverseOrder())
                    .reduce(numList.get(0),(s1,s2) -> s1.multiply(s2.divide(s1.gcd(s2))));
        BigInteger res =numList
                .stream()
                .parallel()
                .map(s -> lcmNum.divide(s))
                .reduce(BigInteger.ZERO,(s1,s2) -> s1.add(s2));
        System.out.println(res.mod(MOD));
    }
}


Measured memory_bytes: 230988
iAC = 0
iWA = 0
iTLE = 0
iRE = 0

N = int(input())
for i in range(N):
    S = input()
    if S == "AC":
        iAC += 1
    elif S == "WA":
        iWA += 1
    elif S == "TLE":
        iTLE += 1
    elif S == "RE":
        iRE += 1

print("AC x {}".format(iAC))
print("WA x {}".format(iWA))
print("TLE x {}".format(iTLE))
print("RE x {}".format(iRE))

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
//repはカウンタ変数が1ずつ増える場合にしか使えない
using veci = vector<int>;
using vecd = vector<double>;
int main(){
  string s;
  cin >> s;//sを前から見ていってAが見つかればその添え字を記録、次に後ろから見ていってZが見つかればその添え字を記録
  //ｚの添え字-aの添え字+1が答え
  int a_ind = -1;
  for (int i=0; i<s.size(); i+=1){
    if (s.at(i) == 'A'){
      a_ind = i;
      break;
    }
  }
  int z_ind = -1;
  for (int i=s.size()-1; i>0; i-=1){
    if (s.at(i) == 'Z'){
      z_ind = i;
      break;
    }
  }
  int ans = z_ind - a_ind +1;
  cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  int X = N / 100, Y = N % 100;
  bool x = (1 <= X && X <= 12);
  bool y = (1 <= Y && Y <= 12);
  if (x && y) cout << "AMBIGUOUS";
  else if (x) cout << "MMYY";
  else if (y) cout << "YYMM";
  else cout << "NA";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

constexpr long long INF = 10000000000;
long long N;
long double sqr;
long long ans;

int main()
{
	std::cin >> N;

	sqr = std::sqrt(N);
	ans = INF;

	for (long long i = 1; i <= sqr; i++) {
		if (N%i == 0) {
			ans = std::min(ans, std::max(i, N / i));
		}
	}

	std::cout << std::to_string(ans).length() << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAXM 55

int N,M,Ans,a[MAXM],b[MAXM],fa[MAXM],Cnt;

int gf(int x)
{
	if(fa[x]!=x)fa[x]=gf(fa[x]);
	return fa[x];
}

void Merge(int x,int y)
{
	int fx=gf(x),fy=gf(y);
	if(fx==fy)return;
	fa[fx]=fy;
	Cnt--;
}

int main()
{
	int i,j;
	
	scanf("%d%d",&N,&M);
	for(i=1;i<=M;i++)scanf("%d%d",&a[i],&b[i]);
	
	for(i=1;i<=M;i++)
	{
		for(j=1;j<=N;j++)fa[j]=j;
		Cnt=N;
		
		for(j=1;j<=M;j++)
		{
			if(j==i)continue;
			Merge(a[j],b[j]);
		}
		
		if(Cnt!=1)Ans++;
	}
	
	printf("%d",Ans);
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
class Cube{
public:
int f[6];
Cube(){}
void roll_z(){ roll(1,2,4,3);}
void roll_y(){ roll(0,2,5,3);}
void roll_x(){ roll(0,1,5,4);}
void roll(int i,int j,int k,int l){
int t=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=t;
}
void move(char ch){
if(ch == 'E') for(int i=0;i<3;i++)roll_y();
if(ch == 'W') roll_y();
if(ch == 'N') roll_x();
if(ch == 'S') for(int i=0;i<3;i++) roll_x();
}
};
int main(){
Cube c;
string com;
for(int i=0;i<6;i++) cin >> c.f[i];
cin >> com;
for(int i=0; i<com.size();i++) c.move(com[i]);
cout << c.f[0] <<endl;
return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000000000
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<long long> x(N);
  long long dist = MAX, tmp = 0;
  
  for (int i = 0; i < N; i++) cin >> x.at(i);
  
  for (int i = 0; i < N - K + 1; i++) {
    if (x.at(i) < 0 && x.at(i + K - 1) <= 0) {
      tmp = abs(x.at(i));
    } else if (x.at(i) >= 0 && x.at(i + K - 1) > 0) {
      tmp = abs(x.at(i + K - 1));
    } else {
      tmp = abs(x.at(i)) + abs(x.at(i + K - 1)) + min(abs(x.at(i)), abs(x.at(i + K - 1)));
    }
    dist = min(dist, tmp);
  }
  
  cout << dist;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>

extern const double eps;
bool eql(const double &a, const double &b) {
    return fabs(a - b) < eps;
}

struct Vector {
    double x, y;
    Vector(int _x, int _y) : x(_x), y(_y) {}
    Vector(double _x, double _y) : x(_x), y(_y) {}
    Vector() :x(0), y(0) {}

    double dot(const Vector &r) const {
        return x * r.x + y * r.y;
    }
    
    double cross(const Vector &r) const {
        return x * r.y - y * r.x;
    }

    double length() const {
        return sqrt(x * x + y * y);
    }

    Vector  operator +  (const Vector &r) const {
        return Vector(x + r.x, y + r.y);
    }
    Vector& operator += (const Vector &r) {
        x += r.x, y += r.y;
        return *this;
    }

    Vector  operator -  () const {
        return Vector(-x, -y);
    }

    Vector  operator -  (const Vector &r) const {
        return *this + -r;
    }
    Vector& operator -= (const Vector &r) {
        x -= r.x, y -= r.y;
        return *this;
    }

    Vector  operator *  (double k) const {
        Vector tmp = *this;
        tmp.x *= k, tmp.y *= k;
        return tmp;
    }

    Vector& operator *= (double k) {
        x *= k, y *= k;
        return *this;
    }

    // 向量单位化
    void unitise() {
        double len = length();
        x /= len, y /= len;
    }
};
typedef Vector Point;
struct Line {
    Point p;
    // 规定方向向量取单位向量
    Vector dir;

    Line(Point _p, Vector _dir) : p(_p), dir(_dir) {
        dir.unitise();
    }
    Line() {}

};

// 向量数乘
Vector operator * (double k, const Vector & r) {
    return r * k;
}

// 点到直线的投影点
Point projection(const Point &p, const Line &l) {
    double d = Vector(p - l.p).dot(l.dir);
    return l.p + d * l.dir;
}
// 点关于直线的对称点
Point reflection(const Point &p, const Line &l) {
    Point pro = projection(p, l);
    return p + 2 * (pro - p);
}

// 直线互相平行？
bool parallel(const Line &l, const Line &r) {
    return fabs(l.dir.cross(r.dir)) < eps;
}

// 直线互相垂直？
bool orthogonal(const Line &l, const Line &r) {
    return fabs(l.dir.dot(r.dir)) < eps;
}

using namespace std;
const double eps = 1e-8;

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

    int q; cin >> q;
    while (q--) {
        Line l[2];
        for (int x1, y1, x2, y2, i = 0; i < 2; ++i) {
            cin >> x1 >> y1 >> x2 >> y2;
            l[i].p = Point(x1, y1);
            l[i].dir = Vector(x2 - x1, y2 - y1);
        }

        if (parallel(l[0], l[1])) {
            cout << "2\n";
        } else if (orthogonal(l[0], l[1])) {
            cout << "1\n";
        } else cout << "0\n";
    }
    return 0;
}


Measured memory_bytes: 3220
using System;

class ABC072C
{
	static public void Main(string[] args)
	{
		int N;
		int[] count = new int[100001+1+1];

		N = int.Parse(Console.ReadLine());
		string[] vals = Console.ReadLine().Split(' ');
		for(int i = 0; i < N; i++)
		{
			int a = int.Parse(vals[i]);
			count[a+1]++;
			count[(a-1)+1]++;
			count[(a+1)+1]++;
		}

		int maxCount = 0;
		for(int i = 0; i < 100001+1+1; i++)
		{
			if(maxCount < count[i])
			{
				maxCount = count[i];
			}
		}
		Console.WriteLine(maxCount);
	}
}


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

int main()
{
   int k, s;
   cin >> k >> s;
   int ans = 0;
   rep(x,k+1)
      rep(y,k+1)
      {
         int z = s-x-y;
         if(z < 0 || z > k ) continue;
         else ++ans;
      }
   
   cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input())

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

A.sort()
A = A[::-1]
ans = 0
counter = 0
buff = []
flag = False
for i in range(0, N-1):
    if flag:
        flag = False
        continue
    if A[i] == A[i+1]:
        buff.append(A[i])
        flag = True
        counter += 1
        if counter >= 2:
            print(buff[0]*buff[1])
            exit()

print(ans)

Measured memory_bytes: 63472
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }

vector<ll> solve(){
    vector<ll> res;
    ll h,w; cin >> h >> w;
    ll G = gcd(h,w);
    h/=G; w/=G;
    if(h == w){
        res = vector<ll>{1,0};
    }else if(h%2 == 0 || w%2 == 0){
        res = vector<ll>{1,1};
    }else{
        res = vector<ll>{h*w/2+1,h*w/2};
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int T; cin >> T;
    while(T--){
        cout << solve() << endl;
    }
    return 0;
}



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


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<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int H, W;
char mas[500][500];
int min_cost[500][500];

int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

int bfs(int sx, int sy, char c) {
	for (int i = 0; i < 500; i++) {
		for (int j = 0; j < 500; j++) {
			min_cost[i][j] = -1;
		}
	}

	queue<pair<int, int>> que;
	que.emplace(sx, sy);
	min_cost[sx][sy] = 0;

	while (!que.empty()) {
		auto p = que.front();
		que.pop();

		if (mas[p.second][p.first] == c)return (min_cost[p.first][p.second]);

		for (int i = 0; i < 4; i++) {
			int nx = p.first + vx[i], ny = p.second + vy[i];

			if (nx < 0 || ny < 0 || nx >= W || ny >= H)continue;
			if (min_cost[nx][ny] != -1)continue;
			if (mas[ny][nx] == '#')continue;

			min_cost[nx][ny] = min_cost[p.first][p.second] + 1;
			que.emplace(nx, ny);
		}
	}

	return -1;
}

int main() {
	cin >> H >> W;

	int proc = 0;

	for (int i = 0; i < H; i++) {
		cin >> mas[i];

		for (int j = 0; j < W; j++) {
			if (mas[i][j] == '#')++proc;
		}
	}

	mas[H - 1][W - 1] = 'G';

	auto s = bfs(0, 0, 'G');

	if (s == -1)cout << -1 << endl;
	else cout << H * W - s - proc - 1 << endl;
}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

ll dp[3000][3000];

int main(void){
    ll n;
    cin>>n;
    vl a(n);
    rep(i,n) cin>>a[i];
    mrep(l,n-1) rep(r,n){
        if(r < l){
            dp[l][r] = 0;
            continue;
        }
        if(r == l){
            dp[l][r] = a[l];
            continue;
        }
        dp[l][r] = max(-dp[l][r-1]+a[r],-dp[l+1][r]+a[l]);
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 70656
n = int(input())
v = list(map(int, input().split()))

res = ''

ht1 = dict()
ht2 = dict()

for i in range(0, n - 1, 2):
    if v[i] not in ht1:
        ht1[v[i]] = 1
    else:
        ht1[v[i]] += 1


for j in range(1, n, 2):
    if v[j] not in ht2:
        ht2[v[j]] = 1
    else:
        ht2[v[j]] += 1

sorted1 = sorted(ht1.items(), key=lambda x: x[1])
sorted2 = sorted(ht2.items(), key=lambda x: x[1])

if (sorted1[-1][0] != sorted2[-1][0]):
    res = n - sorted1[-1][1] - sorted2[-1][1]
else:
    if len(sorted1) == 1 and len(sorted2) == 1:
        res = int(n / 2)
    elif len(sorted1) == 1:
        print('aaa')
        res = n - sorted2[-1][1]
    elif len(sorted2) == 1:
        print('bbb')
        res = n - sorted1[-1][1]
    elif sorted1[-2][1] < sorted2[-2][1]:
        res = n - sorted1[-1][1] - sorted2[-2][1]
    else:
        res = n - sorted2[-1][1] - sorted1[-2][1]

print(res)


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 x;
    cin >> x;
    for(int64 a=0;a<=2000;++a){
        for(int64 b=-2000;b<=2000;++b){
            if(a==b)continue;
            if(x%(a-b))continue;
            if(a*a*a*a*a-b*b*b*b*b==x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3652
# -*- coding: utf-8 -*-

import sys
import os
import math

def to_key(A):
    return ''.join(map(str, A))

def register(A, cnt, i, j):
    B = A[:]
    B[i], B[j] = B[j], B[i]
    key = to_key(B)
    if key not in M:
        Q.append((B, cnt + 1))

# prepare
A = [0, 1, 2, 3, 4, 5, 6, 7]
M = {}
Q = [(A, 0)]

while Q:
    A, cnt = Q.pop(0)
    key = to_key(A)
    M[key] = cnt

    idx = A.index(0)
    if idx == 0:
        register(A, cnt, idx, 1)
        register(A, cnt, idx, 4)
    elif idx == 1:
        register(A, cnt, idx, 0)
        register(A, cnt, idx, 2)
        register(A, cnt, idx, 5)
    elif idx == 2:
        register(A, cnt, idx, 1)
        register(A, cnt, idx, 3)
        register(A, cnt, idx, 6)
    elif idx == 3:
        register(A, cnt, idx, 2)
        register(A, cnt, idx, 7)
    elif idx == 4:
        register(A, cnt, idx, 0)
        register(A, cnt, idx, 5)
    elif idx == 5:
        register(A, cnt, idx, 1)
        register(A, cnt, idx, 4)
        register(A, cnt, idx, 6)
    elif idx == 6:
        register(A, cnt, idx, 2)
        register(A, cnt, idx, 5)
        register(A, cnt, idx, 7)
    elif idx == 7:
        register(A, cnt, idx, 3)
        register(A, cnt, idx, 6)


for s in sys.stdin:
    A = list(map(int, s.split()))
    key = to_key(A)
    print(M[key])

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

int main()
{
	int t;
	string num;
	while (cin >> t >> num, t || num != "0") {
		int n = num.size();
		int ma = -1, cnt, res;
		for (int i = 0; i < (1 << (n - 1)); i++) {
			int val = 0, tmp = num[0] - '0';
			for (int j = 1; j < n; j++) {
				if (i & (1 << (j - 1))) {
					val += tmp;
					tmp = 0;
				}
				tmp *= 10;
				tmp += num[j] - '0';
			}
			val += tmp;
			if (val <= t) {
				if (val > ma) {
					ma = val;
					res = i;
					cnt = 0;
				}
				else if (val == ma) {
					cnt++;
				}
			}
		}
		if (ma == -1) {
			cout << "error" << endl;
		}
		else if (cnt) {
			cout << "rejected" << endl;
		}
		else {
			cout << ma << ' ';
			for (int i = 0; i < n; i++) {
				cout << num[i];
				if (res & (1 << i)) {
					cout << ' ';
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3112
n = int(input())
cnt_AB = 0
cnt_xxA = 0
cnt_Bxx = 0
cnt_BxA = 0
for i in range(n):
    s = input()
    cnt_AB += s.count('AB')
    if s[-1] == 'A' and s[0] != 'B':
        cnt_xxA += 1
    if s[0] == 'B' and s[-1] != 'A':
        cnt_Bxx += 1
    if s[-1] == 'A' and s[0] == 'B':
        cnt_BxA += 1

if cnt_BxA == 0:
    print(cnt_AB + min(cnt_xxA, cnt_Bxx))
else:
    if cnt_Bxx+cnt_xxA > 0:
        print(cnt_AB + cnt_BxA + min(cnt_xxA, cnt_Bxx))
    else:
        print(cnt_AB + cnt_BxA - 1)

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if (x - r < 0 || x + r > W || y - r < 0 || y + r > H) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
import math as mp
ans = []
while True:
    n = int(input())
    if n==0:
        break
    s = list(map(int,input().split()))
    m = sum(s)/len(s)
    ans.append( mp.sqrt(sum([(ele-m)**2 for ele in s])/len(s)) )
for ele in ans:
    print(ele)


Measured memory_bytes: 5708
#include<bits/stdc++.h>
using namespace std;
#define N 100010
#define ll long long

int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int a[N];
int pre[N],bk[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);

    pre[1]=a[1];
    for(int i=2;i<=n;i++)
        pre[i]=gcd(a[i],pre[i-1]);
    bk[n]=a[n];
    for(int i=n-1;i>=1;i--)
        bk[i]=gcd(bk[i+1],a[i]);
    int ans=1;
    for(int i=1;i<=n;i++)
        ans=max(ans,gcd(pre[i-1],bk[i+1]));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1408
/*
USER: caoash3
LANG: JAVA
TASK: 
*/

import java.io.*;
import java.util.*;

public class Main {

	static final boolean stdin = true;
	static final String filename = "";
	static FastScanner br;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException {

		if (stdin) {
			br = new FastScanner();
			pw = new PrintWriter(new OutputStreamWriter(System.out));
		}

		else {
			br = new FastScanner(filename + ".in");
			pw = new PrintWriter(new FileWriter(filename + ".out"));
		}

		X solver = new X();
		solver.solve(br, pw);
	}

	static class X {
		public void solve(FastScanner br, PrintWriter pw) throws IOException {
			long MOD = (long)1e9+7;
			int N = br.nextInt();
			int K = br.nextInt();
			
			int[] in = new int[N];
			
			for(int i = 0; i < N; i++) {
				in[i] = br.nextInt();
			}
			
			long[][] dp = new long[N+1][K+1];
			long[][] pre = new long[N+1][K+1];
			
			
			
			for(int i = 0; i <= in[0]; i++) {
				dp[1][i] = 1;
			}
			
			pre[1][0] = 1;
			
			for(int i = 1; i <= K; i++) {
				pre[1][i] = (pre[1][i-1] + dp[1][i])%MOD;
			}	
			
			for(int i = 2; i <= N; i++) {
				int v = in[i-1];
				for(int j = 0; j <= K; j++) {
					if((j - v-1) >= 0) {
						dp[i][j] = (pre[i-1][j] - pre[i-1][j-v-1]+MOD)%MOD;
					}
					else {
						dp[i][j] = pre[i-1][j];
					}
					
				}
				
				//calc pre sums
				pre[i][0] = dp[i][0];
				for(int j = 1; j <= K; j++) {
					pre[i][j] = (pre[i][j-1] + dp[i][j])%MOD;
				}
			}
			
			pw.println(dp[N][K]%MOD);
			
			pw.close();
		}

	}

	//fastscanner class
	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

}
 



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

int main(void)
{
    int ans = 0;
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] == '1')
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>

using namespace std;

int main()
{
	double r,w,c,g;
	while(cin >> r >> w >> c >> g)
	{
		if(r==0)break;
		int i=0;
		while(true)
		{
			double cc=(double)(r+i*g)/w;
			if(cc>=c)
				break;
			i++;
		}
		cout << i << endl;



	}
}



Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VVL a(n, VL(n));
    REP(i,n) REP(j,n) a[i][j] = in();

    VL score(1<<n);
    REP(mask,1<<n){
        REP(i,n){
            if ((mask >> i) & 1) continue;
            ll tmp = score[mask];
            REP(j,n){
                if ((mask >> j) & 1) tmp += a[i][j];
            }
            score[mask | (1 << i)] = tmp;
        }
    }

    VL dp(1<<n, -1e18);
    dp[0] = 0;
    REP(mask,1<<n){
        int cand = ((1 << n) - 1) ^ mask;
        int next = cand;
        do {
            dp[mask | next] = max(dp[mask | next], dp[mask] + score[next]);
            next = (next - 1) & cand;
        }while (next != cand);
    }
    cout << dp[(1 << n) - 1] << endl;

    return 0;
}


Measured memory_bytes: 1280
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// # pragma GCC optimize "-O3"
# define int long long
#define PI 3.14159265358979323846264338327950L
using namespace std;
  
const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int32_t main() {
    speed;
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double ang_h = 0.5 * ( 60 * h + m ), ang_m = m * 6;
	double ang = abs( ang_h - ang_m );
	if ( ang > 180 ) {
		ang = 360 - ang;
	}
	double rad = ang * PI / 180.0;
	double ans = a * a + b * b - 2 * a * b * cosl(rad);
	cout << setprecision(14) << sqrt(ans);
}


Measured memory_bytes: 4176
#include <iostream>
#include <algorithm>

using namespace std;

int stage[10][5];

void downstone(int h){
	for(int i=h-1;i>=0;--i){
		for(int j=0;j<5;++j){
			if(stage[i][j]==0){
				for(int k=i-1;k>=0;k--){
					if(stage[k][j]){
						swap(stage[k][j],stage[i][j]);
						break;
					}
				}
			}
		}
	}
	return;
}

int deletestone(int h){
	int res=0;
	for(int i=h-1;i>=0;--i){
		for(int j=0;j<5;++j){
			int len=0;
			for(int k=j;k<5;++k){
				if(stage[i][j]==stage[i][k]) len++;
				else break;
			}
			if(len>=3){
				res+=stage[i][j]*len;
				for(int k=0;k<len;++k) stage[i][j+k]=0;
				break;
			}
		}
	}
	return res;
}

void show(int h){
	for(int i=0;i<h;++i){
		for(int j=0;j<5;++j) cout << stage[i][j] << " " ;
		cout << endl;
	}
	cout << endl;
}

int main(void){
	int h;
	while(cin>>h){
		if(h==0)
			break;
		for(int i=0;i<h;++i)for(int j=0;j<5;++j) cin >> stage[i][j];
		int ans=0;
		while(1){
			int cur=deletestone(h);
			if(cur==0) break;
			ans+=cur;
			//show(h);
			downstone(h);
			//show(h);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
const ll N = 1e5 + 1;
ll dp[N][3];
void solve(){
  ll n;
  cin >> n;
  ll a[n + 1], b[n + 1], c[n + 1];
  foa(i, 1, n+1){
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];
  
  for(ll i = 2; i <= n; i++){
    dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
    dp[i][1] = b[i] + max(dp[i - 1][2], dp[i - 1][0]);
    dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
  }
  cout << max3(dp[n][0], dp[n][1], dp[n][2]) << nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 8508
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<string.h>
#include<map>

using namespace std;

typedef pair<int,int> pii;

#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)


int main(){
	int n,a;
	long long s,b;
	vector<int> v;
	for(;;){
		scanf("%d",&n);
		if(n==0)break;
		v.clear();
		rep(i,n){
			scanf("%d",&a);
			v.push_back(a);
		}
		sort(v.begin(),v.end());
		b=s=0;
		rep(i,v.size()-1){
			b+=v[i];
			s+=b;
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1336
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
//#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2])
    cout<<"No";
    else
    cout<<"Yes";
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin >> n;
    lli ans=1, mod = 1000000007;
    if(n==1){
        ans = 0;
        out(0);
        return 0;
    }
    lli tmp9 = 1, tmp8 = 1;
    rep(i, n){
        ans *= 10;
        tmp9 *= 9;
        tmp8 *= 8;
        tmp9 %= mod;
        tmp8 %= mod;
        ans %= mod;
    }
    ans = ans - 2 * tmp9 + tmp8;
    ans %= mod;
    if(ans<0){
        ans += mod;
    }
    out(ans);
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <limits.h>
#define MAX 100

int main(){
  int n, m[MAX+1][MAX+1];
  int i, j, k, r, min;
	
  scanf("%d", &n);
  for(i=1;i<=n;++i) {
    scanf("%d %d", &m[i][i-1], &m[i+1][i]);
    m[i][i] = 0;
  }
	
  for(r=2;r<=n;++r){
    for(i=1;i<=n-r+1;++i){
      j=i+r-1;
      m[i][j] = INT_MAX;
      for(k=i;k<=j-1;++k){
	min = m[i][k]+m[k+1][j]+m[i][i-1]*m[k+1][k]*m[j+1][j];
	if(m[i][j] > min) m[i][j] = min;
      }
    }
  }
  printf("%d\n", m[1][n]);
  return 0;
}



Measured memory_bytes: 2788
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n = n_in()
A = l_in()

from collections import Counter

c = Counter()
for a in A:
    c[a] += 1

for i in range(1,n+1):
    print(c[i])
    


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

if a <= 0 and b >= 0:
  print("Zero")
elif a < 0 and b < 0:
  if (a-b+2)%2 != 0:
    print("Positive")
  else:
    print("Negative")
elif a < 0:
  if -a%2 != 0:
    print("Positive")
  else:
    print("Negative")
else:
  print("Positive")

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include<string.h>
int a[100010]= {0};
int b[100010]= {0};
int main()
{
    int n,m;
    int num,y=0,z=0;
    scanf("%d%d",&n,&m);
    char s[100000];
    while(m--)
    {
        scanf("%d%s",&num,s);
        if(num>n) continue;
        if(strcmp(s,"AC")==0)
            a[num]=1;
        if(strcmp(s,"WA")==0&&a[num]==0)
            b[num]++;
    }
    for(int i=0; i<=n+1; i++)
    {
        y+=a[i];
        if(a[i]==1)
            z+=b[i];
    }
    printf("%d %d",y,z);
}


Measured memory_bytes: 896
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
	
	if A[i] != B[i]:
		count+=1
		if A[i] != C[i] and B[i] != C[i]:
			count+=1

	elif A[i] != C[i]:
		count+=1

print(count)

Measured memory_bytes: 3064
/*
memo for solution
*/
#include <cstdlib> 
#include <numeric>
#include <cstring>
#include <cstdio> 
#include <cfloat> 
#include <map> 
#include <cassert>
#include <cmath> 
#include <climits> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <iomanip>
#include<sys/time.h>
using namespace std; 
double e_time(void){static struct timeval now;gettimeofday(&now, NULL);return (double)(now.tv_sec  + now.tv_usec/1000000.0);}
#define REP(i,b,n) for(int i=b;i<n;i++) 
#define rep(i,n)      REP(i,0,n) 
#define pb push_back  
#define mp make_pair 
#define ALL(C)   (C).begin(),(C).end() 
#define fe(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr != (c).end();itr++)
#define BITSHIFT(X)     ( (1<<(X)) )
#define CONTAIN(S,X) ( ((S)&BITSHIFT(X)) != 0)
typedef complex<double>P; 
typedef long long ll; 
typedef unsigned long long ull; 
typedef pair<int,int> pii; 
typedef vector<int> vint;
template<class T> void vp(T &a,int p){rep(i,p)cout << a[i]<<" ";cout << endl;}  
template<class T> T ceilUp(const T& a,const T& b){return (a+b-1)/b;}
const ll mod =   1000000009;
inline ll modadd(ll a,ll b){a %= mod;b %= mod;return (a+b)%mod;}
inline ll modsub(ll a,ll b){a %= mod;b %= mod;a-=b;a%=mod;if (a<0)a+=mod;return a;}
inline ll modmul(ll a,ll b){a %= mod;b %= mod;return (a*b)%mod;}
inline ll modeq(ll a,ll b,ll m){a = (a%m+m)%m; b = (b%m+m)%m;return a == b;}
//ll modpow(ll n,ll p){if (p == 0)return 1;if (p == 1)return n;ll ret=mypow(n,p/2);ret=ret*ret%mod;if (p&1)ret=ret*n%mod;return ret;}
//ll getinv(ll a){return mypow(a,mod-2);}

int solve(vector<pii> a[2], int num[2]){
  if (a[0][0].second != a[1][0].second){
    return (num[0] - a[0][0].first) + (num[1] - a[1][0].first);
  } else {
    return min(
	       (num[0] - a[0][1].first) + (num[1] - a[1][0].first),
	       (num[0] - a[0][0].first) + (num[1] - a[1][1].first)
	       );
  }
}
 
int main(){
  int n;
  map<int, int> cnt[2];
  int num[2] = {0};
  vector<pii> a[2];// (first, second) = max num, value
  cin >> n;
  rep(i,n){
    int tmp;
    cin >> tmp;
    cnt[i%2][tmp]++;
    num[i%2]++;
  }
  rep(i,2){
    for(auto itr=cnt[i].begin();itr != cnt[i].end();itr++){
      a[i].emplace_back((*itr).second, (*itr).first);
    }
    sort(ALL(a[i]));
    reverse(ALL(a[i]));
    /*
    for(int j = 0;j < a[i].size();j++){
      cout << a[i][j].first <<" " << a[i][j].second << endl;
    }
    */
    if (a[i].size() == 1){
      a[i].emplace_back(0, -1);
    }
  }
    
  int ans = solve(a, num);
  cout << ans << endl;
  
  return 0;
}
 
 


Measured memory_bytes: 6136
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define repp(i,k,n) for(int i=k;i<(int)n;i++)
#define PB(a) push_back(a)
using namespace std;
typedef vector<int>  vi;
int debu(string a)
{
	cout<<a<<endl;
}
int debu()
{
	cout<<"ok"<<endl;
}
int debu(int a)
{
	cout<<a<<endl;
}
int in()
{
	int x;cin>>x;
	return x;
}

int n,m,p,h;
vi a;
int main()
{
	cin>>n>>m>>p;
	rep(i,m)
	{
		a.PB(in());
	}
	sort(a.begin(),a.end());
	rep(i,m)
	{
		a.push_back(a[i]+n);
	}
	rep(i,m)
	{
		a.push_back(a[i]+n+n);
	}
	rep(i,a.size()-1)
	{
		if(a[i]<p+n&&p+n<a[i+1])
		{
			h=i;
			a.insert(a.begin()+h+1, p+n);
			break;
		}
	}
	h++;

	int ans=999999999;

	ans=min(ans,min((a[h+m]-a[h])*100,(a[h]-a[h-m])*100));

	rep(i,m)
	{
		ans=min(ans,((a[h+i]-a[h])*2+a[h]-a[h-(m-i)])*100);
		ans=min(ans,((a[h]-a[h-i])*2+a[h+(m-i)]-a[h])*100);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1352
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b = map(int, input().split())
    print("Even" if a * b % 2 == 0 else "Odd")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
n = int(input())
X = tuple(map(int, input().split()))
XI = sorted((x, i+1) for i, x in enumerate(X))
L = [-1]*(n*n)
A = []
B = []
for x, i in XI:
  A = [i]*(i-1) + A
  B += [i]*(n-i)
  L[x-1] = i
now = 0
while A:
  if L[now] == -1:
    L[now] = A.pop()
  now += 1
now = n-1
while B:
  if L[now] == -1:
    L[now] = B.pop()
  now -= 1
C = [0]*(n+1)
for x, l in enumerate(L, 1):
  C[l] += 1
  if C[l] == l:
    if X[l-1] != x:
      print("No")
      exit()
print("Yes")
print(*L)

Measured memory_bytes: 15072
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut n: u128
    };

    let mut v = vec![true; 1000001];

    let mut ans = 0;
    for i in 2..=1000000 {
        if v[i] == true {
            let mut j = i as u128;
            while j <= n {
                if n % j == 0 {
                    ans += 1;
                    n = n / j;
                }
                j *= i as u128;
            }

            for k in 1.. {
                if i * k > 1000000 {
                    break;
                }
                v[i * k] = false;
            }
        }
    }

    if n > 1000000 {
        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 3136