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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll m, n;
	cin >> m >> n;

	vector<string> a(m);
	FOR(i,0,m) cin >> a[i];
	
	vvl dp(m,vl(n,oo));
	dp[0][0] = a[0][0] == '#';

	FOR(i,0,m) FOR(j,0,n) {
		if (i+1 < m) dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (a[i][j] != a[i+1][j]));
		if (j+1 < n) dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (a[i][j] != a[i][j+1]));
	}
	
	ll res = (dp[m-1][n-1]+1)/2;
	cout << res << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N;
     cin >> N;
     int M = N;
     int c = 0;
     while (N>0) c+=N%10, N/=10;
     if (M % c == 0) {
         cout << "Yes" << endl;
     } else {
         cout << "No" << endl;
     }
}


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

int main()
{
    string s; cin >> s;
    cout << "2018"+s.substr(4) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, i; cin >> N >> i;

    cout << N+1-i << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

int N,ans;

int main(){
    cin>>N;
    N--;
    int C[N],S[N],F[N];
    rep(i,N)cin>>C[i]>>S[i]>>F[i];
    rep(i,N){
        ans=0;
        repi(j,i,N){
            // ans=C[j]+max(S[j],(ans+(F[j]-ans%F[j])));
            if(S[j]>=ans){
                ans=S[j]+C[j];
            }
            else{
                if(ans%F[j]==0){
                    ans+=C[j];
                }
                else{
                    ans+=C[j]+F[j]-ans%F[j];
                }
            }
        }
        out(ans);
    }
    out(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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 (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
   int a, b, c,d;
   cin >> a >> b>> c >> d;
   cout << min(a,b) + min(c,d) fin; 
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int in(){int x; scanf("%d",&x); return x;}
static const int MAX = 100;


int main(){
  int N = in(), M = in(), C = in(), B[MAX], count = 0;
  rep(i, M) cin >> B[i];

  int a, sum = 0;
  rep(i, N){
    sum = 0;
    rep(j, M){
      cin >> a;
      sum += a*B[j];
    }
    if(sum + C > 0) count++;
  }
  cout << count << endl;
}

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

using namespace std;

vector<vector<double>> dp;
int main() {
    int n;
    cin >> n;
    
    vector<double> pb(n);
    for (int i=0; i<n; ++i) cin >> pb[i];

    dp.resize(n+1, vector<double>(n+1, 0.0));
    dp[0][0] = 1.0;
    for (int i=1; i<=n; ++i) {
        dp[i][0] = dp[i - 1][0] * (1.0 - pb[i - 1]);
        for (int j=1; j<=i; ++j) {
            dp[i][j] = (dp[i - 1][j - 1] * pb[i - 1]) +
                       (dp[i - 1][j] * (1.0 - pb[i - 1]));
        }
    }

    double ans = 0.0;
    for (int j=(n+1)/2; j<=n; ++j) {
        ans += dp[n][j];
    }
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 70784
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

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

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 namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int N;
int W[110];

int main(int argc, const char * argv[]) {
    N = inputValue();
    inputArray(W, N);

    int sum =0;
    rep(i, N) {
        sum+=W[i];
    }

    int mind = 10000000;
    int s1 = 0;
    rep(i, N) {
        s1 += W[i];
        chmin(mind, abs(sum-s1 - s1));
    }
    output(mind);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a,b;
  cin>>a>>b;
  int g,h;
  cin>>g>>h;
  string k;
  cin>>k;
  if(k==a){
  cout<<g-1<<" "<<h;
  }
  else{
  	  cout<<g<<" "<<h-1;
  }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>

using namespace std;

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

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}

long long int kaijo(long long int n){
    if(n==0) return 1;
    else return n*kaijo(n-1);
}

long long int product(long long int n, long long int k){
    long long int tmp=1;
    for(int i=k;i<=n;i++){
        if(k==0) continue;
        tmp*=i;
    }
    return tmp;
}


int main(){
    long long int n;
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    return 0;
} //カモンAC


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> Kag(N);
  for( int i = 0; i < N; i++){
    cin >> Kag.at(i);
  }
  sort(Kag.begin(), Kag.end());
  int M; 
  M = 0;
  N = N-1;
   for( int j = 0; j < N; j++){
    if( Kag.at(j) == Kag.at(j+1)){
      M++;
    }
	 }
      int O = 0;
     O = Kag.size();
     cout << O - M << endl; 
}

Measured memory_bytes: 256
using System;

namespace ITP1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input_NM = Console.ReadLine().Split(' ');
            int n = int.Parse(input_NM[0]);
            int m = int.Parse(input_NM[1]);

            int[,] A = new int[n, m];
            for(int i=0;i<n;i++)
            {
                string[] input_A = Console.ReadLine().Split(' ');
                for(int j=0;j<m;j++)
                {
                    A[i, j] = int.Parse(input_A[j]);
                }
            }

            int[] b = new int[m];
            for(int i=0; i<m;i++)
            {
                b[i] = int.Parse(Console.ReadLine());
            }

            int[] c = new int[n];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    c[i] += A[i, j] * b[j];
                }
            }

            for(int i=0; i< n;i++)
            {
                Console.WriteLine(c[i]);
            }
        }
    }
}

