akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (a, b): (usize, usize) = parse!(it, 2);
    let mut i = (a as f64 / 0.08).ceil() as usize;
    loop {
        if (((i as f64) * 0.08).floor() as usize) > a {
            println!("{}", -1);
            return;
        }
        if (((i as f64) * 0.1).floor() as usize) == b {
            println!("{}", i);
            return;
        }
        i += 1;
    }
}


Measured memory_bytes: 4352
INTEGER N,M,X,Y
INTEGER,ALLOCATABLE,DIMENSION(:)::A,B
READ*,N,M,X,Y
ALLOCATE(A(N))
ALLOCATE(B(M))
READ*,A
READ*,B
PRINT"(A)",MERGE("No War","War   ",MAX( X,MAXVAL(A) )<MIN( Y,MINVAL(B) ) )
END

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

using namespace std;

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n, k, ans = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        if(i+k <= n) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	x,y = map(int,input().split())	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# 3
# hoge
# foo
# bar
# n=int(input())
# string_list=[input() for i in range(n)]
X=int(input())
if X==7 or X==5 or X==3:
    print("YES")
else:
    print("NO")

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


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

    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;
typedef pair<llint, llint> P;

llint n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	if(n == 1){
		cout << 1 << endl;
		cout << 0 << endl;
		return 0;
	}
	if(n == 2){
		cout << 2 << endl;
		cout << 0 << endl;
		cout << 11 << endl;
		return 0;
	}
	
	cout << n-1 << endl;
	for(int i = 0; i < n-1; i++){
		cout << 0;
		for(int j = 0; j < i; j++) cout << 1;
		cout << 0 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main()
{
    int h, w;
    char map[105][105];

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> map[i][j];
        }
    }

    for (int i = -1; i <= h; i++) {
        for (int j = -1; j <= w; j++) {
            if (i >= 0 && i < h &&
                    j >= 0 && j < w) {
                cout << map[i][j];
            } else {
                cout << '#';
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
long long N;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    cin >> N;
    vector<long long> B(N + 1);
    for (int i = 1; i < (N + 1); ++i) {
        long long A;
        cin >> A;
        B[i] -= A - i;
    }
    sort(B.begin() + 1, B.end());

    long long b = B[(N + 1) / 2];

    long long ans = 0;
    for (int i = 1; i < (N + 1); ++i) {
        ans += abs(B[i] - b);
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 1792
while True:
    n = int(input())
    if n==0:break
    s = input()

    for _ in range(n):
        i, cnt = 0, 1
        pre=s[i]
        tmp=""
        while i+1<len(s):
            while i+1<len(s) and pre==s[i+1]: cnt, i = cnt+1, i+1
            tmp += str(cnt)+pre
            cnt=0
            if i+1!=len(s): pre=s[i+1]
        s = tmp
    print(s)

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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);
  rep(_, b) cout << a;
  cout << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] c1 = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int[] c2 = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int[] c3 = SpRead(' ').Select(_ => int.Parse(_)).ToArray();
        int a0, a1, a2;
        a0 = c1.Min();
        a1 = c2.Min();
        a2 = c3.Min();

        int[] cx1 = new int[3]; Array.Copy(c1, cx1, 3);
        int[] cx2 = new int[3]; Array.Copy(c2, cx2, 3);
        int[] cx3 = new int[3]; Array.Copy(c3, cx3, 3);
        for (int i = 0; i < 3; i++) { cx1[i] -= a0; cx2[i] -= a1; cx3[i] -= a2; }

        int b0, b1, b2;
        b0 = Math.Min(Math.Min(cx1[0], cx2[0]), cx3[0]);
        b1 = Math.Min(Math.Min(cx1[1], cx2[1]), cx3[1]);
        b2 = Math.Min(Math.Min(cx1[2], cx2[2]), cx3[2]);

        bool ans = true;
        if (a0 + b0 != c1[0]) ans = false;
        else if (a0 + b1 != c1[1]) ans = false;
        else if (a0 + b2 != c1[2]) ans = false;
        else if (a1 + b0 != c2[0]) ans = false;
        else if (a1 + b1 != c2[1]) ans = false;
        else if (a1 + b2 != c2[2]) ans = false;
        else if (a2 + b0 != c3[0]) ans = false;
        else if (a2 + b1 != c3[1]) ans = false;
        else if (a2 + b2 != c3[2]) ans = false;

        Console.WriteLine((ans ? "Yes" : "No"));
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


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

using namespace std;

#define ll long long

const int mxN = 1e5 + 5;

int n, k;

bool dp[mxN];
int a[105];

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

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

    for (int i = 0; i < k; i++) {
        if (!dp[i]) {
            for (int j = 0; j < n; j++) {
                if (i + a[j] <= k) {
                    dp[i + a[j]] = true;
                } else break;
            }
        }
    }
    string s = dp[k] ? "First" : "Second";
    cout << s << endl;
}


Measured memory_bytes: 384
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import sys
sys.setrecursionlimit(10**6)
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq

n,k,x=list(map(int,input().split()))

c=np.array([list(map(int,input().split())) for _ in range(n)])
kumi=[i for i in range(n)]
ans=float("inf")
for k_n in range(n+1):
    t=itertools.combinations(kumi, k_n)
    for each in t:
        cal=c[each,:].sum(axis=0)
        if min(cal[1:])>=x:
            ans=min(cal[0],ans)
if ans==float("inf"):
    ans=-1
print(ans)


Measured memory_bytes: 27320
#include <stdio.h>
#define A 1000

int main()
{
    int n, a[A], i, j;

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

    }
    for(j = 0; j < n; j++)
    {
        if( a[j] % 2 != 0 )
            continue;
        else
        {
            if( a[j] % 3 == 0 || a[j] % 5 == 0 )
                continue;
            else 
            {
                printf("DENIED\n");
                return 0;
            }
        }
    }
    printf("APPROVED\n");

    return 0;
}

