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

using namespace std;

struct Matrix
{
  vector< vector< int > > A;

  Matrix() {}

  Matrix(size_t n, size_t m) : A(n, vector< int >(m, 0)) {}

  Matrix(size_t n) : A(n, vector< int >(n, 0)) {};

  size_t height() const
  {
    return (A.size());
  }

  size_t width() const
  {
    return (A[0].size());
  }

  inline const vector< int > &operator[](int k) const
  {
    return (A.at(k));
  }

  inline vector< int > &operator[](int k)
  {
    return (A.at(k));
  }

  static Matrix I(size_t n)
  {
    Matrix mat(n);
    for(int i = 0; i < n; i++) mat[i][i] = 1;
    return (mat);
  }

  Matrix &operator*=(const Matrix &B)
  {
    size_t n = height(), m = B.width(), p = width();
    assert(p == B.height());
    vector< vector< int > > C(n, vector< int >(m, 0));
    for(int i = 0; i < n; i++)
      for(int j = 0; j < m; j++)
        for(int k = 0; k < p; k++)
          C[i][j] |= (*this)[i][k] & B[k][j];
    A.swap(C);
    return (*this);
  }

  Matrix &operator^=(long long k)
  {
    Matrix B = Matrix::I(height());
    while(k > 0) {
      if(k & 1) B *= *this;
      *this *= *this;
      k >>= 1LL;
    }
    A.swap(B.A);
    return (*this);
  }

  Matrix operator*(const Matrix &B) const
  {
    return (Matrix(*this) *= B);
  }

  Matrix operator^(const long long k) const
  {
    return (Matrix(*this) ^= k);
  }

  friend ostream &operator<<(ostream &os, Matrix &p)
  {
    size_t n = p.height(), m = p.width();
    for(int i = 0; i < n; i++) {
      os << "[";
      for(int j = 0; j < m; j++) {
        os << p[i][j] << (j + 1 == m ? "]\n" : ",");
      }
    }
    return (os);
  }
};

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

  while(cin >> N >> M >> Z, N) {
    vector< pair< int, int > > g;
    for(int i = 0; i < M; i++) {
      int A, B;
      cin >> A >> B;
      g.emplace_back(--A, --B);
      g.emplace_back(B, A);
    }

    Matrix vv(g.size() + 1);
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i].first != g[j].second && g[i].second == g[j].first) {
          vv[i][j] = true;
        }
      }
    }
    for(int i = 0; i < g.size(); i++) {
      vv[g.size()][i] = g[i].first == 0;
    }

    vv ^= Z;

    bool flag = false;
    for(int i = 0; i < g.size(); i++) {
      flag |= g[i].second == N - 1 && vv[g.size()][i];
    }

    if(flag) cout << "yes" << endl;
    else cout << "no" << endl;
  }

}

Measured memory_bytes: 3144
import math

def snuke(x):
    y=0
    xx=x
    while x!=0:
        y+=x%10
        x=x//10
    return xx/y

a=1
k=int(input())
kaisu=0
incre=1
        
while kaisu<k:
    before=a
    print(a)
    b=snuke(a)
    if (a+1)%(10*incre)!=0:
        a+=incre
    else:
        a+=1
        b=a
        snukes=[]
        for j in range(int(math.log10(a+1))):
            b+=9*(10**j)
            snukes.append(b)
        #print(snukes)
        snukes2=[]
        for sks in snukes:
            snukes2.append(snuke(sks))
        if len(snukes2)==1:
            a=snukes[0]
        else:
            answer=[]
            for sn2 in range(len(snukes2)-1):
                if snukes2[sn2]<=snukes2[sn2+1]:
                    answer.append(snukes[sn2])
            #print(answer)
            answer.append(snukes[-1])
            a=answer[0]
            incre=a-before
    kaisu+=1

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

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    vector<vector<ll>> dp(110, vector<ll>(100010, LLINF));
    for (ll i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    // dp[i][j]:=i番目までの品物を見て、価値の総和がjになるような重さの総和の最小値
    dp[0][0] = 0;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j <= 100000; j++)
        {
            if (j - v[i] >= 0)
            {
                chmin(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
            }
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = -LLINF;
    for (ll i = 0; i <= 100000; i++)
    {
        if (dp[N][i] <= W)
        {
            chmax(ans, i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 87296
#include"iostream"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"iomanip"
using namespace std;
typedef long long ll;
const int maxn=2010;
bool rec[maxn][maxn];
int h[maxn][maxn],v[maxn][maxn],b[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,q;cin>>n>>m>>q;
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            char ch;cin>>ch;
            if(ch=='1')
                rec[i][j]=1;
        }
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            v[i][j]=v[i-1][j];
            h[i][j]=h[i][j-1];
            b[i][j]=b[i-1][j];
            if(rec[i][j])
            {
                if(rec[i-1][j])
                    v[i][j]++;
                if(rec[i][j-1])
                    h[i][j]++;
                b[i][j]++;
            }
        }
    }
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            v[i][j]+=v[i][j-1];
            h[i][j]+=h[i-1][j];
            b[i][j]+=b[i][j-1];
        }
    }
    /*
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=m;++j)
        {
            cout<<h[i][j]<<' ';
        }
        cout<<'\n';
    }*/
    while(q--)
    {
        int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2;
        int node=b[x2][y2]+b[x1-1][y1-1]    -        b[x2][y1-1]-b[x1-1][y2];
        int edge=v[x2][y2]+v[x1][y1-1]+h[x2][y2]+h[x1-1][y1]-v[x2][y1-1]-v[x1][y2]-h[x1-1][y2]-h[x2][y1];  
        cout<<node-edge<<'\n';
    }
}


