akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int n;
map<int,int> mp;
int main(){
    cin>>n;
    int ai;
    rep(i,n){
        cin>>ai;
        ++mp[ai];
    }
    int ans=0;
    while(!mp.empty()){
        auto it=*mp.rbegin();
        int x=it.first;
        --mp[x];
        if(mp[x]==0) mp.erase(x);
        int nx=1;
        while(nx<=x) nx*=2;
        auto it2=mp.find(nx-x);
        if(it2!=mp.end()){
            ++ans;
            --mp[it2->first];
            if(mp[it2->first]==0){
                mp.erase(it2);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 10236
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

# n = int(input())
# a, b = map(int, input().split())
# s = input()


yes = "Yes"
no = "No"


N = int(input())
a = list(map(int, input().split()))

four = 0
two = 0
none = 0
for e in a:
	if e % 4 == 0:
		four += 1
	elif e % 2 != 0:
		none += 1
	else:
		two += 1

if four >= none or (two == 0 and four+1 >= none):
	print(yes)
else:
	print(no)


Measured memory_bytes: 63472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
    ll h,w,n,sr,sc;
    string s,t;
    cin>>h>>w>>n>>sr>>sc>>s>>t;
    ll u=sr-1,l=sc-1,d=sr-1,r=sc-1;
    fr(i,n){
        if(s[i]=='U') u--;
        if(s[i]=='L') l--;
        if(s[i]=='D') d++;
        if(s[i]=='R') r++;
        if(u<0||l<0||d>=h||r>=w){
            cout<<"NO"<<endl;
            return 0;
        }
        if(t[i]=='U') d=max(d-1,0ll);
        if(t[i]=='L') r=max(r-1,0ll);
        if(t[i]=='D') u=min(u+1,h);
        if(t[i]=='R') l=min(l+1,w);
    }
    u=0;l=0;d=h-1;r=w-1;
    ifr(i,n){
        if(t[i]=='U') d=min(d+1,h);
        if(t[i]=='L') r=min(r+1,w);
        if(t[i]=='D') u=max(u-1,0ll);
        if(t[i]=='R') l=max(l-1,0ll);
        if(s[i]=='D') d--;
        if(s[i]=='R') r--;
        if(s[i]=='U') u++;
        if(s[i]=='L') l++;
        if(u>d||l>r){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int N=1e6+5;
int n,m,x,b[N],f[N];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&x);
		b[x]=1;
	}
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		if(b[i])continue;
		f[i]=(f[i-1]+f[i-2])%mod;
	}
	cout<<f[n];
}

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

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0) cout << 1.0 / 2.0 << endl;
  else {
    int k = n / 2 + 1;
    cout << fixed << setprecision(7) << (long double)k / n << endl;
  }
}

Measured memory_bytes: 256
# mada dame datta.
def main():
    L = int(input())
    b = bin(L)[2:]
    bl = len(b)
    r = []
    for i in range(bl-1):
        r.append((i+1, i+2, 0))
        r.append((i+1, i+2, 2**i))
    if L == 2**(bl-1):
        pr(r)
        return
    end = bl
    for i in reversed(range(1, end)):
        if L - 2**(i-1) >= 2**(end-1):
            r.append((i, end, L-2**(i-1)))
            L -= 2**(i-1)
    pr(r)
def pr(r):
    m = 0
    for i in r:
        m = max(m, i[1])
    print(m, len(r))
    for i in r:
        print(i[0], i[1], i[2])
main()


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main(){
	var n, rank int
	var mark string
	mark_set := []string{"S", "H", "C", "D"}
	card := make([][]bool, 4)
	for i:=0; i<4; i++{
		card[i] = make([]bool, 13)
	}

	fmt.Scan(&n)
	for i:=0; i<n; i++{
		fmt.Scan(&mark, &rank)
		if mark == "S"{
			card[0][rank-1] = true
		}else if mark == "H"{
			card[1][rank-1] = true
		}else if mark == "C"{
			card[2][rank-1] = true
		}else{
			card[3][rank-1] = true
		}
	}
	for i:=0; i<4; i++{
		for j:=0; j<13; j++{
			if !card[i][j]{
				fmt.Printf("%s %d\n", mark_set[i], j+1)
			}
		}
	}
}