Measured memory_bytes: 128
import sys

if sys.subversion[0] == "PyPy":
    import io, atexit

    sys.stdout = io.BytesIO()
    atexit.register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

    sys.stdin = io.BytesIO(sys.stdin.read())
    input = lambda: sys.stdin.readline().rstrip()
RS = raw_input
RA = lambda x=int: map(x, RS().split())
RN = lambda x=int: x(RS())


def solve():
    s = numberToBase(n, 26)
    for i in reversed(range(len(s))):
        if s[i] <= 0:
            if i-1 >= 0:
                s[i] += 26
                s[i-1] -= 1
            else:
                s.remove(0)
    #print(s)
    ans = [chr(int(c) + ord("a")- 1) for c in s]
    print "".join(ans)
    return


def numberToBase(n, b):
    if n == 0:
        return [0]
    digits = []
    while n:
        digits.append(int(n % b))
        n //= b
    return digits[::-1]

n = RN()
solve()


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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
//typedef pair<int, int> pi;

const double pi = acos(-1);

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A, B, H, M;
    cin >> A >> B >> H >> M;
    double angle1 = 1.0 * M / 60 * (2 * pi);
    double angle2 = 1.0 * (H * 60 + M) / 720 * (2 * pi);
    double delta = fabs(angle1 - angle2);
    delta = min(delta, 2 * pi - delta);
    double c = sqrt(A * A + B * B - 2 * A * B * cos(delta));
    cout << setprecision(10) << c << endl;
    return 0;
}


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