Measured memory_bytes: 52992
# coding: utf-8

# https://atcoder.jp/contests/abc121


def main():
    N, M = map(int, input().split())
    AB = [None] * N
    for i in range(N):
        AB[i] = list(map(int, input().split()))

    AB = sorted(AB, key=lambda x: x[0])

    n_drink = 0
    n_store = 0
    for i in range(N):
        n_drink += AB[i][1]
        n_store = i+1
        if n_drink >= M:
            n_last = M - (n_drink - AB[i][1])
            break

    ans = 0
    for i in range(n_store-1):
        ans += AB[i][0] * AB[i][1]

    ans += AB[n_store-1][0] * n_last

    return ans


print(main())


Measured memory_bytes: 29320
#include<cstdio>
int main()
{
	char a[3],b[3];
	scanf("%s %s",a+1,b+1);
	if(a[1]>b[1]){
		printf(">\n");
	}else if(a[1]<b[1]){
		printf("<\n");
	}else{
		printf("=\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#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 pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n,h;
  cin>>n>>h;
  vll a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  sort(all(a));
  sort(all(b));
  ll k=a[n-1];
  ll j=0;
  rep(i,n){
    if(k>=b[i]) j++;
    else break;
  }
  ll w=0;
  for(int i=n-1;i>=j;i--){
    w+=b[i];
    if(w>=h){
      COUT(n-i);
      return 0;
    }
  }
  h-=w;
  ll ans=n-j;
  ans+=(h+k-1)/k;
  COUT(ans);
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int, int>
#define pll pair <ll, ll>
#define gcd __gcd
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

const ll L = 2e5+5;

ll a[L];
ll b[L];

vector <pll> p;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll N;
    cin >> N;

    for(ll i=0; i<N; i++)
    {
        cin >> a[i] >> b[i];

        p.pb(mp(b[i], a[i]));
    }

    sort(all(p));

    ll cur = 0;
    for(ll i=0; i<N; i++)
    {
        cur+=p[i].ss;

        // cout << i << " " << cur << " " << b[i] << endl;

        if(p[i].ff<cur)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 8432
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define MULT(a,b) (((a)*(b))%1000000007)
typedef long long int llint;

std::map<int, int> decomposition_prime(int n){
  std::map<int, int> ret;
  for(int i=2; i<=n; i++){
    while(n%i == 0){
      if(ret.find(i) == ret.end()) ret[i] = 0;
      ret[i]++;
      n /= i;
    }
  }
  return ret;
}

std::map<int, int> elem_add(const std::map<int, int>& a, const std::map<int, int>& b){
  std::map<int, int> ret = a;
  for(auto elem: b){
    if(ret.find(elem.first) == ret.end()) ret[elem.first] = 0;
    ret[elem.first] += elem.second;
  }
  return ret;
}

int main(void){
  int n;
  std::cin >> n;

  std::map<int, int> final;
  for(int i=1; i<=n; i++){
    final = elem_add(final, decomposition_prime(i));
  }

  llint result = 1;
  for(auto elem: final){
    result = MULT(elem.second+1, result);
  }
  std::cout << result << std::endl;


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int A,B,C,D,x,y;
  cin>>A>>B>>C>>D;
  x=A/D;if(A%D>0)x++;y=C/B;if(C%B>0)y++;
  return cout<<((x>=y)?"Yes":"No")<<endl,0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define sym cout<<"-----------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

//  Illuminaion



int a[110000];
signed main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<n; i++){
    if(i%2) a[i]^=1;
  }
  
  int cur=0;
  vector<int> v;
  for(int i=0; i<n; i++){
    if(i&&a[i]!=a[i-1]){
      v.push_back(cur);
      cur=1;
    }else cur++;
  }
  v.push_back(cur);
  int ret=v[0];
  if(v.size()>1){
    for(int i=0; i<v.size()-1; i++) ret=max(ret,v[i]+v[i+1]);
    for(int i=1; i<v.size()-1; i++){
      ret=max(ret,v[i-1]+v[i]+v[i+1]);
    }
  }
  cout<<ret<<en;
}















Measured memory_bytes: 4204
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner scan = new Scanner(System.in);
    String S = scan.next();
    if(S.equals("ABC")){
    	System.out.println("ARC");
    }else if(S.equals("ARC")){
    	System.out.println("ABC");
    }
  }
}

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

const ll INF = 1000000LL;

int main(){
  int n;
  while(true){
    ll max = -INF, tmp = -INF, d;
    cin >> n;
    if(n == 0)break;
    for(int i = 0; i < n; i++){
      cin >> d;
      tmp=(tmp+d > d ? tmp+d : d);
      if(max<tmp)max=tmp;
    }
    cout<<max<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
n = int(input())

data = []
for _ in range(n):
    a, b, c = list(map(int, input().split()))
    data.append((a, b, c))

dp = [[0] * 3 for _ in range(n)]

dp[0][0] = data[0][0]
dp[0][1] = data[0][1]
dp[0][2] = data[0][2]

for i in range(1, n):
    for j in range(3):
        if j == 0:
            dp[i][j] = max(
                dp[i - 1][1] + data[i][j],
                dp[i - 1][2] + data[i][j],
            )
        elif j == 1:
            dp[i][j] = max(
                dp[i - 1][0] + data[i][j],
                dp[i - 1][2] + data[i][j],
            )
        else:
            dp[i][j] = max(
                dp[i - 1][0] + data[i][j],
                dp[i - 1][1] + data[i][j]
            )

print(max(dp[-1]))

Measured memory_bytes: 75176
n,m=map(int,input().split(" "))
h=input().split(" ")
H=[]
hokan=[1 for i in range(n)]
for i in range(n):
  H.append(int(h[i]))
for i in range(m):
  a,b=map(int,input().split(" "))
  if H[a-1]>H[b-1]:
    hokan[b-1]=0
  elif H[a-1]<H[b-1]:
    hokan[a-1]=0
  elif H[a-1]==H[b-1]:
    hokan[a-1]=0
    hokan[b-1]=0
print(sum(hokan))

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

ll calc(ll a){
    if(a == -1) return 0;
    if(a == 0) return 0;
    if(a == 1) return 1;
    if(a%2==0){
        if((a / 2) % 2 == 0) return a^0;
        else return a^1;
    }else{
        if(((a-1)/2) %2== 0) return a^(a-1)^0;
        else return a^(a-1)^1;
    }
}

int main(){
    ll a, b;
    cin >> a >> b;
    a = calc(a - 1);
    b = calc(b);
    ll ans = a^b;
    cout << ans << endl;
    return 0;
}

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

int main() {
  	int N;
  	cin >> N;
  	int l , r ;
  	int total = 0;
  	for(int i = 0; i < N; i++){
    	cin >> l >> r;
      	total += r - l + 1;
    }
  	cout << total << endl;
}


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

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

using namespace std;


bool even(ll n){
    return n %2 == 0;
}

map<ll, map<ll, map<ll, ll>>> memo;

int main(){
    ll a, b, c;
    cin >> a >> b >> c;

    vector<ll> v(3);
    v[0] = a;
    v[1] = b;
    v[2] = c;
    sort(v.begin(), v.end());

    ll cnt = 1;
    memo[v[0]][v[1]][v[2]] = cnt;
    while(even(v[0]) && even(v[1]) && even(v[2])){
        ll na = v[1]/2 + v[2]/2;
        ll nb = v[0]/2 + v[2]/2;
        ll nc = v[0]/2 + v[1]/2;
        v[0] = na;
        v[1] = nb;
        v[2] = nc;
        sort(v.begin(), v.end());
        cnt++;
        if(memo[v[0]][v[1]][v[2]] == 0){
            memo[v[0]][v[1]][v[2]] = cnt;
        }
        else{
            cnt = 0;
            break;
        }
    }

    cout << cnt-1 << endl;




    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
struct Edge {
	int a, b, c;
	bool operator<(const Edge &p)const {
		return c < p.c;
	}
}w[2010];
int n, m, UF[1010], Mod = 1000000007;
vector<int>G[1010];
long long X, C[1010][1010], S;
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
void Put(int a, int b, int c) {
	a = Find(a), b = Find(b);
	if (a == b)return;
	for (auto &t1 : G[a])for (auto &t2 : G[b]) {
		C[t1][t2] = C[t2][t1] = c;
	}
	S += c;
	for (auto &t2 : G[b])G[a].push_back(t2);
	UF[b] = a;
}
int main() {
	int i, j;
	scanf("%d%d%lld", &n, &m, &X);
	if (n <= 2) {
		puts("0");
		return 0;
	}
	for (i = 1; i <= n; i++) {
		G[i].push_back(i);
		UF[i] = i;
		for (j = 1; j <= n; j++) {
			if (i != j)C[i][j] = 1e18;
		}
	}
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &w[i].a, &w[i].b, &w[i].c);
	}
	sort(w, w + m);
	for (i = 0; i < m; i++) {
		Put(w[i].a, w[i].b, w[i].c);
	}
	if (X < S) {
		printf("0\n");
		return 0;
	}
	if (X == S) {
		int c = 0, res = 1, t = 1;
		for (i = 0; i < m; i++) {
			if (C[w[i].a][w[i].b] == w[i].c)c++;
			else res = res * 2 % Mod;
		}
		for (i = 0; i < c; i++) {
			t = t * 2 % Mod;
		}
		res = 1ll * res*(t + Mod - 2) % Mod;
		printf("%d\n", res);
	}
	else {
		int c = 0, res = 1, t = 2;
		for (i = 0; i < m; i++) {
			if (C[w[i].a][w[i].b] + X - S == w[i].c)c++;
			else if (C[w[i].a][w[i].b] + X - S < w[i].c)res = res * 2 % Mod;
		}
		for (i = 0; i < c; i++) {
			t = t * 2 % Mod;
		}
		res = 1ll * res*(t + Mod - 2) % Mod;
		printf("%d\n", res);
	}
}

Measured memory_bytes: 9600
from collections import defaultdict
from heapq import heapify, heappop, heappush

INF = 10 ** 11 + 1
nV, nE, r = map(int, input().split())
G = defaultdict(list)

for _ in range(nE):
    a, b, c = map(int, input().split())
    G[a].append((b, c))
    # G[b].append((a, c))

# # dijkstra
# r -= 1
# d = dijkstra(r)
# print(d)

d = [INF for _ in range(nV)]
d[r] = 0
queue = [(0, r)]
while queue:
    c, v = heappop(queue)
    # if d[v] < c:
    #     continue
    for u, cost in G[v]:
        if d[v] + cost  < d[u]:
            d[u] = d[v] + cost
            heappush(queue, (d[u], u))

for dd in d:
    if dd == INF:
        print("INF")
    else:
        print(dd)


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

int main(){
	int rect1 = 0;
	int rect2 = 0;
	int a, b, c;
	while(~scanf("%d,%d,%d", &a, &b, &c)){
		if(a*a + b*b == c*c){
			rect1++;
		}
		if(a == b){
			rect2++;
		}
	}
	cout << rect1 << endl;
	cout << rect2 << endl;
	return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		
		int count = 0;
		for(int i=0; i<a+1; i++) {
			for(int j=0; j<b+1; j++) {
				for(int k=0; k<c+1; k++) {
					int sw = i*500 + j*100 + k*50;
					if(sw == x) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21204
##### 解けた #####

a,b,c,d=list(map(int,input().split(" ")))

if abs(c-a)<=d or (abs(c-b)<=d and abs(b-a)<=d): # 直接的もしくは間接的に会話できる場合
    print("Yes")
else: # 会話できない場合
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>x(n);
  vector<int>rep(202020);
  for(int i=0;i<n;i++){
  	cin>>x[i];
  	rep[x[i]]++;
  }
  int best = 0;
  for(int i=1;i<202020;i++){
  	int ans = rep[i]+rep[i-1]+rep[i+1];
  	best=max(best,ans);
  }
  cout<<best<<endl;
}  





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

using namespace std;

typedef long long   ll;
typedef pair<int,int> pii;
typedef pair<int,int> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii > vpi;

//#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define cl(x, v) memset((x), (v), sizeof(x))
#define all(x) x.begin(),x.end()
#define sz(x) int(x.size())
#define MOD 1000000007LL
#define endl '\n'
#define mdc(a, b) (__gcd((a), (b)))
#define mmc(a, b) (( (a)/__gcd((a), (b)) )*(b))

ll memo[30][1<<22];
bool mat[30][30];

int n;

ll dp(int i, int mask){
	if(i == n)
		return 1LL;
			
	if(memo[i][mask] != -1LL)
		return memo[i][mask];
	
	ll ans = 0LL;
		
	for(int k=0; k<n; k++){
		if(mat[i][k] and (mask & (1<<k)) )
			ans = ( ans + dp(i+1, mask &(~(1<<k))) )%MOD;
	}
	
	return memo[i][mask] = ans;
}

int main() {	
	memset(memo, -1, sizeof(memo));
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;

	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin >> mat[i][j];
	
	cout << dp(0, (1<<n) -1) << endl;

	return 0;	
}


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

using namespace std;
using ll = long long;

int main() {
	const ll MOD = 1e9 + 7;
	const int A = 0, C = 1, G = 2, T = 3;

	int N;
	cin >> N;

	int dp[110][4][4][4] = { 0 };
	dp[0][T][T][T] = 1;
	ll res = 0;
	for (int i = 1; i <= N; ++i) {
		for (int j = 0; j < 4; ++j) {
			for (int k = 0; k < 4; ++k) {
				for (int l = 0; l < 4; ++l) {
					for (int m = 0; m < 4; ++m) {
						if (j == A && k == G && l == C) { continue; }
						if (j == G && k == A && l == C) { continue; }
						if (j == A && k == C && l == G) { continue; }
						if (j == A && l == G && m == C) { continue; }
						if (j == A && k == G && m == C) { continue; }

						(dp[i][j][k][l] += dp[i - 1][k][l][m]) %= MOD;
						if (i == N) {
							(res += dp[N - 1][k][l][m]) %= MOD;
						}
					}
				}
			}
		}
	}

	cout << res % MOD << endl;

	return 0;
}


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

int main(void){
    int N, M;
    scanf("%d %d", &N, &M);

    int p[M];
    char S[M][3];
    int ans[2] = {};

    int isACed1[N];
    int isACed2[N];

    for(int i=0; i<N; i++){
        isACed1[i] = 0;
        isACed2[i] = 0;

    }

    for(int i=0; i<M; i++){
        scanf("%d %s", &p[i], S[i]);
        if(strcmp(S[i], "AC")==0){
            isACed1[p[i]-1] = 1;
        }
    }
/*     for(int i=0; i<N; i++){
        printf("%d %d\n", i, isACed1[p[i]-1]);

    } */
    for(int i=0; i<M; i++){

        if( (isACed1[p[i]-1] == 1) && (isACed2[p[i]-1] == 0) ){
            if(strcmp(S[i], "WA")==0) ans[1] += 1;

            else if(strcmp(S[i], "AC")==0){
                ans[0] += 1;
                isACed2[p[i]-1] = 1;
            }
        }else if(isACed1[p[i]-1] == 0){
        }


    }

    printf("%d %d\n", ans[0], ans[1]);
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
using namespace std;

string s;

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

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

using namespace std;

int main(){

  string marbles;

  while(cin >> marbles){
    int cont = 0;

    for(int i=0;i<marbles.length();i++){
      if(marbles.at(i)== '1')cont++;
    }
    cout << cont << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int k = in.ni();
        long ans = 0;
        for (int i = 1; i <= k; i++) {
            for (int j = 1; j <= k; j++) {
                for (int l = 1; l <= k; l++) {
                    ans += gcd(gcd(i,j),l);
                }
            }
        }
        out.println(ans);
    }
    public static long gcd(long a, long b){
        long c;
        if(a < b){
            c = a;
            a = b;
            b = c;
        }
        while(b > 0){
            c = a;
            a = b;
            b = c%b;
        }
        return a;
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 32980
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}


void solve(void){
    int N;
    cin >> N;
    vector <int> xs(N+1), ys(N+1), ts(N+1);
    xs[0] = ys[0] = ts[0] = 0;
    Rep(1, N, i) cin >> ts[i] >> xs[i] >> ys[i];
    rep(N, i) {
        int t = ts[i+1] - ts[i], d = abs(xs[i+1]-xs[i])+abs(ys[i+1]-ys[i]);
        if (t < d || (t-d) & 1) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

int N;
int A[200200];
int A2[200200];

signed main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        A2[i] = A[i];
    }
    sort(A2, A2 + N);
    rep(i, N) {
        if (A[i] == A2[N - 1]) {
            cout << A2[N - 2] << endl;
        } else {
            cout << A2[N - 1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int
ll dp[3001][3001] ;
ll a[3001];
ll  cs[3001] ;
ll ans( int i,int j)
{
    if(i==j)
    {
      dp[i][j]=a[i];
      return dp[i][j] ;
    }
    if(!dp[i+1][j])
       dp[i+1][j]=ans(i+1,j);

    if(!dp[i][j-1])
       dp[i][j-1]=ans(i,j-1);

       if(dp[i+1][j]<dp[i][j-1])
    dp[i][j]=cs[j]-cs[i-1]-dp[i+1][j];
       else 
    dp[i][j]=cs[j]-cs[i-1]-dp[i][j-1]; 

   // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
    return dp[i][j] ;
}


int main() {
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  cin>>a[i];

ll c_s=0;
   for(int i=1;i<=n;i++)
   {  c_s+=a[i] ;
     cs[i]=c_s ;
   }
   
    ans(1,n) ;
   ll x=0;
   ll y=0;
   int i=1;
   int j=n;
   int count=0;
  cout<< 2*dp[i][j]-cs[j]<<endl;
}

Measured memory_bytes: 70144
#include<iostream>
#include<cstring>
#include<cstdio> 
#define INF 0x3f3f3f3f

using namespace std;

const int N=20;
int c[N];
int n,m,x;
int a[N][N];
int ans=INF;
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++){
		cin>>c[i];
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<(1<<n);i++){
		int sum=0;//记录每种状态所花的钱 
		int res[N];//记录每种算法掌握程度 
		memset(res,0,sizeof(res));
		for(int j=0;j<n;j++){
			if(i&(1<<j)){//如果选择j+1本书 
				for(int k=1;k<=m;k++){
					res[k]+=a[j+1][k];
				}
				sum+=c[j+1];
			}
		}
		bool flag=0;
		for(int j=1;j<=m;j++){
			if(res[j]<x){
				flag=1;
				break;
			}
		}
		if(!flag) ans=min(sum,ans);
	}
	if(ans==INF) puts("-1");
	else cout<<ans<<endl;	
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
 #define fast() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll  long long
#define f(i,a,b) for(int i=a; i<b; i++)
#define pb push_back
#define MP make_pair
#define vi vector<int>
#define vll vector<long long>
#define F     first
#define S    second
#define all(x) x.begin(), x.end()

int main()
{
    fast();
 	int n, k;
 	cin >> n >> k;
 	int h[n];
 	for(int i = 0 ; i < n; i++)
 		cin >> h[i];
 	int cost[n] = {0};
 	cost[0] = 0;
 	cost[1] = abs(h[1] - h[0]);
 	for(int i = 2; i < n; i++)
 	{
 		int p = k;
 		int minn = INT_MAX;
 		for(int j = i-1; j >= 0; j--)
 		{
 			minn = min(minn, cost[j] + abs(h[i] - h[j]));
 			p--;
 			if(p == 0)
 			break;   
 		}
 		cost[i] = minn;
 	}
 	cout << cost[n-1];
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        StringBuilder sb = new StringBuilder(s);
        int idx = 0;
        int count = 0;

        while (idx < sb.length()-1) {
            if (sb.charAt(idx) != sb.charAt(idx+1)) {
                count += 2;
                sb.deleteCharAt(idx+1);
                sb.deleteCharAt(idx);
                if (idx != 0) idx--;
            } else {
                idx++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 26576
#include <bits/stdc++.h>
 
using namespace std;
 
int s[100005];
int main()
{
    int n,k,i,sum=0;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&s[i]);
    }
    n=n-k;
    sum=1;
    if(n>0)
    {
        sum=sum+n/(k-1);
        n=n-(sum-1)*(k-1);
    }
    if(n>0)
        sum=sum+1;
    printf("%d\n",sum);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef tuple<ll, ll, ll> tii;
typedef vector<pii> vii;

#define pb push_back
#define mp make_pair
#define sq(a) (a)*(a)
#define rep(i,a,b) for (int i = a; i < b; i++)
#define mod 1e9+7
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-7

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	IOS

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	double t1 = ceil((double)c / b);
	double t2 = ceil((double)a / d);
	if (t1 - t2 > 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
int main(){
	int H,W,h,w;
	in4(H,W,h,w);
	printf("%d",(H-h)*(W-w));
	return 0; 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   string s;
   cin>>s;
    if(s[s.size()-1]=='s') {
        cout<<s+"es"<<endl;
    }else {
        cout<<s+"s"<<endl;
    }
    
   
   return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        int N;
        int[] Pi=null;
        int[] Qi = null;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
            Pi = new int[N];
            Qi = new int[N];

            for (int i = 0; i < N; i++) {
                Pi[i] = sc.nextInt();
            }
            for (int i = 0; i < N; i++) {
                Qi[i] = sc.nextInt();
            }

        }
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = i+1;
        }

        int a =0;
        int b =0;
        int index = 1;
        while(intNextPermutation(arr)){
            if(compare(arr,Pi) ){
                a = index;
            }
            if(compare(arr,Qi)){
                b = index;
            }
            index++;
        }
        System.out.println(Math.abs(a -b));
    }

    public static boolean compare(int[] a,int[] b){
        for (int i = 0; i < a.length; i++) {
            if(a[i] != b[i]){
                return false;
            }
        }
        return true;
    }

    public static boolean intNextPermutation(int[] arr){
        int size = arr.length;
        for (int i = size - 2; i >=0; i--) {
            if(arr[i] < arr[i+1]){
                int j = size;
                do{
                    j--;
                }while (!(arr[i] < arr[j]));
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
                Arrays.sort(arr,i+1,size);
                return true;
            }
            if(i == 0){
                int[] temp = Arrays.copyOf(arr,size);
                for (int j = 0; j < size; j++) {
                    arr[j] = temp[(size-1) -j];
                }
            }
        }
        return false;
    }
}


Measured memory_bytes: 23632
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
ll dp[105][2]; 
// dp[a][b]:= 左から a bitまで見て 
// K以下が b=0:確定していない b=1確定している
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N)cin >> A[i];
    rep(i,105)dp[i][0] = dp[i][1] = -1;
    dp[50][0] = 0;

    for(int bit=49;bit>=0;bit--){ // bit bit 目を考える
        ll mask = (1LL<<bit);
        ll num = 0; // bit bit 目が立っている A[i] の個数
        rep(i,N)if(A[i]&mask)num++; // もしもbitが立っていたらnumを加算

        if(dp[bit+1][1]>=0)chmax(dp[bit][1],dp[bit+1][1] + mask*max(num,N-num));
        
        if(dp[bit+1][0]>=0){
            if(K&mask){
                chmax(dp[bit][1],dp[bit+1][0] + mask*num);
                chmax(dp[bit][0],dp[bit+1][0] + mask*(N-num));
            }else{
                chmax(dp[bit][0],dp[bit+1][0] + mask*num);
            }
        }
    }
    cout << max(dp[0][0],dp[0][1]) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+10;
const int mod=1e9+7,inv2=(mod+1)/2;
int n,m;
int dp[maxn][maxn],val[maxn],tot=1;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&val[i]);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)if(i!=j)dp[i][j]=val[i]<val[j];
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		dp[x][y]=dp[y][x]=(dp[x][y]+dp[y][x])*1LL*inv2%mod;
		for(int i=1;i<=n;i++)
		{
			if(i==x||i==y)continue;
			dp[i][x]=dp[i][y]=(dp[i][x]+dp[i][y])*1LL*inv2%mod;
			dp[x][i]=dp[y][i]=(dp[x][i]+dp[y][i])*1LL*inv2%mod;
		}
		tot=tot*1LL*2%mod;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	for(int j=1;j<i;j++)ans+=dp[i][j]*1LL*tot%mod,ans%=mod;
	printf("%d\n",ans);

}

Measured memory_bytes: 35584
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define LL long long
int N, K;
LL ans = 8000000000000000000;
std::vector<std::pair<int, int>> xy;
std::vector<int> x;
std::vector<int> y;
int main() {
	std::cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int ta, tb;
		std::cin >> ta >> tb;
		xy.push_back({ ta,tb });
		x.push_back(ta);
		y.push_back(tb);
	}
	std::sort(x.begin(), x.end());
	std::sort(y.begin(), y.end());
	for (int i = 0; i < N - 1; i++) {
		for (int j = i; j < N; j++) {
			for (int p = 0; p < N - 1; p++) {
				for (int q = p; q < N; q++) {
					int inc = 0;
					for (int g = 0; g < N; g++) {
						if (x[i] <= xy[g].first && xy[g].first <= x[j]) {
							if (y[p] <= xy[g].second&&xy[g].second <= y[q]) {
								inc++;
							}
						}
					}
					if (inc >= K) {
						ans = std::min(ans, (LL)(x[j] - x[i])*(LL)(y[q] - y[p]));
					}
				}
			}
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
using namespace std;
#define fr(i,n) for (long long int i = 0; i < n; i++)
#define fro(i,m,n) for (long long int i = m; i < n; i++)
#define MAX_CHAR 26
#define vi vector<int>
#define vll vector<ll>
#define pb push_back


void io(){
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}

void solve(){
  //io();
  ll dp[100000]={0};
  dp[0]=0;
  ll n,k;
  cin>>n>>k;
  ll h[n];
  fr(i,n){
    cin>>h[n-1-i];
  }
  dp[1]=abs(h[1]-h[0]);
  fro(i,2,n){
    ll mi=1000000007;
    fro(j,1,k+1){
      if(i-j<0){
        break;
      }
      mi=min(mi,dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=mi;
    //std::cout << dp[i] << '\n';
  }
  std::cout << dp[n-1] << '\n';


}
int main(){
  std::ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef pair<int,int> pr;

vector <pr> ans;

int main() {
  int n;
  scanf("%d",&n);
  int m=((n&1)?n:n+1);
  for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
      if (i+j!=m) ans.push_back(pr(i,j));
  printf("%d\n",ans.size());
  for(int i=0;i<ans.size();i++) printf("%d %d\n",ans[i].FR,ans[i].SE);
  return 0;
}

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    vector<int> a(3);
    for (int i = 0; i < 3; ++i) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a.back() - a[0] << endl;
}


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

int main(){
char s[5];
scanf("%s",s);

char tmp;
int i;
tmp =s[0];
for(i=0;i<3;++i){
	
  if(tmp==s[i+1]){
	  
	  printf("Bad");
	  return 0;
  }
  tmp = s[i+1];
}

printf("Good");
return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.HCPC2019_15
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] ts = new int[n];
            for (int i = 0; i < n; i++) ts[i] = ReadInt();
            int[][] abs = new int[m][];
            for(int i = 0; i < m; i++) abs[i] = ReadInts();

            int[,] dp = new int[n, m];
            for(int i = 0; i < m; i++)
            {
                if (abs[i][0] <= ts[0] && ts[0] <= abs[i][1]) dp[0, i] = 0;
                else dp[0, i] = -1;
            }

            for(int i = 1; i < n; i++)
            {
                for(int j = 0; j < m; j++)
                {
                    if (ts[i] < abs[j][0] || abs[j][1] < ts[i]) dp[i, j] = -1;
                    else
                    {
                        int max = 0;
                        for(int k = 0; k < m; k++)
                        {
                            if (dp[i - 1, k] == -1) continue;

                            max = Max(max, dp[i - 1, k]
                                + Abs(abs[j][2] - abs[k][2]));
                        }
                        dp[i, j] = max;
                    }
                }
            }

            int res = 0;
            for (int i = 0; i < m; i++) res = Max(res, dp[n - 1, i]);
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



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

int main() {
  ll x,a,b;
  cin >> x >> a >> b;
  if(a>=b) cout << "delicious" << endl;
  else if(b-a<=x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,ans;
  cin >> A >> B >> C;
 
  ans=(B+C)-A;
  
  if(ans <= 0){
    cout << 0 << endl;
  }else{
    cout << ans << endl;
  }

  }
  


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
}

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int n;
int a[N];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

	cin >> n;

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

	sort(a, a + n);

	int cnt = 0;
	for (int i = 1; i < N; i++) {
		int lb = lower_bound(a, a + n, i) - a;
		int ge = n - lb;
		if (ge == n - ge) {
			cnt++;
		}
	}

	cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  string s;
  cin >> s;
  int ans = 700;
  if(s[0] == 'o') ans += 100;
  if(s[1] == 'o') ans += 100;
  if(s[2] == 'o') ans += 100;
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll d, n;
double x[100][100];

int main(){
    cin >> n >> d;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> x[i][j];
        }
    }


    double tmp;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            tmp = 0.0;
            for(int k = 0; k < d; k++){
                tmp += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
            }
        ll mem = tmp;
        mem = sqrt(mem);
        tmp = sqrt(tmp);
        if(abs((double)mem - tmp) <= 0.00001)    ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
AA = [2,4,8,16,32,64]

if N >=64:
    print(64)

elif N in AA:
    print(N)

else:
    for i in range(6):
        num = AA[i]
        if num < N:
            pass

        elif num > N:
            print(round(num/2))
            break


Measured memory_bytes: 9152
#include <iostream>
using namespace std;
int main(void){
    int N, A, B, C, D, total_X, total_Y;
    cin >> N >> A >> B >> C >> D;
    
    if(N%A!=0){
        total_X=(N/A+1)*B;
    }
    else total_X=(N/A)*B;
    
    if(N%C!=0){
        total_Y=(N/C+1)*D;
    }
    else total_Y=(N/C)*D;

    if(total_X>total_Y) cout << total_Y << endl;
    else cout << total_X << endl;
    return 0;
}
    


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
using namespace std;

typedef long long ll;

int ap[200005][30];
string anc[200005];

bool comp(const string &s, const string &t) {
	if (s == "-1") return true;
	if (t == "-1") return false;
	if (s.length() != t.length()) return s.length() > t.length();
	return s >= t;
}

int main() {
	string s; cin >> s;
	for (int c = 0; c <= 'z' - 'a'; ++c) ap[s.length()][c] = -1;
	for (int i = (int)s.length() - 1; i >= 0; --i) {
		for (int c = 0; c <= 'z' - 'a'; ++c) {
			ap[i][c] = ('a' + c == s[i]) ? i : ap[i + 1][c];
		}
	}

	deque<int> que;
	for (int i = 0; i <= (int)s.length(); ++i) anc[i] = "-1";
	for (int c = 0; c <= 'z' - 'a'; ++c) {
		if (ap[0][c] == -1) {
			cout << (char)('a' + c) << endl;
			return 0;
		}
		que.push_back(ap[0][c]);
		anc[ap[0][c]] = "";
	}
	string ans = "-1";
	while (!que.empty()) {
		int pos = que.front(); que.pop_front();
		string t = anc[pos] + s[pos];
		for (int c = 0; c <= 'z' - 'a'; ++c) {
			if (ap[pos + 1][c] == -1) {
				if (comp(ans, (t + (char)('a' + c)))) ans = (t + (char)('a' + c));
				continue;
			}
			if (comp(t, anc[ap[pos + 1][c]])) continue;
			que.push_back(ap[pos + 1][c]);
			anc[ap[pos + 1][c]] = t;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 197636
K, A, B = map(int, input().split())

if not B - A <= 2:
    if not (A == K or A == K + 1):
        if (K - A) % 2 == 0:
            print(B + (B - A) * ((K - A - 1) // 2) + 1)
        else:
            print(B + (B - A) * ((K - A - 1) // 2))
    else:
        print(K + 1)

else:
    print(K + 1)


Measured memory_bytes: 2940