Measured memory_bytes: 1136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

const string FILENAME = "input";
const int MAXN = 1e5 + 5;

int n;
int L;
vector <int> a;

int main() {
	ios::sync_with_stdio(false);
	srand(time(0));
	//read(FILENAME);
	cin >> n >> L;
	a.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i + 1 < n; ++i) {
		if (a[i] + a[i + 1] >= L) {
			cout << "Possible\n";
			for (int j = 0; j < i; ++j) {
				cout << j + 1 << '\n';
			} 
			for (int j = n - 1; j > i; --j) {
				cout << j << '\n';
			} 
			return 0;
		}
	}
	cout << "Impossible\n";
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<string, pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 109;
ll i,n;
ii a[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n + 1){
        cin>>a[i].f>>a[i].se.f;
        a[i].se.se = i;
    }
    sort(a + 1,a + n + 1,[&](ii a,ii b){
        if(a.f == b.f) return a.se.f > b.se.f;
        return a.f < b.f;
    });
    rep(i,1,n + 1) cout<<a[i].se.se<<endl;
    return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int K;
	int n = 0;
	
	cin>>K;
	
	for(int i = 1; i <= 100000000; i++){
		n = n * 10 + 7;
		n %= K;
		
		if(n == 0) {
			cout<<i<<endl;
			return 0;
		}
	}
	
	cout<<-1<<endl;
	
	
	return 0;
}

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

int n;
vector<vector<int>> graph;
vector<int> ord, low;
vector<pair<int, int>> bridge;
vector<int> articulation;

void dfs(int v, int p, int& k) {
    ord[v] = low[v] = k++;
    bool isArticulation = false;
    int cnt = 0;
    for (int u : graph[v]) {
        if (u == p) continue;
        else if (ord[u] == -1) {
            cnt++;
            dfs(u, v, k);
            low[v] = min(low[v], low[u]);
            if (low[u] == ord[u]) {
                bridge.emplace_back(v, u);
            }
            if (p != -1 && low[u] >= ord[v]) {
                isArticulation = true;
            }
        }
        else {
            low[v] = min(low[v], ord[u]);
        }
    }
    if (p == -1 && cnt > 1) {
        isArticulation = true;
    }
    if (isArticulation) {
        articulation.push_back(v);
    }
}

void build() {
    ord.assign(n, -1);
    low.resize(n);

    int k = 0;
    dfs(0, -1, k);
}

int main() {
    int V, E;
    cin >> V >> E;
    graph.resize(V);
    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        graph[s].push_back(t);
        graph[t].push_back(s);
    }

    n = V;
    build();
    sort(articulation.begin(), articulation.end());
    for (int v : articulation) {
        cout << v << endl;
    }
}


Measured memory_bytes: 4780
H,W=map(int,input().split())
INF=float('inf')
dp=[[INF]*10 for _ in range(10)]
for i in range(10):
  a=list(map(int,input().split()))
  for j in range(10):
    dp[i][j]=a[j]
for k in range(10):
  for i in range(10):
    for j in range(10):
      dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j])
cnt=0
for i in range(H):
  a=list(map(int,input().split()))
  for j in range(W):
    if a[j]==-1 or a[j]==1:
      pass
    else:
      cnt+=dp[a[j]][1]
