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

#define M 1000000007
#define pb emplace_back
#define f first
#define s second
#define rep(i, st, ed) for(ll i=st; i<ed; ++i)
#define repn(i, st, ed) for(ll i=st; i<=ed; ++i)
#define repb(i, ed, st) for(ll i=ed; i>=st; --i)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vec;
typedef vector<pll> vecp;
typedef map<ll, ll> mpll;

const long double PI  = 3.141592653589793238463;
const int N = 1e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << to_string(H) << endl;
  debug_out(T...);
}
#define LOCAL 3
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve()
{
	ll a, b;
  cin>>a>>b;
  cout<<max(a+b, max(a-b, a*b))<<endl;
}


int main()
{
	ll Tests = 1;
    //cin>>Tests;
    while(Tests--)
    {
    	solve();
    }
    return 0;
}

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

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

    int n, a;
    cin >> n;

    // vector<int> a(n + 1);

    vector<int> cnt(n);
    for (int i = 1; i < n; i++) {
    	cin >> a;
    	cnt[a-1]++;
    }

    for (int i = 0; i < n; i++) {
    	cout << cnt[i] << "\n";
    }
}

Measured memory_bytes: 3984
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

int main(){
  string s;
  cin>>s;
  int cnt=0;
  for(int i=1;i<s.size();i++){
      if(s[i]!=s[i-1])
        cnt++;
  }
  cout<<cnt<<"\n";
}