void Main()
{
    int64_t N, M;
    cin >> N >> M;
    vector<int64_t> A(N);
    double sum = 0;
    for(int64_t i = 0; i < N; ++i)
    {
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(), A.end(), greater<int64_t>());
    if(A[M - 1] >= sum / (4 * M))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+999;

struct edge{
	int to,nxt,dis;
}e[maxn];
int head[maxn],tot;
void add(int x,int y,int z){
	e[++tot].to=y;
	e[tot].nxt=head[x];
	e[tot].dis=z;
	head[x]=tot;
}
int n,m,col[maxn],cnt0,cnt1,cnt2,cnt,fl;

void dfs(int x,int c){
	col[x]=c;
	if(c==0)cnt0++;
	if(c==1)cnt1++;
	if(c==2)cnt2++;
	for(int i=head[x];i;i=e[i].nxt){
		int y=e[i].to;
		if(e[i].dis>0)++cnt;
		if(col[y]==-1)dfs(y,(c+e[i].dis+3)%3);
		else if(col[y]!=(c+e[i].dis+3)%3)fl=1;
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y,1);add(y,x,-1);
	}
	long long ans=0;
	memset(col,-1,sizeof(col));
	for(int i=1;i<=n;++i){
		if(col[i]==-1){
			fl=cnt=cnt0=cnt1=cnt2=0;
			dfs(i,0);
			if(fl){//染色失败 完全图 
				ans+=1ll*(cnt0+cnt1+cnt2)*(cnt0+cnt1+cnt2);
			}
			else if(cnt0&&cnt1&&cnt2){
				ans+=1ll*cnt0*cnt1+1ll*cnt1*cnt2+1ll*cnt2*cnt0;
			}
			else ans+=cnt;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 6912
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j,N,H,W,ans=0;
  cin>>N;
  string s;
  cin>>s;
  rep1(i,N){
    if(s[i]!=s[i-1])ans++;
  }
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
long g(long X,long Y){
  if ((X=X%Y)) return g(Y,X);
  else         return (Y);
}
int main(void) {
  long X,Y;
  scanf("%ld %ld\n",&X,&Y);
  if(Y>X) {long t=X;X=Y;Y=t;}
  printf("%ld\n",g(X,Y));
  return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {FIN;
    
    int a,b,c;cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
    return 0;
}



Measured memory_bytes: 256
N=int(input())
L=[0 for i in range(10**4+1)]
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            n=x*x+y*y+z*z+x*y+y*z+z*x
            if n<=10**4:
                L[n]+=1
for i in range(1,N+1):
    print(L[i])

Measured memory_bytes: 68784
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> div = {0,0,0,0,0};

    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        if (a % 4 == 0) div[4]++;
        else if (a % 2 == 0) div[2]++;
        else div[0]++;
    }

    bool ans = false;
    ans = ans || div[2] == n;
    ans = ans || (div[2] == 0 && div[4] >= div[0] - 1);
    ans = ans || div[4] >= div[0];
//    ans = ans || (n == 3 && div[4]>=1);


    cout << (ans? "Yes" : "No") << endl;
}

/*
 * 1 4 1
 * 1 4 1
 * 1 4 1 4 2 2
 * 1 4 1 4 1
 */

Measured memory_bytes: 632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String input = Console.ReadLine();
        bool flag = false;
        for (int i = 0; i < input.Length; i++)
        {
            if (input[i]=='7') { flag = true; }
        }
        if (flag) { Console.WriteLine("Yes"); }
        else { Console.WriteLine("No"); }
    }
}

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

using namespace std;
#define mod 1000000007
int main()
{
    int n;
    cin >> n;
    bool b[n][n];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin >> b[i][j];
        }
    }
    int f[2097153];
    memset(f,0,sizeof(f));
    f[0]=1;
    for(int mask=0;mask<(1<<n);mask++)
    {
        int man=__builtin_popcount(mask);
        for(int i=0;i<n;i++)
        {
            if(!(mask&(1<<i)) && b[man][i])
            {
                f[mask|(1<<i)]+=f[mask];
                f[mask|(1<<i)]%=mod;
            }
        }
    }
    cout << f[(1<<n)-1];
    return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>
