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

long long a[100007];
int main(){
    int n,t,maxx = 0;
    long long ans = 1;

    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> t;
        if(!i&&t){
            cout << 0 << endl;
            return 0;
        }
        a[t]++;
        if(t>maxx) maxx = t;
    }
    if(a[0]!=1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1;i<=maxx;i++){
        if(!a[i]){
            cout << 0 << endl;
            return 0;
        }
        for(int j = 0;j < a[i];j++){
            ans*=a[i-1];
            ans%=998244353;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
/**
 * THIS IS CFMASTER'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a(9);
  for (int i = 0; i < 9; i++) {
    cin >> a[i];
  }
  vector<int> mark(9);
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    for (int j = 0; j < 9; j++) {
      if (b[i] == a[j]) {
        mark[j] = true;
      }
    }
  }
  if (mark[0] && mark[1] && mark[2] || mark[3] && mark[4] && mark[5] || mark[6] && mark[7] && mark[8] || mark[0] && mark[3] && mark[6] || mark[1] && mark[4] && mark[7] || mark[2] && mark[5] && mark[8])
  {
    cout << "Yes" << '\n';
    return 0;
  }
  if (mark[0] && mark[4] && mark[8] || mark[2] && mark[4] && mark[6]) {
    cout << "Yes" << '\n';
    return 0;
  }
  cout << "No" << '\n';
  return 0;
}

Measured memory_bytes: 256
# include <vector>
# include <stdio.h>
# include <string.h>
# include <iostream>

using namespace std;

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

const int M = 5e5 + 10, N = 95;
const int mod = 1e9 + 7;

vector < pair <ll, ll> > g[N];
ll f[N];


int main() {
//  freopen("euclid.in", "r", stdin);
//  freopen("euclid.out", "w", stdout);
  ios :: sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  f[0] = f[1] = 1;
  for (int i = 2; i < N; ++ i) f[i] = f[i-1] + f[i-2];
  g[1].push_back(make_pair(1, 2));
  g[1].push_back(make_pair(1, 3));
  g[1].push_back(make_pair(1, 4));
  for (int i = 1; i < N; ++ i) {
    for (int j = 0; j < g[i].size(); ++ j) {
      pair <ll, ll> cur = g[i][j];
      ll x = cur.second, y = cur.first + cur.second;
      while(y <= f[i+3] + f[i]) {
        g[i+1].push_back(make_pair(x, y));
        y += x;
      }
    }
  }
  
  int q; cin >> q;
  ll a, b;
  while(q--) {
    cin >> a >> b;
    if(a > b) swap(a, b);
    int ans = 1;
    while(f[ans+1] <= a && f[ans+2] <= b) ++ ans;
    cout << ans << ' ';
    if(ans == 1) cout << 1ll * a * b % mod << '\n';
    else {
      int cnt = 0;
      for (int i = 0; i < g[ans-1].size(); ++ i) {
        pair<ll, ll> cur = g[ans-1][i];
        ll x = cur.first, y = cur.second;
        if(y <= a) cnt = cnt + 1ll * (b - x) / y % mod;
        if(cnt >= mod) cnt -= mod;
        if(y <= b) cnt = cnt + 1ll * (a - x) / y % mod;
        if(cnt >= mod) cnt -= mod; 
      }
      cout << cnt << '\n';
    }
  }
  
  
  
  return 0;
}




Measured memory_bytes: 4096
/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define endl '\n'

const int max4 = 10004;
const int maxx = 100005;
const int max6 = 1000006;
const int lg5 = 17;

const int INF = 2 * 1000000007;
const long long INFLL = 4LL * 1000000000 * 1000000000;

/***************/

int powmod (int a, int b, int mod) {
    int res = 1; a %= mod;
    for (; b; b >>= 1) {
        if (b & 1) {
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
    }
    return res;
}
#define ll long long
ll gcd (ll a, ll b) {
    while (b > 0) {
        ll t = a % b;
        a = b, b = t;
    }
    return a;
}

int lcm (int a, int b) {
    return (a / gcd (a, b)) * b;
}

int is_prime (int n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (int i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

/******Don't forget to use long long when needed!!******/

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    /// (a, b, c) -> (b/2+c/2, a/2+c/2, a/2+b/2)
    int cnt = 0, x, y, z;
    while (true) {
        if (cnt == 100000000) {
            cout << -1 << endl; return 0;
        }
        if ((a & 1) || (b & 1) || (c & 1)) break;
        x = (b + c) / 2, y = (a + c) / 2, z = (a + b) / 2;
        a = x, b = y, c = z;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
import collections as c
ip = lambda : map(int, input().split())
# ##############
N = int(input())
a = c.deque([int(i) for i in input().split()])
l,r = 0,0
while len(a) > 0:
    if l>=r:
        r += a.pop()
    else:
        l += a.popleft()
print(abs(l-r))

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

int main(){
  int N,M,K;

  while(1){
    vector<vector<int> > p(101,vector<int>(101,-1));
    vector<int> l(101,-1);

    cin>>N;
    if(N==0)break;    
    for(int i=0;i<N;i++){
      cin>>M;
      for(int j=0;j<M;j++) cin>>p[i][j];
    }
    
    cin>>K;
    for(int i=0;i<K;i++) cin>>l[i];

    int ans=-1;
    for(int i=0;i<N;i++){
      int count=0;
      for(int j=0;p[i][j]!=-1;j++){
	for(int k=0;l[k]!=-1;k++){
	  if(p[i][j]==l[k]) count++;
	}
      }
      if(count==K&&ans==-1) ans=i+1;
      else if(ans!=-1&&count==K){
	ans=-1;
	break;
      }
    }

    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1256
import java.util.*;

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

        long n = sc.nextLong();
        long m = sc.nextLong();


        for (long x = 0; x <= n; ++x) {
            long tmpx = x * 10000L;
            if (tmpx > m) {
                break;
            }
            for (long y = 0; y <= n - x; ++y) {
                long tmpy = tmpx + y * 5000L;
                if (tmpy > m) {
                    break;
                }
                for (long z = 0; z <= n - x - y; ++z) {
                    long tmpz = tmpy + z * 1000L;
                    if (tmpz > m) {
                        break;
                    }
                    if (tmpz == m && x + y + z == n) {
                        System.out.println(String.format("%d %d %d", x, y, z));
                        return;
                    }
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i < n; ++i)
	{
		for(int j = 1; j < n; ++j)
		{
			int req = n - i * j;
			if(req > 0)
				++ans;
			else
				break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		System.out.println((A + B) % 24);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 22996
import math
s = input().split(' ')
h = int(s[0])
w = int(s[1])
w1 = math.ceil(w/2)
w2 = math.trunc(w/2)
h1 = math.ceil(h/2)
#print(h, w)
if h == 1:
    print(1)
elif w == 1:
    print(1)
else:
    print(h1*w1 + (h-h1)*w2)

Measured memory_bytes: 3064
from operator import itemgetter
import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)

BC = [tuple(map(int, input().split())) for _ in range(M)]
BC.sort(reverse=True, key=itemgetter(1))

for b, c in BC:
    if A[0] < c:
        while b:
            heapq.heappushpop(A, c)
            b -= 1
    else:
        break

print(sum(A))

Measured memory_bytes: 22080
#include <iostream>
#include <sstream>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b && b == c){
  cout<<1<<endl;}else if((a==b &&b !=c)or (c==b &&b !=a)or (c==a &&c !=b)){
  cout<<2<<endl;}else{
  cout<<3<<endl;}
  return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;


int a[200000];
signed main(){
  int n;
  scanf("%lld", &n);
  rep(i,n)scanf("%lld", &a[i]);
  int up = -1, ans = 1;
  repi(i,1,n){
    if(up == 0 and a[i]-a[i-1] < 0){up = -1;ans++;continue;}
    if(up == 1 and a[i]-a[i-1] > 0){up = -1;ans++;continue;}
    if(a[i]-a[i-1] > 0)up = 0;
    if(a[i]-a[i-1] < 0)up = 1;
  }
  printf("%lld\n", ans);
	return 0;
}









Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n,x;
  cin>>n>>x;
  vi s(n);
  rep(i,n){
    cin>>s[i];
  }
  sort(all(s));
  vector<vi> dp(n+1,vi(x+1,0));
  
  rep(j,x+1) dp[0][j]=j;
  rep(i,n){
    rep(j,x+1){
      dp[i+1][j]=Madd(dp[i+1][j],dp[i][j%s[i]]);
      dp[i+1][j]=Madd(dp[i+1][j],Mmul(dp[i][j],i));
    }
  }

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

}

Measured memory_bytes: 158592
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

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

    int s = -n;
    REP (i, n)
    {
        int a;
        cin >> a;
        s += a;
    }

    cout << s << endl;

	return 0;
}


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

using namespace std;

int main(void)
{
    ios::sync_with_stdio(false);
    double maxh = -1, minh = 114514810;
    double h;
    while(cin >> h) {
        maxh = max(maxh, h);
        minh = min(minh, h);
    } 
    cout << maxh - minh << endl;

    return 0;
}

Measured memory_bytes: 1288
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
struct Disk{
	double x, y, r;
	int c, id;
}disk[30];
vector<Disk> colors[6];
char dp[1<<24];
double dis[25][25];
bool iscover(int a, int b){
	double r = (disk[a].r+disk[b].r)*(disk[a].r+disk[b].r);
	if(dis[a][b] < r){
		return true;
	}
	return false;
}
bool ontop(int a, int state){
	for(int i = 0; i < a; i++)
		if(!((state >> i) & 1) && iscover(i, a)){
			return false;
		}
	return true;
}
bool pairable(int a, int b, int state){
	if(!iscover(a, b) && ontop(a, state) && ontop(b, state))
		return true;
	return false;
}
int main(){
	int n;
	while(scanf("%d", &n), n){
		memset(dp, 0, sizeof(dp));
		for(int i = 1; i <= 4; i++)
			colors[i].clear();
		for(int i = 0; i < n; i++){
			scanf("%lf%lf%lf%d", &disk[i].x, &disk[i].y, &disk[i].r, &disk[i].c);
			disk[i].id = i;
			colors[disk[i].c].push_back(disk[i]);
		}
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				dis[i][j] = (disk[i].x-disk[j].x)*(disk[i].x-disk[j].x)+(disk[i].y-disk[j].y)*(disk[i].y-disk[j].y);
		int M = 1 << n;
		for(int i = 0; i < M; i++){
			if(i > 0 && !dp[i])
				continue;
			for(int c = 1; c <= 4; c++){
				for(int j = 0; j < colors[c].size(); j++){
					if((1<<colors[c][j].id)& i)
						continue;
						for(int k = j+1; k < colors[c].size(); k++){
							if((1<<colors[c][k].id) & i)
								continue;
							if(pairable(colors[c][j].id, colors[c][k].id, i)){
								int nstate = i | (1<<colors[c][j].id) | (1<<colors[c][k].id);
								if(dp[nstate] < dp[i] + 2)
									dp[nstate] = dp[i]+2;
							}
						}
				}
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++)
			if(ans < dp[i])
				ans = dp[i];
		printf("%d\n", ans);
	}
	return 0;
}

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

using namespace std;

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

    struct removed_t: vector< int >
    {
        void satisfy( int u, int v )
        {
            if ( lower_bound( begin(), end(), u ) == end() )
                push_back( v );
        }
    };

    struct requests_t: map< int, int >
    {
        requests_t( int M )
        {
            while( M-- > 0 )
            {
                int a, b; cin >> a >> b; auto it = find( --b );

                if ( it == end() )
                    emplace( b, a );
                else
                    if ( a > it->second )
                        it->second = a;
            }
        }

        int min_removed()
        {
            removed_t removed;

            for( auto p: *this )
                removed.satisfy( p.second, p.first );

            return removed.size();
        }

    } requests( M );

    cout << requests.min_removed();
}


Measured memory_bytes: 3328
import itertools as it

n,m = map(int,input().split())

d = []
for i in range(m):
    l = list(map(int,input().split()))
    d.append(l)

cs = [[] for i in range(3)]
for i in range(1,n+1):
    row = list(map(int,input().split()))
    for j, c in enumerate(row):
        cs[(i + (j+1)) % 3].append(c)

#print(cs)
ds = [[] for i in range(3)]
for i in range(1,m+1):
    for j in range(3):
        t = 0
        for e in cs[j]:
            t += d[e-1][i-1]
        ds[j].append(t)

#print(ds)
ans = -1
for (x,y,z) in list(it.permutations(range(m),3)):
    cand = ds[0][x] + ds[1][y] + ds[2][z]
    if ans == -1:
        ans = cand
    else:
        ans = min(ans,cand)
print(ans)


Measured memory_bytes: 7136
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

pre = sum(a)

for i in range(n):
    if b[i] > a[i]:
        b[i] -= a[i]
        a[i] = 0
        if b[i] > a[i+1]:
            b[i] -= a[i+1]
            a[i+1] = 0
        elif b[i] < a[i+1]:
            a[i+1] -= b[i]
            b[i] = 0
        else:
            a[i+1] = b[i] = 0

    elif b[i] < a[i]:
        a[i] -= b[i]
        b[i]

    elif b[i] == a[i]:
        b[i] = a[i] = 0

print(pre-sum(a))

Measured memory_bytes: 18476
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  string s[n];
  vector<pair<ll,string>> ans;
  map<string,ll> mp;
  vector<string> puter;
  for(int i=0;i<n;i++){
    cin >> s[i];
    mp[s[i]]++;
  }
  for(auto p:mp){
    ans.push_back({p.second,p.first});
  }
  sort(ans.begin(),ans.end());
  ll val = ans.back().first;
  for(int i=(ll)ans.size()-1;i>=0;i--){
    if(ans[i].first!=val) break;
    puter.push_back(ans[i].second);
  }
  sort(puter.begin(),puter.end());
  for(auto s:puter) cout << s<<endl;
}


Measured memory_bytes: 32876
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    int N;
    string S;
    cin >> N >> S;
    ll rc = 0, gc = 0, bc = 0;
    rep(i, N){
        if(S[i] == 'R') rc++;
        if(S[i] == 'G') gc++;
        if(S[i] == 'B') bc++;
    }
    ll total = rc * gc * bc;
    // kは間隔
    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            int a = i;
            int b = i + k;
            int c = i + k + k;
            if(S[a] == 'R' && S[b] == 'G' && S[c] == 'B') total--;
            if(S[a] == 'R' && S[b] == 'B' && S[c] == 'G') total--;
            if(S[a] == 'G' && S[b] == 'R' && S[c] == 'B') total--;
            if(S[a] == 'G' && S[b] == 'B' && S[c] == 'R') total--;
            if(S[a] == 'B' && S[b] == 'G' && S[c] == 'R') total--;
            if(S[a] == 'B' && S[b] == 'R' && S[c] == 'G') total--;
        }
    }
    cout << total << endl;
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 3600
/*
ID: hafiz.i1
TASK: milk2
LANG: C++
*/
#include<bits/stdc++.h>

#define ll long long
#define debug(x) cout<<x<<"DE"<<endl;

using namespace std;



int main()
{
//    freopen("milk2.in", "r", stdin);
//    freopen("milk2.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,c,s=0;
    cin>>n>>m>>c;
    ll l1[m+1],l2[m+1];
    for(int i=1;i<=m;i++)cin>>l1[i];
    for(int j=1;j<=n;j++){ll x=0;
        for(int i=1;i<=m;i++){
            cin>>l2[i];
            x+=(l2[i]*l1[i]);
        }x+=c;
        if(x>0)s++;
    }
    cout<<s;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1) a=14;
  if(b == 1) b=14;
  if(a > b){
    cout << "Alice" <<endl;
  }else if(a < b){
    cout << "Bob" << endl;
  }else{
    cout << "Draw" << endl;
  }
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> a(N), S(N + 1);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		S[i + 1] = S[i] + a[i];
	}

	Int ans = 0;
	map<Int, int> mp;
	for (int i = 0; i <= N; ++i) {
		ans += mp[S[i]];
		mp[S[i]] += 1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000000000007;
const int MOD=1000000007;
int n;
int memo[500][500];
int a[500]={};
int Size[500]={};
int rec(int l,int r){
    if(memo[l][r]!=inf)return memo[l][r];
    else{
        int buf=inf;
        for(int i=l+1;i<r;++i){
            buf=min(buf,rec(l,i)+rec(i,r)-Size[l]+Size[r]);
        }
        memo[l][r]=buf;
        return buf;
    }
}
signed main(){
  cin>>n;
  rep(i,n){
      cin>>a[i];
  }
  Size[0]=0;
  for(int i=1;i<=n;++i){
      Size[i]=Size[i-1]+a[i-1];
  }
  rep(i,500){
      rep(j,500){
          memo[i][j]=inf;
          if(i==j)memo[i][j]=0;
          else if(j==i+1)memo[i][j]=a[i]*0;
      }
  }
  cout<<rec(0,n)<<endl;
  return 0;
}

Measured memory_bytes: 2176
#include<iostream>
using namespace std;
#define ll long long
#define int long long

pair<int,int> ans[100010];
int ans2[100010];
int p;

signed main(){
    int n,k;cin>>n>>k;

    if(k>(n+1)/2){
        cout<<"-1"<<endl;
        return 0;
    }

    ll now=(3*n+1)/2;
    if(n%2){
        for(int i=1;i<=n;i++){
            int tmp=i%2==0?(n+1)/2+i/2:(i+1)/2;
            ans[p++]={tmp,now+i-tmp};
        }
    }
    else{
        for(int i=1;i<n;i++){
            int tmp=i%2==0?n/2+1+i/2:(i+1)/2;
            ans[p++]={tmp,(now+1+i/2*2)-tmp};
        }
        ans[p++]={n/2+1,2*n};
    }

    for(int i=0;i<n;i++)ans2[i]=k+n*2+i,ans[i].first+=k-1,ans[i].second+=k-1;
    // for(int i=0;i<n;i++){
    //     if(ans[i].first+ans[i].second>ans2[i]){
    //         cout<<"-1"<<endl;
    //         return 0;
    //     }
    // }
    for(int i=0;i<n;i++){
        cout<<ans[i].first<<" "<<ans[i].second<<" "<<ans2[i]<<endl;
    }
}


Measured memory_bytes: 4608
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
double tanka,ryou;
double sum,heikin;
int main()
{
  sum = 0;
  heikin = 0;
  double cnt = 0;
  while(scanf("%lf,%lf",&tanka,&ryou) !=EOF){
    cnt++;
    sum += tanka*ryou;
    heikin +=ryou;
  }
  heikin /=cnt;
  heikin +=0.5;
  heikin =(int)heikin;
  cout <<sum<<endl;
  cout <<heikin<<endl;
  
  return 0;
}

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

using namespace std;

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<ll> A;
int main() {
  cin >> N;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  map<ll, int> sum_cnts;
  ll sum = 0;
  for (int i = 0; i < N; i++){
    sum += A[i];
    sum_cnts[sum]++;
  }
  sum = 0;
  ll result = 0;
  for (int i = 0; i < N; i++){
    result += sum_cnts[sum];
    sum_cnts[sum + A[i]]--;
    // cerr << i << " " << sum << " " << result << endl;
    sum += A[i];
  }
  cout << result << endl;
  return 0;
}


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

using namespace std;

int main() {
    long long a, b, n, t, ans;

    cin >> a >> b >> n;

    ans = 0;
    
    if (b > 1000000) {
        t = b - 1;
        ans = (a * n / b) - a * (n / b);
        while (t <= n) {
            ans = max(ans, (a * t / b) - a * (t / b));
            t += b;
        }        
    } else {
        t = 1;
        while (t <= min(b, n)) {
            ans = max(ans, (a * t / b) - a * (t / b));
            t++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    int a[4]={0};
    for(int i=0;i<s.size();i++){
        if(s[i]=='K')a[0]++;
        if(s[i]=='U')a[1]++;
        if(s[i]=='P')a[2]++;
        if(s[i]=='C')a[3]++;
    }
    int x=1000;
    for(int i=0;i<4;i++)if(a[i]<x)x=a[i];
    cout<<x<<endl;

    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


main(){
  int n,x;
  cin>>n>>x;
  vector<int> v(n);
  rep(i,n){
    cin>>v[i];
  }

  int l=0;
  int ans=1;
  int i=0;

  while(i<n){
    l+=v[i++];
    if(l>x) break;
    ans++;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
s = gets.chomp.split('').map(&:to_i)
8.times do |i|
    ope = []
    3.times do |j|
        if (i & (1 << j)) > 0
            ope.push('-')
        else
            ope.push('+')
        end
    end
    hoge = ''
    3.times do |j|
        hoge += s[j].to_s + ope[j]
    end
    hoge += s[3].to_s
    if eval(hoge) == 7
        hoge += "=7"
        puts hoge
        exit
    end
end

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    FOR(i, 1, n+1){
        if(floor(i*1.08) == n){
            cout << i << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int getDigit(int x)
{
    char digits[20];
    sprintf(digits, "%d", x);
    return strlen(digits);
}

int main()
{
    char digits[20];
    int a, b;
    while(scanf("%d %d", &a,&b)==2){
        a += b;
        printf("%d\n", getDigit(a));
    }
    return 0;
}

Measured memory_bytes: 612
h, w = map(int,input().split())
s = []
for i in range(h):
  s += [input()]
sh = [[0 for _ in range(h)] for _ in range(w)]
sw = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
  c = 0
  for j in range(w):
    if s[i][j]=='.':
      c += 1
    else:
      sw[i][(j-c):j] = [c]*c
      c = 0
  if c>0:
    sw[i][(w-c):w] = [c]*c
for j in range(w):
  c = 0
  for i in range(h):
    if s[i][j]=='.':
      c += 1
    else:
      sh[j][(i-c):i] = [c]*c
      c = 0
  if c>0:
    sh[j][(h-c):h] = [c]*c
print(max([sw[i][j]+sh[j][i] for i in range(h) for j in range(w)])-1)

Measured memory_bytes: 234832
require 'prime'

### constant

MAX_N = 1299709

### subroutines

def lower_bound(arr, key, i0 = 0, i1 = arr.length)
  lb = i0 - 1
  ub = i1

  while lb + 1 < ub
    m = (lb + ub) / 2
    if arr[m] >= key
      ub = m
    else
      lb = m
    end
  end
  ub
end

### main

pnums = Prime.each(MAX_N).to_a

loop do
  n = gets.to_i
  break if n == 0

  i = lower_bound(pnums, n)

  if i == 0 || n == pnums[i]
    puts 0
  else
    puts pnums[i] - pnums[i - 1]
  end
end

Measured memory_bytes: 7272
a=list(map(str,input().split()))
j=0
b=[]
for i in range(len(a)):
    if(a[i]=='+'):
        b[j-2]=(b[j-2]+b[j-1])
        j-=1
        b.pop(-1)
    elif(a[i]=='-'):
        b[j-2]=(b[j-2]-b[j-1])
        j-=1
        b.pop(-1)
    elif(a[i]=='*'):
        b[j-2]=(b[j-2]*b[j-1])
        j-=1
        b.pop(-1)
    else:
        b.append(int(a[i]))
        j+=1
print(b[0])



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    int dp[n+1];
    for(int i=1;i<=n;i++) dp[i]=1000000000;
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i-j<=0)break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#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++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#define debug(args...) \
cout << "#" << __LINE__ << ": "; \
__dbg(split(#args, ',').begin(), args);
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}
template<typename T, typename... Args>
inline string to_str(T x) {
	stringstream ss; ss << "[";
	for (auto it = x.begin(); it != x.end(); it++) {
		if (it != x.begin()) ss << " ";
		ss << (*it);
	}
	ss << "]";
	return ss.str();
}
template<typename T, typename... Args>
inline string to_str(stack<T> x) {
	stringstream ss; ss << "[";
	bool first = 1;
	while (!x.empty()) {
		if (!first)
			ss << " ";
		ss << x.top();
		x.pop();
		first = 0;
	}
	ss << "]";
	return ss.str();
}
template<typename T> inline void __dbg_var(vector<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(list<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(unordered_set<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(stack<T> x) { cout << to_str(x); }
template<typename T> inline void __dbg_var(T val) { cout << val; }
inline void __dbg(vector<string>::iterator it) { cout << endl; }
template<typename T, typename... Args>
inline void __dbg(vector<string>::iterator it, T a, Args... args) {
	cout << it->substr((*it)[0] == ' ', it->length()) << "=";
	__dbg_var(a);
	cout << " ";
	__dbg(++it, args...);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll x, ans = 0;
	cin >> x;
	ll a[x];
	unordered_map<ll,ll> s;
	
	for (int i = 0; i < x; i++) {
		cin >> a[i];
		if (s.find(i-a[i]) != s.end())
			ans+=s[i-a[i]];
		s[a[i]+i]++;
	}
	cout << ans << "\n";
	return 0;
}



Measured memory_bytes: 12860
#include <stdio.h>

int* HmsConvert(int time);
void HmsPrint(int* hmsArr);

int main(void) {

    int S;

    do {
        scanf("%d", &S);
    } while(S < 0 || S > 86400);

    printf("%d:%d:%d\n", S / 3600, (S % 3600) / 60, (S % 3600) % 60);


}




Measured memory_bytes: 2056
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    Rep(i, N) cin >> A[i];
    Sort(A);
    int index = A.size() - 1;
    ll e1 = 0, e2 = 0;
    while (index >= 1) {
        if (A[index] == A[index - 1]) {
            e1 = A[index];
            index -= 2;
            break;
        }
        index--;
    }
    while (index >= 1) {
        if (A[index] == A[index - 1]) {
            e2 = A[index];
            break;
        }
        index--;
    }
    cout << e1 * e2 << endl;
    return 0;
}

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


#define _x real()
#define _y imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 0}, {0, 1}, {1, 1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {1, -1} };
ll mod = 1e9 + 7;

int sz[100007], rep[100007], nc;
vector<pair<int, int>> points;

bool compX(int a, int b) {
	if (points[a].first < points[b].first)
		return true;
	return false;
}

bool compY(int a, int b) {
	if (points[a].second < points[b].second)
		return true;
	return false;
}

int find(int u) {
	if (rep[u] == u)
		return u;
	return rep[u] = find(rep[u]);
}

void join(int a, int b) {
	a = find(rep[a]);
	b = find(rep[b]);
	if (a == b)
		return;
	if (sz[a] < sz[b])
		swap(a, b);
	rep[b] = a;
	sz[a] += sz[b];
	nc--;
}

int main() {
	fastIO;
	int n, mst = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		rep[i] = i;
		sz[i] = 1;
	}
	int idsX[n], idsY[n];
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		points.push_back({a, b});
		idsX[i] = i;
		idsY[i] = i;
	}
	sort(idsX, idsX+n, compX);
	sort(idsY, idsY+n, compY);

	map<int, vector<pair<int, int>>> diffs;
	for (int i = 1; i < n; i++) {
		int diffX = abs(points[idsX[i]].first - points[idsX[i-1]].first);
		int diffY = abs(points[idsY[i]].second - points[idsY[i-1]].second);
		diffs[diffX].push_back({idsX[i], idsX[i-1]});
		diffs[diffY].push_back({idsY[i], idsY[i-1]});
	}
	for (auto i : diffs) {
		for (auto j : i.second) {
			int a = j.first, b = j.second;
			if (find(rep[a]) != find(rep[b])) {
				join(a, b);
				mst += i.first;
			}
		}
	}
	cout << mst << endl;

}


Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int n;
  cin>>n;
  for (int i = 1; i <= 9; ++i)
  {
    for (int j = 1; j <= 9; ++j)
    {
      if(i*j==n)
      {
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main(void)
{
  int ans = 0;
  int A,B,C,X;

  cin >> A >> B >> C >> X;
  
  X /= 50;
  for(int i = 0; i <= A; i++){
    for(int j = 0; j <= B; j++){
      for(int k = 0; k <= C; k++){
	int tmp = i * 10 + j * 2 + k;
	if(tmp == X)
	  ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int compare_int(const void *a,const void *b)
{
	return *(int*)a-*(int*)b;
}
int main()
{
	int n,k,p[1011],a=0,i;

	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
		scanf("%d",&p[i]);

	qsort(p,n,sizeof(int),compare_int);
	for(i=0;i<k;i++)
		a+=p[i];
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define _for(i,n) for(int i = 0; i < n; i++)

using namespace std;
void dfs(int,vector<vector<int> >,int*);


int ans = 0;
int n,m;
int main() {
  cin >> n >> m;
  int a[m], b[m];
  _for(i,m) cin >> a[i] >> b[i];
  _for(i,m) {
    a[i]--;
    b[i]--;
  }
  int visited[n];
  _for(i,n) visited[i] = 0;
  vector<vector<int> > connected(n,vector<int>());
  _for(i,m) {
    connected[a[i]].push_back(b[i]);
    connected[b[i]].push_back(a[i]);
  }
  dfs(0,connected,visited);
  cout << ans << endl;  
  return 0;
}

int visited_all(int* visited) {
  int all_visited = true;
  _for(i,n) if (visited[i]!=1) all_visited = false;
  return all_visited;
}

void dfs(int current,vector<vector<int> > connected,int* visited) {
  visited[current] = 1;
  if (visited_all(visited)) ans++;
  else {
    _for(i,connected[current].size()) if (visited[connected[current][i]]!=1) {
      dfs(connected[current][i],connected,visited);
    }
  }
  visited[current] = 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;

signed main(){
    int a,b,c;
    cin >> a >> b >> c;
    int cnt = 0;
    if(a % 2 == 1 || b % 2 == 1 || c % 2 == 1){ 
        cout << 0 << '\n';
        return 0;
    }   
    if(a == b && b == c){ 
        cout << -1 << '\n';
        return 0;
    }   
    int xa,xb,xc;
    while(!(a % 2 == 1 || b % 2 == 1 || c % 2 == 1)){
        xa = a;
        xb = b;
        xc = c;
        a = xb/2 + xc/2;
        b = xa/2 + xc/2;
        c = xa/2 + xb/2;
        ++cnt;
    }   
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
import math
a,b,h,m = map(int,(input().split()))

ha = 360/12*h + 360/12*m/60
ma = 360/60*m
da = 0
if abs(ha - ma) > 180:
  da = 360 - abs(ha - ma)
else:
  da = abs(ha - ma)

cos = math.cos(math.radians(da))
print(math.sqrt(a**2 + b**2 - 2*a*b*cos))


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

bool check(vector<string>& S) {
    int N = S.size();
    vector<int> color(N, -1);
    color[0] = 0;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int u = que.front();
        que.pop();

        for (int i = 0; i < N; i++) {
            if (S[u][i] == '1') {
                if (color[i] == -1) {
                    color[i] = 1 - color[u];
                    que.push(i);
                } else if (color[i] == color[u]) {
                    return false;
                }
            }
        }
    }
    return true;
}

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S[i];
    }

    if (!check(S)) {
        cout << -1 << endl;
        return 0;
    }

    vector<vector<int>> dist(N, vector<int>(N, 1e9));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                dist[i][j] = 0;
            } else if (S[i][j] == '1') {
                dist[i][j] = 1;
            }
        }
    }
    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    for (auto& v : dist) {
        ans = max(ans, *max_element(v.begin(), v.end()));
    }
    cout << ans + 1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

typedef long long int ll;
const int N_MAX = 3005;
const int MOD = 998244353;
int A[N_MAX];
ll dp[N_MAX][N_MAX];
int N, S;

int main(){
    cin >> N >> S;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++){
        dp[i][0] = (dp[i-1][0] + 1) % MOD;
        for(int j = 1; j < S; j++){
            if (A[i] > j)dp[i][j] = dp[i-1][j] % MOD;
            else{
                dp[i][j] = (dp[i-1][j-A[i]] + dp[i-1][j]) % MOD;
            }
        }
        if (S < A[i])dp[i][S] = dp[i-1][S] % MOD;
        else dp[i][S] = (dp[i-1][S] + dp[i-1][S-A[i]] * (N+1-i)) % MOD;
    }
    cout << dp[N][S] << endl;
    return 0;
}

Measured memory_bytes: 70784
//#include<bits/stdc++.h> using namespace std;
#include<iostream>
using namespace std;
#include<algorithm>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue> //priority_queue inside queue
#include<deque>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl '\n'
typedef long long ll;
typedef unsigned long long ull;
#define f(i,start,end) for(i=start;i<=end;i++)
#define min_heap priority_queue<int, vector<int>, greater<int> >
#define max_heap priority_queue<int>

bool isPrime(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        if(n%i==0) return false;
    }
    return true;
} //returns true if prime!

bool b[200001];
int dp[200001];

int main()
{
    fast;
//int t=0,tc=0; cin >> tc; f(t,1,tc) //testcases
    {
        int n, k; cin >> n >> k;
        bool b[n+1] = {0};
        while(k--)
        {
           int d; cin  >> d;
           while(d--)
           {
              int tmp; cin >> tmp;
              if(b[tmp]==0)
              {
                 n--; b[tmp]=1;
              }
           }
        }
        cout << n << nl;
    }
    return 0;
}
    

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

using namespace std;
#define ll long long

int main()
{
  string s,t;cin>>s>>t;
  ll ans=0;
  for(ll i=0;i<s.length();i++){
      if(s[i]!=t[i])ans++;
  }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 3916
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
using namespace std;
int main(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    int c=s.length();
    rep(i,c)if(s[i]!=t[i])ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3560
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
l=[0]*(n+1)
for i in range(n):
    if s[i:i+2]=='AC':
        l[i+1]=l[i]+1
    else:l[i+1]=l[i]
for j in range(q):
    print( l[lr[j][1]-1] - l[lr[j][0]-1])

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)(n); i++)
#define reps(i,s,e) for(int i=s; i<(int)(e); i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Set = std::set<T>;
template<class T, class U>
using Map = std::map<T, U>;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    ll movestep = std::abs(X / D);
    if (movestep >= K) {
        cout << std::abs((X > 0) ? X - D*K : X + D*K) << endl;
        return 0;
    }

    ll now = X % D;
    if (X < 0) {
        now += D;
        movestep++;
    }
    if ((K - movestep) % 2 == 0) {
        cout << now << endl;
    } else {
        cout << std::abs(now - D) << endl;
    }
}

Measured memory_bytes: 3568