akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    double n,m,d;
    cin >> n >> m >> d;
    if( d== 0) 
    printf("%.10f\n",(double)(m-1)*(1/n));
    else{
        printf("%.10f\n",(double)(m-1)*(2*(n-d)/n/n));
    }

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	s := IOInitialize()
	N := Int(s)
	D := Int(s)
	X := Int(s)
	nums := scanNums(s, N)
	eatNum := 0

	for i := 1; i < N+1; i++ {
		A := nums[i-1]
		for j := 0; j < D; j++ {
			day := j*A + 1
			if day > D {
				break
			}
			eatNum++
		}
	}
	fmt.Println(eatNum + X)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <map>
#include <string>
using namespace std;

int main(void){
  map<string, bool> dict;
  int n;
  char com[13], str[10];
  
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s %s", com, str);
    if (com[0] == 'i') {
      dict[string(str)] = true;
    } else {
      if (dict[string(str)]) printf("yes\n");
      else printf("no\n");
    }
  }
  
  return 0;
}

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

using namespace std;

int main()
{
    cout << fixed;
    cout << setprecision(10);
    int n;
    cin >> n;
    int c[3];
    int x;
    for(int i=0;i<n;i++)
    {
        cin >> x;
        c[x-1]++;
    }
    double f[301][301][301];
    for(int k=0;k<=n;k++)
    {
        for(int j=0;j+k<=n;j++)
        {
            for(int i=0;i+j+k<=n;i++)
            {
                if(i+j+k==0)continue;
                f[i][j][k]=1.0;
                if(i)f[i][j][k]+=f[i-1][j][k]*i/n;
                if(j)f[i][j][k]+=f[i+1][j-1][k]*j/n;
                if(k)f[i][j][k]+=f[i][j+1][k-1]*k/n;
                f[i][j][k]=f[i][j][k]/(i+j+k)*n;
            }
        }
    }
    cout << f[c[0]][c[1]][c[2]];
    return 0;
}


Measured memory_bytes: 213120
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    void solve(){
        ll n, cx = 1, cy = 1, x, y;
        cin >> n;
        rep(i, n) {
            cin >> x >> y;
            ll m = max(cx/x + !!(cx%x), cy/y + !!(cy%y));
            cx = x*m, cy = y*m;
        }
        cout << cx + cy << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
     */
      //te
      solve();
      return 0;
    } 

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