int main(void) {
    int n;
    scanf("%d", &n);
    int d[n], ans=0;
    for (int i=0; i<n; i++) {
        scanf("%d", d+i);
    }
    for (int i=0; i<n-1; i++) {
        for (int j=i+1; j<n; j++) {
            ans += d[i]*d[j];
        }   
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int _b=(b),i=(a);i<=_b;++i)
#define ROF(i, b, a) for(int _a=(a),i=(b);i>=_a;--i)
#define REP(n) for(int _n=(n);_n--;)
#define _1 first
#define _2 second
#define PB(x) push_back(x)
#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define MSET(m,v) memset(m,v,sizeof(m))
#define MAX_PQ(T) priority_queue<T>
#define MIN_PQ(T) priority_queue<T,vector<T>,greater<T>>
#define IO(){ios_base::sync_with_stdio(0);cin.tie(0);}
#define cint1(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long int ll; typedef pair<int,int> PII;typedef unsigned long long int ull;
typedef vector<int>VI; typedef vector<ll> VL; typedef vector<PII> VP;
template<class A,class B>inline bool mina(A &x,const B &y){return(y<x)?(x=y,1):0;}
template<class A,class B>inline bool maxa(A &x,const B &y){return(x<y)?(x=y,1):0;}

string SA, SB, SC;
int main() {
	IO();
	cin >> SA >> SB >> SC;
	reverse(ALL(SA));
	reverse(ALL(SB));
	reverse(ALL(SC));
			
	char term = 'a';
	while(true) {
		if (term == 'a') {
			if (SA.empty()) {cout<<"A"<<endl; return 0; }
			term = *(SA.end() - 1);	
			SA.pop_back();
			//cout << "A: " << term << endl;
		}
		else if (term == 'b') {
			if (SB.empty()) {cout<<"B"<<endl; return 0; }
			term = *(SB.end() - 1);
			//cout << "B: " << term << endl;
			SB.pop_back();
			
		}
		else {
			if (SC.empty()) {cout<<"C"<<endl; return 0; }
			term = *(SC.end() - 1);
			//cout << "C: " << term << endl;
			SC.pop_back();
		}
	}
	return 0;
}

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

const ll INF = 1LL << 60;




int main(){
  int MAX_N = 1e5;
  int sum[MAX_N+3];
  bool sosu[MAX_N+3];

  sum[0] = 0, sum[1] = 0;
  sosu[0] = false; sosu[1] = false;

  for(int i = 2; i <= MAX_N; i++){
    int sq = sqrt(i);
    bool flg = true;
    for(int j = 2; j <= sq; j++){
      if(i%j == 0) flg = false;
    }
    if(flg){
      sosu[i] = true;
      if(sosu[int((i+1)/2)]){
        sum[i] = sum[i-1] + 1;
      }else{
        sum[i] = sum[i-1];
      }
    }else{
      sosu[i] = false;
      sum[i] = sum[i-1];
    }
  }

  int Q;
  cin >> Q;

  //rep(i,10) cout << i << ' ' << sum[i] <<endl;

  rep(i,Q){
    int l,r;
    cin >> l >> r;
    cout << sum[r] - sum[l-1] << endl;
  }
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    map<int,vector<int>> ma;
    for(int i = 0;i < N;i++) {
        ma[i - vec.at(i) + 1].push_back(i);
    }
    ll ret = 0;
    for(int i = 0;i < N;i++) {
        ll cnt = ma[i + vec.at(i) + 1].size();
        ret += cnt;
    }
    cout << ret << endl;
}

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

using namespace std;

void Main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int minMoveX = tx - sx;
    int minMoveY = ty - sy;

    string ans;
    for (int i = 0; i < minMoveX; ++i) {
        ans += 'R';
    }
    for (int i = 0; i < minMoveY; ++i) {
        ans += 'U';
    }
    for (int i = 0; i < minMoveX; ++i) {
        ans += 'L';
    }
    for (int i = 0; i < minMoveY; ++i) {
        ans += 'D';
    }

    ans += 'D';
    for (int i = 0; i < minMoveX; ++i) {
        ans += 'R';
    }
    ans += 'R';
    ans += 'U';
    for (int i = 0; i < minMoveY; ++i) {
        ans += 'U';
    }
    ans += 'L';
    ans += 'U';
    for (int i = 0; i < minMoveX; ++i) {
        ans += 'L';
    }
    ans += 'L';
    ans += 'D';
    for (int i = 0; i < minMoveY; ++i) {
        ans += 'D';
    }
    ans += 'R';
    cout << ans << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int x, n;
int p[100];

bool contain(int x) {
	for (int i = 0; i < n; i++) {
		if (p[i] == x) {
			return true;
		}
	}
	return false;
}

int main() {
	cin >> x >> n;
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; ; i++) {
		if (!contain(x-i)) {
			cout << x-i << endl;
			return 0;
		}
		if (!contain(x+i)) {
			cout << x+i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3588
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int A = Integer.parseInt(sc.get());
		int B = Integer.parseInt(sc.get());
		int X = Integer.parseInt(sc.get());
		double height = 1. * X / A / A;
		double result;
		if (height <= 0.5 * B){
			result = Math.atan2(B, 2. * X / B / A);
		} else {
			result = Math.atan2(B - height, 0.5 * A);
		}
		System.out.printf("%.10f",Math.toDegrees(result));
		System.out.println();
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 21588
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string a;
	string b;
	cin >> a;
	cin >> b;
	int la = a.length();
	int lb = b.length();
	if(la > lb){	
		printf("GREATER\n");
		return 0;
	}
	else if(lb > la){
		printf("LESS\n");
		return 0;
	}
	else{
		for(int i = 0; i < la; i++){
			if(a[i] > b[i]){
				printf("GREATER\n");
				return 0;
			}
			else if(a[i] < b[i]){
				printf("LESS\n");
				return 0;
			}
			else if(a[i] == b[i] && i == la - 1){
				printf("EQUAL\n");
				return 0;
			}
		}
	}
}

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

using namespace std;

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

    unsigned long long n, p = 2, last = 0, fives = 0, cnt = 0;
    cin >> n;

    if (n % 2 == 0) {
        while (p * 5 <= n)
            p *= 5, cnt++;

        while (p > 2) {
            unsigned long long cur = n / p - last;
            last += cur;
            fives += cur * cnt;
            cnt--;
            p /= 5;
        }
    }
    cout << fives << '\n';

    return 0;
}

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

int main(){
  int N; cin >> N;
  
  int count = 0;
  for(int i=1; i<=N; i++){
    string S = to_string(i);
    if(S.size()%2 != 0)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char x,y;
    scanf("%c %c",&x,&y);
    if(x>y){
        printf(">\n");
    }
    else if(x<y) {
        printf("<\n");
    }
    else{
        printf("=\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}

int main()
{
    ll x;
    cin >> x;
    ll now = 100;
    int ans=0;
    while(now<x){
        double tmp=now;
        tmp*=1.01;
        now=tmp;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
n = int(input())
s = input()

r=[0]*(n+1)
g=[0]*(n+1)
b=[0]*(n+1)

for i in reversed(range(n)):
    if s[i]=='R':
        r[i]=r[i+1]+1
        b[i]=b[i+1]
        g[i]=g[i+1]
    if s[i]=='B':
        r[i]=r[i+1]
        b[i]=b[i+1]+1
        g[i]=g[i+1]
    if s[i]=='G':
        r[i]=r[i+1]
        b[i]=b[i+1]
        g[i]=g[i+1]+1

ans=0

for i in range(n):
    for j in range(i+1,n):
        if s[i]!=s[j]:
            if s[i] != 'R' and s[j] != 'R':
                ans+=r[j]
                if (2*j-i)<n and s[2*j-i] == 'R':
                    ans-=1
            if s[i] != 'G' and s[j] != 'G':
                ans+=g[j]
                if (2*j-i)<n and s[2*j-i] == 'G':
                    ans-=1
            if s[i] != 'B' and s[j] != 'B':
                ans+=b[j]
                if (2*j-i)<n and s[2*j-i] == 'B':
                    ans-=1

print(ans)

Measured memory_bytes: 68956
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int n; string s; cin >> n >> s;
  if(n%2 != 0){
    cout << "No" << endl;
    return 0;
  } else {
    string sub;
    int counter = 1;
    for(counter = 1; counter <= n/2; counter++){
      if(s[counter - 1] == s[n/2 + counter - 1]){
	
      } else {
	cout << "No" << endl;
	return 0;
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

using namespace std;

void quick_sort(long long s[], long long left, long long right){
	long long p, l, r, t;
    l = left, r = right;
    p = s[(l+r)/2];
    while(1){
    	while(s[l] < p)
    		l++;
    	while(s[r] > p)
        	r--;
        if(l >= r) break;
        t = s[r];
        s[r] = s[l];
        s[l] = t;
        l++;r--;
    }
    if(left < l-1)
    	quick_sort(s, left, l-1);
    if(right > r+1)
    	quick_sort(s, r+1, right);
}

int comb(long n, long r){
	if(n == 0) return 1;
    else if(r == 0) return 1;
    else if(r == n) return 1;
    else return comb(n-1, r) + comb(n-1, r-1);
}

int main(){
    long long n, t, l, count = 0;
    cin >> n;
    long long a[n], s[n+2];
    
    for(int i = 0; i < n; i++){
    	cin >> t;
    	a[i] = t;
    }
    
    s[0] = 0;
    for(int i = 1; i < n+1; i++){
    	s[i] = a[i-1] + s[i-1];
    }
    
    //sort(s, s+n+1);
    quick_sort(s, 0, n);

    l = 0;s[n+1] = 1000000000000000LL;
    for(int i = 0; i <= n+1; i++){
    	if(s[i]!=s[l]){
        	count += (i-l)*(i-l-1)/2;
            l = i;
        }
    }
    
    cout << count << endl;
}






Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll number1, ll number2)
{
    return number1 * number2 / gcd(number1, number2);
}
template <class T>
bool contain(const std::string &s, const T &v)
{
    // contain(to_string(N), '3')
    return s.find(v) != std::string::npos;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
        return c - '0';
    return 0;
}
using namespace std;

int main()
{

    int n;
    string ans = "No";
    cin >> n;

    rep(i, 100)
    {
        rep(j, 100)
        {
            if (i * 4 + j * 7 == n)
            {
                ans = "Yes";
            }
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8

ll p[3];  //kazu
ll g[3];  //p[i]no kazu

int main(){
    ll n;
    ll c=0;   //cor
    int t=1;   //tigau num
    int l;     //tigau sum
    cin >> n;
    ll a[100007];

    rep(i,n){
        cin >> a[i];
    }

    p[0]=a[0];

    rep(i,n-1){      //同じ個数判定
        l=0;
        rep(j,t){
            if(a[i+1]!=p[j]){
                l++;
            }
            else{
                g[j]++;
            }
        }
        if(l==t){
            p[t]=a[i+1];
            t++;
        }
        if(t==4){
            c++;
            break;
        }
    }

    if(t==1){
        if(a[0]!=0){
            c++;
        }
    }
    if(t==2){
        if(p[0]==0){
            if(p[1]!= (p[0] xor p[1]) || (g[0]+1)*2!=g[1]+1){
                c++;
            }
        }
        else if(p[1]==0){
            if(p[0]!= (p[0] xor p[1]) || (g[1]+1)*2!=g[0]+1){
                c++;
            }
        }
        else{
            c++;
        }
    }
    if(t==3){
        if(p[0]!= (p[1] xor p[2]) || g[0]!=g[1] || g[1]!=g[2] || g[2]!=g[0]){
            c++;
        }
    }
    if(c==0){
        cout << "Yes" << endl;
    }
    else{
        cout <<  "No" << endl;
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long

using namespace std;



	

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

	ll x;cin>>x;

	ll count = 0;
	
	if(x >= 500)
	{
		count += (x/500) * 1000;
		x %= 500;

	}	
	if(x >= 5)
	{
		count += (x/5) * 5;
		
	}
	
	cout<<count<<"\n";


		
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N;
  int A[101];
  
  cin >> N;
  
  for (int i = 1; i <= N; i++)
  {
    cin >> A[i];
  }
  
  int count = 0;
  
  for (int i = 1; i <= N; i++)
  {
    if (i % 2 != 0 && A[i] % 2 != 0)
    {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3524
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    vector<string> c(2);
    cin >> c[0];
    cin >> c[1];

    bool flag = true;
    for (int i = 0; i < 3; ++i) {
        if (c[0][i] != c[1][2 - i]) {
            flag = false;
            break;
        }
    }

    if (flag)
        cout << "YES\n";
    else
        cout << "NO\n";
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*b)/gcd
#define rep(i,n)     for(int i=0;i<n;i++)
#define Rep(i,n)     for(int i=1;i<=n;i++)
#define REP(i,j,n)   for(int i=j;i<=n;i++)
#define FOR(i,n)   for(int i=n;i>=0;i--)
#define n_digit(n)   floor(log10(n))+1





int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
   char  s;
   cin>>s;
   if(s>='A'&&s<='Z') cout<<"A"<<endl;
   else cout<<"a"<<endl;
   return 0;
    
}

Measured memory_bytes: 3556
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
#include <list>
#define ll long long int
using namespace std;
 vector <list <ll>> arr;
 vector <ll> vis;
    vector <ll> val;
ll solve(ll i)
{
    //cout<<"//////inside "<<i<<endl;
    if(vis[i]==1)
    return val[i];
     ll temp=arr[i].size();
        list <ll> tarr(temp);
        if(temp==0)
       {
           val[i]=0;
           vis[i]=1;
           //cout<<"0 wala i = "<<i<<" "<<val[i]<<endl;;
           return 0;
       }
        ll max=0;
         list <ll> :: iterator it; 
         
         for(it = arr[i].begin(); it != arr[i].end(); ++it) 
         {
             ll t1=solve(*it);
             val[*it]=t1;
             vis[*it]=1;
             if(t1>max)
             max=t1;
           //  cout<<" i = "<<*it<<" "<<val[*it]<<endl;

         }
         val[i]=max+1;
         vis[i]=1;
         //cout<<" i = "<<i<<" "<<val[i]<<endl;
         return max+1;


         

}


int main()
{
    ll n,m;
    cin>>n>>m;
    arr.resize(n);
   
    for(ll i=0;i<m;i++)
    {
        ll temp1,temp2;
        cin>>temp1>>temp2;
        arr[temp1-1].push_back(temp2-1);
    }
    
    for(ll i=0;i<n;i++)
    {
       vis.push_back(0);
       val.push_back(0);
    }
   
    for(ll i=0;i<n;i++)
    {
       // cout<<"inside "<<i<<endl;
        if(vis[i]==1)
        continue;
        solve(i);     
    }
    ll max=0;
   // for(ll i=0;i<n;i++)
   // cout<<" i = "<<val[i]<<endl;
    for(ll i=0;i<n;i++)
    if(val[i]>max)
    max=val[i];
    cout<<max<<endl;
   // cin>>n;
    return 0;

}

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

int n, m;
string a[60], b[60];

bool match(int x, int y) {
    int i, j;
    for (i = 0; i < m; i++) {
        for (j = 0; j < m; j++) {
            if (a[x + i][y + j] != b[i][j]) {
                return false;
            }
        }
    }
    return true;
}

int main(void){
    int i, j;
    cin >> n >> m;
    bool found = false;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < m; i++) cin >> b[i];
    
    for (i = 0; i <= n-m; i++) {
        for (j = 0; j <= n-m; j++){
            if(match(i, j)) found = true;
        }
    }
    cout << (found ? "Yes":"No") << endl;
    return 0;
}


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

int main() {
   while (1) {
      string s;
      getline(cin, s);
      if (s == ".") break;

      stack<char> stk;
      bool ok = true;
      int n = s.size();
      for (int i = 0; i < n; i++) {
         if (s[i] == '(') stk.push(s[i]);
         if (s[i] == '[') stk.push(s[i]);
         if (s[i] == ')') {
            if (stk.empty() || stk.top() != '(') {
               ok = false;
               break;
            }
            stk.pop();
         }
         if (s[i] == ']') {
            if (stk.empty() || stk.top() != '[') {
               ok = false;
               break;
            }
            stk.pop();
         }
      }
      if (stk.empty() && ok) {
         puts("yes");
      } else {
         puts("no");
      }
   }
}


Measured memory_bytes: 3196
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
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;

// パスカルの三角形
VVL comb(51, VL(51, 1));
void build_comb() {
    FOR(n, 1, 50)FOR(k, 1, n - 1)
        comb[n][k] = comb[n - 1][k - 1] + comb[n - 1][k];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, p;
    cin >> n >> p;
    int even_cnt = 0;
    REP(i, n) {
        int a;
        cin >> a;
        if(a % 2 == 0) even_cnt++;
    }
    int odd_cnt = n - even_cnt;

    build_comb();
    ll ans = 0;
    if(p == 0) {
        for(int k = 0; k <= odd_cnt; k += 2) ans += comb[odd_cnt][k];
        ans *= pow(2, even_cnt);
        cout << ans << endl;
    } else {
        for(int k = 1; k <= odd_cnt; k += 2) ans += comb[odd_cnt][k];
        ans *= pow(2, even_cnt);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>

using namespace std;
using ll = long long;

const int N = 301;
const int M = N * N;
const ll MOD = 998244353;

ll binpow(ll a, int p) {
    ll res = 1;
    while (p) {
        if (p & 1) {
            (res *= a) %= MOD;
        }
        (a *= a) %= MOD;
        p >>= 1;
    }
    return res;
}

ll dp[M], kek[M];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll ans = binpow(3, n);
    dp[0] = binpow(2, n);
    kek[0] = 1;
    ll q = binpow(2, MOD - 2);
    int tot = 0;
    for (int i = 0; i < n; i++) {
        for (int j = tot; j >= 0; j--) {
            (dp[j + a[i]] += dp[j] * q) %= MOD;
            (kek[j + a[i]] += kek[j]) %= MOD;
        }
        tot += a[i];
    }

    for (int w = (tot + 1) / 2; w <= tot; w++) {
        ans = (ans + MOD - 3 * dp[w] % MOD) % MOD;
    }

    if (tot % 2 == 0) {
        ans = (ans + kek[tot / 2] * 3) % MOD;
    }

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

Measured memory_bytes: 1664
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b = 
# s = input()

N = int(input())
A = [0] + list(map(int, input().split()))

ans = [0]*(N+1)
for i in range(1, N+1):
    ans[A[i]] = i

ans = list(map(str, ans))
print(" ".join(ans[1:]))
    


Measured memory_bytes: 62572
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;

#define int int64_t

int X, Y, A, B, C;


template <class T>
string myToStr(const vector<T>& vec) {
    string ret = "[";
    for (int i=0; i<vec.size(); ++i) {
        if (i == vec.size() -1 ) ret += to_string(vec[i]) + "]";
        else ret += to_string(vec[i]) + ", ";
    }
    return ret;
}

template <class U>
string myToStr(const vector<vector<U>>& vec_vec) {
    string ret = "[";
    for (int j=0; j<vec_vec.size(); ++j) {
        ret += myToStr(vec_vec[j]);
        if (j == vec_vec.size() -1) ret += "]";
        else  ret += "\n";
    }
    return ret;
}



signed main(){
    cin>>X>>Y>>A>>B>>C;

    vector<int> Alist(A, 0);
    vector<int> Blist(B, 0);
    vector<int> Clist(C, 0);

    for(int i=0; i<A; ++i) {
        int l;
        cin>>l;
        Alist[i] = l;
    }
    for(int i=0; i<B; ++i) {
        int l;
        cin>>l;
        Blist[i] = l;
    }
    for(int i=0; i<C; ++i) {
        int l;
        cin>>l;
        Clist[i] = l;
    }    

    sort(Alist.begin(), Alist.end());
    sort(Blist.begin(), Blist.end());
    sort(Clist.rbegin(), Clist.rend());

    // cout<<"Alist: "<<myToStr(Alist)<<endl;
    // cout<<"Alist: "<<myToStr(Blist)<<endl;
    // cout<<"Alist: "<<myToStr(Clist)<<endl;

    int a = A - X;
    int b = B - Y;
    int c = 0;

    // cout<<"a, b, c:"<<a<<", "<<b<<", "<<c<<endl;

    while(true) {
        if (c >= C) break;
        // if (a >=A)
        int ac = a < A ? Alist[a] : 9999999999;
        int bc = b < B ? Blist[b] : 9999999999;
        int cc = Clist[c];
        int m = min(ac, bc);
        if (m < cc) {
            c++;
            if (ac > bc) {
                b++;
            } else {
                a++;
            }
        }else{
            break;
        }
    }
    int score=0;

    for(int i=a; i<A; ++i) {
        score+=Alist[i];
    }
    for(int i=b; i<B; ++i) {
        score+=Blist[i];
    }
    for(int i=0; i<c; ++i) {
        score+=Clist[i];
    }
    cout<<score<<endl;
    // cout<<"a, b, c:"<<a<<", "<<b<<", "<<c<<endl;


    // sort(Alist.rbegin(), Alist.rend());
    // sort(Blist.rbegin(), Blist.rend());
    // sort(Clist.rbegin(), Clist.rend());


    // cout<<"Alist: "<<myToStr(Alist)<<endl;
    // cout<<"Alist: "<<myToStr(Blist)<<endl;
    // cout<<"Alist: "<<myToStr(Clist)<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N, Q;
    cin >> N >> Q;
    atcoder::dsu T(N);
    while(Q--){
        int t, u, v;
        cin >> t >> u >> v;
        if(t == 0)T.merge(u, v);
        else{
            cout << T.same(u, v) << endl;
        }
    }
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, N;
  long long max_dmg = 0;
  cin >> H >> N;
  int dmg;
  while(N--){
    cin >> dmg;
    max_dmg += dmg;
  }
  cout << (max_dmg >= H ? "Yes" : "No") << endl;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

string al = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

    int n;
    while (cin >> n, n) {
        vector<int> k(n);
        rep(i, n) cin >> k[i];
        string s;
        cin >> s;
        string t = "";
        rep(i, s.size()) {
            int id;
            if ('a' <= s[i] && s[i] <= 'z') {
                id = s[i] - 'a';
            } else {
                id = s[i] - 'A' + 26;
            }
            t += al[(id - k[i % n] + 52) % 52];
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 3092
// B. 

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cstdio>
#include <cstring>

using namespace std;
typedef long long LL;

int main(int argc, char *argv[])
{
	LL N, x, ans = 1LL << 60;
	cin >> N >> x;
	vector<LL> a(N);
	for (LL i = 0; i < N; ++i) {
		cin >> a[i];
	}
	vector<LL> b = a;
	for (LL i = 0; i < N; ++i) {
		LL sum = accumulate(b.begin(), b.end(), x * i);
		ans = min(ans, sum);
		for (LL j = 0; j < N; ++j) {
			int k = (j - i - 1 + 2 * N) % N;
			b[j] = min(b[j], a[k]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256