print(cnt)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
  char c[3];
  cin >> c[0] >> c[1] >> c[2];
  for (int i = 0; i < 3; i++) {
    if(c[i] == '1') c[i] = '9';
    else c[i] = '1';
  }

  cout << c[0] << c[1] << c[2] << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,s,sum=0,k,i;
   cin>>n>>s;
  long long int ar[n];
  for(i=0; i<n; i++)
  {
    cin>>ar[i];
  }
  sort(ar,ar+n);
  if(n<=s)
    cout<<0;
  else
  {
    for(i=0; i<n-s; i++)
    {
      sum+=ar[i];
    }
    cout<<sum;
  }
  
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
	if (!b)
	{
		return a;
	}
	return gcd(b, a % b);
}
long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}
int main()
{
	long long a, b;
	scanf("%lld %lld", &a, &b);
	printf("%lld", lcm(a, b));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<ll,ll> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    ll n,ansn,ansm;
    cin>>n;
    vector<ll> v(n);

    for(int i=0;i < n;i++)
    {
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    ansn=v.at(n-1);
    ansm=v.at(0);

    for(int i=0;i < n;i++)
    {
        ll x=upper_bound(v.begin(),v.begin()+n-2,v.at(n-1)/2)-v.begin();

        if(-1<x-1 && abs((v.at(n-1)+1)/2-v.at(x))>abs(v.at(n-1)/2-v.at(x-1))){
            ansm=v.at(x-1);
        }else if(x!=n-1){
            ansm=v.at(x);
        }

    }
    cout<<ansn<<" "<<ansm<<endl;

}
    

Measured memory_bytes: 1024
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    ll tot=0;
    for(ll a=1;a<=n;a++)
        tot+=((a*(a+1))/2);
    rep(a,0,n-1)
    {
        ll u=nxt(),v=nxt();
        if(u>v)
            swap(u,v);
        tot-=(u*(n-v+1));
    }
    cout<<tot<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define fill(x,y) memset(x,y,sizeof(x))
#define name(x) #x
using namespace std;


const int INF = INT_MAX-100;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

int main() {
    // if double is required
    
    int N,T;
    cin >> N >>T;
    vector<int> A(N);
    cin >> A;
    
    priority_queue<int,vector<int>,greater<int>> pq;
    pq.push(A[0]);
    
    vector<int> maxv;
    for(auto i = 1; i<N;i++){
        maxv.push_back( A[i] - pq.top());
        pq.push(A[i]);
    }
    
    sort(all(maxv),greater<int>());
    
    int count = 0;
    while(maxv[count] == maxv[0]) count++;
    
    cout << count << endl;
    return 0;
}




Measured memory_bytes: 1660
import java.util.Scanner;

public class Main {

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

		int N = in.nextInt();
		int[] W = new int[N+1];
		int total = 0;
		for ( int i = 1; i <= N; i++ ) {
			W[i] = in.nextInt();
			total += W[i];
		}

		int s1 = 0;
		int s2 = total;
		int diff = Integer.MAX_VALUE;
		for ( int t = 1; t < N; t++ ) {
			s1 += W[t];
			s2 -= W[t];
			if ( diff > Math.abs(s1 - s2) ) diff = Math.abs(s1 - s2);
		}
		System.out.println(diff);
		in.close();
	}
}

Measured memory_bytes: 23892
A=[[]]*1001
x=1.0
y=0.0
for i in range(1,1001):
    A[i]=[x,y]
    tmp=i**.5
    x,y=x-y/tmp,y+x/tmp
 
while 1:
    n = input()
    if n==-1:break
    print A[n][0]
    print A[n][1]

Measured memory_bytes: 4440
using System;

namespace ABC122
{
    class Program
    {
        static int Main(string[] args)
        {
            Program.ProblemA();
                return 0;

        }

        static void ProblemA()
        {
            string input = Console.ReadLine();
            string output;
            if(input == "A")
            {
                output = "T";
            }
            else if(input == "T")
            {
                output = "A";
            }
            else if(input == "C")
            {
                output = "G";
            }
            else
            {
                output = "C";
            }
            Console.WriteLine(output);
        }
    }
}


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

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

int main() {

	double a,b,c,d;
	cin >> a>> b >> c >> d;

	double ans = a * b / 2;
	bool flg = (c * 2 == a) && (d * 2 == b);

	cout << ans << " " << flg << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
void vprint() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
template <class T> void mprint(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << "";
        }
    }
}