Measured memory_bytes: 19944
#include<stdio.h>
int main(void)
{
    int a,b,c,d,f[20];
		scanf("%d",&a);
		while(a!=-1){
		    d=0;
			while(1){
				b=a/4;
				c=a%4;
				f[d]=c;
				a=b;
				d++;
				if(a<4) {
					f[d]=a;
					break;
				}
			}
			if(f[d]==0) d=d-1;
			for(d;d>=0;d--){
				printf("%d",f[d]);
			}
			printf("\n");
			scanf("%d",&a);
		}
		return 0;
}

Measured memory_bytes: 2628
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,a[110000] ,b[110000] ,c[110000];
int mem[110000][3];
int dp(int i, int last){
if(i == n) return 0;
if(mem[i][last] != -1 && last != -1) return mem[i][last];
int x =0,x2 = 0, x3 = 0;
if(last != 0){
    x = a[i] + dp(i+1,0);
}
if(last != 1){
    x2 = b[i] + dp(i+1,1);
}
if(last != 2){
    x3 = c[i] + dp(i+1, 2);
}

return mem[i][last] = max(max(x,x2),x3);

}
int main()
{
  cin>>n;
  for(int i=0; i<n; i++)
  for(int j=0; j< 3 ; j++){
    if(j == 0) cin>>a[i];
    if(j==1) cin>>b[i];
    if(j == 2) cin>>c[i];
  }
  memset(mem,-1,sizeof(mem));
  cout<<dp(0,-1);

}


Measured memory_bytes: 8960
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
using namespace std;
char T[10][10000];
template<typename T> T max2(T head,T n){return max(n,head-n);}
int main(){
	int Y,X,i,j,r,y;
	for(;scanf("%d%d",&Y,&X),Y;printf("%d\n",r)){
		for(j=0;j<Y;j++)for(i=0;i<X;i++)scanf("%hhd",T[j]+i);

		vector<int> itx(X);iota(itx.begin(),itx.end(),0);
		vector<int> ity(Y);iota(ity.begin(),ity.end(),0);
		for(r=y=0;y<1<<Y;y++){
			r=max(r,accumulate(itx.begin(),itx.end(),0,[&](int s,int &i){
				return s+max2(Y,(int)count_if(ity.begin(),ity.end(),[&](int &j){return ((y>>j&1)==T[j][i]);}));
			}));
		}
	}
}

Measured memory_bytes: 1148
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int f(int h, int m) { return h * 60 + m; }

