akhauriyash/Code-Regression huggingface dataset:
//file_name:ABC69_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int h,w,n;
    scanf("%d%d%d",&h,&w,&n);
    int aa[n] = {};
    rep(i,n){
        scanf("%d",&aa[i]);
    }


    int a[h][w];
    int count = 0;
    rep(i,n){
        rep(j,aa[i]){
            if((count/w)%2==0){
                a[count/w][count%w] = i+1;
            }else{
                a[count/w][w-1-(count%w)] = i+1;
            }
            count++;
        }
    }

    rep(i,h){
        rep(j,w){
            cout << a[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    double sum = 0.0;
    for (int i = 0; i < N; i++) {
        int Ai;
        cin >> Ai;
        sum += 1.0 / Ai;
    }
    printf("%.10f\n", 1.0 / sum);

    return 0;
}


Measured memory_bytes: 256
object Main extends App {
  import scala.io.StdIn._

  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val positions = readLine.trim.split(' ').map(_.toLong).sorted
  val distances = positions.indices.tail.map(i ⇒ positions(i) - positions(i - 1)).toArray.sorted(Ordering.Long.reverse)
  if (n >= m){
    println(0)
  }else {
    println(distances.drop(n - 1).sum)
  }
}

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

using namespace std;
using LL = long long;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    if (s.size() <= n) cout << s << endl;
    else {
        for (int i = 0; i < n; i++) cout << s[i];
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define con continue
#define bk break
#define LL long long
#define db double
#define pt cout<<'\n';
#define ms(a, b) memset((a), (b), sizeof(a))
#define mp make_pair
#define endl '\n'
LL inf=2147483647;const long long ll =9223372036854775807,ninf=1000000000;const double eps = 1e-6; const long long nll =1000000000000000000;
#define sz size()
#define len(X) strlen(X)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ULL unsigned long long
#define de cout<<"test"<<endl;
#define st system("pause");
#define F first
#define S second
int main()
{

int a,b;
while(cin>>a>>b){
    LL A[1005]={},B[1005]={},C[1005]={};
    for(int i=0;i<a;i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    LL ans=0;
    for(int i=0;i<(1<<3);i++){
        LL num[1005]={};
        for(int j=0;j<a;j++){
            LL sum=0;
            if(i&1){
                sum+=A[j];
            }
            else{
                sum+=(-1*A[j]);
            }

            if(i&2){
                sum+=B[j];
            }
            else{
                sum+=(-1*B[j]);
            }
            if(i&4){
                sum+=C[j];
            }
            else{
              sum+=(-1*C[j]);
            }
            num[j]=sum;
        }
        sort(num,num+a);
        reverse(num,num+a);
        LL tmp=0;
        for(int j=0;j<b;j++)
            tmp+=num[j];

        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define ppb pop_back
#define orta ((bas+son)>>1)
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 10000000000000000ll
#define MOD 1000000007
#define LOG 31
#define EPS 0.000000001
#define M 305
#define PI 3.14159265359
using namespace std;

int n;
int a[N], cnt[N][3];
ll dp[N][3]; // h - 1, h, h + 1

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);

	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		int value = (i >> 1) - 1;
		for(int j = 0; j < 3; j++)
			cnt[i][j] = value + j;
	}
	dp[0][0] = dp[0][2] = -inf;
	for(int i = 1; i <= n; i++) {
		fill(dp[i], dp[i] + 3, -inf);
		for(int j = 0; j < 3; j++) {
			if(cnt[i][j] < 0) 
				continue ;
			for(int k = i; k >= 1; k--) {
				int prv = max(0, k - 2);
				if(cnt[prv][2] + 1 < cnt[i][j])
					break ;
				for(int z = 0; z < 3; z++) {
					if(cnt[prv][z] + 1 == cnt[i][j]) {
						dp[i][j] = max(dp[i][j], dp[prv][z] + a[k]);
					}
				}
			}
			if(cnt[i][j] == 0) 
				dp[i][j] = 0;
		}
	}
	cout << dp[n][1];

}

Measured memory_bytes: 11464
(let* ((n (read))
       (k (read))
       (r (read))
       (s (read))
       (p (read))
       (x (read-line))
       (y (make-array (list (1+ n)) :initial-element #\x))
       (ans 0))
  (loop :for i :from 1 :to k
        :for h := (aref x (1- i))
        :do (cond ((char= h #\r)
                   (incf ans p)
                   (setf (aref y i) #\r))
                  ((char= h #\s)
                   (incf ans r)
                   (setf (aref y i) #\s))
                  ((char= h #\p)
                   (incf ans s)
                   (setf (aref y i) #\p))))
  (loop :for i :from (1+ k) :to n
        :for h := (aref x (1- i))
        :if (char/= (aref y (- i k)) h)
        :do (cond ((char= h #\r)
                   (incf ans p)
                   (setf (aref y i) #\r))
                  ((char= h #\s)
                   (incf ans r)
                   (setf (aref y i) #\s))
                  ((char= h #\p)
                   (incf ans s)
                   (setf (aref y i) #\p))))
  (format t "~A~%" ans))


Measured memory_bytes: 26656
#include<bits/stdc++.h>
using namespace std;
bool D[10],used[10];
int kei[10],m,an;
void dfs(int x,int sum){
  if(x==m){
    if(sum==0)an++;
    return;
  }
  for(int i=0;i<10;i++){
    if((i==0&&D[x])||used[i])continue;
    used[i]=1;
    dfs(x+1,sum+kei[x]*i);
    used[i]=0;
  }
}

int main(){
  int n;
  while(cin>>n&&n){
    m=0,an=0;
    memset(D,0,sizeof(D));
    string s;
    map<char,int> c;
    vector<char> v;
    for(int i=0;i<n;i++){
      cin>>s;
      int l=1;
      if(i==n-1)l=-1;
      for(int j=s.size()-1,k=1;j>=0;j--,k*=10){
	if(j==0&&s.size()!=1)v.push_back(s[j]);
	if(c.find(s[j])==c.end())c[s[j]]=l*k;
	else c[s[j]]+=l*k;
      }
    }
    map<char,int>::iterator it;
    for(it=c.begin();it!=c.end();it++){
      for(int i=0;i<v.size();i++)
	if((*it).first==v[i])D[m]=1;
      kei[m++]=(*it).second;
    }
    dfs(0,0);
    cout<<an<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
n=int(input())
s=list(map(int,input().split()))
p,q,r,d=[0]*(n+1),[i for i in range(n+2)],[i for i in range(n+2)],0
for i in range(n):
    p[s[i]]=i
for i in range(n,0,-1):
    h=p[i]
    x,y=q[h],r[h]
    d+=i*(h-x+1)*(y-h+1)
    q[y+1],r[x-1]=x,y
print(d)

Measured memory_bytes: 36904
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = inputs[0];
        var k = inputs[1];

        Dictionary<long, long> persons = new Dictionary<long, long>();

        for(int i = 0; i < n; i++)
        {
            persons[i] = 0;
        }

        for (int i = 0; i < k; i++)
        {
            var d = long.Parse(Console.ReadLine());

            // d個
            var tmp = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            for(int j = 0;j < d; j++)
            {
                persons[tmp[j] - 1] += 1;
            }
        }

        var ans = persons.Where(t => t.Value == 0).Count();

        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 28544
#include<bits/stdc++.h>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define vic vector<int>
#define vit vector<int>::iterator
#define pir pair<int,int>
#define fr first
#define sc second
#define mp(x,y) make_pair(x,y)
#define rsort(x,y) sort(x,y),reverse(x,y)
using namespace std;

inline char gc() {
//	static char buf[100000],*p1,*p2;
//	return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}

template<class T>
int read(T &ans) {
	ans=0;char ch=gc();T f=1;
	while(!isdigit(ch)) {
		if(ch==EOF) return -1;
		if(ch=='-') f=-1;
		ch=gc();
	}
	while(isdigit(ch))
		ans=ans*10+ch-'0',ch=gc();
	ans*=f;return 1;
}

template<class T1,class T2>
int read(T1 &a,T2 &b) {
	return read(a)!=EOF&&read(b)!=EOF?2:EOF;
}

template<class T1,class T2,class T3>
int read(T1 &a,T2 &b,T3 &c) {
	return read(a,b)!=EOF&&read(c)!=EOF?3:EOF;
}

typedef long long ll;
const int Maxn=1100000;
const int inf=0x3f3f3f3f;

int n;

signed main() {
//	freopen("test.in","r",stdin);
	read(n);
	if(n&1) {
		printf("%d\n",(n-1)*(n-1)/2);
		for(int i=1;i<n;i++) printf("%d %d\n",i,n);
		for(int i=1;i<n;i++)
			for(int j=i+1;j<n;j++) if(i+j!=n) printf("%d %d\n",i,j); 
	}
	else {
		printf("%d\n",n*(n-2)/2);
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++) if(j+i!=n+1) printf("%d %d\n",i,j);
	}
	return 0;
}



Measured memory_bytes: 256
from heapq import heapify, heappushpop
from operator import itemgetter
inputs = open(0).readlines()

n, m = map(int, inputs[0].split())
*A, = map(int, inputs[1].split())
heapify(A)
BC = [tuple(map(int, bc.split())) for bc in inputs[2:]]
BC.sort(key=itemgetter(1), reverse=True)

for b, c in BC:
    for _ in range(b):
        if c > A[0]:
            _ = heappushpop(A, c)
        else:
            break
print(sum(A))

Measured memory_bytes: 30892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n);
  rep(i, n) cin >> v.at(i);
  rep(i, n) {
    cout << "node " << i+1 << ": ";
    cout << "key = " << v.at(i) << ", ";
    if (1<=(i+1)/2 && (i+1)/2<=n) {
      cout << "parent key = " << v.at((i+1)/2-1) << ", ";
    }
    if (1<=2*(i+1) && 2*(i+1)<=n) {
      cout << "left key = " << v.at(2*(i+1)-1) << ", ";
    }
    if (1<=2*(i+1)+1 && 2*(i+1)+1<=n) {
      cout << "right key = " << v.at(2*(i+1)) << ", ";
    }
    cout << endl;
  }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int N,X;
int m1,m2,sum=0;
int main(){
  cin >> N >> X;
  cin >> m1;
  sum=m1;
  for(int i=1;i<N;i++){
    cin >> m2;
    sum+=m2;
    m1=min(m1,m2);
  }
  cout << N+(X-sum)/m1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll n; cin>>n;
    int cost[3] = {0};
    vector<int> dp(3);
    loop(n){
        for(int i = 0; i<3; i++) cin>>cost[i];

        vector<int> temp(3,0);

        for(int i = 0; i<3; i++){
            for(int j = 0; j<3; j++){
                if(i!=j) temp[j] = max(temp[j], dp[i]+cost[j]);
            }
        }
        dp = temp;
    }

    cout<<max({dp[0], dp[1], dp[2]})<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n,k,s;cin>>n>>k>>s;

  for(int i=1;i<=k;i++)
    cout<<s<<" ";
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  for(int i=k+1;i<=n;i++)
    cout<<1+rng()%inf<<" ";
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 1280
M, K = map(int, input().split())

ans = []
if M == 0 or M == 1:
    if K == 0:
        for i in range(2**M):
            ans.append(str(i))
            ans.append(str(i))
    else:
        ans.append('-1')
elif K >= 2**M:
    ans.append('-1')
else:
    for i in range(2**M):
        if i != K:
            ans.append(str(i))
    ans.append(str(K))
    for i in reversed(range(2**M)):
        if i != K:
            ans.append(str(i))
    ans.append(str(K))

print(' '.join(ans))


Measured memory_bytes: 70160
#include <stdio.h>

int main(void)
{
        int a,b,c;
        scanf("%d%d%d",&c,&a,&b);
        if(b-a<=0)printf("delicious\n");
        else if(b-a<=c)printf("safe\n");
        else printf("dangerous\n");
        return 0;
}


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

int main() {
  string s;
  cin>>s;
  int ans=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]) ans++;
  }
  cout<<ans<<endl;;
  }


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = [int(x) for x in input().split()]
g = [[] for _ in range(n)]
for _ in range(m):
    x, y = [int(x) for x in input().split()]
    g[x - 1].append(y - 1)

memo = [-1]*n

def dp(v):
    if memo[v] >= 0:
        return memo[v]
    else:
        res = 0
        for u in g[v]:
            res = max(res, dp(u) + 1)
        memo[v] = res
        return res

for i in range(n):
    dp(i)
print(max(memo))




Measured memory_bytes: 154972
#
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, k, q = map(int, input().split())
    scores = [k-q] * n
    success = [0] * n
    for _ in range(q):
        a = int(input())
        success[a-1] += 1

    for i in range(n):
        scores[i] += success[i]
        if scores[i] > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 51544
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int main(){
	long long N,A,B,P,X,ans=0;
	cin>>N>>A>>B;
	cin>>P;
	for(int i=1;i<N;i++){
		cin>>X;
		ans+=min(A*(X-P),B);
		P=X;
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 256
n,p = map(int,input().split())
an = [int(i) for i in input().split()]
dpo = [0]*n
dpe = [0]*n

if an[0] % 2 == 0:
  dpe[0] = 2
else:
  dpo[0] = 1
  dpe[0] = 1
  
for i in range(1,n):
  if an[i] % 2 == 0:
    dpe[i] = dpe[i-1] * 2
    dpo[i] = dpo[i-1] * 2
  else:
    dpe[i] = dpe[i-1] + dpo[i-1]
    dpo[i] = dpo[i-1] + dpe[i-1]
if p:
  print(dpo[n-1])
else:
  print(dpe[n-1])

Measured memory_bytes: 3064
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// D - Candy Distribution
ll N, M;
vector<ll> A;
map<ll, ll> X;
ll ans = 0;

int main(){
    cin >> N >> M;
    ll tmp;
    rep(i, 0, N){
        cin >> tmp;
        A.push_back(tmp);
    }

    ++X[0];
    ll sum=0;
    rep(i, 0, N){
        sum += A[i];
        ++X[sum%M];
    }

    repi(X, i){
        ans += i->second*(i->second -1)/2;
    }

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




Measured memory_bytes: 4980
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define show(x) cout<< #x << " = " << (x) << endl
#define show_array(arr) REP(i,int((arr).size()))cout<< #arr << "["<<i<<"]"<<"="<<arr[i]<<endl



int main(){
	ios::sync_with_stdio(false);
	ll Q,H,S,D;
	ll N;
	cin>>Q>>H>>S>>D;
	cin>>N;
	
	Q = 4 * Q;
	H = 2 * H;



	ll minv = min({Q,H,S});
	
	ll answer = 0;	
	
	
	if( D < 2 * minv ){
		
		ll shou = N / 2;
		ll ama = N % 2;

		if(ama == 1){

			answer = shou * D + minv;
		}
		else{
			answer = shou * D;
		}
	}
	else{
		answer = N * minv;
	}


	cout<<answer<<endl;

	return 0;
}


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

int main() {
	string S;
	cin >> S;
	char x = S.at(0);
	if (S.at(1) == S.at(0) && S.at(2) == S.at(0)) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

map<string, bool>mp;
bool check(string s) {
	if (s.empty())return true;
	if (*s.begin() != 'm' || *s.rbegin() != 'w')return false;
	if (mp.find(s) != mp.end())return mp[s];
	for (int i = 1; i < s.size() - 1; i++) {
		if (s[i] != 'e')continue;
		if (check(s.substr(1, i - 1)) && check(s.substr(i + 1, s.size() - i - 2)))return mp[s] = true;
	}
	return mp[s] = false;
}
int main() {
	string s; cin >> s;
	puts(check(s) ? "Cat" : "Rabbit");
}

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

int main () {
  string A;
  cin >> A;
  int a[4];
  for(int i=0; i<4; i++){
    a[i] = (int)(A[i] - '0');
  }
  
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    int sum = a[0];
    string ans;
    ans += (char)('0'+a[0]);
    for (int i = 0; i < 3; i++) {
      if (s.test(i)) {
        sum += a[i+1];
        ans += '+';
        ans += (char)('0'+a[i+1]);
      }else{
        sum -= a[i+1];
        ans += '-';
        ans += (char)('0'+a[i+1]);
      }
    }
    if(sum == 7){
      cout << ans << "=7" << endl;
      return 0;
    }
  }
  cout << "error" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
      	Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int l = sc.nextInt();
      	String[] s = new String[n];
      	for(int i = 0; i < n; i++){
        	s[i] = sc.next();
        }
      	Arrays.sort(s);
      	for(int i = 0; i < n; i++){
        	System.out.print(s[i]);
        }
    }
}

Measured memory_bytes: 37256
/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#include <dirent.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define PLLI pair<LLI,LLI>
#define PDD pair<double,double>
#define FREP(i,I,N) for(int (i)=(int)(I);(i)<=(int)(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(int)(N);(i)>=(int)(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
#define INRANGED(val,l,r) (((l)<(val) || fabs((val)-(l))<eps) && ((val)<(r) || fabs((val)-(r))<eps))
#define INRANGEI(val,l,r) ((val)>=(l) && (val)<=(r))
#define MSET(a,b) memset(a,b,sizeof(a))
using namespace std;
using namespace __gnu_pbds;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction


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

bool ispal(string oka){
    FREP(i,0,oka.size()-1){
        if(oka[i]!=oka[oka.size()-1-i])return false;
    }
    return true;
}

string tonum(int pp){
    string vv = "";
    while(pp){
        vv.PB(pp%10+'0');
        pp/=10;
    }
    if(vv.size()==0)vv.PB('0');
    REVV(vv);
    return vv;
}

int main(){
    int n;
    cin>>n;
    if(ispal(tonum(n)))cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int mod = 1e9+7;
const int mo = 1e9+7;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int size[5050];
struct node{
	int to,next;
}e[100010];
ll base[5050],f[5050][5050],g[5050],h[5050],tot,n;
inline void add_edge(int from,int to){e[++tot].next=h[from];h[from]=tot;e[tot].to=to;}
inline void Pre(int now,int ffa){
	size[now]=1;for(register int i=h[now];i;i=e[i].next){int to=e[i].to;if(to==ffa) continue;Pre(to,now);size[now]+=size[to];}
}
inline void DFS(int now,int ffa)
{
	for(register int i=h[now];i;i=e[i].next)
	{
		int to=e[i].to;if(to==ffa) continue;
		DFS(to,now);
	}
	f[now][1]=1;int las=1;
	for(int p=h[now];p;p=e[p].next)
	if (e[p].to!=ffa){
		int y=e[p].to;
		for(register int i=1;i<=las;++i){
			g[i]=f[now][i];
			f[now][i]=0;
		}
		for(register int i=1;i<=las;++i)
			for(register int j=1;j<=size[y];++j){
				f[now][i+j]=(f[now][i+j]+g[i]*f[y][j])%mo;
				if (j%2==0)f[now][i]=(f[now][i]+mo-g[i]*f[y][j]%mo*base[j/2]%mo)%mo;
			}
			las+=size[y];
		}
}
int main()
{
	n=read();
	for(register int i=1,u,v;i<n;++i) u=read(),v=read(),add_edge(u,v),add_edge(v,u);
	base[0]=1;for(register ll i=1;i<=n;++i) base[i]=1ll*base[i-1]*(2*i-1)%mod;
	Pre(1,0);
	DFS(1,0);ll ans=0;
	for(register int i=1;i<=n;++i) if(i%2==0) ans=(ans+f[1][i]*base[i/2]%mod)%mod;
	cout<<ans%mod;
	return 0;
}

Measured memory_bytes: 198272
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;

int main(){
    const int size = 3;
    int a[size][size];
    rep(i, size)rep(j, size) cin >> a[i][j];
    int n; cin >> n;
    bool f[size][size];
    memset(f, 0, sizeof(f));
    rep(i, n) {
        int b; cin >> b;
        rep(i, size)rep(j, size){
            if(b == a[i][j]) f[i][j] = true;
        }
    }

    bool ans = false;
    if(f[0][0]&&f[0][1]&&f[0][2]) ans = true;
    else if(f[1][0]&&f[1][1]&&f[1][2]) ans = true;
    else if(f[2][0]&&f[2][1]&&f[2][2]) ans = true;
    else if(f[0][0]&&f[1][0]&&f[2][0]) ans = true;
    else if(f[0][1]&&f[1][1]&&f[2][1]) ans = true;
    else if(f[0][2]&&f[1][2]&&f[2][2]) ans = true;
    else if(f[0][0]&&f[1][1]&&f[2][2]) ans = true;
    else if(f[0][2]&&f[1][1]&&f[2][0]) ans = true;

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

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#define INF 100000000
using namespace std;
typedef pair<double,int> P;
struct edge {
  int to;
  double cost;
};
int n,m;
int b[1000],x[1000],y[1000];
double d[1000];
vector<edge> V[1000];
int prev[1000];

double dist(int from, int to) {
  return sqrt( (x[to] - x[from])*(x[to] - x[from]) + (y[to] - y[from])*(y[to] - y[from]) );
}

void dijkstra(int s) {
  priority_queue <P, vector<P>, greater<P> > que;
  for(int i=0;i<n;i++) {
    d[i] = INF;
  }
  d[s] = 0;
  prev[s] = INF;
  que.push(P(0,s));

  while(!que.empty()) {
    P p = que.top();que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i=0;i<V[v].size();i++) {
      edge e = V[v][i];
      if(d[e.to] > d[v] + e.cost) {
	d[e.to] = d[v] + e.cost;
	prev[e.to] = v;
	que.push(P(d[e.to],e.to));
      }
    }
  }
}

int main() {

  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> b[i] >> x[i] >> y[i];
    }

    for(int i=0;i<n;i++) {
      for(int j=i+1;j<n;j++) {
	double r = dist(i,j);
	if(r <= 50.0) {
	  edge temp;
	  temp.to = j;
	  temp.cost = r;
	  V[i].push_back(temp);
	  temp.to = i;
	  V[j].push_back(temp);
	}
      }
    }
    cin >> m;
    for(int i=0;i<m;i++) {
      int s,g,ps,pg;
      cin >> ps >> pg;
      for(int i=0;i<n;i++) {
	if(b[i] == ps) s = i;
	else if(b[i] == pg) g = i;
      }
      dijkstra(s);
      if(d[g] != INF) {
	int t = g;
	vector<int> path;
	for(;t != s;t = prev[t]) {
	  path.push_back(t);
	}
	path.push_back(s);
	reverse(path.begin(),path.end());
	for(int i=0;i<path.size();i++) {
	  cout << (i==0 ? "":" ") << b[path[i]];
	}
	cout << endl;
	path.clear();
      }
      else
	cout << "NA" << endl;
    }
    for(int i=0;i<n;i++) {
      V[i].clear();
    }
  }
}

Measured memory_bytes: 0
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        var k = int.Parse(line[2]);
        var c = new List<int>();
        for (int i = 1; i <= 100; i++)
            if (i <= a && a % i == 0 && i <= b && b % i == 0) c.Add(i);
        c.Reverse();
        Console.WriteLine(c[k -1]);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        
        int length = kb.nextInt(), numhouses = kb.nextInt();
        
        int[] houses = new int[numhouses];
        for(int i = 0; i < numhouses; i++){
            houses[i] = kb.nextInt();
        }
        
        int max = houses[0]+(length-houses[numhouses-1]);
        for(int i = 1; i < numhouses; i++){
            if(max < houses[i]-houses[i-1]){
                max = houses[i]-houses[i-1];
            }
        }
        System.out.println(length-max);
    }
}


Measured memory_bytes: 77104
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n;
int a[MAXN],pre[MAXN];
int sum;
int main(){
    SF("%d",&n);
    for(int i=1;i<=n;i++)
        SF("%d",&a[i]);
    for(int i=1;i<=n+1;i++)
        pre[i]=a[i]-a[i-1];
    for(int i=1;i<=n+1;i++)
        sum+=abs(pre[i]);
    for(int i=1;i<=n;i++){
        int t=a[i+1]-a[i-1];
        PF("%d\n",sum-abs(pre[i])-abs(pre[i+1])+abs(t));
    }
}


Measured memory_bytes: 1920
#include <stdio.h>

int main(void){
	float x1 , y1 , x2 , y2 , xq , yq , a , b , x , y , xp , yp;
	while(scanf("%f,%f,%f,%f,%f,%f" , &x1 , &y1 , &x2 , &y2 , &xq , &yq)!=EOF){
		if(x1 == x2){
			xp = 2 * x1 - xq;
			yp = yq;
		}else if(y1 == y2){
			xp = xq;
			yp = 2 * y1 - yq;
		}else{
			a = (y2-y1) / (x2-x1);
			if(x1==0){
				b = y2 - ((y2-y1) / (x2-x1)) * x2;
			}else{
				b = y1 - ((y2-y1) / (x2-x1)) * x1;
			}

			x = (xq + (yq - b) * a) / (a * a + 1);
			y = ((xq + (yq - b) * a) / (a * a + 1)) * a + b;
			xp = 2 * x - xq;
			yp = 2 * y - yq;
		}
		printf("%.6f %.6f\n" , xp , yp);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#define NUM 300

int main()
{
  int H[NUM],W[NUM], num;
  int i, j, k;

  for(i=0; i<NUM; i++){
    scanf("%d %d",&H[i],&W[i]);
    if(H[i]==0 && W[i]==0) break;
  }

  num=i;

  for(i=0; i<num; i++){
    for(j=0; j<H[i]; j++){
      for(k=0; k<W[i]; k++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 572
/* 解説を見て、解法#1を参考にして解きました */
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
 
typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;
 
using namespace std;
 
int main(int argc, const char* argv[]) {
  u64 x, y, z, num;
  cin >> x >> y >> z >> num;
  
  vector<u64> a(x, 0), b(y, 0), c(z, 0);
  for(u64 i = 0; i < x; ++i) cin >> a.at(i);
  for(u64 i = 0; i < y; ++i) cin >> b.at(i);
  for(u64 i = 0; i < z; ++i) cin >> c.at(i);
  
  sort(a.begin(), a.end(), greater<u64>());
  sort(b.begin(), b.end(), greater<u64>());
  sort(c.begin(), c.end(), greater<u64>());
  
  // d: aとb
  vector<u64> d(x * y, 0);
  for(u64 i = 0; i < x; ++i) {
    for(u64 j = 0; j < y; ++j) {
      d.at(i * y + j) = a.at(i) + b.at(j);
    }
  }
  sort(d.begin(), d.end(), greater<u64>());
  if(d.size() > num) d.resize(num);
  
  // e: dとcを組合せ
  vector<u64> e(d.size() * z, 0);
  for(u64 i = 0; i < d.size(); ++i) {
    for(u64 j = 0; j < z; ++j) {
      e.at(i*z+j) = d.at(i) + c.at(j);
    }
  }
  sort(e.begin(), e.end(), greater<u64>());
  if(e.size() > num) e.resize(num);
  
  for(u64 i = 0; i < e.size(); ++i) {
    cout << e.at(i) << endl;
  }        
  
  return 0;
}

Measured memory_bytes: 31616
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B0Or1Swap solver = new B0Or1Swap();
        solver.solve(1, in, out);
        out.close();
    }

    static class B0Or1Swap {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n + 1];
            int count = 0;
            for (int i = 1; i <= n; i++) a[i] = in.nextInt();
            for (int i = 1; i <= n; i++) {
                if (a[i] == i) {
                    continue;
                }
                if (a[a[i]] == i) {
                    count++;
                    int temp = a[i];
                    a[i] = i;
                    a[temp] = temp;
                    continue;
                }
                out.println("NO");
                return;
            }
            if (count <= 1)
                out.println("YES");
            else {
                out.println("NO");
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22740
#include <iostream>
#include <string>
#include <algorithm>
#include<math.h>
using namespace std;

int main() {
	int N,K,l[110],sum=0;
	cin >> N>>K;
	for (int i = 0; i < N; i++) cin >> l[i];

	sort(l, l + N, greater<int>());
	int a=0,b=0;
	for (int i = 0; i < K; i++) {
		sum += l[i];
    }
	cout << sum << endl;
}


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

int main() {
int A,B,i;
cin>>A>>B;
int ans=0;
for(i=A ; i<=B ; i++){
if( i%10==i/10000 && i%100/10==i/1000 - i/10000*10){
ans++;
}
}
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll n,A,B;

vector <ll> vec[100005];

ll maxdep[100005];
ll par[100005];
ll dep[100005];
ll solve(ll u,ll p,ll x)
{
	x++;
	dep[u] = x;
	par[u] = p;
	ll m = 0;
	for(ll i=0;i<vec[u].size();i++)
	{
		ll v = vec[u][i];
		if(v!=p)
		{
			m = max(m,solve(v,u,x));
		}
	}
	
	maxdep[u] = m;
	return m+1;
	
}

ll ans(ll u,ll d)
{
	if(dep[u]<d)return 0;
	if(par[u]==-1)return 0;
	
	//cout<<u<<" "<<maxdep[u]<<" "<<dep[u]<<" "<<d<<endl;
	
	if((dep[u]-d)%2==1)
	{
		return max(maxdep[u]+dep[u]-1,ans(par[u],d+1));
	}
	else{
		return max(maxdep[u]+dep[u]-1,ans(par[u],d+1));
	}
	
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>A>>B;
	
	for(ll i=1;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		vec[x].push_back(y);
		vec[y].push_back(x);
	}
	
	solve(B,-1,-1);
	
	cout<<ans(A,0);
	
	
	return 0;
}


Measured memory_bytes: 11392
#include<iostream>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  string ans = "No";
  for(int i = 0; i <= N/7; i++){
    if((N-7*i) % 4 == 0){
    ans = "Yes";
    break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define int long long
#define ld  long double
#define pb push_back
#define mod 1000000007
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
long long binpow(long long a, long long b, long long m=mod) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
main()
{   IO
    ll n;
    cin>>n;
    ll s=0;
    ll a[n];
    for(int x=0;x<n;x++)
        {cin>>a[x];
        s^=a[x];}
    for(int x=0;x<n;x++)
        cout<<(s^a[x])<<" ";
}


Measured memory_bytes: 5128
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std ;
 
typedef long long ll ;
typedef long double ld ;

 
#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

string s , t ;
int n ; 

int32_t main()                     
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> s >> t ;
	if ( s == t )
		return cout << n << '\n' , 0 ;
	string cur = "" ; 
	for ( int j = 0 ; j < n ; ++ j ) {
		// s [ j ] ... s [ n - 1 ] == t [ 0 ] ... t [ n - j - 1 ] 
		string suf = "" ;
		cur = "" ;
		for ( int i = j ; i < n ; ++ i )
			cur += s [ i ] ; 
		for ( int i = 0 ; i < n - j ; ++ i )
			suf += t [ i ] ;
		if ( suf == cur ) {
			cout << n + j << '\n' ;
			return 0 ; 
		}
	}
	cout << ( n << 1 ) << '\n' ; 
}


Measured memory_bytes: 256
//置き換えて解を改善する系。
//s + tとt + sの順序を考えると、最適解はs…st…tまたはt…ts…sの形だと分かる。
//[s…s]と[t…t]の順序(文字数=lcm(|s|, |t|))を考えると、最適解は、[sをできるだけ多く]t…t, [sをできるだけ少なく]t…t, とその逆の
//4パターンの形のどれかになると分かる。4パターン試す時間はあるので、試してminを取ればよい。
//sとtの個数をそれぞれx, yとおくと、|s|x + |t|y = lとなればよいことが分かる。O(l)が間に合うので, xを全部試せばOK。
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int l;
string s;
string t;

string getS(int type, int x, int y) {
	string ret;
	
	if (type == 0) {
		for (int i = 0; i < x; i++) ret += s;
		for (int i = 0; i < y; i++) ret += t;
	}
	else {
		for (int i = 0; i < y; i++) ret += t;
		for (int i = 0; i < x; i++) ret += s;
	}
	return ret;
}

int main() {
	cin >> l >> s >> t;
	int n = s.length();
	int m = t.length();
	
	int minX = 114514;
	int maxX = -114514;
	for (int x = 0; x * n <= l; x++) {
		if ((l - x * n) % m != 0) continue;
		if (minX > x) minX = x;
		if (maxX < x) maxX = x;
	}
	
	int y1 = (l - minX * n) / m;
	int y2 = (l - maxX * n) / m;
	
	string s1 = getS(0, minX, y1);
	string s2 = getS(0, maxX, y2);
	string s3 = getS(1, minX, y1);
	string s4 = getS(1, maxX, y2);
	
	string ans = min(s1, min(s2, min(s3, s4)));
	cout << ans << endl;
	return 0;
}

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

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int max_e = 0;

	REP(i, 3){
		if(a[max_e] < a[i]){
			max_e = i;
		}
	}

	if(a[max_e] % 2 == 0){
		cout << 0 << endl;
	}else{
		ll mul = 1;
		REP(i, 3){
			if(i != max_e){
				mul *= a[i];
			}
		}
		cout << mul << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define fast ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int mod=998244353;
const  int N=2e5+5;
ll fac[N],inv[N];

ll mp(ll a,ll p)
{
    ll res=1;
    while(p)
    {
        if(p%2)res=res*a%mod;
        a=a*a%mod;
        p/=2;
    }
    return res;
}


void start()
{
    fac[0]=1;
    for(ll i=1;i<N;i++)
        fac[i]=fac[i-1]*i%mod;
    inv[N-1]=mp(fac[N-1],mod-2);
    for(ll i=N-1;i>=0;i--)
        inv[i-1]=inv[i]*i%mod;
    return ;
}

int com(int n,int r)
{
    return fac[n]*inv[r]%mod*inv[n-r]%mod;
}

int32_t main()
{
    fast
    start();
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    for(ll i=0;i<=k;i++)
    {
        ans+=m*com(n-1,i)%mod*mp(m-1,n-i-1)%mod;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6752
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BContestWithDrinksEasy {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n; in >> n;
        vector<int> v(n);
        for(int& x: v) in >> x;
        int t; in >> t;
        while(t--) {
            int a, b; in >> a >> b;
            a--;
            int tmp = v[a];
            v[a] = b;
            ll sum = 0ll;
            for (int i: v) sum += i;
            out << sum << el;
            v[a] = tmp;
        }
	}
};


int main() {
	BContestWithDrinksEasy solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){

	long int N;

	scanf("%ld",&N);
	
	long int minDef=N-1;

	for(long int i=2;i<sqrt(N)+1;i++){
		if((N%i)==0){
			minDef=(N/i)+i-2;
          //printf("%d,%d\n",N/i,i);
		}
	}

	printf("%ld",minDef);

	return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std ;
using ll = long long ;
using vi = vector<ll> ;
using vii = vector<vi> ;

int main(){
    int n,m,l ;
    cin >> n >> m >> l ;
    vii a(n,vi(m)) ;
    vii b(m,vi(l)) ;
    for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
    cin >> a.at(i).at(j) ;
    for(int i=0;i<m;i++)
    for(int j=0;j<l;j++)
    cin >> b.at(i).at(j) ;
    vii c(n,vi(l,0)) ;
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            ll sub = 0 ;
            for(int k=0;k<m;k++){
                sub += a.at(i).at(k)*b.at(k).at(j) ;
            }
            c.at(i).at(j) = sub ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j!=0) cout << " " ;
            cout << c.at(i).at(j) ;
        }
        cout << endl ;
    }
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define fastio                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL)
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define repeat(n) for (int i = 0; i < n; i++)

#define ll long long
#define ld long double
#define ull unsigned long long
#define infl LONG_MAX
#define infi INT_MAX
#define nl cout << '\n'

#define all(v) v.begin(), v.end()
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mkpr make_pair
#define pq priority_queue

void show(auto a)
{ //for debugging we often need to see the array
	for (auto i : a)
		cout << i << " ";
	cout << endl; // a must be vector
}
const int N = 5e3 + 3;
long long a[N], b[N];
map<pair<int, int>, long long> mp;
int n, m;
ll sm, t;
long long fun(int st, int k,long long sum)
{
	cout << " i am called with " << st << " k = " << k << endl;
	if (k < 1 || st >= n)
		return -1;
	if (mp.count(make_pair(st, k)) > 0)
		return mp[make_pair(st, k)];
	if (m * k > n - st)
	{
		cout << " i am here " << st << " k = " << k << endl;
		return -1;
	}
	sm = 0LL;
	for (int i = 0; i < m; i++)
	{
		sm = sm + a[st + i];
		cout << " sm = " << sm << endl;
	}
	if (mp.count((make_pair(st, k))) > 0)
	{
		t = fun(st+m,k-1,sum);
		mp[make_pair(st, k)] = max(mp[make_pair(st, k)], sm + max(0LL,t));
	}
	else
	{
		t = fun(st + m, k - 1,sum);
			mp[make_pair(st, k)] = sm + max(0LL,t);
	}
	if (st < n - 1)
	{
		if (mp.count(make_pair(st + 1, k)) > 0){
			mp[make_pair(st + 1, k)] = max(fun(st + 1, k,sum), mp[make_pair(st + 1, k)]);}
		else
		{
			t = fun(st+1,k,sum);
			if(t >= 0)
			mp[make_pair(st + 1, k)] = t;
		}
	}
	return mp[make_pair(st, k)];
}

int main()
{
	fastio;
  long double a,b;
  cin >> a >> b;
  cout << (long long)((long long)a*b)<<endl;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?

  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?

  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?

  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/


Measured memory_bytes: 3704
#include<iostream>
#include<algorithm>

using namespace std;

void selection_sort(int a[]);
void print(int a[]);

int number=0;
int a[100];
int numberOfSwap=0;

int main(){
    cin>>number;
    for (int i=0; i<number; i++) {
        cin>>a[i];
    }
    selection_sort(a);
    print(a);
    cout<<numberOfSwap<<endl;
}

void selection_sort(int a[]){
    for (int i=0; i<number; i++) {
        int mini = i;
        for (int j=i; j<number; j++) {
            if (a[j]<a[mini]) {
                mini = j;
            }
        }
        if (i!=mini) {
            swap(a[i],a[mini]);
            numberOfSwap++;
        }
    }
}

void print(int a[]){
    for (int i=0; i<number-1; i++) {
        cout<<a[i]<<" ";
    }
    cout<<a[number-1]<<endl;
}



Measured memory_bytes: 3112
#include<stdio.h>
#include<stdlib.h>

int main()
{
	int N;
	int d[55];
	int i;
	int j;
	long sum=0;

	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&d[i]);
	for(i=0;i<N-1;i++)
	{
		for(j=i+1;j<N;j++)
		{
			sum+=d[i]*d[j];
		}
	}
	printf("%ld\n",sum);
	return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
from collections import defaultdict


def main():
    N = int(input())
    A = list(map(int,input().split()))
    D = defaultdict(int)
    for i in range(N):
        D[A[i]+i] +=1
    s = 0
    for i in range(N):
        s += D[i-A[i]]
    print(s)
    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 145420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    ll N = s.size();
    ll sum = 0;
    rep(i, 1<<(N-1)){
        int now = -1;
        rep(j, N-1){
            if(i & (1<<j)){
                string a = s.substr(now+1, j-now);
                ll x = atoll(a.c_str());
                sum += x;
                now = j;
            }
        }
        string a = s.substr(now+1, N-now-1);
        ll x = atoll(a.c_str());
        sum += x;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256