template <class T> T up(T a, T div) { return (a + div - 1) / div; }

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

    int N;
    cin >> N;
    vector<ll> T(N), A(N);
    REP(i, N) cin >> T[i] >> A[i];

    ll a = 1, t = 1;
    REP(i, N) {
        ll N = max(up(t, T[i]), up(a, A[i]));
        a    = A[i] * N;
        t    = T[i] * N;
    }
    ll ans = a + t;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26388
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

constexpr ll mod = 998244353;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return x ? mod - x : 0;}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}

  friend ostream& operator << (ostream& os, const mint& m) noexcept {
    return os << m.x;
  }

  friend istream& operator<< (istream& is, mint& m) noexcept {
    return is >> m.x;
  }
};

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

  int n;
  cin >> n;
  vector<mint> d(n, 0);
  rep(i, n) {
    int x;
    cin >> x;
    if (i == 0 && x != 0) {
      cout << 0 << endl;
      return 0;
    }
    d[x] += 1;
  }

  if (d[0].x != 1) {
    cout << 0 << endl;
    return 0;
  }

  bool flag = false;
  for (int i = n-1; i >= 0; i--) {
    if (flag && d[i].x == 0) {
      cout << 0 << endl;
      return 0;
    } else if (!flag && d[i].x > 0) flag = true;
  }

  mint ans = 1;
  for (int i = 1; i < n; i++) {
    if (d[i].x == 0) break;
    ans *= d[i-1].pow(d[i].x);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3940
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<fstream>
#include<sstream>
#include<vector>
#include<set>
#include<deque>
#include<cstring>
#include<queue>
#include<stdio.h>
#include<set>
#include<stack>
#include<numeric>
#include<map>
#include<cstdio>
#include<bitset>
#include<array>
#include<list>
using namespace std;
#define ll long long 
const ll mod = 1e9 + 7;

ifstream f1;
ofstream f2;

map<ll, ll> change;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	f1.open("INP.txt");
	f2.open("OUT.txt");
	ll n;
	cin >> n;
	vector<ll> hold(n);
	vector<ll> sub(n);
	for (ll i = 0; i < n; i++) {
		cin >> hold[i];
		sub[i] = hold[i];
	}
	sort(hold.begin(), hold.end());
	change[hold[n - 1]] = hold[n - 2];
	for (ll i = 0; i < hold.size() - 1; i++) {
		change[hold[i]] = hold[n - 1];
	}
	for (ll i = 0; i < sub.size(); i++) {
		cout << change[sub[i]] << endl;
	}
	//system("pause");
	return 0;
}


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