int main() {
    int t[2];
    rep(i, 2) {
        int h, m;
        cin >> h >> m;
        t[i] = f(h, m);
    }

    int k;
    cin >> k;
    cout << t[1] - t[0] - k << "\n";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

void uf_init(vector<int>& uf_par, vector<int>& uf_rank, vector<int>& uf_size) {
    for (int i = 0; i < static_cast<int>(uf_par.size()); i++) {
        uf_par[i] = i;
        uf_rank[i] = 0;
        uf_size[i] = 1;
    }
}

int uf_find(vector<int>& uf_par, vector<int>& uf_rank, vector<int>& uf_size, int a) {
    if (uf_par[a] != a) {
        uf_par[a] = uf_find(uf_par, uf_rank, uf_size, uf_par[a]);
    }

    return uf_par[a];
}

void uf_union(vector<int>& uf_par, vector<int>& uf_rank, vector<int>& uf_size, int a, int b) {
    int root_a = uf_find(uf_par, uf_rank, uf_size, a);
    int root_b = uf_find(uf_par, uf_rank, uf_size, b);

    if (root_a == root_b) {
        return;
    }

    if (uf_rank[root_a] < uf_rank[root_b]) {
        uf_par[root_a] = root_b;
        uf_size[root_a] = uf_size[root_b] = uf_size[root_a] + uf_size[root_b];
    } else {
        uf_par[root_b] = root_a;
        uf_size[root_a] = uf_size[root_b] = uf_size[root_a] + uf_size[root_b];

        if (uf_rank[root_a] == uf_rank[root_b]) {
            uf_rank[root_a]++;
        }
    }
}

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

    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    vector<int> uf_par(n), uf_rank(n), uf_size(n);
    uf_init(uf_par, uf_rank, uf_size);

    vector<long long> res(m + 1);
    res[m] = n * (n - 1LL) / 2;
    for (int i = m - 1; i >= 0; i--) {
        int root_a = uf_find(uf_par, uf_rank, uf_size, a[i]);
        int root_b = uf_find(uf_par, uf_rank, uf_size, b[i]);

        if (root_a == root_b) {
            res[i] = res[i + 1];
        } else {
            res[i] = res[i + 1] - static_cast<long long>(uf_size[root_a]) * uf_size[root_b];
            uf_union(uf_par, uf_rank, uf_size, root_a, root_b);
        }
    }

    for (int i = 1; i <= m; i++) {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)
ll o[100010];
ll e[100010];

int main(void) {
	ll n, a;
	cin >> n;
	for (ll i = 1;i <= n;i++) {
		cin >> a;
		if (i % 2 == 1)o[a]++;
		else e[a]++;
	}
	ll omax1 = 0, o1 = 0, omax2 = 0, o2 = 0, emax1 = 0, e1 = 0, emax2 = 0, e2 = 0;
	for (ll i = 1;i <= 100000;i++) {
		if (o[i] >= omax1) {
			omax1 = o[i];
			o1 = i;
		}
		if (e[i] >= emax1) {
			emax1 = e[i];
			e1 = i;
		}
	}
	for (ll i = 1;i <= 100000;i++) {
		if (o[i] >= omax2&&o[i] <= omax1&&i!=o1) {
			omax2 = o[i];
			o2 = i;
		}
		if (e[i] >= emax2&&e[i] <= emax1&&i!=e1) {
			emax2 = e[i];
			e2 = i;
		}
	}
	if (o1 != e1) {
		cout << n - omax1 - emax1 << endl;
	}
	else {
		cout << min(n - omax1 - emax2, n - emax1 - omax2) << endl;
	}
	return 0;

}

Measured memory_bytes: 1792
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);



	void run() {

		for (; sc.hasNextLine();) {

			String buffer = sc.nextLine();

			Scanner l = new Scanner(buffer.replace(',', ' '));

			int[] cards = new int[15];

			for (int i = 0; i < 5; i++) {

				int a = l.nextInt();

				cards[a]++;

				if(a==1) cards[14]++;

			}

//			System.out.println(Arrays.toString(cards));

			int count = 0;

			int max = 0;

			int sub = 0;

			boolean str = false;

			for (int i = 1; i < 15; i++) {

				if (cards[i] == 1) {

					count++;

				}else{

					count=0;

				}

				if (count == 5) {

					str = true;

					break;

				}

				if(i==14) break;

				if (cards[i] > max) {

					max = cards[i];

				} else if (cards[i] > sub) {

					sub = cards[i];

				}

			}

			if (str) {

				System.out.println("straight");

			} else {

				if (max == 4) {

					System.out.println("four card");

				} else if (max == 3) {

					if (sub == 2) {

						System.out.println("full house");

					} else {

						System.out.println("three card");

					}

				} else if (max == 2) {

					if (sub == 2) {

						System.out.println("two pair");

					} else {

						System.out.println("one pair");

					}

				} else {

					System.out.println("null");

				}

			}

		}

	}



	public static void main(String[] args) {

		Main m = new Main();

		m.run();



	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	rep (i, n) cin >> a[i+1];

	vector<int> imos(200005, 0);

	for (int i = 1; i < min(k+1, 100); i++) {
		rep (j, 200005) imos[j] = 0;
		for (int j = 1; j <= n; j++) {
			imos[max(1, j - a[j])]++;
			imos[min(n+1, j + a[j] + 1)]--;
		}
		for (int j = 2; j <= n; j++) imos[j] += imos[j-1];
		for (int j = 1; j <= n; j++) a[j] = imos[j];
	}

	for (int i = 1; i <= n; i++) cout << a[i] << endl;
	return 0;
}


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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n,ans=0;
  vector<vector<long>> a(10, vector<long>(10, 0));
  cin >>n;
  for(int i=1;i<=n;i++)a[to_string(i)[0]-'0'][i%10]++;
  rep(i,10) rep(j,10) ans+=a[i][j]*a[j][i];
  cout << ans << endl;
}

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

