akhauriyash/Code-Regression huggingface dataset:
MOD = 10**9 + 7

n, m = map(int, input().split())
wlist = [int(input()) for _ in range(m)]

dp = []
dp.append(0)
dp.append(1)
dp.append(2)
for i in range(3, n+1):
  dp.append((dp[i-1] + dp[i-2])%MOD)

start = 0
ans = 1
for w in wlist:
  end = w - 1
  if end - start > 0:
    ans *= dp[w - 1 - start]
  elif end -start == 0:
    pass
  else :
    ans = 0
    break
  ans %= MOD
  start = w + 1
if not start == n:
  ans *= dp[n - start]
  ans %= MOD
print(ans)

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

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

  return 0;
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std ;
#define An setprecision(16) 
int main(){
    int  N,K;
    cin >> N >> K;
    int h;
    int count=0;
    for(int i=0;i<N;i++){
        cin >> h;
        if(h>=K)count++;
    }
    cout << count << endl;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

signed main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a%2&&b%2&&c%2)cout<<min(min(a*b,b*c),c*a)<<endl;
    else cout<<0<<endl;
    return 0;
}


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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
    int h, w, k;
    cin>> h >> w >> k;

    vector<string> c;
    for(int i = 0; i<h; ++i){
        string s;
        cin>> s;
        c.pb(s);
    }
    int ans = 0;
    for(int i = 0; i< (1 << h); ++i){
        for(int j = 0; j < (1 << w); ++j){
            int cnt = 0;

            for(int ii = 0; ii<h; ++ii){
                for(int jj = 0; jj<w; ++jj){
                    if((i & (1 << ii)) || (j & (1 << jj))) continue;
                    if(c[ii][jj] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout<< ans<< endl;
}



int32_t main(){
	fastio;
	solve();
	return 0;
}



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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, l, r;
	while (cin >> n >> l >> r, n) {
		vi v(n);
		REP(i, n)cin >> v[i];
		int ans = 0;
		
		for (int x = l; x <= r; ++x) {
			bool b = false;
			REP(i, n) {
				if (x%v[i] == 0) {
					b = true;
					if (i % 2 == 0)ans++;
					break;
				}
			}
			if (!b&&n % 2 == 0)ans++;
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3132
N=int(input())
A=[int(input())for _ in range(N)]

A=sorted(A)
B=A[:]

ans=0
#小さいのが真ん中
top=A[0]
bottom=A[0]
tmp=0
turn=True
del A[0]
while  A:
  if len(A)==1:
    tmp+=max(abs(top-A[0]),abs(bottom-A[0]))
    break
    pass
  if turn:
    a,b=A[-2],A[-1]
  else:
    a,b=A[0:2]
    
  if abs(a-bottom)+abs(b-top)<abs(a-top)+abs(b-bottom):
    a,b=b,a
  tmp+=abs(a-bottom)+abs(b-top)
  bottom,top=a,b
  if turn:
    del A[-1]
    del A[-1]
  else:
    del A[0]
    del A[0]
  turn=not turn

ans=tmp
A=B
top=A[-1]
bottom=A[-1]
tmp=0
del A[-1]
turn = True
while  A:
  #print("center big:tmp: ", tmp)
  if len(A)==1:
    tmp+=max(abs(top-A[0]),abs(bottom-A[0]))
    break
    pass
  if turn:
    a,b=A[0],A[1]
  else:
    a,b=A[-1],A[-2]
    
  if abs(a-bottom)+abs(b-top)<abs(a-top)+abs(b-bottom):
    a,b=b,a
  tmp+=abs(a-bottom)+abs(b-top)
  bottom,top=a,b
  if turn:
    del A[0] 
    del A[0]
  else:
    del A[-1]
    del  A[-1]
  turn= not turn

ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 8308
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,d; cin>>n>>d;
    vector <vector<int>> data(n ,vector <int>(d ));
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>data[i][j];
        }
    }
    int cnt = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j) continue;
            double dis=0;
            for(int l=0;l<d;l++){
                dis += (data[i][l] - data[j][l])*(data[i][l] - data[j][l]);
            }
            dis = sqrt(dis);
            int c = dis;
            double v = c;
            if(v==dis) cnt++;
        }
    }
    cout<<cnt/2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int i,n,q,A[2000];

int solve(int i,int t){
  if(t == 0)return 1;
  if(i >= n)return 0;
  int res= solve(i+1,t) || solve(i+1,t-A[i]);
  return res;
}
    
int main(){
  int ans;
  scanf("%d",&n);
  for(i=0;i < n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i < q;i++){
    scanf("%d",&ans);
    if(solve(0,ans))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}
    
  



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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e6)+3;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;


int main(){
    string s;
    cin >> s;
    int n = s.size(), ans = 0;
    for(int i=0;i<n;i++){
        if(s[i] == '?'){
            s[i] = 'D';
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

	int tempH;
	int countH = 0;
	vector<int> h;
	for (int i = 0; i < n; i++) {
		cin >> tempH;
		h.push_back(tempH);

		countH++;
	}

	sort(h.begin(), h.end());

	if (countH < k) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < k; i++) {
		h.pop_back();
	}

	unsigned long long result=0;

	
	for (int i = 0; i < h.size(); i++) {
		result += h[i];
	}

	cout << result << endl;
	
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdint>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    int n;
    cin >> n;
    int ans=1;
    for(int i=1;i*i<=n;i++){
        ans=i*i;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
while True:
    i = input()
    W,H = map(int, i.split())
    
    if W == 0 and H == 0:
        break
    
    while W > 0:
        x = 0
        while H != x:
            print("#", end="")
            x += 1
        print("")
        W -= 1
    
    print  ("")


Measured memory_bytes: 7012
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  vector<int> a(3);
  rep(i,3) cin>>a[i];
  int ans=0;
  sort(ALL(a));
  ans+=a[2]-a[1];
  if((a[1]-a[0])%2==0)
  ans+=(a[1]-a[0])/2;
  else
  ans+=(a[1]-a[0])/2+2;

  cout<<ans<<endl;

  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dbg1(x) cerr<<#x<<"="<<(x)<<" "
#define dbg2(x) cerr<<#x<<"="<<(x)<<"\n"
#define dbg3(x) cerr<<#x<<"\n"
using namespace std;
#define reg register
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int L,a[25],cnt;
int main()
{
	int L=read();
	reg int i,j,N=0,M=0;
	for(i=0;i<=20;++i)if(L>>i&1)a[++cnt]=i-1,++M;
	N=a[cnt]+2;M=M+N*2-3;
	printf("%d %d\n",N,M);
	a[0]=-1;
	for(i=1;i<=cnt;++i)
	{
		for(j=a[i-1];j<a[i];++j)
			printf("%d %d %d\n",j+2,j+3,0),
			printf("%d %d %d\n",j+2,j+3,(1<<(j+1)));
		if(i==cnt) break;
		printf("%d %d %d\n",a[i]+2,N,L-(1<<a[i]+1));
		L-=1<<a[i]+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N;
    scanf("%d\n", &N);

    double isum = 0.0;
    for(int ni=0; ni<N; ni++){
        int A;
        scanf("%d", &A);
        isum += 1.0 / A;
    }
    printf("%f\n", 1.0 / isum);

    return 0;
}


Measured memory_bytes: 128
import Data.List

main :: IO ()
main = do
  l1 <- getLine
  let x = read l1 :: Int
  print $ head $ dropWhile (<x) primes

primes :: [Int]
primes = primes' [2..]

primes' :: [Int] -> [Int]
primes' (p:l) = ps' ++ primes' l''
  where (ps, l') = span (<p*p) l
        ps' = p:ps
        l'' = filter (\x -> all (\p -> x `mod` p /= 0) ps') l'

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

const int SIZE = 3000;

int n;
double dp[SIZE][SIZE + 1];

int main() {
    // dp[n][i] - probability of tossing n coins and having i HEADS
    dp[0][0] = 1.0; // base
    
    cin >> n;
    for (int i = 1; i <= n; i++) {
        double p; cin >> p;
        for (int h = 0; h <= i; h++) {
            dp[i][h+1] += dp[i-1][h] * p;
            dp[i][h] += dp[i-1][h] * (1 - p);
        }
    }

    double ans = 0.0;
    for (int heads = n; heads > n - heads; heads--) {
        ans += dp[n][heads];
    }
    printf("%.10lf\n", ans);
}

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

int main(){
    double r,s,l,pi; 
    cin>>r;
    
    pi=3.141592653589;
    
    s=r*r*pi;
    l=2*r*pi;
    
   printf("%f %f\n", s,l);
    
    return 0;
    
}


Measured memory_bytes: 3204
#include<stdio.h>

int main(void)
{
        int n, k;
        int sum = 0;

        scanf("%d%d", &n, &k);

        int h[n];

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

                if(h[i] >= k){
                        sum++;
                }
        }

        printf("%d\n", sum);

        return 0;
}

Measured memory_bytes: 512
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N, M; cin >> N >> M;

    int ans = 0;
    vector< pair<int, int> > store;
    for(int i=0; i<N; i++) {
        int A, B; cin >> A >> B;
        store.emplace_back(A, B);
    }
    sort(store.begin(), store.end());

    int rem = M;
    for(auto e : store) {
        int A, B; tie(A, B) = e;
        for(int i=0; i<B and rem>0; i++, rem--) {
            ans += A;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m1!=m2) cout<<1;
    else cout<<0;
}

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

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

#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize ("O2")

using namespace std;

typedef unsigned long long ull;

struct RollingHash{
  static const ull p=100000007;
  string s;
  int n;
  vector<ull> pow, phash;

  RollingHash(string s) : s(s), n(SZ(s)), pow(n+1), phash(n+1){
    pow[0]=1,phash[0]=0;
    REP(i, n) {
      phash[i+1] = s[i] + phash[i] * p;
      pow[i+1] = pow[i] * p;
    }
  }

  static ull hash(const string &t) {
    ull h=0;
    REP(i,SZ(t))h=t[i]+h*p;
    return h;
  }

  inline ull hash(int b, int e){
    return phash[e]-phash[b]*pow[e-b];
  }

  inline int find(string t) {
    int w=t.size(),count=0;
    if(w > SZ(s))return 0;
    ull h=hash(t);
    REP(i,n-w+1)if(hash(i,i+w)==h){count++,cout << i << "\n";}
    return count;
  }
};


int main(void){
  ios::sync_with_stdio(false);
  string s,t;
  cin >> s >> t;
  RollingHash rh = RollingHash(s);
  rh.find(t);

  return 0;
}

Measured memory_bytes: 18868
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
    int n,l;
    scanf("%d",&n);
    scanf("%d",&l);
    vector<string>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    string s;
    for(int i=0;i<n;i++){
        s+=a[i];
    }
    cout<<s;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265358979323846
const int MAX = 1e5+10;
const ll INF = 1e18;
const ll MOD = 1e9;

int main()
{
    set<ll> s;
    vector<ll> a;
    ll i,j,k,l,p,q,t=9;
    for(i=1;i<10;i++)
        s.insert(i);
    
    while(t<MAX)
    {
        l = *s.begin();
        s.erase(l);
        a.push_back(l);
        k = l%10;
        if(k==0)
        {
            s.insert(l*10+0);
            s.insert(l*10+1);
        }
        else if(k==9)
        {
            s.insert(l*10+8);
            s.insert(l*10+9);
        }
        else
        {
            s.insert(l*10+k-1);
            s.insert(l*10+k);
            s.insert(l*10+k+1);
        }
        t++;
    }
    cin >> k;
    cout << a[k-1];
}

Measured memory_bytes: 9972
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{int a,s;
cin>>a>>s;
int d[s];
FOR(s) cin>>d[i];
int sum =accumulate(d,d+s,0);
if(sum>=a)
{
    cout<<"Yes";
    
}
else 
cout<<"No";






return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            //ここから

            var vs = IO.ReadLineToLongList();
            var N = vs[0];
            var K = vs[1];

            var A = IO.ReadLineToLongList();

            var ans = Math.Ceiling((N - 1) *1.0/ (K - 1));

            //ここまで

            Console.WriteLine(ans);
            Console.ReadKey();
        }

    }

    static class Func
    {
        static public long mod = 1000000007;
        static public void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
        static public long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
        static public long LCM(long a, long b) { return (long)a * b / GCD(a, b); }
        static public long Factorial(long a) { return a == 1 ? a : a * Factorial(a - 1); }


        public static double ToAngle(this double radian)
        {
            return (double)(radian * 180 / Math.PI);
        }

        public static double ToRadian(this double angle)
        {
            return (double)(angle * Math.PI / 180);
        }

        static public long Conbination(long n,long m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * Conbination(n - 1, m - 1) / m;
        }

        static public void Factoring(long num, ref long[] vs)
        {
            if (num == 1)
            {
                vs[1]++;
            }
            for (long i = 2; i < Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    vs[i]++;
                    Factoring(num / i, ref vs);
                }
            }
            vs[1]++;
        }
    }

    static class IO
    {
        static public string ReadLineToString() { return Console.ReadLine(); }
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> ReadLineToStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }

        static public List<double> ReadLineToDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }

        static public void WriteStrings(object[] strings) { foreach (var o in strings) { Console.Write(o + " "); } }
    }
}

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

string cip(const string& s,int& i);

string let(const string& s,int& i)
{
	if(s[i]=='+' || s[i]=='-'){
		char op=s[i++];
		char c=let(s,i)[0];
		if(op=='+') c=c=='?'?c:c=='Z'?'A':c+1;
		if(op=='-') c=c=='?'?c:c=='A'?'Z':c-1;
		return string(1,c);
	}
	return s.substr(i++,1);
}

string str(const string& s,int& i)
{
	if(s[i]=='['){
		i++; string t=cip(s,i); i++;
		return string(t.rbegin(),t.rend());
	}
	return let(s,i);
}

string cip(const string& s,int& i)
{
	string t=str(s,i);
	if(i<s.size() && s[i]!=']')
		t+=cip(s,i);
	return t;
}

int main()
{
	for(string s;cin>>s && s!=".";){
		int i=0;
		string t=cip(s,i);
		replace(begin(t),end(t),'?','A');
		cout<<t<<endl;
	}
}

Measured memory_bytes: 1200
// Stack_ex.cs

using System;
using System.Collections.Generic;

class Stack_ex {
	public static void Main() {

		Stack<int> numbers = new Stack<int>();

		string str = Console.ReadLine();
		string[] arr = str.Split();

		foreach(string num in arr) {
			if(num == "+") {
				numbers.Push(numbers.Pop() + numbers.Pop());
			} else if(num == "-") {
				numbers.Push(-1 *(numbers.Pop() - numbers.Pop()));
			} else if(num == "*") {
				numbers.Push(numbers.Pop() * numbers.Pop());
			} else {
				numbers.Push(int.Parse(num));
			}
		}

		Console.WriteLine(numbers.Pop());

	}
}

Measured memory_bytes: 10032
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
int main() {
    ios_base::sync_with_stdio(false);
    LL n,k;
    cin >> n >> k;
    LL a[n],dp[n]={0};
    for(int i=0; i<n; i++) {
        cin >> a[i];
        int j = i-k<=0?0:i-k;
        if(j<i) dp[i] = abs(dp[j]+abs(a[i]-a[j]));
        j++;
        for(;j<i;j++) {
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=2e5;
const ll mod=1e9+7;
int main()
{
    ll a,b;
    cin >> a >> b;
    char c;
    cin >> c;
    int d;
    cin >> d;
    b=(b*100)+d;
    ll ans= a*b;
    ans/=100;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3632
//include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cstring> 
#include <set>
#include <map>
#define db double 
#define LL long long
//#define int LL
#define rep(i,x,y) for (int i=x;i<=y;++i)
#define mp make_pair
#define ft first
#define sd second
#define P pair<int ,int >
#define pb push_back 
using namespace std;
const int N  =  5e5+233;
//const int mod = ;
void read(int &x)
{
	int f=1;
	x=0;
	char ch=getchar();
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
	return ;
}
struct xx
{
	int V,nxt;
}b[N<<1];
int G;int head[N];
void add(int x,int y)
{
	b[++G]=(xx){y,head[x]	};
	head[x]=G;
}
int vis[N],dep[N],f[N];
char s[N];
int dfs(int x)
{
	int tmp=0;
	for (int i=head[x];i;i=b[i].nxt)
	{
		#define v b[i].V
		if (vis[v]&&!(dep[x]&1)&&(s[v]^s[x])&&dep[x]>dep[v]) 
		 return 1;
		//if (!vis[v])
	//	{
			if (dep[x]&1) if (s[v]==s[x]) vis[v]=1,dep[v]=dep[x]+1,tmp|=dfs(v);
			if (!(dep[x]&1)) if (s[v]^s[x]) vis[v]=1,dep[v]=dep[x]+1,tmp|=dfs(v);
		if (tmp) return 1;
	//		continue;
	//	}
		
	}
	return tmp;
}
int n,m,x,y;
int ans,t1[N],t2[N],In[N],q[N];int hd=1,tl=0;
signed main()
{
	read(n);read(m);
	scanf("%s",s+1);
	rep(i,1,m) 	read(x),read(y),add(x,y),add(y,x);
	
	rep(x,1,n)
	{

		for (int i=head[x];i;i=b[i].nxt)
		{	
			#define v b[i].V
			if (s[v]=='A') t1[x]++;
			if (s[v]=='B') t2[x]++;
		}	
		if (!(t2[x]&&t1[x])) 
		In[x]=1,q[++tl]=x;
	}
	
	while (hd<=tl)
	{
		int x=q[hd++];
		for (int i=head[x];i;i=b[i].nxt)
		{	
			#define v b[i].V
			if (s[x]=='A') t1[v]--;
			if (s[x]=='B') t2[v]--;
			
			if (!In[v]&&(t1[v]<=0||t2[v]<=0)) 
			In[v]=1,q[++tl]=v;
		}	
	/*	for (int i=head[x];i;i=b[i].nxt)
		{	
			#define v b[i].V
			if (!In[v]&&(t1<=0||t2<=0)) 
			In[v]=1,q[++tl]=v;
		}	*/
	//	if (!In[x]&&(t1<=0||t2<=0)) In[x]=1,q[++tl]=x;
	}
	
	printf("%s",tl<n?"Yes": "No");
	return 0;	
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
vector<int> dislikes(10, 0);

bool isValidNumber(int N) {
  while (N > 0) {
    int d = N%10;
    if (dislikes[d])
      return false;
    N /= 10;
  }
  return true;
}
int main (){
  int N, K;
  cin >> N >> K;
  for(int i = 0; i < K; i++){
    int k; cin >> k;
    dislikes[k] = true;
  }
  int mini = N;

  while (!isValidNumber(mini)) {
    ++mini;
  }
  cout << mini << endl;
  return 0;
}

/*
  N * D * 10
 */

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

int main() {
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  vector<char> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  int ans = 0;
  for (int cursol = 0; cursol < K; cursol++) {
    int start = cursol;
    bool change = false;
    while (cursol < N) {
      if (cursol >= K) {
        if (T[cursol - K] != T[cursol] || T[cursol - K] == T[cursol] && change) {
          if (T[cursol] == 'r') ans += P;
          else if (T[cursol] == 's') ans += R;
          else ans += S;
          change = false;
        }
        else {
          change = true;
        }
      }
      else {
        if (T[cursol] == 'r') ans += P;
        else if (T[cursol] == 's') ans += R;
        else ans += S;
      }
      cursol += K;
    }
    cursol = start;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int a, b;
cin >> a >> b;
int d = a / b;
int r = a % b;
double f = (double) a / (double) b;
cout << d << " " << r << " " << fixed << setprecision(8) << f << "\n";
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define int long long
#define fill(x, v) memset(x, v, sizeof(x))
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define ios std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1)
{
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
/*
std::cout << std::setprecision(9) << f << '\n';//3.141590000;
map<char,int>::reverse_iterator rit;
for(rit = mp.rbegin(); rit!=mp.rend(); rit++)
*/
int n;

int32_t main()
{
    ios;
    int a, c, b, k;
    cin >> a >> b >> c >> k;
    if (k <= a)
        cout << k << endl;
    else if (a < k && k <= b)
        cout << a << endl;
    else
        cout << a - (k - (a + b)) << endl;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define eps 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
int A, B;
vector<ll> v;

template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}

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

  vector<vector<ll>> com;
  com = binomial_table<ll>(N+1);

  Rep(i, N) {
    ll tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  sort(All(v), greater<ll>());

  double ans = 0;
  Rep(i, A) {
    ans += v[i];
  }

  ans /= A;
  printf("%.16f\n", ans);

  //printv(v);

  if (v[0] != v[A-1]) {
    ll tmp = v[A-1];
    int p = 0;
    int q = 0;

    for (int i=0;i<A;++i) {
      if (v[i] == tmp) {
        p++; q++;
      }
    }
    for (int i=A;i<N;++i) {
      if (v[i] == tmp) {
        p++;
      }
    }

    cout << com[p][q] << "\n";
  } else {
    ll tmp = v[A-1];
    int p = 0;
    for (int i=0;i<N;++i) {
      if (v[i] == tmp) {
        p++;
      }
    }

    //cout << p << "\n";

    ll ans = 0;

    for (int i=A;i<=min(p, B);++i) {
      //cout << com[p][i] << "\n";
      ans += com[p][i];
    }

    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define all(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int mod = 1e9+7;

int main() {
    int n;
    cin >> n;
    int a[n];
    set<int> s;
    int red = 0;
    rep(i, n) {
        cin >> a[i];
        if (a[i] < 3200) s.insert(a[i] / 400);
        else red++;
    }
    int MIN = max((int)s.size(), 1);
    int MAX = (int)s.size() + red;
    printf("%d %d\n", MIN, MAX);
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 18;
int col[N], ans, n;
vector<int> G[N];
void DFS(int v = 1, int par = 0) {
	int mx = 0, b = 0;
	for (auto u : G[v])
		if (u ^ par) {
			DFS(u, v);
			mx |= col[v] & col[u];
			col[v] |= col[u];
		}
	while ((1 << b) <= mx || col[v] & (1 << b))
		b ++;
	ans = max(ans, 31 - __builtin_clz(col[v] = col[v] & ~((1 << b) - 1) | (1 << b)));
}
int main () {
	scanf("%d", &n);
	for (int i = 1, v, u; i < n; i ++) {
		scanf("%d%d", &v, &u);
		G[v].push_back(u);
		G[u].push_back(v);
	}
	DFS();
	printf("%d", ans);
}

Measured memory_bytes: 15616
#define scanf_s scanf
#include <string>
#include <stdio.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100
//#define MAX_ 1000
int main(void)
{
	int G[MAX][MAX] = { false };
	int n, u, k, v;
	scanf_s("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf_s("%d %d", &u, &k);
		for (int j = 0; j < k; ++j) {
			scanf_s("%d", &v);
			G[u - 1][v - 1] = true;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (j != 0) printf(" ");
			printf("%d", G[i][j]);
		}
		printf("\n");
	}
}

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

class Combination {
public:
    Combination(int64_t max_num, int64_t mod) {
        fact_.resize(max_num + 1, 1);
        inv_fact_.resize(max_num + 1, 1);
        mod_ = mod;
        for (int64_t i = 2; i <= max_num; i++) {
            fact_[i] = i * fact_[i - 1] % mod_;
            inv_fact_[i] = MODpow(fact_[i], mod_ - 2);
            assert(fact_[i] * inv_fact_[i] % mod_ == 1);
        }
    }
    int64_t operator()(int64_t n, int64_t m) const {
        if (m < 0 || m > n) return 0;
        return fact_[n] * inv_fact_[n - m] % mod_ * inv_fact_[m] % mod_;
    }
private:
    int64_t MODpow(int64_t n, int64_t m) const {
        int64_t result = 1;
        while (m) {
            if (m % 2 == 1) {
                result *= n;
                result %= mod_;
            }

            m /= 2;
            n *= n;
            n %= mod_;
        }

        return result;
    }

    vector<int64_t> fact_, inv_fact_;
    int64_t mod_;
};

int main() {
    constexpr int64_t MOD = 1e9 + 7;

    int64_t r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    Combination comb(r2 + c2 + 1, MOD);

    function<int64_t(int64_t, int64_t)> f = [&](int64_t r, int64_t c) {
        return comb(r + c, c);
    };

    //(0, 0)から(r, c)で囲まれる長方形についての和
    function<int64_t(int64_t, int64_t)> sum_f = [&](int64_t r, int64_t c) {
        //各行について和を取る
        //sum_{j = 1}^{c}f(r, j) = f(r + 1, c) - 1
        int64_t result = 0;
        for (int64_t i = 0; i <= r; i++) {
            (result += MOD - 1 + f(i + 1, c)) %= MOD;
        }
        return result;
    };

    int64_t ans = 0;
    (ans += sum_f(r2, c2)) %= MOD;
    (ans += MOD - sum_f(r2, c1 - 1)) %= MOD;
    (ans += MOD - sum_f(r1 - 1, c2)) %= MOD;
    (ans += sum_f(r1 - 1, c1 - 1)) %= MOD;
    cout << ans << endl;
}

Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int sum[n + 1];
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
  }
  sort(sum, sum + n + 1);
  int count = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (sum[i] == sum[i + 1]) {
      res++;
    } else if (res) {
      count += res * (res + 1) / 2;
      res = 0;
    }
  }
  if (res) {
    count += res * (res + 1) / 2;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int moto=sc.nextInt();
		int wa=0;
		int tmp=moto;

		while(tmp>0) {
			wa+=tmp%10;
			tmp/=10;
		}

		if(moto%wa==0) {
			System.out.println("Yes");
		}

		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22740
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <assert.h>
#include <random>
#include <bitset>
#include <string>
#include <cstring>
#include <memory.h>

using ll = long long;

const int inf = 1e9;
const ll infll = 1e18;

using namespace std;

struct Solution {
	Solution() {
		int a, b;
		cin >> a >> b;
		set<int>s;
		s.insert(a);
		s.insert(b);
		for (int i = 1; i <= 3; i++) {
			if (s.find(i) == s.end()) {
				cout << i << endl;
				return;
			}
		}
	}
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (; t; t--) {
		Solution s;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a,b,c;
	cin>>a>>b>>c;
	int d=0;
	if(a=='1'){
		d++;
	}
	if(b=='1'){
		d++;
	}
	if(c=='1'){
		d++;
	}
	cout<<d<<endl;
}


Measured memory_bytes: 256
X, K, D = map(int, input().split())

X = abs(X)

tmp = int(X/D)

if tmp <= K:
    X -= tmp*D
    K -= tmp

    tmp = K % 2

    for i in range(tmp):
        if abs(X-D) < X + D:
            X = abs(X-D)
        else:
            X = X + D
else:
    X -= K*D

print(X)

Measured memory_bytes: 9144
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	ll N, M;
	cin >> N >> M;
	vll A(N + 1, 0), B(N + 1, 0);
	fori(i, 1, N + 1) cin >> A[i];
	fori(i, 1, N + 1) B[i] = (B[i - 1] + A[i]) % M;

	unordered_map<ll, ll> um;
	rep(i, N + 1) ++um[B[i]];

	ll ans = 0;
	for (auto p : um) ans += p.second * (p.second - 1) / 2;

	cout << ans << endl;


}

Measured memory_bytes: 5260
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long A, long long B, long long C, long long D, long long E){
    vll rec(6, 0); rec[0]=N;
    vll a(5);
    a[0] = A; a[1] = B; a[2] = C; a[3] = D; a[4] = E;
    sort(a.begin(), a.end());
    ll cnt = 4+ ((N+a[0]-1)/a[0]);
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    solve(N, A, B, C, D, E);
    return 0;
}


Measured memory_bytes: 256
class Main
{
  public static void main(String[] args) {
    java.io.BufferedReader reader = null;
    try {
      reader = new java.io.BufferedReader(
         new java.io.InputStreamReader(System.in)
      );
      int rank1 = 0;
      int rank2 = 0;
      int rank3 = 0;
      for (int i = 0; i < 10; i++) {
         int x = Integer.parseInt(reader.readLine());
         if (x > rank1) {
           rank3 = rank2;
           rank2 = rank1;
           rank1 = x;
         } else if (x > rank2) {
           rank3 = rank2;
           rank2 = x;
         } else if (x > rank3) {
           rank3 = x;
         }
      }
      System.out.println(rank1);
      System.out.println(rank2);
      System.out.println(rank3);
    } catch (java.io.IOException e) {
      e.printStackTrace();
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (java.io.IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  if (a >= k)
  {
    cout << k << endl;
  }else if (a+b >= k)
  {
    cout << a << endl;
  }else
  {
    cout << 2*a+b-k << endl;
  }
  return 0;
  

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int h,w;
  cin>>h>>w;
  char ans[2*h][w];
  rep(i,0,h){
    rep(j,0,w){
      char c;
      cin>>c;
      ans[2*i][j]=c;
      ans[2*i+1][j]=c;
    }
  }
  rep(i,0,2*h){
    rep(j,0,w){
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string t;
    cin>>t;
    string a="CODEFESTIVAL2016";
    int ans=0;
    REP(i,t.length()){
        if(a[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
     
#define pb emplace_back
#define fi first
#define se second
     
using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ ll x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head


int n, m;

int a[128];

multiset<int> odd, even;

int main(){

  n = in();
  m = in();
  REP( i , m ){
    a[i] = in();
    if( a[i] % 2 == 0 ){
      even.insert( a[i] );
    } else {
      odd.insert( a[i] );
    }
  }

  if( m == 1 ){
    printf( "%d\n" , a[0] );
    if( a[0] == 1 ){
      printf( "1\n" );
      printf( "1\n" );
    } else {
      printf( "2\n" );
      printf( "%d 1\n" , a[0]-1 );
    }
  } else {
    if( SZ(odd) >= 3 ){
      puts( "Impossible" );
    } else {
      vi v(0);
      if( !odd.empty() ){
	v.pb( *odd.begin() );
	odd.erase( odd.begin() );
      }

      YYS( w , even ){
	v.pb( w );
      }

      if( !odd.empty() ){
	v.pb( *odd.begin() );
	odd.erase( odd.begin() );
      }

      assert( odd.empty() );

      REP( i , SZ(v) ){
	if( i != 0 ){
	  printf( " " );
	}
	printf( "%d" , v[i] );
      }
      printf( "\n" );

      if( v[0] > 1 ){
	printf( "%lld\n" , SZ(v) );
	printf( "%d " , v[0]-1 );
      } else {
	printf( "%lld\n" , SZ(v)-1 );
      }

      FOR( i , 1 , SZ(v)-1 ){
	if( i != 1 ){
	  printf( " " );
	}
	printf( "%d" , v[i] );
      }

      printf( " %d\n" , v[SZ(v)-1]+1 );
    } 
  }
  
  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()


N = parseInt(readline())

W = parseMap(split(readline()))

min_abs = 100000

for i in 1:N-1
    min_abs = min(min_abs, abs(sum(W[1:i]) - sum(W[i+1:N])))
end


println(min_abs)

end

main()

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

int main(){
	int N,M,C;
	cin >> N >> M >> C;
	int B[M];
	int A[N][M];
	int sum[M];
	int count = 0;

	for(int i=0;i<M;i++){
		cin >> B[i];
		sum[i] = 0;
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<M;j++){
			cin >> A[i][j];
			sum[i] += A[i][j] * B[j];
		}
		if(sum[i] > (-1)*C){
			count++;
		}
	}
	cout << count << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

long long int dp[10001][200];

int main() {
	/*int N; cin >> N;
	while (N--) {
		string ast, bst; cin >> ast >> bst;
		reverse(ast.begin(), ast.end());
		for (char c : ast) {
			switch (c) {
			case 'A': {
				reverse(bst.begin(), bst.end());
			}
					  break;
			case 'C': {
				rotate(bst.begin(), bst.begin() + 1, bst.end());
			}
					  break;
			case 'J':{
						  rotate(bst.begin(), bst.end() - 1, bst.end());
					  }
					 break;
			case 'E': {
				bst = string(bst.begin() + (bst.size() + 1) / 2, bst.end()) + string(bst.begin() + bst.size() / 2, bst.begin()+(bst.size()+1)/2) + string(bst.begin(), bst.begin() + bst.size() / 2);

			}
					  break;
			case 'M': {
				transform(bst.begin(), bst.end(), bst.begin(), [](const char c) {
					if (c == '9')return '0';
					else if (c >= '0'&&c <= '9')return char(c + 1);
					else return c;
				});
			}
					  break;
			case 'P': {
				transform(bst.begin(), bst.end(), bst.begin(), [](const char c) {
					if (c == '0')return '9';
					else if (c >= '0'&&c <= '9')return char(c - 1);
					else return c;
				});
			}
					  break;
			default:
				assert(false);
			}
			
		
		cout << bst << endl;
	}*/

	while (1) {
		int N, M; cin >> N >> M;
		if (!N)break;
		for (int i = 0; i < 10001; ++i) {
			for (int j = 0; j < 200; ++j) {
				dp[i][j] = 999999999999;
			}
		}
		vector<vector<long long int>>stimes(N, vector<long long int>(N, 999999999999)),ltimes(N, vector<long long int>(N,999999999999));

		
		for (int i = 0; i < M; ++i) {
			int x, y; long long int  t; char c;
			cin >> x >> y >> t >> c;
			x--; y--;
			if (c == 'L') {
				ltimes[x][y] = min(ltimes[x][y], t);
				ltimes[y][x] = min(ltimes[y][x], t);
			}
			else {
				stimes[x][y] = min(stimes[x][y], t);
				stimes[y][x] = min(stimes[y][x], t);
			}
		}
		for (int i = 0; i < N; ++i) {
			ltimes[i][i] = 0;
			stimes[i][i] = 0;
		}
		for (int k = 0; k < N; ++k) {
			for (int i = 0; i < N; ++i) {
				for (int j = 0; j < N; ++j) {
					ltimes[i][j] = min(ltimes[i][j], ltimes[i][k] + ltimes[k][j]);
					stimes[i][j] = min(stimes[i][j], stimes[i][k] + stimes[k][j]);
				}
			}
		}
		int R; cin >> R;
		vector<int>vs(R);
		for (int i = 0; i < R; ++i) {
			cin >> vs[i];
			vs[i]--;
		}
		dp[0][vs[0]] = 0;
		for (int time = 0; time< R-1; ++time) {
			for (int f= 0; f < N; ++f) {
				for (int t = 0; t < N; ++t) {
					dp[time + 1][t] = min(dp[time + 1][t], dp[time][f] + ltimes[vs[time]][f] + stimes[f][t] + ltimes[t][vs[time + 1]]);
				}

				dp[time + 1][f] = min(dp[time + 1][f], dp[time][f] + ltimes[vs[time]][vs[time+1]]);
			}
		}
		long long int ans = 999999999999;
		for (int i = 0; i < N; ++i) {
			ans = min(ans, dp[R-1][i]);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 19096
#include<stdio.h>
int main(void){
int a,b;
scanf("%d\n",&a);
scanf("%d\n",&b);
if(a<b){
printf("a < b\n");
}
else if(a>b){
printf("a > b\n");
}
else{
printf("a == b\n");
}
return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] a = new long[N];
    for (int i =0; i<N; i++) {
      a[i] = sc.nextLong();
    }
    long ans =0;
    for (int i =0; i<N; i++) {
      ans += a[i] -1;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 40572
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

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

int main()
{
	ll a,b,c,d;
	ll ans=0;
	cin>>a>>b>>c>>d;
	ll g=gcd(c,d);
	ll lm=c*d/g;
	ll ccnt=b/c-(a-1)/c;
	ll dcnt=b/d-(a-1)/d;
	ll cnt=b/lm-(a-1)/lm;
	cerr<<lm<<" "<<cnt<<endl;
	ans=(b-a+1)-ccnt-dcnt+cnt;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		long[] b = new long[n];
		b[0]=a[0];
		for (int i=1;i<n;i++) {
			b[i]=b[i-1]+a[i];
		}

		long ans = Long.MAX_VALUE;
		long[] tmpArray = new long [4];
		for (int i=1;i<n-1;i++) {
			int tmp = Arrays.binarySearch(b, b[i]/2);

			if (tmp >= 0) {
				tmpArray[0] = b[tmp];
			} else {
				if (tmp==-1) {
					tmpArray[0]=b[0];
				} else if (b[-tmp-1] < b[i]-b[-tmp-2]) {
					tmpArray[0]=b[-tmp-1];
				} else {
					tmpArray[0]=b[-tmp-2];
				}
			}
			tmpArray[1]= b[i]-tmpArray[0];

			tmp = Arrays.binarySearch(b,b[i]+(b[n-1]-b[i])/2);
			if (tmp >= 0) {
				tmpArray[2] = b[tmp]-b[i];
			} else {
				if (tmp==-i-2) {
					tmpArray[2] = b[i+1]-b[i];
				} else if (b[-tmp-1]-b[i] < b[n-1]-b[-tmp-2]) {
					tmpArray[2]=b[-tmp-1]-b[i];
				} else {
					tmpArray[2]=b[-tmp-2]-b[i];
				}
			}
			tmpArray[3]=b[n-1]-tmpArray[2]-b[i];
			Arrays.sort(tmpArray);
			ans = Math.min(ans, tmpArray[3]-tmpArray[0]);
		}
		System.out.println(ans);
	}



}


Measured memory_bytes: 80184
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const LL MOD = 1000000007LL;
int main() {
	int N;
	cin >> N;
	int L[200];
	for (int i = 0; i < 2*N; i++) cin >> L[i];
	sort(L, L + 2*N);
	int ans = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		ans += min(L[i], L[i + 1]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256