int main() {
  int N, M;
  cin >> N >> M;
  priority_queue<int> price;
  rep(i,N) {
    int A;
    cin >> A;
    price.push(A);
  }
  rep(i,M) {
    int tmp = price.top();
    price.pop();
    tmp /= 2;
    price.push(tmp);
  }
  ll sum = 0;
  rep(i,N) {
    sum += price.top();
    price.pop();
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 892
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, X; cin >> N >> X;
    vl L(N); REP(i, N) cin >> L[i];
    
    ll sum = 0; ll ans = 1;
    REP(i, N){
        sum += L[i];
        if(sum <= X) ans++;
    }
    
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d",&a,&b);
	if(a==1&&b==2)
		printf("3");
	else if(a==2&&b==3)
		printf("1");
	else if(a==3&&b==1)
		printf("2");
	else if(b==2&&a==3)
		printf("1");
	else if(b==3&&a==1)
		printf("2");
	else if(b==1&&a==2)
		printf("3");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

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

        if(a.equals("H")){
            if(b.equals("H")){
                System.out.println("H");
            } else {
                System.out.println("D");
            }
        } else {
            if(b.equals("H")){
                System.out.println("D");
            } else {
                System.out.println("H");
            }
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21332
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	int ans = INF;
	rep(i, 1, sqrt(N) + 1)
	{
		if (N%i == 0)
		{
			int syo = N / i;
			chmin(ans, i - 1 + syo - 1);
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  string N;
  cin >> N;
  int p =0;
  int k =N.size() ;
  
  
for (int i = 0; i < k; i++) {
  if(i%2 ==0){
    if(N.at(i) == 'L'){
      p += 1;
    }
  }
  if(i%2 ==1){
    if(N.at(i) == 'R'){
      p += 1;
    }
  }
}
  
  if(p ==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

    
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

ll modpow(ll a, ll b){
    if(b == 0) return 1;
    else if(b % 2 == 0){
        ll d = modpow(a, b / 2) % MOD;
        return (d * d) % MOD;
    }
    else{
        return (a * modpow(a, b - 1)) % MOD;
    }
}

const int MAX_N = 2010;

ll fact[MAX_N], finv[MAX_N];
ll comb(int n, int r){
    if(n < r || r < 0) return 0;
    return fact[n] * finv[n-r] % MOD * finv[r] % MOD;
}

void calc(int n){
    fact[0] = finv[0] = 1;
    for(int i=1; i<=n; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        finv[i] = modpow(fact[i], MOD - 2);
    }
}

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

    int n, k; cin>>n>>k;
    calc(2005);

    n -= k;

    cout << comb(n + k - 1 , n) << endl;

    return 0;
}


Measured memory_bytes: 3176
from collections import deque
n,m = map(int,input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

seen = [False]*n
ans = [0]*n
Q = deque()
def f(s):
    Q.append(s)
    seen[s] = True
    while Q:
        now = Q.popleft()
        for nxt in G[now]:
            if seen[nxt]: continue
            ans[nxt] = now+1
            Q.append(nxt)
            seen[nxt] = True
f(0)
print("Yes")
for i in range(1,n): print(ans[i])

    


Measured memory_bytes: 37860
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
string t,st[100010];
long long dp[100010][3],ans = 0;
int main(){
	long long i,j,n,k,r,s,p;
	cin >> n >> k >> r >> s >> p >> t;
	for(i=0;i<n;i++){
		st[i%k].push_back(t[i]);
	}
	for(i=0;i<k;i++){
		for(j=0;j<st[i].size();j++){
			dp[j][0] = 0;
			dp[j][1] = 0;
			dp[j][2] = 0;
		}
		if(st[i][0]=='r') dp[0][0] = p;
		if(st[i][0]=='s') dp[0][1] = r;
		if(st[i][0]=='p') dp[0][2] = s;
		for(j=1;j<st[i].size();j++){
			dp[j][0] = max(dp[j- 1][1],dp[j - 1][2]);
			dp[j][1] = max(dp[j - 1][0],dp[j - 1][2]);
			dp[j][2] = max(dp[j - 1][0],dp[j - 1][1]);
			if(st[i][j]=='r') dp[j][0] += p;
			if(st[i][j]=='s') dp[j][1] += r;
			if(st[i][j]=='p') dp[j][2] += s;
		}
		int z = st[i].size();
		ans += max({dp[z - 1][0],dp[z - 1][1],dp[z - 1][2]});
	}
	cout << ans << endl;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

    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;
    }

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        string s,t;
        cin>>s>>t;
        umap<char,char> m;
        umap<char,ll> used;
        rep(i,Size(s)){
            if(!m.count(s[i])){
                if(used[t[i]]){
                    cout<<"No"<<"\n";
                    return 0;
                }
                m[s[i]]=t[i];
                used[t[i]]++;
            }
            else{
                if(m[s[i]]!=t[i]){
                    cout<<"No"<<"\n";
                    return 0;
                }
            }
        }
        cout<<"Yes"<<"\n";
    }

Measured memory_bytes: 3812
N = int(input())
A = list(map(int,input().split()))

def GCD(x,y):
    while y != 0:
        x,y = y,x%y
    return x

l,r = [0],[0]
for i in range(N-1):
    l.append(GCD(l[-1],A[i]))
    r.append(GCD(r[-1],A[N-i-1]))

ans = 0
for i in range(N):
    ans = max(ans,GCD(l[i],r[N-i-1]))
print(ans)


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

typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    for(ll i=0; i<N; i++) cin >> A[i];
    for(ll i=0; i<N; i++) cin >> B[i];
    for(ll i=0; i<N; i++) cin >> C[i];
    
    sort(A.begin(),A.end());
    sort(C.begin(),C.end());
    
    ll sum=0;
    for(ll i=0; i<N; i++){
        ll cntA=0, cntC=0;
        
        cntA = (ll)(lower_bound(A.begin(),A.end(),B[i])-A.begin());
        
        cntC = (ll)(C.end()-upper_bound(C.begin(),C.end(),B[i]));
        
        sum += cntA*cntC;
    }
    cout << sum << endl;
}


Measured memory_bytes: 2684
#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<queue>
#include<cmath>

using namespace std;

#define max(a,b) a > b ? a : b


int N;
int W;
int vvec[100];
int wvec[100];
int dp[200][20000];

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

    for (int i = 0; i < N; i++)
    {
        cin >> vvec[i] >> wvec[i];
    }

    // DP初期条件: dp[0][w] = 0
    for (int w = 0; w <= W; ++w) dp[0][w] = 0;

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {
            if (w >= wvec[i])
            {
                dp[i + 1][w] = max(dp[i][w - wvec[i]] + vvec[i], dp[i][w]);
            }
            else
            {
                dp[i + 1][w] = dp[i][w];
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7460
#include <iostream>
#include <cstdlib>
#include <vector>
//数列 A を読み込み、バブルソートで昇順に並び変え出力するプログラムを作成してください。また、バブルソートで行われた要素の交換回数も報告してください。
using namespace std;
int main(){
	int n, count = 0;
	cin >> n;
	int A[n];
	for(int i = 0; i < n; i++){
		int num;
		cin >> num;
		A[i] = num;
	}
	bool flag = true;
	while(flag){
		flag = false;
		for(int i = n - 1; i >= 1; i--){
			if(A[i] < A[i - 1]){
				flag = true;
				int tmp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = tmp;
				count++;
			}
		}
	}
	for(int i = 0; i < n; i++){
		cout << A[i];
		if(i != n - 1) cout << ' ';
	}
	cout << endl;
	cout << count << endl;
}



Measured memory_bytes: 3092
n,m,x,y=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
X.sort()
Y.sort()

for i in range(x+1,y+1):
  if X[-1] < i and Y[0] >= i:
    print('No War')
    exit()
print('War')

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
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; }



int main() {
    int n;
    cin >> n;
    map<string,int>mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    ll ans = 0;
    for(pair<string,int>p:mp) {
        ll s = p.second;
        ans += s*(s-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll a, b;
    cin >> a >> b;

    if(a <= 9 && b <= 9) {
        out(a*b);
    }
    else {
        out(-1);
    }

    /*exrep(i, 1, 9) {
        exrep(j, 1, 9){
            if(i*j == a*b) {
                out(a*b);
                re0;
            }
        }
    }*/

    
    //out(-1);
    re0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1

ans = "No"

if N - cnt4*2 <= 1:
    ans =  "Yes"
elif N - cnt4*2 > 1:
    if N - cnt4*2 <= cnt2:
        ans = "Yes"
elif N - cnt4*2 == N:
    if N == cnt2*2:
        ans = "Yes"

print(ans)

Measured memory_bytes: 20108
from collections import deque
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
visited=[0]*n
def bfs(s):
    q=deque([s])
    visited[s]=1
    while q:
        x=q.popleft()
        for nx in edge[x]:
            if visited[nx]==0:
                visited[nx]=1
                q.append(nx)
    return
ans=0
for s in range(n):
    if visited[s]==0:
        bfs(s)
        ans+=1
print(ans-1)

Measured memory_bytes: 82068
n = int(input())
g = [[] for _ in range(n)]
 
for i in range(n-1):
  a, b = map(int, input().split())
  a, b =  a-1, b-1
  g[a].append(b)
  g[b].append(a)

from collections import deque
f = deque()
s = deque()
 
f.append(0)
s.append(n-1)
 
f_visit = [-1]*n
s_visit = [-1]*n
f_visit[0] = 0
s_visit[n-1] = 0

def bfs(queue, visit):
  x = queue.popleft()
  for new_x in g[x]:
    if visit[new_x] == -1:
      visit[new_x] = visit[x]+1
      queue.append(new_x)
    else:
      continue

while f:
  bfs(f, f_visit)

while s:
  bfs(s, s_visit)

fp = 0
sp = 0
for i in range(n):
  if f_visit[i] <= s_visit[i]:
    fp += 1
  else:
    sp += 1
if fp <= sp:
  print('Snuke')
else:
  print('Fennec')

Measured memory_bytes: 64032
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();

if(s[n-1]=='1')
{
	ol("-1");
	return 0;
}
if(s[0]=='0')
{
	ol("-1");
	return 0;
}

rep(i,0,n-2)
{
	if(s[i]!=s[n-2-i])
	{
		ol("-1");
		return 0;
	}
}

int lst=1,cc=0;

rep(i,0,n-1)
{
	if(s[i]=='0')cc++;
	else
	{
		rep(i,1,cc+1)
		{
			o2(lst,lst+i);on;
		}
		lst=lst+cc+1;
		cc=0;
	}
}

return 0;
}



Measured memory_bytes: 1616
#pragma region Macros
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("funroll-loops")
#pragma GCC optimize("fomg-optimize")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn, now, ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos) n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos) k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos) a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos) pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos) b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


Measured memory_bytes: 7864
N = int(input())
A = int(input())

max_500 = N//500


list = []


for i in range(max_500 + 1):
    for j in range(A + 1):
        if  500 * i + j == N:
            list.append(j)

if len(list) >= 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int a;
	string s;
	
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
	return 0;
}

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

int main(){

	int N,M,X,Y;
  	cin >> N >> M >> X >> Y;
  	
  	int x,y;
  	int max_x = -100;
  	int min_y = 100;
  	
  	for(int i = 0; i < N ; i++){
		cin >> x;
      	if(x > max_x) max_x = x;
    }
  
    for(int i = 0; i < N ; i++){
		cin >> y;
      	if(y < min_y) min_y = y;
    }
  

  
  	int flag = -1;
  	for(int z = -100; z < 101; z++){
    
    	if(X < z && z <= Y){
        
        	if(max_x < z && min_y >= z){
            
              	cout << "No War" << endl;
            	flag = 1;
              	break;
              	
            }
        
        
        }
    
    
    }
  
 	 if(flag == -1)cout << "War" << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#define b 100
int main(){
    int n,hang,lie,cisu;
    scanf("%d",&n);
    int mtx[b][b]={0};
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&hang,&cisu);
        for(int j=0;j<cisu;j++){
            scanf("%d",&lie);
            mtx[hang-1][lie-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for (int j=0; j<n-1; j++) {
            printf("%d ",mtx[i][j]);
            }
        printf("%d",mtx[i][n-1]);
        printf("\n");
    }
}



Measured memory_bytes: 3260
n=int(input())
h=list(map(int,input().split()))

dp=[0]
dp.append(abs(h[1]-h[0]))

for i in range(2,n):
    step1=dp[i-1]+abs(h[i]-h[i-1])
    step2=dp[i-2]+abs(h[i]-h[i-2])
    dp.append(min(step1,step2))
print(dp[-1])

Measured memory_bytes: 55280
#include <stdio.h>
 
int main(void)
{
    int i, j, n, tmp;
    char s;
    int card[4][13];
    for(i=0; i<4; i++){
        for(j=0; j<13; j++)
            card[i][j] = 0;
    }
     
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%s%d", &s, &tmp);
        //printf("%c %d\n",s,  tmp);
         
        if(s == 'S')
            card[0][tmp-1] = 1;
        else if(s == 'H')
            card[1][tmp-1] = 1;
        else if(s == 'C')
            card[2][tmp-1] = 1;
        else
            card[3][tmp-1] = 1;
         
    }
    for(i=0; i<4; i++){
        for(j=0; j<13; j++){
            if(card[i][j] == 0){
                if(i==0)
                    printf("S %d\n", j+1);
                else if(i==1)
                    printf("H %d\n", j+1);
                else if(i==2)
                    printf("C %d\n", j+1);
                else
                    printf("D %d\n", j+1);
                }
        }
    }
    return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		
		int[] Fib = new int[45];
		Fib[0] = 1;
		Fib[1] = 1;
		
		for(int i=2; i<=n; i++){
			Fib[i] = Fib[i - 1] + Fib[i - 2];
		}
		System.out.println(Fib[n]);
	}
}


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

int main(){
  int N, X, L, D=0;
  int count=1;
  cin >> N >> X;
  for(int i=0; i<N; i++){
    cin >> L;
    D += L;
    if(D<=X) count++;
  }
  cout << count << endl;
}

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

using namespace std;

int main()
{
    string s, t;

    cin >> s >> t;
    bool ans = false;

    for (int i = 0; i < s.length(); i++)
    {
        if (s == t)
        {
            ans = true;
        }
        s = s.back() + s.substr(0, s.size() - 1);
    }

    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


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

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    LL N;
    cin >> N;
    FOR(h, 1, 3501) {
        FOR(w, 1, 3501) {
            LL buf1 = N * h * w;
            LL buf2 = 4 * h * w - N * w - N * h;
            if (buf1 && buf2 && buf1 % buf2 == 0 && buf1 / buf2 <= 3500 && buf1 / buf2 > 0) {
                cout << h << " " << buf1 / buf2 << " " << w << endl;
                return 0;
            }
        }
    }
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N,D; cin>>N>>D;
    D = 2*D + 1;
    cout<<(N-1)/D+1<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li,li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li,li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b){
  if(b)cout<<"Yes";
  else cout<<"No";
}
void yes(li b){
  if(b)cout<<"yes";
  else cout<<"no";
}

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


li H,N;
 
 cin >>H>>N;

 vi A(N);
 Input(A);
 
 li sum=0;
 for(auto a:A){
 	sum +=a;
 }

 Yes(sum >= H);
 


}

Measured memory_bytes: 3960
import math
n = int(input())
x, y = [list(map(int, input().split())) for _ in range(2)]
for p in (1,2,3,0):
    if p == 0:
        print(max(abs(x-y) for x, y in zip(x,y)))
    else:
        print(math.pow(sum(abs(x-y) ** p for x, y in zip(x,y)), 1.0 / p))

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

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

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct edge {
  int to, cost;
  edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

#define MAX_N 100000

double P;
int N;
vector<edge> graph[MAX_N];
double tsum;

double rec1(int u, int p) {
  double res = 0.0;
  for(edge& e : graph[u]) {
    if(e.to != p) res += P * (e.cost + rec1(e.to, u));
  }
  return res;
}

double rec2(int u, int p) {
  double res = tsum;
  for(edge& e : graph[u]) {
    if(e.to != p) res += P * (e.cost + rec2(e.to, u));
  }
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> P >> N;
  rep(i, N-1) {
    int x, y, c;
    cin >> x >> y >> c; --x, --y;
    graph[x].emplace_back(y, c);
    graph[y].emplace_back(x, c);
  }

  tsum = rec1(0, -1);
  cout << rec2(0, -1) << endl;

  return 0;
}

Measured memory_bytes: 16560
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int K = scan.nextInt();
    String S = scan.next();
    scan.close();

    System.out.println(S.length() <= K ? S : S.substring(0, K) + "...");
  }
}

Measured memory_bytes: 27060
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> s(n);
    ll flag = INF;
    ll ans = 0;
    for(ll i=0;i<n;++i){
        cin>>s[i];
        if(s[i] % 10 != 0){
            flag = min(s[i], flag);
        }
        ans += s[i];
    }

    if(flag == INF){
        ans = 0;
    }else if(ans % 10 == 0){
        ans -= flag;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    ABC=[tuple(map(int,input().split())) for i in range(n)]
    dp=[[0,0,0]for _ in range(n+1)] #i日目にjをするときの幸福度の総和
    for i in range(n):
        ni=i+1
        dp[ni][0]=max(dp[i][1],dp[i][2])+ABC[ni-1][0]
        dp[ni][1]=max(dp[i][0],dp[i][2])+ABC[ni-1][1]
        dp[ni][2]=max(dp[i][0],dp[i][1])+ABC[ni-1][2]
    print(max(dp[n]))

if __name__=='__main__':
    main()

Measured memory_bytes: 73436
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;

const int N=305;

int n,m,num,ans,p,mx,mn;
int a[N][N],cnt[N];
bool vis[N];

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	mn=n;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) scanf("%d",&a[i][j]);
	for (i=1;i<=m;i++) vis[i]=1;
	while (1){
		memset(cnt,0,sizeof(cnt));
		ans=0;
		for (i=1;i<=n;i++)
			for (j=1;j<=m;j++)
				if (vis[a[i][j]]){
					cnt[a[i][j]]++; ans++;
					break;
				}
		if (ans<n) break;
		mx=0;
		for (i=1;i<=m;i++)
			if (cnt[i]>mx&&vis[i]){
				mx=cnt[i]; p=i;
			}
		vis[p]=0; mn=min(mn,mx);
	}
	printf("%d\n",mn);
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
#define TRUE 1
#define FALSE 0
#define MAX 1000
#define VMAX 10000

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve(){
  int i, j, tmp, ans = 0;
  int V[MAX];
  for(i = 0; i < n; i++){
    B[i] = A[i];
    V[i] = FALSE;
  }
  for(i = 0; i < n; ++i){
    for(j = i + 1; j < n; ++j){
      if(B[i] > B[j]){
	tmp = B[i];
	B[i] = B[j];
	B[j] = tmp;
      }
    }
  }
  for(i = 0; i < n; i++) T[B[i]] = i;
  for(i = 0; i < n; i++){
    if(V[i] == TRUE) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while(1){
      V[cur] = TRUE;
      an++;
      int v = A[cur];
      m = (int)fmin(m, v);
      S += v;
      cur = T[v];
      if(V[cur] == TRUE) break;
    }
    ans += (int)fmin(S + (an - 2) * m, m + S + (an + 1) * s);
  }

  return ans;
}

int main(){
  int i;
  scanf("%d",&n);
  s = VMAX;
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
    s = (int)fmin(s, A[i]);
  }
  int ans = solve();
  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i = 0 ; i < n ; i++){
		cin>>a[i];
	}
	int t;
	cin>>t;
	while(t--){
		long long  c,b,sum = 0 ;
		
		cin>>c>>b;
		
		for(int i = 0 ; i < n ; i++){
			if(i==c-1){
				sum+=b;
			}
			else
				sum+=a[i];
		}
		cout<<sum<<endl;
	}
	
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int, input().split()))