using namespace std;

#define mod 1000000007

#define inf 1000000000000000
#define MAX 200000

int h, w;
int a[100][100];
int b[100][100];
vector<vector<vector<bool> > > ischecked(100, vector<vector<bool> >(100, vector<bool>(12800, false)));
vector<vector<vector<bool> > > result(100, vector<vector<bool> >(100, vector<bool>(12800, false)));

bool solve(int x, int y, int k)
{
	// cout << x << " " << y << " " << k << endl;
	if(x >= h || y >= w || k < 0 || k >= 12800) return false;
	if(x == h - 1 && y == w - 1){
		return (k == abs(a[x][y] - b[x][y]));
	}
	if(ischecked[x][y][k]) return result[x][y][k];
	ischecked[x][y][k] = true;
	int absSub = abs(a[x][y] - b[x][y]);
	return result[x][y][k] = solve(x + 1, y, abs(k - absSub))
					|| solve(x, y + 1, abs(k - absSub))
					|| solve(x + 1, y, k + absSub)
					|| solve(x, y + 1, k + absSub);
}

int main()
{
	cin >> h >> w;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cin >> b[i][j];
		}
	}
	for(int i = 0; i <= 12800; i++){
		if(solve(0, 0, i)){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 32896
#pragma GCC optimize ("-O3","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
const Int Inf = 1e17;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep1(i,n) for(int(i)=0; i<n; i++)
#define rep(i,n) for(unsigned 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'
#define var(type) valarray<type>
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;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n;
  gnr(i,1,9)if((n%i)==0){n/=i; break;}
  if(n>9){pri1("No");return 0;}
  pri1("Yes");
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n), b(n), c(n);
  for(int i=0; i<n; ++i)cin>>a[i]>>b[i]>>c[i];

  vector<int> dpa(n,0), dpb(n,0), dpc(n,0);
  dpa[0]=a[0]; dpb[0]=b[0]; dpc[0]=c[0];

  for(int i=1; i<n; ++i){
    dpa[i]=max(dpb[i-1], dpc[i-1])+a[i];
    dpb[i]=max(dpc[i-1], dpa[i-1])+b[i];
    dpc[i]=max(dpa[i-1], dpb[i-1])+c[i];
  }

  cout<<max({dpa[n-1],dpb[n-1], dpc[n-1]})<<endl;
}


Measured memory_bytes: 2560
from collections import defaultdict
N,p = map(int,input().split())

S = input()[::-1]

d = {}

ans = 0
if p == 2:
    for i in range(N):
        if S[i] in ['0','2','4','6','8']:
            ans += N-i
elif p==5:
    for i in range(N):
        if S[i] in ['0','5']:
            ans += N-i
else:
    d = defaultdict(lambda:0)
    n = 0
    for i in range(N):
        n += pow(10,i,p)*int(S[i])
        n %= p
        d[n] += 1
    ans += d[0]
    for k in d:
        ans += d[k]*(d[k]-1)//2
print(ans)

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

int main() {
    int n;
    vector<pair<int,int> >ans;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++) {
            if (n % 2 == 0 && i + j != n + 1)
                ans.emplace_back(i, j);
            if (n % 2 == 1 && i + j != n)
                ans.emplace_back(i, j);
        }
    printf("%d\n", (int)ans.size());
    for (auto p : ans)
        printf("%d %d\n", p.first, p.second);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int a[1000000]={1,1},s[500000],c;
int main(){
	r(i,2,100000)
	for(int j=i*2;j<1000000;j+=i)a[j]++;
	r(i,2,1000000)if(!a[i])s[c++]=i;
int n;
while(cin>>n,n){
	int ss=0;
	r(i,0,c){
		if(s[i]>n/2)break;
		if(!a[n-s[i]])ss++;
	}cout<<ss<<endl;
}
}

Measured memory_bytes: 7188
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <math.h>

typedef long long int64;
typedef unsigned long long uint64;

#define min(a,b) (((a) < (b)) ? (a) : (b))