int main()
{
	string s;
	cin >> s;

	deque<char> dq(s.begin(), s.end());

	bool flag = true;

	int q;
	cin >> q;

	for (int _ = 0; _ < q; _++)
	{
		int t;
		cin >> t;

		if (t == 1)
		{
			flag = !flag;
		}
		else if (t == 2)
		{
			int f;
			char c;
			cin >> f >> c;

			if (f == 1)
			{
				if (flag)
				{
					dq.emplace_front(c);
				}
				else
				{
					dq.emplace_back(c);
				}
			}
			else if (f == 2)
			{
				if (flag)
				{
					dq.emplace_back(c);
				}
				else
				{
					dq.emplace_front(c);
				}
			}
		}
	}

	string ans = "";
	for (auto &&c : dq)
	{
		ans += c;
	}

	if (!flag)
	{
		reverse(ans.begin(), ans.end());
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1412
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        s,t=map(int,input().split())
        s-=1; t-=1
        E[s].append(t)
    dp=[0]*n
    for v in range(n-2,-1,-1):
        for nv in E[v]:
            dp[v]+=dp[nv]
        dp[v]/=len(E[v])
        dp[v]+=1
    ans=dp[0]

    # u→nu を削除する
    for u in range(n):
        if(len(E[u])<=1): continue
        nu=max(*((dp[nu],nu) for nu in E[u]))[1]
        dp2=[0]*n
        for v in range(n-2,-1,-1):
            for nv in E[v]:
                if(v==u and nv==nu): continue
                dp2[v]+=dp2[nv]
            dp2[v]/=(len(E[v]) if v!=u else len(E[v])-1)
            dp2[v]+=1
        ans=min(ans,dp2[0])
    print(ans)
resolve()

Measured memory_bytes: 58204
#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 ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

using P = pair<int, int>;

int n, m, s, t;
vector<vector<int>> g;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    g.resize(n);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].emplace_back(v);
    }
    cin >> s >> t;
    s--;
    t--;
    vector<vector<int>> d(n, vector<int>(3, INF));
    queue<P> que;
    d[s][0] = 0;
    que.push(P(s, 0));
    while(que.size()) {
        auto tmp = que.front();
        que.pop();
        int v = tmp.first;
        int r = tmp.second;
        int nr = (r + 1) % 3;
        if(d[v][r] == INF) {
            continue;
        }
        for(int u : g[v]) {
            if(d[u][nr] == INF) {
                chmin(d[u][nr], d[v][r] + 1);
                que.push(P(u, nr));
            }
        }
    }
    cout << (d[t][0] == INF ? -1 : d[t][0] / 3) << endl;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
#define ALL(a) a.begin(),a.end()
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}

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

    ll ans = 10e12+1;
    for (ll i = 1; i*i <= n; i++){
        if(n % i == 0){
            ll a = i;
            ll b = n / i;
            ans = min(ans, a - 1 + b - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
W, H, x, y, r = [int(x) for x in input().split()]
def is_inside(W,H,x,y,r):
    if x-r<0 or W<x+r or y-r<0 or H<y+r:
        return False
    return True
print("Yes" if is_inside(W,H,x,y,r) else "No")
    


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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n; cin >> n;
	vll a(n); cin >> a;
	sort(a.begin(), a.end());
	vll ps(n);
	partial_sum(a.begin(), a.end(), ps.begin());
	ll ans = -BINF; int x = -1;
	for (int i=0;i+1<n;i++) {
		// [0..i] - [i+1..n-1]
		ll now = -ps[i];
		now += ps[n - 1] - ps[i];
		if (now > ans) ans = now, x = i;
	}
	cout << ans << endl;
	// cerr << x << endl;
	// x + 1 minus
	// fix the plus
	for (int j=x+1;j<n-1;j++) {
		cout << a[x] << ' ' << a[j] << '\n';
		a[x] -= a[j];
	}
	for (int i=0;i<=x;i++) {
		cout << a[n - 1] << ' ' << a[i] << '\n';
		a[n - 1] -= a[i];
	}
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

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

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 3456
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<vector>
using namespace std;
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int ans=a+b+c;
    int mx=max({a,b,c});

    ans-=mx;

    for(int i=0;i<k;i++){
        mx=2*mx;
    }

    ans+=mx;
    cout<<ans<<endl;


    
return 0;
}

Measured memory_bytes: 256
import java.util.*;

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 D = sc.nextInt();

		System.out.println(Math.min(A,B) + Math.min(C,D));

	}
}

Measured memory_bytes: 21972
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki

#include <bits/stdc++.h>
using namespace std;

int nums[100100];
int n;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> nums[i];
	}
	long long int cost = 0;
	for(int i = 1; i <= n; i++) {
		cost += abs(nums[i] - nums[i - 1]);
	}
	nums[n + 1] = 0;
	cost += abs(nums[n + 1] - nums[n]);
	for(int i = 1; i <= n; i++) {
		long long int cur = cost;
		cur = cur - abs(nums[i] - nums[i - 1]);
			cur -= abs(nums[i + 1] - nums[i]);
			cur += abs(nums[i + 1] - nums[i - 1]);
		cout << cur << endl;
	}
   	return 0;
}

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