cnt = 0
while True:
    for i in range(len(A)):
        if A[i] % 2 != 0:
            break
    else:
        A = [a/2 for a in A]
        cnt += 1
        continue
    break

print(cnt)

Measured memory_bytes: 3060
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int T_length,P_length,range;
int *Rank;
int *Suffix_Array;
int *Work;

char *T,*P;


int strCmp_Suffix_Array(int start){
	int index,ret;

	ret = 0;

	for(index = 0; index < P_length && T[start+index] != '\0'; index++){
		if(P[index] != T[start+index]){
			if(P[index] > T[start+index]){
				ret = 2;
			}else{
				ret = 1;
			}
			break;
		}
	}
	if(ret == 0 && index < P_length){
		ret = 2;
	}
	return ret;
}


bool compare_Suffix_Array(int a,int b){
	if(Rank[a] != Rank[b])return Rank[a] < Rank[b];
	else{
		int rank_a = a + range <= T_length ? Rank[a+range]:-1;
		int rank_b = b + range <= T_length ? Rank[b+range]:-1;
		return rank_a < rank_b;
	}
}

bool isContain(){
	int left = 0,right = T_length,m;
	m = (left+right)/2;

	while(left <= right){
		switch(strCmp_Suffix_Array(Suffix_Array[m])){
		case 0:
			return true;
		case 1:
			right = m-1;
			break;
		case 2:
			left = m+1;
			break;
		}
		m = (left+right)/2;
	}
	return false;
}