int main()
{

	uint64 a, b, n;

	scanf("%llu %llu %llu", &a, &b, &n);

	printf("%llu", (uint64)floor(a * min(b - 1, n) / b));

	return 0;
}


Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    vi vec(n+1);
    REP(i,m){
        int a,b;
        cin>>a>>b;
        vec[--a]++;
        vec[b]--;
    }
    REP(i,n){
        vec[i+1]+=vec[i];
    }
    int ans=0;
    REP(i,n){
        if(vec[i]==m){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;

int main(void)
{
	int x;

	for (int i = 0; i < 5; i++)
	{
		cin >> x;
		if (x == 0)
		{
			cout << i+1;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
int n;
long long x, a[100001], S;

long long check(long long m) {
	int i = 0;
	long long sum = a[0] + a[1];
	for (int j = 1; j < n; j++) {
		long long tmp = a[j];
		if (sum > x) {
			tmp -= (sum - x);
			if (tmp < 0) tmp = 0;
			m -= (sum - x);
		}
		sum = a[j + 1] + tmp;
	}
	return m;
}
long long solve() {
	long long l = 0, r = S + 1, m;
	while (r - l >= 1) {
		m = (l + r) / 2;
		long long v = check(m);
		if (v > 0) r = m;
		else if (v < 0) l = m + 1;
		else return m;
	}
}
int main() {
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		S += a[i];
	}
	cout << solve() << endl;
}

Measured memory_bytes: 1024
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> VU.Vector Int -> Int
solve n hs = maximum
  [ gcd (leftmost VU.! i) (rightmost VU.! (i + 1)) | i <- [0 .. n - 1] ]
 where
  -- [a0,a0-a1,a0-a2,...,a0-a(n-1)]
  leftmost = VU.fromList $ (0 :) $ reverse $ foldl'
    (\(a:acc) i -> gcd (hs VU.! i) a : a : acc)
    [hs VU.! 0]
    [1 .. n - 1]

  -- [a(n-1),a(n-1)-a(n-2),...,a(n-1)-a1]
  rightmost = VU.fromList $ (++ [0]) $ foldl'
    (\(a:acc) i -> gcd (hs VU.! i) a : a : acc)
    [hs VU.! (n - 1)]
    (reverse [0 .. n - 2])

main = do
  let readInt = fmap (second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


Measured memory_bytes: 28028
N = int(input())
S = [int(input()) for _ in range(N)]
t = sum(S)

if t%10==0:
    f = True
    for s in sorted(S):
        if s%10!=0:
            f = False
            break
    if f:
        print(0)
    else:
        print(t-s)
else:
    print(t)

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

int N,K,L;

struct uni {
  int d[200005];
  void init(){ memset( d,-1,sizeof(d) ); }
  int find(int a){ return d[a]<0?a:(d[a]=find(d[a])); };
  bool merge(int a,int b){
    a = find(a); b = find(b);
    if( a == b ) return false;
    if( d[a] > d[b] ) swap( a, b );
    d[a] += d[b]; d[b] = a;
    return true;
  }
  bool same(int a,int b){
    return find(a) == find(b);
  }
  int size(int id){ return -d[find(id)]; }
};
uni U1,U2;


typedef pair<int,int> P;
map<P,int> pc;
int main() {
  cin >> N >> K >> L;
  U1.init(); U2.init();
  vector<int> A,B;
  for(int i=0;i<K;i++){
    int a,b; cin >> a >> b; --a; --b;
    A.push_back( a ); B.push_back( b );
    U1.merge( a, b );
  }
  for(int i=0;i<L;i++){
    int a,b; cin >> a >> b; --a; --b;
    A.push_back( a ); B.push_back( b );
    U2.merge( a, b );    
  }

  
  for(int i=0;i<N;i++)
    pc[ P( U1.find(i), U2.find(i) ) ]++;
  
  for(int i=0;i<N;i++) {
    if( i ) cout << " ";
    cout << pc[ P( U1.find(i), U2.find(i) ) ];
  }
  cout << endl;
}


Measured memory_bytes: 15084
#include <cstdio>
int main (){
	int a[3];
	int ans;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	for (int i = 0; i < 3; ++i)
	{
		if(a[i]==5) ans++;
		if(a[i]==7) ans+=3;
	}
	if(ans==5) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int n,m,k,a,stock[35],count = 0;
    cin >> n >> m;
    for(int i = 0;i < 35;i++){stock[i] = 0;}
    for(int i = 0;i < n;i++)
    {
        cin >> k;
        for(int j = 0;j < k;j++)
        {
            cin >> a;
            stock[a] += 1;
        }
    }
    for(int i = 1;i <= m;i++){if(stock[i] == n){count++;}}
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,m;
    cin>>n>>m;
    if(2*n>=m) cout<<m/2;
    else cout<<n+(m-2*n)/4;
}

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

int water[3005],sugar[3005];

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

    int a,b,c,d,e,f,i,j,k;
    cin >> a >> b >> c >> d >> e >> f;
    vector<int>v1,v2;
    int now = 0;
    while(now<=f)
    {
        v1.push_back(now);
        now += (a*100);
    }
    now = 0;
    while(now<=f)
    {
        v2.push_back(now);
        now += (b*100);
    }
    for(int x:v1)
    {
        for(int y:v2)
        {
            if((x+y)<=f)
                water[x+y] = 1;
        }
    }
    vector<int>v3,v4;
    now = 0;
    while(now<=f)
    {
        v3.push_back(now);
        now += c;
    }
    now = 0;
    while(now<=f)
    {
        v4.push_back(now);
        now += d;
    }
    for(int x:v3)
    {
        for(int y:v4)
        {
            if((x+y) <= f)
                sugar[x+y] = 1;
        }
    }
    int up=0,down=1,u1,d1;
    for(int i=1;i<=f;i++)
    {
        for(int j=0;j<=f-i;j++)
        {
            if(water[i]==1 && sugar[j]==1)
            {
                if((e*i) < (j*100))
                    continue;
                u1 = j;
                d1 = i+j;


                if((u1*down)>(up*d1))
                {
                    up=u1;
                    down=d1;
                }
            }


        }
    }
    if(up==0) cout << a*100 << ' ' << 0 << endl;
    else cout << down << ' ' << up << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

void warshall_floyd(Graph &G){
    int V = G.size();
    rep(k, V)rep(i, V)rep(j, V){
        if(G[i][k] == LLINF || G[k][j] == LLINF) continue;
        G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
    }
    // G[i][i] < 0が存在 <=> 負閉路が存在
}

int main(){
    fastcin();

    int n, m, l;
    cin >> n >> m >> l;
    Graph G(n, vector<LL>(n, LLINF));
    rep(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a][b] = c;
        G[b][a] = c;
    }
    warshall_floyd(G);

    Graph H(n, vector<LL>(n, LLINF));
    rep(i, n)rep(j, n)if(G[i][j] <= l) H[i][j] = 1;
    warshall_floyd(H);

    int q;
    cin >> q;
    vector<pair<int, int>> Q(q);
    rep(i, q){
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (H[s][t] == LLINF ? -1 : H[s][t]-1) << endl;
    }
}

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

struct StNode
{
  StNode* m_poParnt;
  StNode* m_poLeft;
  StNode* m_poRigt;
  int m_nKey;

  StNode(int nNo) :
    m_poParnt(nullptr), m_poLeft(nullptr), m_poRigt(nullptr), m_nKey(nNo)
  { }
};

void fnPreOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  cout << " " << poNode->m_nKey;
  fnPreOrder(poNode->m_poLeft);
  fnPreOrder(poNode->m_poRigt);
}

void fnInOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnInOrder(poNode->m_poLeft);
  cout << " " << poNode->m_nKey;
  fnInOrder(poNode->m_poRigt);
}

int fnFind(StNode* poRoot, int nNo)
{
  StNode* poNode = poRoot;
  while (poNode != nullptr)
    if (nNo == poNode->m_nKey)
      return 1;
    else if (nNo < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;

  return 0;
}

void fnInsert(StNode*& rpoRoot, StNode* poNewNod)
{
  StNode* poParnt = nullptr;
  StNode* poNode = rpoRoot;

  while (poNode != nullptr)
  {
    poParnt = poNode;
    if (poNewNod->m_nKey < poNode->m_nKey)
      poNode = poNode->m_poLeft;
    else
      poNode = poNode->m_poRigt;
  }

  poNewNod->m_poParnt = poParnt;
  if (poParnt == nullptr)
    rpoRoot = poNewNod;
  else if (poNewNod->m_nKey < poParnt->m_nKey)
    poParnt->m_poLeft = poNewNod;
  else
    poParnt->m_poRigt = poNewNod;
}

void fnBinSchTree(StNode*& rpoRoot)
{
  int nMaxSiz;
  cin >> nMaxSiz;

  for (int i = 0; i < nMaxSiz; ++i)
  {
    string sCmd;
    cin >> sCmd;
    if (sCmd[0] == 'i')
    {
      int nNo;
      cin >> nNo;
      StNode* poNewNod = new StNode(nNo);
      fnInsert(rpoRoot, poNewNod);
    }
    if (sCmd[0] == 'f')
    {
      int nNo;
      cin >> nNo;
      if (fnFind(rpoRoot, nNo))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
    if (sCmd[0] == 'p')
    {
      fnInOrder(rpoRoot);
      cout << endl;
      fnPreOrder(rpoRoot);
      cout << endl;
    }
  }
}

void fnPstOrder(StNode* poNode)
{
  if (poNode == nullptr)  return;

  fnPstOrder(poNode->m_poLeft);
  fnPstOrder(poNode->m_poRigt);
  delete poNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  StNode* poRoot = nullptr;

  fnBinSchTree(poRoot);
  fnPstOrder(poRoot);
  return 0;
}

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

using namespace std;

int a[19], b[19];
int f[300001][19];
int n;

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n;
	for (int i=1;i<=n;i++)
		cin >> a[i];
	for (int i=1;i<=n;i++)
		cin >> b[i];
	for (int i=0;i<=300000;i++)
		for (int j=0;j<=18;j++)
			f[i][j] = 1e9;
	for (int i=1;i<=n;i++)
		f[(1<<(i-1))][i] = 0;
	for (int mask = 1;mask < (1<<n);mask++)
	{
		int pos = __builtin_popcount(mask) + 1;
		for (int i=0;i<=n-1;i++)
			if ((1<<i) & mask)
			{
				int cnt = 0;
				for (int j=0;j<=n-1;j++)
				{
					if (!((1<<j) & mask))
					{
						int cost = pos - 1 - cnt;
						int pre_val = ((abs((i + 1) - (pos - 1)) % 2) == 0) ? a[i+1] : b[i+1];
						int cur_val = ((abs((j + 1) - pos) % 2) == 0) ? a[j+1] : b[j+1];
						if (cur_val >= pre_val)
							f[mask | (1<<j)][j+1] = min(f[mask | (1<<j)][j+1],f[mask][i+1] + cost);
					}
					else
						cnt++;
				}
			}
	}
	int res = 1e9;
	for (int i=1;i<=n;i++)
		res = min(res,f[(1<<n)-1][i]);
	if (res == 1e9) cout << -1;
	else cout << res;
	return 0;
}

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

int main(){
  int n,i,kotae=1;
  char a,b;
  cin>>n;
  cin>>a;
  for(i=1;i<n;i++){
    cin>>b;
    if(a!=b){
      kotae++;
    }
    a=b;
  }
  cout<<kotae;
}


Measured memory_bytes: 256
// Aizu Vol0 0019: Factorial
// 2017.7.28

#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long ans;
	int n;

	scanf("%d", &n);
	if (n == 0) ans = 1;
	else {
		ans = n;
		while (--n > 1) ans *= n;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int A,B,ans,a,b,c;
  cin>>A>>B;
  ans=0;
  if(A<=0&&B>=0){
    cout<<"Zero"<<endl;
    return 0;
  }
  else{
    if(A>0){
      cout<<"Positive"<<endl;
    return 0;
    }
    else{
      if((B-A)%2==1){
              cout<<"Positive"<<endl;
    return 0;
    }
      else{
              cout<<"Negative"<<endl;
    return 0;
    }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e7+9;
int main()
{
    int n,a[10000],b[10000],i;
    long long int sum=0;
    cin>>n;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++) cin>>b[i];
    for(i=0;i<n;i++)
	{
  		if(b[i]>=a[i]) sum+=(b[i]-a[i])/2;
    	else sum-=a[i]-b[i];
    }
    if(sum>=0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  FOR(i,1,10){
    if(n%i==0 & n/i<10){
      cout<<"Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>

using namespace std;

int main(void){
    double r;
    cin >> r;
    
    double s = M_PI * (r * r);
    double circumference = 2 * M_PI * r;
    
    cout << fixed << setprecision(6) << s << " " << circumference << endl;
    
    return 0;
}



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

int main() {
    ll N, ans = 0;
    cin >> N;

    vector<ll> div;
    for (ll i = 10; i <= 1e18; i *= 5) {
        div.push_back(i);
    }
    if (N % 2 == 0) {
        for (ll i: div) {
            ans += N / i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define vin vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define mod 1000000007
#define cone __builtin_popcount
#define conel __builtin_popcountll
typedef vector<vector<ll> > matrixl;
typedef vector<vector<int> > matrix;
#define N 100009

int h[N], dp[N], n;

int solve(int i)
{
    if(i > n) return 0;
    if(dp[i] != -1) return dp[i];
    int k = (n - i == 1? 1 : 2);
    return dp[i] = min(solve(i + 1) + (i + 1 <= n? abs(h[i+1] - h[i]) : 0), solve(i + k) + (i + k <= n? abs(h[i+k] - h[i]) : 0));
}

int main()
{
    memset(dp, -1 ,sizeof(dp));
    cin >> n;
    for(int i=1; i<=n; i++) cin >> h[i];
    cout << solve(1) << endl;
}


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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  cin>>N;
  vector<int> P(N),Q(N),R(N);
  for(int i = 0; i < N; i++) R[i]=i+1;
  for(int i = 0; i < N; i++) cin>>P[i];
  for(int i = 0; i < N; i++) cin>>Q[i];
  int cnt = 0,a,b;
  do{
    if(R==P)a=cnt;
    if(R==Q)b=cnt;
    cnt++;
  }while(next_permutation(R.begin(),R.end()));
  cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int ps[100000];
int cnt[16];
int dp[1 << 16];

int bitcount(int x) {
    int ret = 0;
    while (x) {
        ret += (x & 1);
        x >>= 1;
    }
    return ret;
}

int xorbit(int x) {
    int ret = 0;
    for (int i = 0; i < 16; ++i) {
        if ((x >> i) & 1) ret ^= i;
    }
    return ret;
}
vector<int> bc[16];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i < n; ++i) {
        int x, y, a;
        cin >> x >> y >> a;
        ps[x] ^= a;
        ps[y] ^= a;
	}
	for (int i = 0; i < n; ++i) ++cnt[ps[i]];
	int ans = cnt[0];
	int val = 0;
	for (int i = 1; i < 16; ++i) {
        ans += (cnt[i] >> 1);
        if (cnt[i] & 1) val ^= (1 << i);
	}
	for (int i = 0; i < (1 << 16); i += 2) {
        if (xorbit(i)) continue;
        bc[bitcount(i)].push_back(i);
	}
	
	for (int it = 2; it < 16; ++it) {
        for (int i : bc[it]) {
            for (int j = 1; j < 16; ++j) {
                if (((i >> j) & 1) == 0) continue;
                for (int k = 1; k < j; ++k) {
                    if (((i >> k) & 1) == 0) continue;
                    dp[i] = max(dp[i], dp[i ^ (1 << j) ^ (1 << k) ^ (1 << (j ^ k))] + ((i >> (j ^ k)) & 1));
                }
            }
        }
	}
	
	ans += dp[val];
	printf("%d\n", n - ans);
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p.at(i);
  int ans = 0;
  rep2(i, 1, n-1){
    if(p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1)) ans++;
    if(p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int x;
  cin >> x;
  int a = x / 500;
  int b = (x % 500) / 5;
  cout << (a*1000) + (b*5) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
a, b, c, x, y = map(int, input().split())
ans=sys.maxsize
for i in range(max(x,y)+1):
  temp=2*c*i
  if x-i>0:
    temp+=a*(x-i)
  if y-i>0:
    temp+=b*(y-i)
  ans=min(ans,temp)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;
  
/*
Node treeMinimum(Node x){
  

}

Node treeMaximum(Node x){


}
*/
Node treeSearch(Node u, int k){
while(u!=NIL&&k!=u->key){
    if(k>u->key)
      u=u->right;
    else
      u=u->left;
  }
  return u;

}
/*
Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z==NIL){
    return;
  }
  if(z->left!=NIL){
    treeDelete(z->left);
  }
  if(z->right!=NIL){
    treeDelete(z->right);
  }
  free(z);
}
*/
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(y->key>z->key){
      y->left=z;
    }
    else{
      y->right=z;
    }
  }
}
void inorder(Node u){
  if(u==NIL){
    return;
  }
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL){
    return;
  }
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
      if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else
     if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } /*else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
    */
  }
  return 0;
}




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

using namespace std;

int main() {
  int a, b, c, d, n;
  scanf("%d %d %d %d %d", &a, &b, &c, &d, &n);
  b = min(b, 2 * a);
  c = min(c, 2 * b);
  d = min(d, 2 * c);
  long long res = (long long)(n / 2) * d + (n & 1) * c;
  printf("%lld\n", res);
  return 0;
}

Measured memory_bytes: 256
N = int(input())
def sum_order(x):
    order=[]
    while True:
        order.append(x % 10)
        x = int(x/10)
        if x == 0:
            break
    return sum(order)

min_order = 9*5
for A in range(1, N):
    B = N - A
    sum_A = sum_order(A)
    sum_B = sum_order(B)
    if min_order > sum_A + sum_B:
        min_order = sum_A + sum_B

print(min_order)


Measured memory_bytes: 3060