int main() {
  #define int long long
  int d, g;
  cin >> d >> g;
  const int INF = 100000000;
  vector<int> p(d);
  vector<int> c(d);
  for (int i = 0; i < d; i++) {
    cin >> p.at(i) >> c.at(i);
  }
  int res = INF;
 
  for (int bit = 0; bit < (1<<d); bit++) {
    int g2 = g;
    int cnt = 0;
    for (int i = 0; i < d; i++) {
      if (bit & (1<<i)) {
        cnt += p.at(i);
        g2 -= c.at(i) + 100 * (i + 1) * p.at(i);
      }
    }
    if (g2 <= 0) {
      res = min(res, cnt);
    }
    else {
      for (int i = d - 1; i >= 0 && g2 > 0; i--) {
        
        if (!(bit & (1<<i))) {
          cnt += min(g2 / (100 * (i + 1)), p.at(i) - 1);
          g2 -= 100 * (i + 1) * min(g2 / (100 * (i + 1)), p.at(i) - 1);
        }
      }
      if (g2 > 0) {
        continue;
      }
      res = min(res, cnt);
    }
  }
  cout << res << endl;
}




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

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

int main() {
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    cout << (h - x) * (w - y) << endl;

    return 0;
}

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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << endl;
}

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

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int a,b,c,d;
  string s;
  int x[10005];
  cin>>a;
  for(int i=0;i<a;i++)cin>>x[i];

  int ans = 0;
  for(int i=0;i<a;i++){
    while((x[i]%2) == 0){
      ans++;
      x[i]/=2;
    }
  }

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


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 2);
  for (int i = 0; i < n; ++i) cin  >> a[i + 1];
  int s = 0;
  for (int i = 0; i < n + 1; ++i) s += abs(a[i] - a[i + 1]);
  for (int i = 0; i < n; ++i) cout << s + abs(a[i] - a[i + 2]) - abs(a[i] - a[i + 1]) - abs(a[i + 1] - a[i + 2]) << endl;
}



Measured memory_bytes: 1664
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<' '<<y<<endl
#define p3(x,y,z)               out<<x<<' '<<y<<' '<<z<<endl
#define p4(x,y,z,w)             out<<x<<' '<<y<<' '<<z<<' '<<w<<endl
#define pl(x)                   out<<x
#define pll(x)                  out<<x<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}

int dfs(int node, vector<int>& dp, vector<vector<int>>& edges){
    int d = 0;
    if(dp[node]){return dp[node];}
    for(int x: edges[node]){
        d = max(d, dfs(x, dp, edges));
    }
    dp[node] = d + 1;
    return dp[node];
}


void ssolve(std::istream& in, std::ostream& out){
    int n, m; s2(n, m);
    vvi edges(n + 1);
    f(i, 0, m){
        int from, to; s2(from, to);
        edges[from].emplace_back(to);
    }
    vi dp(n + 1, 0);
    int ans = 0;
    f(i, 1, n + 1){
        ans = max(ans, dfs(i, dp, edges));
    }
    p(ans - 1);
    return;
}

class GLongestPath {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    GLongestPath solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvl vector<vector<long long>>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vpli vector<pair<long long, int>>
#define vs vector<string>
#define deb(x) cout << x << endl;
#define all(x) x.begin(), x.end()
ll M = 1e9 + 7;
int n;
vvl adj;

void modadd(ll &a, ll b)
{
    a = ((a + M) % M + (b + M) % M) % M;
}
ll modmul(ll a, ll b)
{
    return ((a + M) % M * (b + M) % M + M) % M;
}
vvl mat_mul(vvl &a, vvl &b)
{
    vvl ans(a.size(), vll(b.size(), 0ll));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            for (int k = 0; k < n; k++)
            {
                modadd(ans[i][j], modmul(a[i][k], b[k][j]));
            }
        }
    }
    return ans;
}