void make_Suffix_Array(){
	for(int i = 0; i <= T_length; i++){
		Suffix_Array[i] = i;
		Rank[i] = i < T_length? T[i]:-1;
	}

	for(range = 1; range <= T_length; range*=2){
		sort(Suffix_Array,Suffix_Array+(T_length+1),compare_Suffix_Array);

		Work[Suffix_Array[0]] = 0;
		for(int i = 1; i <= T_length; i++){
			Work[Suffix_Array[i]] = Work[Suffix_Array[i-1]] + (compare_Suffix_Array(Suffix_Array[i-1],Suffix_Array[i])?1:0);
		}
		for(int i = 0; i <= T_length; i++){
			Rank[i] = Work[i];
		}
	}
}


int main(){

	T = new char[1000001];
	scanf("%s",T);

	for(T_length = 0; T[T_length] != '\0'; T_length++);
	Rank = new int[T_length+1];
	Suffix_Array = new int[T_length+1];
	Work = new int[T_length+1];

	make_Suffix_Array();

	int Q;
	scanf("%d",&Q);

	P = new char[1001];
	for(int loop = 0; loop < Q; loop++){
		scanf("%s",P);

		for(P_length = 0; P[P_length] != '\0'; P_length++);

		if(isContain()){
			printf("1\n");
		}else{
			printf("0\n");
		}
	}

	return 0;
}