Measured memory_bytes: 512
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		while (read())
			solve();
	}
	
	static int n, m;
	static int[] M = new int[100];
	static String[] N = new String[100], B = new String[1000];
	static boolean read() {
		n = sc.nextInt(); m = sc.nextInt();
		if (n == 0 && m == 0) return false;
		for (int i = 0; i < n; i++) {
			N[i] = sc.next();
			M[i] = sc.nextInt();
		}
	
		for (int i = 0; i < m; i++) {
			B[i] = sc.next();
		}
		
		return true;
	}
	
	static void solve() {
		int res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				boolean ok = true;
				for (int k = 7; k >= 0; k--) {
					char a = N[i].charAt(k), b = B[j].charAt(k);
					if (a == '*') break;
					else if (a != b) ok = false;
				}
				if (ok) {
					res += M[i];
				}
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 13000
a,b,c,d=map(int,input().split())

s=0
while s==0:
    c-=b
    if c<1:
        s=1
        break

    a-=d
    if a<1:
        s=2
        break

if s==1:
    print('Yes')

if s==2:
    print('No')        

Measured memory_bytes: 9176
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
	string s;cin>>s;
	FOR(i,0,s.size()/2){
		if(s[i]!=s[s.size()-i-1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    vll a(n), b(n), c(n);
    rep(i, n)
        cin >> a[i];
    rep(i, n)
        cin >> b[i];
    rep(i, n-1)
        cin >> c[i];
    int ans = 0;
    rep(i, n)
        ans += b[i];
    rep(i, n) {
        if (a[i]+1 == a[i+1])
            ans += c[a[i]-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def eprint(s):
    if type(s) != type('str'):
        s=str(s)

    sys.stderr.write(s+'\n')
    return

def main():
    n = int(input())
    As = list(map(int, input().split()))
    As.sort()
    for i in range(n-1):
        if As[i+1] == As[i]:
            print('NO')
            return
    print('YES')
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 27184
A = int(input());
answer = str();
i=0;

if(A==0):
    print("0");
else:
    while(A!=0):
        if(A%abs(pow(-2,i+1))!=0):
            A-=pow(-2,i);
            answer = str(1) + answer;
        else:
            answer = str(0) + answer;
        i+=1;
    print(answer);


Measured memory_bytes: 3060
program polynomial_construction
  implicit none
  integer :: p, a(0:3000) = 0, b(0:3000) = 0, i, j
  integer :: f(0:3000) = 0, g(0:3000) = 0, h
  read(*,*) p
  read(*,*) a(0:p-1)
  f(0) = 1
  do i = 1, p
    f(i) = mod(i*f(i-1),p)
  end do
  do i = 0, p-1
    if (a(i) == 0) cycle
    h = mod(f(i)*f(p-1-i),p)
    if (mod(p-1-i,2) == 1) h = p-h
    h = inv(h,p)
    g(0:p) = 0
    g(1) = p-1
    g(p) = 1
    do j = p-1, 0, -1
      b(j) = mod(b(j)+h*g(j+1),p)
      g(j) = mod(g(j)+i*g(j+1),p)
    end do
  end do
  write(*,*) b(0:p-1)
contains
  function inv(n,p) result(y)
    integer, intent(in) :: n, p
    integer :: a, b, x, y, t, q
    a = mod(n,p)
    b = p
    x = 0
    y = 1
    do while (b /= 0)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = mod(y,p)
    if (y < 0) y = y+p
  end
end program polynomial_construction

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;


int main() {
    int a,b,c;
    cin >> a >> b >> c ;  
    int temp;
    temp = a;
    a=b;
    b=temp;
    temp = a;
    a = c;
    c = temp;
    cout << a << ' '<< b << ' '<< c;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
class dj{
public:
  vector<int>rank,p;
  dj(){}
  dj(int size){
    rank.resize(size,0);
    p.resize(size,0);
    for(int i=0;i<size;++i){ p[i]=i; rank[i]=0;}
  }
  bool same(int x,int y){
    return findset(x)==findset(y);
  }
  void unite(int x,int y){
    link(findset(x),findset(y));
  }
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
    }else{
      p[x]=y;
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  int findset(int x){
    if(x!=p[x]) p[x]=findset(p[x]);
    return p[x];
  }
};

int main(){
  int n,a,b,q;
  int t;

  cin>>n>>q;
  dj ds=dj(n);

  for(int i=0;i<q;++i){
    cin>>t>>a>>b;
    if(t==0) ds.unite(a,b);
    else if(t==1){
      if(ds.same(a,b)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3196
/*input
1
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793238462;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r; cin >> r;
    cout << fixed << setprecision(20);
    cout << 2 * pi * r;

    return 0;
}

Measured memory_bytes: 3804
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N;
    cin >> N;
    vector<long long> A(N);
    map<long long, int> m;
    int Zero = 0;;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (A[i] == 0) Zero++;
        m[A[i]]++;
    }
    if (m.size() == 1 && A[0] == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    if (m.size() == 2 && N % 3 == 0 && N/3 == Zero) {
        cout << "Yes" << endl;
        return 0;
    }
    if (m.size() != 3) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 1; i < N; i++) {
        if (m[A[i]] != m[A[i-1]]) {
            cout << "No" << endl;
            return 0;
        } 
    }

    vector<long long> b;
    for (auto i : m) {
        b.push_back(i.first);
    }
    if ((b[0] ^ b[1]) != b[2]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;


}

Measured memory_bytes: 5632
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
/*#define fast ios_base::sync_with_stdio(0); cin.tie(0)*/
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
const double pi = acos(-1);
typedef long long ll;
int main()
{
	//fast;
	
	ll a,b,c,x;
	cin>>a>>b>>c>>x;
	if((abs(a-b)<=x and abs(b-c)<=x)or abs(a-c)<=x)
	cout<<"Yes\n";
	else cout<<"No\n";
}

Measured memory_bytes: 3576
//defines e includes
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep1(i, n) for(i=0;i<(int)n;i++)
#define rep2(i, a, b) for(i=(int)a;i<(int)b;i++)
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define p_b pop_back
#define p_f pop_front
#define mp make_pair
#define MAX 100010
#define oo INT_MAX
using namespace std;
//tipagem de pares
typedef pair<int, int> ii;
typedef pair<char, char> cc;
typedef pair<int, char> ic;
typedef pair<char, int> ci;
typedef pair<int, string> istr;
//tipagem de vetores
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<istr> vistr;
typedef vector<bool> vb;
//tipagem de outras estruturas
typedef queue<int> qi;
typedef deque<int> dqi;
//tipagem de tipos primitivos
typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
	
	fastio;
	int n, m, i;
	cin >> n >> m;
	vistr sub;
	rep1(i, m){
		int p; string v;
		cin >> p >> v;
		sub.pb(mp(p, v));
	}
	int pen = 0;
	int cor = 0;
	vb ac(MAX, false);
	vi wa(MAX, 0);
	rep1(i, m){
		if(sub[i].nd == "AC"){
			ac[sub[i].st] = true;
		}
		else{
			if(!ac[sub[i].st])
				wa[sub[i].st]++;
		}

	}
	rep1(i, n+1){
		if(ac[i]){
			cor++;
			pen += wa[i];
		}
	}

	cout << cor << " " << pen << '\n';

	return 0;
}

Measured memory_bytes: 6896
using System;

namespace ABC144A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);

            if (a < 1 || a > 9 || b < 1 || b > 9)
                Console.WriteLine(-1);
            else
                Console.WriteLine(a * b);
            Console.ReadKey();
            

        }
    }
}


Measured memory_bytes: 13140
h,w=map(int,input().split())
s=[[0]*(w+2)]
for i in range(h):
  t=[0]
  u=input()
  for j in range(w):
    t.append(u[j])
  t.append(0)
  s.append(t)
s.append([0]*(w+2))

for i in range(1,h+1):
  v=[]
  for j in range(1,w+1):
    x=[s[i-1][j-1],s[i-1][j],s[i-1][j+1],s[i][j-1],s[i][j+1],s[i+1][j-1],s[i+1][j],s[i+1][j+1]]
    if s[i][j]=='#':
      v.append('#')
    else:
      v.append(x.count('#'))
  
  print(*v, sep='')

Measured memory_bytes: 3444
#define PN 1000000007

#include <algorithm>
#include <iostream>

long long Modpow(long long a, long long n, long long mod)
{
    long long ans = 1;
    while(n > 0)
    {
        if(n & 1)
        {
            ans = ans * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return ans;
}

long long Modinv(long long a, long long mod)
{
    return Modpow(a, mod - 2, mod);
}

int main()
{
    long long goalX = 0;
    long long goalY = 0;
    std::cin >> goalX >> goalY;
    if((goalX + goalY) % 3 != 0)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    const long long n = (goalX + goalY) / 3;
    const long long r = (goalX < goalY ? goalX : goalY) - n;

  	if(r < 0)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
  
  	// nCr
    unsigned long long numer = 1;
    unsigned long long denom = 1;
    
    for(long long i = 0; i < r; ++i)
    {
        numer = numer * (n - i) % PN;
        denom = denom * (i + 1) % PN;
    }
    std::cout << numer * Modinv(denom, PN) % PN << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
     //https://www.codechef.com/viewsolution/28454497
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define int long long
vector < ll> primes;
 int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n,m;
bool isvalid(int x,int y){
  return (x>=0 and x<n and y>=0 and y<m);
}
void Sieve(ll n) 
{ 
    bool prime[n+1];
	for(ll i=0;i<n+1;++i)
		prime[i]=true;
    for (ll p=2;p*p<=n;++p) 
    {
        if (prime[p] == true) 
        {  
            for (ll i=2*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    }  
    for(ll p=2; p<=n; p++) 
       if (prime[p]) 
		primes.push_back(p);  
}
 const int N = 5e5 + 5;
 	int connected;
	int par[N], sz[N];
 
struct DSU
{

	void init(int n) 
	{
		for(int i=1;i<=n;i++)
		{
			par[i]=i;
			sz[i]=1;
		}
		connected=n;
	}
 
	int getPar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}
 
	int getSize(int k)
	{
		return sz[getPar(k)];
	}
 
	void unite(int u, int v)
	{
		int par1=getPar(u), par2=getPar(v);
 
		if(par1==par2)
			return;
 
		connected--;
 
		if(sz[par1]>sz[par2])
			swap(par1, par2);
 
		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
	}
};
 
 

DSU dsu;
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
        return gcd(b % a, a); 
} 
ll powermod(ll x, ll y){
    if(y==0)
    return 1;
        
    if(y%2==0)
    return (powermod(x,y/2)*powermod(x,y/2))%mod;
    else
    return (((powermod(x,y/2)*powermod(x,y/2))%mod)*x)%mod;
}
   
int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
   
   int n,k,s;
   cin>>n>>k>>s;
   int cnt=0;
   for(int i=0;i<n;i++)
   {
       if(cnt<k)
       {
           cout<<s<<" ";
           cnt++;
       }
       else 
       {
           if(s-1!=0)cout<<s-1<<" ";
           else cout<<s+1<<" ";
       }
   }
}



Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
#include  <cstdio>
#include  <sstream>
#include  <bitset>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using ld = long double;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vd = vector<double>;
using Vld = vector<long double>;
using Vll = vector<vector<ll> >;
using Vldd = vector<vector<ld> >;
using Vs = vector<string>;
using Vb = vector<bool>;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Pli = pair<ll, int>;
using VPi = vector<Pi>;
using VPl = vector<Pl>;
using VPli = vector<Pli>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

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

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };


int main()
{
	int x;
	cin >> x;
	if (x) cout << 0 << endl;
	else cout << 1 << endl;
}


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

int main()
{
	int64_t N;
	scanf("%lld", &N);
	int64_t min{1ll << 60};
	for (int64_t i{1}; i * i <= N; i++)
		if (N % i == 0)
			min = std::min(min, i + N / i);
	
	printf("%lld\n", min - 2);

	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque, Counter
from sys import exit
import math
import copy
from bisect import bisect_right

import sys
sys.setrecursionlimit(1000000)
import heapq
INF = 10**10

def dijkstra(graph, start, n):
    h = []
    heapq.heappush(h, (0, start))
    costs = [INF for _ in range(n)]
    while h:
     cost, cur = heapq.heappop(h)
     if costs[cur] != INF:
         continue
     costs[cur] = cost
     for edge in graph[cur]:
         ecost, tgt = edge
         if costs[tgt] == INF:
             heapq.heappush(h, (cost + ecost, tgt))

    return costs

def main():
    nums = getList()
    for i in range(5):
        if nums[i] == 0:
            print(i+1)
            return
if __name__ == "__main__":
    main()


Measured memory_bytes: 67988
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>

using namespace std;

int func(string &s, vector<pair<char, char> > &vp, int pos)
{
  int N = s.size();
  int Q = vp.size();
  for (int i = 0; i < Q; ++i) {
    char t = vp[i].first;
    char d = vp[i].second;
    if (s[pos] == t) {
      if (d == 'L') --pos;
      else ++pos;
      if (pos < 0) return -1;
      if (pos >= N) return N;
    }
  }
  return pos;
}

int myfind(string &s, vector<pair<char, char> > &vp, int num)
{
  int N = s.size();
  int L = -1;
  int R = N;
  while (R - L > 1) {
    int M = (L + R) / 2;
    if (func(s, vp, M) < num) {
      L = M;
    }
    else {
      R = M;
    }
  }
  return R;
}

int main()
{
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  vector<pair<char, char> > vp;
  for (int i = 0; i < Q; ++i) {
    char t, d;
    cin >> t >> d;
    vp.push_back(make_pair(t, d));
  }

  int begin = myfind(s, vp, 0);
  int end = myfind(s, vp, N);
  cout << end - begin << endl;
  
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <algorithm>
#include <functional>

using namespace std;

int main (void){
    int n;
    vector<int> p;
    int old,now,fu;
    int count = 0;

    cin >> n;

    cin >> old;
    cin >> now;


    for(int i=2; i < n;i++){
        cin >> fu;
        int a = (now - old) * (now - fu);
        if(a < 0 ) count ++;
        old = now;
        now = fu;
    }

    cout << count << endl;

    return 0; 
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

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

  ll c1 = 0;
  if (a > 0) {
    c1 = (a - 1) / x + 1;
  }
  ll ans = b/x + 1 - c1;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
var main = function main(input) {
  var args = input.split('\n')
  var pay = +args[0]
  var oneCoins = +args[1]
  var rest = pay % 500
  if (rest - oneCoins > 0) {
      console.log('No')
  } else {
      console.log('Yes')
  }

}
 
main(require('fs').readFileSync('/dev/stdin', 'utf-8'))


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

int main(){
  int N;
  cin>>N;
  multiset<int> L;
  for (int i=0; i<N; i++){
    int x;
    cin>>x;
    L.insert(x);
  }
  int longest=*L.rbegin();
  L.erase(L.find(*L.rbegin()));
  int other_sum=accumulate(L.begin(),L.end(),0);
  if (other_sum>longest){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  } 
}
  

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

static const int MAX = 1e5 + 1;

// Union-Find木
int par[MAX]; // 親の番号

// n要素で初期化
void init(int n) {
  for(int i = 0; i < n; i++) par[i] = i;
}

// 木の根を求める
int find(int x) {
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyが同じ集合に属するか
bool same(int x, int y) {
  return find(x) == find(y);
}

// xとyの属する集合を併合
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x == y) return;
  par[x] = y;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  
  vector<int> p(n);
  for(int i = 0; i < n; i++) cin >> p.at(i);
  
  init(n);
  
  int x, y;
  for(int i = 0; i < m; i++){
    cin >> x >> y;
    unite(x, y);
  }
  
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(same(i + 1, p.at(i))) ans++;
  }
  
  cout << ans << "\n";
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
int a[114514];
signed main(){
	int n;
	cin>>n;
	int sum=0;
	rep(0,i,n)cin>>a[i];
	rep(0,i,n){
		if(a[i+1]>a[i])sum++;
	}
	c(sum)
}	


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int a, b;
  cin >> a >> b;
  int c = abs(a + b);
  if (c % 2 == 0) {
    cout << c / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

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

#include <cmath>
#include <iostream>
int main() {
  double N;
  cin >> N;
  vector<long long>vec(N);
  for(long long i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  double ans =0;
  for(long long i = 0; i < N; i++){
    ans += vec.at(i);
  }

    double ANS = ans / N;
  ANS = round(ANS);
  long long sna = 0;
  for(long long i = 0; i < N; i++){
    sna += (vec.at(i) - ANS)*(vec.at(i) - ANS);
  }
  cout << sna << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n;
    string s;
    cin >> s;
    n = s.size();

    for (int i = 1; i <= n - 1; i++) {
    	if (s[i - 1] != s[n - i - 1]) {
    		cout << "-1";
    		return 0;
    	}
    }

    if (s[0] == '0' || s.back() == '1') {
    	cout << "-1";
    	return 0;
    }

    vector<pair<int, int>> v;

    int last = 1, i = 2;

    for (int i = 2; i <= n; i++) {
    	if (s[i - 2] == '1') {
    		v.push_back({last, i});
    		last = i;
    	}
    	else {
    		v.push_back({last, i});
    	}
    }

    for (auto p : v) {
    	cout << p.first << " " << p.second << "\n";
    }

    return 0;   
}

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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::string S){
  for(int i=0; i<S.length(); i++) {
    if(S[i]+N>'Z') {
      S[i] = 'A'+N-1-('Z'-S[i]);
    } else
      S[i] = S[i]+N;
  }
  std::cout << S << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n, a[100000], b1, b2;
long long G(long long p1, long long p2) { if (p2 == 0)return p1; return G(p2, p1%p2); }
int main() {
	cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] % 2 == 1)b1++; else b2++; }
	int turn = 0;
	while (b1 == 1 && b2 % 2 == 0) {
		bool flag = false;
		for (int i = 0; i < n; i++) { if (a[i] % 2 == 1) { a[i]--; if (a[i] == 0)flag = true; } }
		if (flag == true)break;
		long long gcd = a[0]; for (int i = 1; i < n; i++)gcd = G(gcd, a[i]);
		for (int i = 0; i < n; i++) { a[i] /= gcd; }
		b1 = 0; b2 = 0;
		for (int i = 0; i < n; i++) { if (a[i] % 2 == 0)b2++; else b1++; }
		turn ^= 1;
	}
	while (true) {
		if (b2 % 2 == 1) { b2--; b1++; }
		else {
			if (turn == 0)cout << "Second" << endl;
			else cout << "First" << endl;
			break;
		}
		turn ^= 1;
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h =sc.nextInt(), a=sc.nextInt();
		if(h%a==0) System.out.println(h/a);
		else System.out.println(h/a+1);
	}
}


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

/*
usage:

std::uint_fast64_t i;
decltype(std::sign(i)) // => std::int_fast64_t
*/

namespace tools {
  template <typename T> constexpr typename std::make_signed<T>::type sign(const T x) noexcept {
    return x;
  }
}

int main() {
  std::string s, t;
  std::cin >> s >> t;

  for (std::int_fast64_t s_i = tools::sign(s.size()) - tools::sign(t.size()); s_i >= 0; --s_i) {
    bool is_matched = true;
    for (std::int_fast64_t t_j = 0; t_j < tools::sign(t.size()); ++t_j) {
      const std::int_fast64_t s_j = s_i + t_j;
      if (s[s_j] != '?' && s[s_j] != t[t_j]) {
        is_matched = false;
        break;
      }
    }

    if (is_matched) {
      std::string answer = s;
      for (std::int_fast64_t t_j = 0; t_j < tools::sign(t.size()); ++t_j) {
        const std::int_fast64_t s_j = s_i + t_j;
        answer[s_j] = t[t_j];
      }
      for (std::int_fast64_t s_j = 0; s_j < tools::sign(s.size()); ++s_j) {
        if (answer[s_j] == '?') answer[s_j] = 'a';
      }

      std::cout << answer << std::endl;
      return 0;
    }
  }

  std::cout << "UNRESTORABLE" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

ll sum[200001];

int main(){
  int N;
  while(~scanf("%d",&N)){
    vector<ll> baumkuchen;

    memset(sum,0,sizeof(sum));
    for(int i=0;i<N;i++){
      ll width;
      scanf("%lld",&width);
      baumkuchen.push_back(width);
      sum[i+1] = sum[i] + width;
    }
    
    for(int i=0;i<N;i++){
      sum[N + i + 1] = sum[N] + sum[i + 1];
    }

    ll lhs = 0;
    ll rhs = 100000000000000LL;
    for(int round = 0; round < 50; round++){
      ll mid = lhs + (rhs - lhs) / 2LL;

      bool isok = false;
      for(int i=0;i<N;i++){
        ll offset = sum[i];
        int div_idx = lower_bound(sum,sum + 2 * N,offset + mid) - sum;
        div_idx = lower_bound(sum,sum + 2 * N,sum[div_idx] + mid) - sum;
        div_idx = lower_bound(sum,sum + 2 * N,sum[div_idx] + mid) - sum;
        if(div_idx <= i + N){
          isok = true;
          break;
        }
      }
      if(isok){
        lhs = mid;
      }
      else{
        rhs = mid;
      }
    }

    printf("%lld\n",lhs);
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>

using namespace std;

int x[11][11];

int main() {
  int N, D;
  while (cin >> N >> D) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < D; j++) {
        cin >> x[i][j];
      }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int dist = 0;
        for (int k = 0; k < D; k++) {
          dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        }
        for (int i = 0; i * i <= dist; i++) {
          if (i * i == dist) ans++;
        }
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll h,w,k;
cin>>h>>w>>k;
string s[h]={};
ll a[h]={};
ll b[w]={};
ll ca=1;
for(ll i=0; i<h; i++){
cin>>s[i];}
for(ll i=0; i<h; i++){
for(ll j=0; j<w; j++){
if(s[i].at(j)=='#')
a[i]++;}
//cout << a[i] << endl;
}
ll y = 0;
ll as= 0;
for(ll i=0; i<h; i++){
if(a[i]!=0){
y=i;
break;}}
//cout << "y" << " " << y << endl;
ll x = 0;
for(ll i=h-1; i>=0; i--){
if(a[i]!=0){
x=i;
break;}}
//cout << "x " << x << endl;
ll yy = y;
ll xx = x;
x = h - 1 - x;
for(ll i=yy; i<=xx; i++){
if(a[i]==0){
y++;
continue;}
else{
  
for(ll j=0; j<w; j++){
if(as==0){
if(s[i].at(j)=='#'){
as++;}
b[j]=ca;}
else{
if(s[i].at(j)=='#'){
ca++;}
b[j]=ca;}}
//cout << b[0] << b[1] << b[2] << endl;
for(ll n=0; n<y+1; n++){
for(ll m=0; m<w; m++){
cout << b[m] << " ";}
cout << endl;}
//cout << y << endl; 
y=0;
ca++;
as = 0;}}
for(ll i=0; i<x; i++){
for(ll j=0; j<w; j++){
cout << b[j] << " ";}
cout << endl;}}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    vector<int> num;
    map<int, int> cnt;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(cnt.count(A[i])){
            cnt[A[i]]++;
        }else{
            cnt[A[i]] = 1;
        }
    }
    sort(A.begin(), A.end());
    num.push_back(cnt[A[0]]);
    for(int i = 1; i < N; i++){
        if(A[i] != A[i - 1])num.push_back(cnt[A[i]]);
    }
    sort(num.begin(), num.end());
    int ans = 0;
    int kind = num.size();
    for(int i = 0; i < kind - K; i++){
        ans += num[i];
    }
    cout << ans << endl;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > v;
    rep (i, m) {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());
    int left = -1;
    int cnt = 0;
    rep (i, m) {
        if (left <= v[i].second) {
            cnt++;
            left = v[i].first;
        }
    }
    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> x;
	int temp;
	for(int i=0;i!=2*n;++i){
		cin>>temp;
		x.push_back(temp);
	}
	sort(x.begin(),x.end());
	int ans=0;
	for(int i=0;i<2*n-1;i+=2)
		ans+=min(x[i],x[i+1]);
	cout<<ans;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
	int n,m;
	scanf("%d",&n);
	m=n;
	int sum=0;
	while (n) {
		sum+=n%10;
		n/=10;
		
	}
	if (m%sum==0) printf("Yes");else printf("No"); 
} 

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++){
    scanf("%hu",&A[i]);
  }
  
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }

  for(i=0;i<n;i++){
    C[A[i]]++;
  }

  for(i=1;i<VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  
  for(i=n-1;i>=0;i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
  
  for(i=0;i<n;i++){
    printf("%hu",B[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  return 0;
}



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

signed main() {
  int a, b;
  cin >> a >> b;

  for (int i = 1; i <= 10000; i++) {
    int c = i * 8 / 100;
    int d = i * 10 / 100;
    if (c == a && d == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
import copy
def main():

    N = int(input())
    A =list(map(int, input().split()))
    AD = copy.copy(A)
    AAA = []

    while len(AD) > 1:
        if len(AD)%2==1:
            AD.append(0)
        for i in range(0,len(AD),2):
            AAA.append(AD[i]^AD[i+1])
        AD = copy.copy(AAA)
        AAA.clear()
    
    for i in range(N):
        A[i] = AD[0] ^ A[i]
    
    print(*A)





if __name__ == '__main__':
    main()

Measured memory_bytes: 103152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin >> S >> T;

    int count=0;

    for(int i=0,j=0;i<S.size(),j<T.size();i++,j++)
    {
        if(S[i]!=T[j])
            count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  map<ll,ll>mp;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin>>a[i];
    mp[a[i]]++;
  }
  sort(a,a+n);
  ll ans=0;
  for(ll i=n-1;i>=0;i--){
    if(mp[a[i]]==0)continue;
    ll c;
    for(ll j=0;;j++){
      if(pow(2,j)>a[i]){
        c=j;
        break;
      }
    }
      ll sa=pow(2,c)-a[i];
      mp[a[i]]--;
    ll d=0;
      if(mp[sa]>0){
        ans++;
        mp[sa]--;
        d=1;
      }
      if(d==0)mp[a[i]]++;
    
  }
  cout<<ans;
}

Measured memory_bytes: 26752
import java.util.*;

public class Main {

	public static int span; // 何日間のスケジューリングをするか
	public static int minus[]; // 26種類のコンテストの飽きやすさ
	public static int plus[][]; // 26種類のコンテストの満足感

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		span = Integer.parseInt(sc.next()); // 何日間のスケジューリングをするか
		minus = new int[26]; // 26種類のコンテストの飽きやすさ
		for (int i = 0; i < 26; i++) {
			minus[i] = Integer.parseInt(sc.next());
		}
		plus = new int[span][26]; // 26種類のコンテストの満足感
		for (int d = 0; d < span; d++) {
			for (int i = 0; i < 26; i++) {
				plus[d][i] = Integer.parseInt(sc.next());
			}
		}

		// 提出用配列を初期化しておく（初期値はまぁ適当に26種類のコンテストをローテーション開催で）
		int teishutu[] = new int[span];
		for (int d = 0; d < span; d++) {
			teishutu[d] = (d % 26) + 1;
		}

		// 貪欲法をやってみよう（ちゃんと貪欲法になっているかは知らん）
		for (int d = 0; d < span; d++) {

			// d日目は何を開催したら満足度最大かを求めて、提出用配列をそれにする
			int bestKaisai = 1;
			long bestScore = -99999;
			for (int i = 0; i < 26; i++) {

				teishutu[d] = i + 1;
				long score = calc(teishutu);
				// System.out.println(Arrays.toString(teishutu) + "\t" + score);

				if (score > bestScore) {
					bestKaisai = i + 1;
					bestScore = score;
				}
			}
			teishutu[d] = bestKaisai;

		}

		// 提出
		for (int d = 0; d < span; d++) {
			System.out.println(teishutu[d]);
		}

	}

	public static long calc(int[] input) {

		int last[] = new int[26]; // 各コンテストが最終開催日から何日経過しているか
		long result = 0; // ユーザ満足度

		for (int d = 0; d < input.length; d++) {

			// lastの更新
			for (int i = 0; i < 26; i++) {
				if (i == input[d] - 1) {
					last[i] = 0;
				} else {
					last[i]++;
				}
			}

			// 開催による満足度アップ
			result += plus[d][input[d] - 1];

			// 日数経過による満足度ダウン
			for (int i = 0; i < 26; i++) {
				result -= (minus[i] * last[i]);
			}
		}

		return result;
	}
}


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

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll x = n;
    if(n >= b - 1) x = b - 1;
    ll ans = a * (x % b) / b;
    cout << ans << endl;
    return 0;
}


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


ll comb(ll all, ll select){
    if(select == 0)     return 1;
    if(all == select)   return 1;
    if(all == 0)        return 0;
    if(all < select)    return 0;
    
    ll res = 1;
    rep(i, all-select){
        res *= all-i;
        res /= i+1;
    }
    return res;
}

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

    rep(i, n)   a[i] %= 2;

    int cnt = 0;
    rep(i, n){
        if(a[i] == 1)   cnt++;
    }

    ll r = pow(2, n-cnt);

    ll res = 0;

    
    for(int i = ((p == 0)? 0:1); i <= cnt; i += 2){
        res += comb(cnt, i);
    }

    cout << res*r << endl;



 
    return 0;
}

Measured memory_bytes: 512
n,m,*a=map(int,open(0).read().split())
d=[]
for i,j in((7,3),(9,6),(8,7),(6,6),(5,5),(4,4),(3,5),(1,2),(2,5)):
    if i in a:
        d.append((i,j))
dp=[0]*-~n
for i in range(1,n+1):
    for j,k in d:
        if i-k<0 or i-k!=0 and not dp[i-k]:continue
        dp[i]=max(dp[i],dp[i-k]*10+j)
print(dp[n])

Measured memory_bytes: 51420
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, A, B;
  cin >> N >> A >> B;

  if (B < A) {
    cout << 0 << endl;
  } else if (B > A && N == 1) {
    cout << 0 << endl;
  } else {
    const int64_t min_value = A * (N - 1) + B;
    const int64_t max_value = A + B * (N - 1);
    cout << (max_value - min_value + 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll check[110000]={};
  ll n, x, m;
  cin >> n >> x >> m;
  if(x==0) {
    cout << 0 << endl;
    return 0;
  }
  vll v;
  ll cnt = 0LL;
  ll a = x;
  rep(i,m*2) {
    v.push_back(a);
    cnt += a;
    check[a] = true;
    a *= a;
    a %= m;
    if(check[a]) break;
    if(a==0) {
      cout << cnt << endl;
      return 0;
    }
  }
  if(a==x) {
    ll s = v.size();
    ll ans = 0LL;
    ll c = n - n%s;
    ll b = c/s;
    ans += cnt*b;
    rep(i,n%s) ans += v[i];
    cout << ans << endl;
  }
  else {
    ll ans = 0LL;
    bool swi = true;
    vll vv;
    ll vs = v.size();
    rep(i,vs) {
      if(v[i]==a) swi = false;
      if(swi) {
        ans += v[i];
        n--;
      }
      else vv.push_back(v[i]);
    }
    ll s = vv.size();
    ll sum = 0LL;
    rep(i,s) sum += vv[i];
    ll b = n/s;
    ans += sum*b;
    rep(i,n%s) ans += vv[i];
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 5128
#include <iostream>
#include <queue>
#define INF 1000000000
using namespace std;

struct edge{ int to,cost; };
typedef pair<int,int> P;

int main(){
	int n;
	vector<edge> es[10000];
	priority_queue<P,vector<P>,greater<P> > que;
	int d[10000];
	cin >> n;
	for(int i = 0;i < n;i++){
		int now,m;
		cin >> now >> m;
		for(int j = 0;j < m;j++){
			int a,b;
			cin >> a >> b;
			es[now].push_back({a,b});
		}
		d[i] = INF;
	}
	d[0] = 0;
	que.push(make_pair(0,0));
	while(!que.empty()){
		P p = que.top();
		que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i = 0;i < es[v].size();i++){
			edge e = es[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(make_pair(d[e.to],e.to));
			}
		}
	}
	for(int i = 0;i < n;i++) cout << i << " " << d[i] << endl;
	return 0;
}

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

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

using namespace std;

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

  vector<int> l(n);
  vector<int> d(n);
  rep (i, n)
	cin >> l[i];

  d[0] = 0;
  int sum = 1;
  for (int i = 1; i < n + 1; i++) {
	d[i] = d[i - 1] + l[i - 1];
	if (d[i] <= x)
	  sum++;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll mx = *max_element(a.begin(), a.end());
    ll mn = *min_element(a.begin(), a.end());
    if (mn >= 0) {
        cout << n-1 << endl;
        rep(i, 1, n) cout << i << " " << i+1 << endl;
    } else if (mx <= 0) {
        cout << n-1 << endl;
        for(ll i = n; i > 1; i--) cout << i << " " << i-1 << endl;
    } else if (abs(mx) >= abs(mn)) {
        cout << 2*n-1 << endl;
        auto pos = max_element(a.begin(), a.end()) - a.begin();
        rep(i, 1, n+1) cout << pos+1 << " " << i << endl;
        rep(i, 1, n) cout << i << " " << i+1 << endl;
    } else {
        cout << 2*n-1 << endl;
        auto pos = min_element(a.begin(), a.end()) - a.begin();
        rep(i, 1, n+1) cout << pos+1 << " " << i << endl;
        for(ll i = n; i > 1; i--) cout << i << " " << i-1 << endl;
    }
    return 0;
}

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

int main(){
  while (1) {
    long long n, sum = 0, s[1001];
    double sum2 = 0;

    cin >> n;
    if (n == 0) break;

    for (int i = 1; i <= n; i++){
      cin >> s[i];
      sum += s[i];
    }
    double m = (double)sum / n;

    for (int i = 1 ; i <= n; i++){
       sum2 += (s[i]-m)*(s[i]-m);
    }
    double a2 = (double)sum2 / n;

    printf("%lf\n", sqrt(a2));


  }

return 0;
}

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

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<int> red(a);
    rep(i, a) {
        cin >> red[i];
    }
    vector<int> green(b);
    rep(i, b) {
        cin >> green[i];
    }
    vector<int> clear(c);
    rep(i, c) {
        cin >> clear[i];
    }
    sort(red.begin(), red.end(), greater<int>());
    sort(green.begin(), green.end(), greater<int>());
    sort(clear.begin(), clear.end(), greater<int>());
    red.resize(x);
    green.resize(y);

    vector<int> all;
    all.insert(all.end(), red.begin(), red.end());
    all.insert(all.end(), green.begin(), green.end());
    sort(all.begin(), all.end(), greater<int>());
    int k = all.size() - 1;
    rep(i, c) {
        if (k >= 0 && all[k] < clear[i]) all[k--] = clear[i];
        else break;
    }
    ll ans = 0;
    for (auto v : all) ans += v;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2432
# -*- coding: utf-8 -*-
import sys
from heapq import heappush, heappop
from itertools import product
from math import sqrt
from collections import defaultdict
#input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))
N = int(input())
D = [[-1]*N for i in range(N)]

for i in range(N):
    a = int(input())
    for _ in range(a):
        x, y = inpl()
        D[i][x-1] = y

ans = 0
for X in product(range(2), repeat=N):
    OK = True
    for i in range(N):
        if X[i] == 0:
            continue
        for j in range(N):
            if D[i][j] == -1:
                continue
            if D[i][j] != X[j]:
                OK = False
                break
    if OK:
        ans = max(ans, sum(X))
print(ans)

Measured memory_bytes: 48752
N, K = map(int, input().split())
d = []
A = []
setA = set(A)
ListN=[]
for i in range(1, N+1):
  ListN.append(i) 
setN = set(ListN) 

for i in range(K):
  d.append(input())
  setA = setA | set(list(map(int, input().split())))

print(len(setA^setN))

Measured memory_bytes: 9208
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  vector<int> t(N+1),x(N+1),y(N+1);
  for(int i = 1;i <= N;i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }

  for(int i = 0;i < N;i++) {
    int T = t.at(i+1) - t.at(i);
    int X = abs(x.at(i+1) - x.at(i));
    int Y = abs(y.at(i+1) - y.at(i));

    if(X+Y > T || (X+Y) % 2 != T % 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

}

Measured memory_bytes: 1408