vvl mat_pow(ll k)
{
    if (k == 0)
    {
        vvl id(n, vll(n, 0));
        for (int i = 0; i < n; i++)
            id[i][i] = 1;
        return id;
    }
    vvl ans = mat_pow(k / 2);
    ans = mat_mul(ans, ans);

    if (k & 1)
        ans = mat_mul(ans, adj);
    return ans;
}

int main()
{

    ll k, ans = 0;
    cin >> n >> k;
    adj.resize(n, vll(n));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cin >> adj[i][j];
        }
    }
    adj = mat_pow(k);
    for (auto x : adj)
    {
        for (auto y : x)
        {
            modadd(ans, y);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >>a >>b;
  if(a%3==0||b%3==0||(a+b)%3==0){
    cout <<"Possible" <<endl;
  }
  else {
    cout <<"Impossible" <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;i++)
const int N = 444444;
int n,a[N];
void GG(){puts("No");exit(0);}
void solve(int l, int r){
	int v=0;rep(i,l,r)if(a[i]<i){if(v>a[i])GG();v=a[i];}
	v=0;rep(i,l,r)if(a[i]>i){if(v>a[i])GG();v=a[i];}
	int mn=n,mx=1;rep(i,l,r)mn=mn<a[i]?mn:a[i],mx=mx>a[i]?mx:a[i];
	if(mx-mn!=r-l)GG();
}
int main(){
	scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
	rep(i,1,n)if(a[i]!=i){
		int j;for(j=i;j<=n;j+=2)if(a[j]==j)break;j-=2;
		//[i,j]
		if(i==j)GG();for(int k=i+1;k<=j-1;k+=2)if(a[k]!=k)GG();solve(i,j);i=j;
	}
	puts("Yes");return 0;
}

Measured memory_bytes: 1408
//Range Update Query
//reference https://kujira16.hateblo.jp/entry/2016/12/15/000000
//https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_D
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

template <typename T>
struct RUQ {
  T n;
  T k;//バケットの数
  T sqrt_n;//バケットの大きさ
  vector<T> data;
  vector<T> lazy_update;
  T INF;

  RUQ() = delete;
  RUQ(T n_,T sqrt_n_ = 1000,T INF_ = 1e9) {
    initialize(n_,sqrt_n_,INF_);
  }

  void initialize(T n_,T sqrt_n_ = 1000,T INF_ = 1e9) {
    n = n_;

    sqrt_n = sqrt_n_;

    k = (n + sqrt_n - 1) / sqrt_n;//切り上げ割り算

    data.clear();lazy_update.clear();

    data.resize(k * sqrt_n,INF_);
    lazy_update.resize(k,INF_ + 1);

    INF = INF_;
  }

  void delay_propagation(T bucket_id) {
    if (lazy_update[bucket_id] <= INF) {
      for (int i = bucket_id * sqrt_n;i < (bucket_id + 1) * sqrt_n;i++) {
        data[i] = lazy_update[bucket_id];
      }
      lazy_update[bucket_id] = INF + 1;
    }
  }

  void update(T a,T b,T x) {
    if (a >= sqrt_n * k || b > sqrt_n * k) {
      cerr << "error index k" << endl;
      return;
    }
    if (a >= n || b > n) {
      cerr << "warning index k" << endl;
    }

    rep (i,k) {
      T l = i * sqrt_n,r = (i + 1) * sqrt_n;
      if (b <= l|| r <= a) continue;
      if (l < a || b < r) {
        delay_propagation(i);
        for (int i = max(l,a);i < min(b,r);i++) {
          data[i] = x;
        }
      } else {
        lazy_update[i] = x;
      }
    }
  }

  T get(T i) { // i番目(0-indexed)の値を取得する
    T bucket_id = i / sqrt_n;

    if (lazy_update[bucket_id] > INF)return data[i];
    return lazy_update[bucket_id];
  }
};

using ll = long long;

signed main() {
  ll n,q;
  cin >> n >> q;

  RUQ<ll> ruq(n,1000,(1ll << 31) - 1ll);

  rep(i,q) {
    ll c;
    cin >> c;
    if(c) {
      ll i;
      cin >> i;
      cout << ruq.get(i) << endl;
    } else {
      ll s,t,x;
      cin >> s >> t >> x;
      ruq.update(s,t+1,x);
    }
  }
  return 0;
}



Measured memory_bytes: 3568
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n*a,b))
    return