Measured memory_bytes: 15324
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
bool comp(const pii &a, const pii &b){
	return a.second < b.second;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<pii> br;
	for(int i=0; i<m; i++){
		int a,b;
		cin >> a >> b;
		br.emplace_back(a, b);
	}
	sort(br.begin(), br.end(), comp);

	int ans=0;
	int last=-1;
	for(auto bridge: br){
		int a=bridge.first, b=bridge.second;
		if(a<=last and last<b) continue;
		ans++;
		last = b-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
use num::complex::Complex;
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

#[allow(unused_macros)]
macro_rules! echo {
    ($($e:expr),+) => ( { $(println!("{}", $e))+ } );
}

fn main() {
    input! {
        a: f64,
        b: f64,
        h: f64,
        m: f64,
    }

    let l = Complex::from_polar(&b, &(m / 60.0 * 2.0 * std::f64::consts::PI));
    let s = Complex::from_polar(&a, &((60.0 * h + m) / 720.0 * 2.0 * std::f64::consts::PI));
    let ans = (l - s).norm();

    echo!(ans);
}


Measured memory_bytes: 2944
def e(x,y):
 A[y][x]='0'
 for dx,dy in[[-3,0],[-2,0],[-1,0],[1,0],[2,0],[3,0],[0,-3],[0,-2],[0,-1],[0,1],[0,2],[0,3]]:
  if 0<=x+dx<8 and 0<=y+dy<8 and A[y+dy][x+dx]=='1':e(x+dx,y+dy)

for i in range(int(input())):
 print(f'Data {i+1}:')
 input()
 A=[list(input())for _ in[0]*8]
 e(int(input())-1,int(input())-1)
 for r in A:print(*r,sep='')


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int N, A, B, C;
int l[9];

int dfs(int cur, int a, int b, int c){
    if(cur == N){
        if(min(a,min(b,c)) > 0) return abs(a-A) + abs(b-B) + abs(c-C) - 30;
        else return 1000000000;
    }
    int ret0 = dfs(cur+1,a,b,c);
    int ret1= dfs(cur+1,a+l[cur],b,c) + 10;
    int ret2 = dfs(cur+1,a,b+l[cur],c) + 10;
    int ret3 = dfs(cur+1,a,b,c+l[cur]) + 10;
    return min(min(ret0,ret1),min(ret2,ret3));
}
int main(){
    cin >> N;
    cin >> A >> B >> C;
    REP(i,N) cin >> l[i];
    cout << dfs(0,0,0,0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	
	int  dig1 = input.nextInt();
	int dig2 = input.nextInt();
	
	input.close();
	
	int prod = dig1 * dig2;
	
	if(prod % 2 == 0 ) {
		System.out.println("Even");
	}else{
		System.out.println("Odd");
		}
	}

}

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

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


Measured memory_bytes: 3088
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)998244353;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    LL N,S;
    cin>>N>>S;
    VI a(N);
    REP(i,N) cin>>a[i];
    VI q(S+1,0);
    LL ans=0;
    REP(i,N){
        q[0] += 1;
        VI q2(S+1,0);
        REP(j,S+1){
            (q2[j] += q[j])%=MOD;
            if(j+a[i]<=S){
                (q2[j+a[i]] += q[j])%=MOD;
            }
        }
        q = q2;
        (ans += q[S])%=MOD;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 384