#B
def B():
    a = S()
    print(a.count("1"))
    return

#C
def C():
    n = II()
    a = list(str(n))
    a = list(map(int,a))
    if not n % sum(a):
        print("Yes")
    else:
        print("No")
    return

#D
def D():
    n = II()
    a = LI()
    ans = 0
    for a_ in a:
        while not a_ % 2:
            ans += 1
            a_ /= 2
    print(ans)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 39152
module ArrayL = ArrayLabels
module ListL = ListLabels

let dbg = Printf.printf "[debug]%s"

let max_num = 100_000_000_000

let id = fun x -> x
let tuple2 x y = (x,y)
let tuple3 x y z = (x,y,z)
let succ x = x + 1
let pred x = x - 1

let (++) n m =
  let rec aux i =
    if i = m then [m]
    else i :: aux (i+1) in
  if n > m then [] else aux n

let (++^) n m = n ++ (m-1)

let scan fmt f = Scanf.sscanf (read_line ()) fmt f

let scan_list ~sep cnv =
  let line = read_line () in
  Str.split (Str.regexp_string sep) line
  |> List.map cnv

let scan_lines n fmt f =
  List.map (fun _ -> scan fmt f) (0++^n)

let scan_matrix n m e conv =
  let arr = Array.make_matrix n m e in
  Array.iteri (fun i line ->
      let s = Scanf.Scanning.from_string @@ read_line () in
      Array.iteri (fun j _ ->
          arr.(i).(j) <- Scanf.bscanf s " %s" conv;
        ) line) arr; arr

let rec powerset = function
  | [] -> [[]]
  | hd::tl ->
    let pws =  powerset tl in
    pws @ ListL.map pws ~f:(fun pw -> hd::pw)

let permutations l =
  let rec interleave x = function
    | [] -> [[x]]
    | (hd::tl) as l ->
      (x::l) :: (interleave x tl |> ListL.map ~f:(fun l -> hd::l)) in
  let rec aux = function
    | [] -> [[]]
    | a::rest ->
      aux rest |> ListL.map ~f:(interleave a) |> List.concat in
  aux l

let between n x m = n <= x && x < m

let string_to_list s =
  List.map (String.get s) (0 ++^ String.length s)

let n = scan "%d" id

let dfs arr pre post  =
  let m = ref 1 in
  let rec aux i =
    pre.(i) <- !m; incr m;
    ArrayL.iter arr.(i) ~f:(fun v -> if pre.(v) = 0 then aux v);
    post.(i) <- !m; incr m;
  in
  ListL.iter (1++n) ~f:(fun i -> if pre.(i) = 0 then aux i)

let () =
  let arr = Array.make (succ n) [||] in
  ListL.iter (0++^n) ~f:(fun _ ->
      let a = Array.of_list @@ scan_list ~sep:" " int_of_string in
      arr.(a.(0)) <- Array.sub a 2 a.(1));
  let pre = Array.make (succ n) 0 in
  let post = Array.make (succ n) 0 in
  dfs arr pre post;
  ListL.iter (1++n) ~f:(fun i ->
      Printf.printf "%d %d %d\n" i pre.(i) post.(i))



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

int main()
{
    long N,A[5]={0};
    string S;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> S;
        if(S[0] == 'M'){
            A[0]++;
        }else if(S[0] == 'A'){
            A[1]++;
        }else if(S[0] == 'R'){
            A[2]++;
        }else if(S[0] == 'C'){
            A[3]++;
        }else if(S[0] == 'H'){
            A[4]++;
        }
    }
    long ans=0;
    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans += A[i] * A[j] * A[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256