akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    current = 1
    MAX = 10**18
    if 0 in A:
        print(0)
        exit()
    for a in A:
        current*=a
        if current > MAX:
            print(-1)
            exit()
    print(current)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 87092
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int count = 0;
		for (int i=0; i<n; i++) {
			if (isPrime(sc.nextInt())) {count++;}
		}
		System.out.println(count);
	}
	public static boolean isPrime(int num) {
	    if (num < 2) return false;
	    else if (num == 2) return true;
	    else if (num % 2 == 0) return false;
	    double sqrtNum = Math.sqrt(num);
	    for (int i = 3; i <= sqrtNum; i += 2) {
	        if (num % i == 0) {return false;}
	    }
	    return true;
	}
}				


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

class UnionFind {
private:
  int n;
  vector<int> a;
public:
  UnionFind(int n) : n(n), a(n, -1) {}
  int find(int x) {return a[x] < 0 ? x : (a[x] = find(a[x]));}
  bool equal(int x, int y) {return find(x) == find(y);}
  void unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (a[x] > a[y]) swap(x, y);
    a[x] += a[y];
    a[y] = x;
    --n;
  }
  int size() {return n;}
  int size(int x) {return -a[find(x)];}
  bool isRoot(int x) {return find(x) == x;}
  vector<vector<int>> groups() {
    vector<vector<int>> r(a.size()), res;
    for (uint i = 0; i < a.size(); ++i) r[find(i)].emplace_back(i);
    for (auto&& i : r) if (!i.empty()) res.emplace_back(move(i));
    return res;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n + m);
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int l;
      cin >> l;
      uf.unite(i, n + l - 1);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (uf.equal(0, i)) continue;
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include <fstream>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
ll T,n,m;
int main() {
	int cnt = 0;
	int sum;
	cin>>n;
	sum = n/100;
	n%=100;
	for(int i=5;i>=1;i--){
		while(n>=i){
			cnt++;
			n-=i;
		}
	}
	if(sum>=cnt){
		cout<<1<<endl;
	}
	else {
		cout<<0<<endl;
	}
	return 0;
	
}



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

using namespace std;



int main(void)
{
    long long  x, y, a,b,c;
    cin >> x >> y >> a >> b >> c;

    vector<long long> p(a), q(b), r(c);
    for ( int i = 0; i < a; ++i) cin >> p[i];
    for ( int i = 0; i < b; ++i) cin >> q[i];
    for ( int i = 0; i < c; ++i) cin >> r[i];
    
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    reverse(p.begin(), p.end());
    reverse(q.begin(), q.end());

    //先ずx個，y個食べちゃう
    vector<long long> rest;
    rest.reserve(x+y+c);
    for ( int i=0; i < x; ++i) rest.push_back(p[i]);
    for ( int i=0; i < y; ++i) rest.push_back(q[i]);    
    for ( int i=0; i < c; ++i) rest.push_back(r[i]);    
    
    sort(rest.begin(), rest.end());
    reverse(rest.begin(), rest.end());

    long long cnt = 0;
    for ( int i=0; i < x+y; ++i) cnt += rest[i];    
    cout << cnt;
    
    return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

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

using namespace std;
int main() {
	string s[3];
	rep(i, 3) cin >> s[i];

	if (s[0][s[0].size() - 1] == s[1][0] && s[1][s[1].size() - 1] == s[2][0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define sd second
#define ft first
#define ios                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int32_t main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    bool flag = true;
    deque<char> l;
    l.push_back('.');
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            flag = !flag;
        }
        else
        {
            char f, ch;
            cin >> f >> ch;
            if (f == '1')
            {
                if (flag)
                {
                    l.push_front(ch);
                }
                else
                {
                    l.push_back(ch);
                }
            }
            else
            {
                if (flag)
                {
                    l.push_back(ch);
                }
                else
                {
                    l.push_front(ch);
                }
            }
        }
    }
    string ans;
    for (auto x : l)
    {
        if (x == '.')
        {
            ans += s;
        }
        else
        {
            ans += x;
        }
    }
    if (!flag)
    {
        reverse(ans.begin(), ans.end());
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n,W;
	cin>>n>>W;
	ll dp[W+1];
	memset(dp,0,sizeof(dp));
	for (ll i = 0,w,v; i < n; ++i)
	{
		cin>>w>>v;
		for(ll j=W;j>=w;j--){
			dp[j] = max(dp[j],dp[j-w]+ v);
		}
	}

	cout<<dp[W]<<endl;
	return 0;
}

Measured memory_bytes: 4400
#coding:utf-8
n = int(input())
alpha = dict.fromkeys(list("abcdefghijklmnopqrstuvwxyz"),0)
string = input()
for i in range(n):
    alpha[string[i]] += 1

keys = list(alpha.keys())
for key in keys:
    if alpha[key] == 0:
        del alpha[key]
Q = []
maxv = 0
for i in range(n):
    if string[i] not in Q:
        Q.append(string[i])
    alpha[string[i]] -= 1
    if alpha[string[i]] == 0:
        del alpha[string[i]]
    keys = list(alpha.keys())
    cnt = 0
    for ch in Q:
        if ch in keys:
            cnt += 1
    maxv = max(maxv, cnt)

print(maxv)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int main() {
  int n;
  cin >> n;
  map<string, int> words;
  int m = 1; 
  for(int i=0; i<n; ++i){
    string temp;
    cin >> temp;
    if (words[temp] > 0) {
      words[temp] += 1; 
      if (m < words[temp]) {
        m = words[temp];
      }
    } else {
      words[temp] = 1; 
    }
  }

  for (auto const& x : words)
  {
    if (x.second == m) {
      cout << x.first << endl;
    }
  }
}


Measured memory_bytes: 25216
n = int(input())

lst = [[0 for _ in range(25)] for _ in range(25)]
int_cnt = 0
for _ in range(n):
    a = input()
    if "." in a:
        pos = a.index(".")
        a1, a2 = a[:pos], a[pos + 1:]
        l = len(a2)
        a = a1 + a2
        a = int(a)
        a *= 10 ** (9 - l)
    else:
        a = int(a)
        int_cnt += 1
        a *= 10 ** 9
    t = 0
    while a % 2 == 0:
        t += 1
        a //= 2
    f = 0
    while a % 5 == 0:
        f += 1
        a //= 5
    t = min(t, 24)
    f = min(f, 24)
    lst[t][f] += 1


 
ans = 0
for i in range(25):
    for j in range(25):
        for k in range(25):
            for l in range(25):
                if i + j >= 18 and k + l >= 18:
                    if i == j and k == l:
                        tmp = lst[i][k]
                        ans += tmp * (tmp - 1)
                    else:
                        ans += lst[i][k] * lst[j][l]
print(ans // 2)

Measured memory_bytes: 9212
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    p,x=input().split()
    P.append(int(p))
    X.append(int(x))

for i in range(M):
        print(sum(T)-(T[P[i]-1]-X[i]))



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    int cnt = 0;
    int now = 0;
    while (n--) {
        cnt++;
        now = a[now];
        if (now == 1) break; 
    }
    if (now != 1) cout << -1 << endl;
    else cout << cnt << endl;
    

}

Measured memory_bytes: 640
n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}
 
t = Array.new(n+1){ -1 } 
 
cur = 1
t[1] = i = 0

loop do
  
  cur = a[cur]
  i +=1
  if i == k
    puts cur
    exit
  end
  
  t[cur] >= 0 ? break : (t[cur] = i)
end

dist = t[cur]
puts t.index((k - dist) % (i - dist) + dist)
# cycle = i - dist
# idx = (k - dist) % (i - dist) + dist

Measured memory_bytes: 30468
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int x3, y3, x4, y4;
  x3 = x2 - (y2 - y1);
  y3 = y2 + (x2 - x1);

  x4 = x1 - (y2 - y1);
  y4 = y1 + (x2 - x1);
  
  cout << x3 << " "<< y3 <<" "<< x4 <<" "<< y4 << endl;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    int n; cin >> n;
    vector<int> arr(n);
    rep(i, n) cin >> arr[i];

    ll odd = 0, even = 0;
    ll sum1 = 0, sum2 = 0;
    rep(i, n) {
        sum1 += arr[i], sum2 += arr[i];
        if(i&1) {
            if(sum1 <= 0) odd += 1-sum1, sum1 = 1;
            if(sum2 >= 0) even += sum2-(-1), sum2 = -1;
        } else {
            if(sum1 >= 0) odd += sum1-(-1), sum1 = -1;
            if(sum2 <= 0) even += 1-sum2, sum2 = 1;
        }
    }
    cout << min(odd, even) << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <numeric>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <stack>

using namespace std;

#define rep(i,n) for(int i = 0; i<n ; i++)
#define FOR(i,a,n) for(int i=a; i<n; i++)
#define REPSTR(i,s) for(int i=0; (s)[i]; i++)
#define REPITR(i,s) for(auto i=(s).begin(); i!=(s).end();i++)

#define RANGE(a,i,b) ((a)<=(i)&&(i)<=(b))

#define pb push_back
#define mp make_pair

#define ALL(a) (a).begin(), (a).end()

#define EXIST(s,x) ((s).find(x)!=(s).end())

#define SET(a,c) memset(a,c,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))

#ifdef _DEBUG
#define DEBUG(x) cerr<<#x<<":"<<x<<endl
#else
#define DEBUG(x)
#endif

#define PRINTJOIN(x,n) rep(i,n){if(i)cout<<" ";cout<<x[i];}cout<<endl 

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef stringstream SS;

#define PQ priority_queue

#define FST first
#define SEC second

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

//---------------------------------------
//  AOJ 2015: Space Coconut Grab
//  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2012
//
//  思考の流れ
//      
//  
//
//  参考資料
//      
//---------------------------------------

int isqrt (int x) {
    // floor(sqrt(x)) 的な感じ
    // doubleの大小比較やfloorは誤差が怖いので，二分探索で求める。
    int a = 0; // 常にsqrt(x)と等しいかより小さい
    int b = 1123; // 常にsqrt(x)より大きい
    while (b-a > 1) {
        int c = (a+b)/2;
        if (c*c <= x) {
            a = c;
        } else {
            b = c;
        }
    }
    return a;
}

int iqurt (int x) {
    // floor(pow(x, 1.0/3)) 的な感じ
    // isqrtとほぼ同じ
    int a = 0;
    int b = 112;
    while (b-a > 1) {
        int c = (a+b)/2;
        if (c*c*c <= x) {
            a = c;
        } else {
            b = c;
        }
    }
    return a;
}

int E(int x, int y, int z) {
    return x + y*y + z*z*z;
}

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

    int e;
    while (cin>>e && e) {
        int Z = iqurt(e);
        int m = 1123456;
        rep (z, Z+1) {
            int Y = isqrt(e - E(0, 0, z));
            int X = e - E(0, Y, z);
            m = min(m, X+Y+z);
        }
        cout<<m<<endl;
    }
	return 0;
}


Measured memory_bytes: 3032
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <math.h>

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

using namespace std;

typedef long long ll;

ll w, h, x, y;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> w >> h >> x >> y;
    double result = (double)w * (double)h / 2;
    
    if (w == x + x && h == y + y) {
        cout << result << " " << 1 << endl;
    } else {
        cout << result << " " << 0 << endl;
    }
    
    return 0;
}



Measured memory_bytes: 256
def wrong(s):
    c = 0

    for x in s:
        if(x == '('):
            c += 1
        elif(x == ')'):
            c -= 1

        if(c < 0):
            return c

    return c

n = int(input())
s = input()

w = wrong(s)

while(w):
    if(w > 0):
        s = s + ')'
    elif(w < 0):
        s = '(' + s

    w = wrong(s)

print(s)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
// inline int cntd(long long x){
//   int res=0;
//   while(x){x/=2;res++;}
//   return res;
// }
// int main(){
//   int n;cin>>n;
//   long long k;cin>>k;
//   long long a[100010]={};
//   for(int i=0;i<n;++i)cin>>a[i];
//   int dig=cntd(k);
//   long long q=0;
//   for(int i=dig-1;i>=0;--i){
// 	if(q+pow(2,i)>k)continue;
// 	int cnt=0;
// 	for(int j=0;j<n;++j)
// 	  if(a[j]&(long long)pow(2,i))cnt++;
// 	if(cnt<(n+1)/2)q+=pow(2,i);
//   }
//   long long ans=0;

//   for(int i=0;i<n;++i)
// 	ans+=q^a[i];

//   cout<<ans<<endl;
//   return 0;

  

// }

void chmax(long long & a, long long b){if(a<b)a=b;}


int main(){
  int n;cin>>n;
  long long k;cin>>k;
  vector<long long>a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  long long dp[100][2];
  fill(dp[0],dp[0]+100,-1);
  fill(dp[1],dp[1]+100,-1);
  dp[0][0]=0;
  for(int i=0;i<60;++i){
	long long num=0;
	for(int j=0;j<n;++j)
	  if(a[j]&(1LL<<(59-i)))num++;
	if(dp[i][0]!=-1){
	  dp[i+1][0]=dp[i][0]+((k&(1LL<<(59-i)))?(1LL<<(59-i))*(n-num):(1LL<<(59-i))*num);
	  dp[i+1][1]=(k&(1LL<<(59-i)))?(1LL<<(59-i))*num+dp[i][0]:-1;
	}
	if(dp[i][1]!=-1)
	  chmax(dp[i+1][1],dp[i][1] + max(num,n-num)*(1LL<<(59-i)) );
	
  }
  cout<<max(dp[60][0],dp[60][1])<<endl;
  return 0;
}


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

void trace(vector<int> vec) {
    for(int i = 0; i < vec.size(); i++) {
        if(i > 0) cout << " ";
        cout << vec.at(i);
    }
    cout << endl;
}

int selectionSort(vector<int> &A, int N) {
    int minj;
    int sw = 0;
    for(int i = 0; i < N; i++) {
        minj = i;
        for(int j = i; j < N; j++) {
            if(A.at(j) < A.at(minj)) {
                minj = j;
            }
        }
        swap(A.at(i), A.at(minj));
        if(i != minj) {
            sw++;
        }
    }
    return sw;
}

int main() {
    int N, ans;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    ans = selectionSort(A, N);
    trace(A);
    cout << ans << endl;
}


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

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

ll lcm(ll a, ll b) {
  if (a % gcd(a,b) == 0) {
    ll agcd = a / gcd(a,b);
    return b * agcd;
  }
  else if (b % gcd(a,b) == 0) {
    ll bgcd = b / gcd(a,b);
  	return a * bgcd;
  }
  return a*b / gcd(a,b);
}

void Main()
{
  ll N; cin >> N;
  ll T;
  ll ans = 1;
  rep(i,N) {
    cin >> T;
    //cout << T << endl;
    ans = lcm(T, ans);
    //cout << ans << endl;
  }
  cout << ans << endl;
}

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


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

int main() {
    ll h,w;
    ll n;
    std::cin >> h>>w;
    std::cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> c(h,vector<ll>(w));
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    ll now = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            ll p;
            if(i%2==0){
                p = j;
            }else{
                p = w-1-j;
            }
            if( a[now] == 0 ){
                now++;
            }
            c[i][p] = now+1;
            a[now]--;
        }
    }
    for (int i = 0; i < h; i++) {
        if(w==1){
            std::cout << c[i][0] << std::endl;
        }else{
            for (int j = 0; j < w-1; j++) {
                std::cout << c[i][j]<<" ";
            }
            std::cout << c[i][w-1] << std::endl;
        }
    }
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main() {
    int n, k;
    int r, s, p;
    cin >> n >> k >> r >> s >> p;
    string arr;
    cin >> arr;
    int scr = 0;

    for (int i = 0; i < k; i++) {
        char cur = arr[i];
        int cnt = 1;
        if (cur == 'r') scr += p;
        if (cur == 's') scr += r;
        if (cur == 'p') scr += s;
        for (int j = i+k; j < n; j+=k) {
            if (cur != arr[j]) {
                cnt = 1;
                cur = arr[j];
                if (cur == 'r') scr += p;
                if (cur == 's') scr += r;
                if (cur == 'p') scr += s;
            } else {
                cnt++;
                if (cnt%2==0) continue;
                if (cur == 'r') scr += p;
                if (cur == 's') scr += r;
                if (cur == 'p') scr += s;
            }
        }
    }
    cout << scr << endl;
    return 0;
}


Measured memory_bytes: 512
def maybe_prime(d,s,n):
    for a in (2,3,5,7):
        p = False
        x = pow(a,d,n)
        if x==1 or x==n-1:
            continue
        for i in range(1,s):
            x = x*x%n
            if x==1: return False
            elif x == n-1:
                p = True
                break
        if not p: return False
    return True

def is_prime(n):
    if n in (2,3,5,7): return True
    elif n%2==0: return False
    else:
        d,s = n-1, 0
        while not d%2:
            d,s = d>>1,s+1
        return maybe_prime(d,s,n)
cnt = 0
n = int(input())
for i in range(n):
  n = int(input())
  if is_prime(n): cnt+=1

print(cnt)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    ll ans=0;
    ll a,b,c; cin>>a>>b>>c;

    ll v1=(a-a/2)*b*c - a/2*b*c;
    ll v2=(b-b/2)*a*c - b/2*a*c;
    ll v3=(c-c/2)*b*a - c/2*b*a;

    cout<<min(v1,min(v2,v3))<<endl;

}

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

int main() {
    int N;
    cin >> N;
    vector<long long> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    const int INF = 1e16;
    long long dp[N];
    fill(dp, dp + N, INF);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);

    for (int i = 2; i < N; i++) {
        dp[i] = min({dp[i], dp[i - 1] + abs(h[i] - h[i - 1]),
                     dp[i - 2] + abs(h[i] - h[i - 2])});
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1792
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int N, M;
 
int main() {

    cin >> N >> M;
 
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    sort(A.begin(), A.end());
 
    map<int, int> m;
    m[1] = 2;
    m[2] = 5;
    m[3] = 5;
    m[4] = 4;
    m[5] = 5;
    m[6] = 6;
    m[7] = 3;
    m[8] = 7;
    m[9] = 6;
 
    vector<int> use;
    for (int i = 0; i < A.size(); i++) use.push_back(m[A[i]]);
    sort(use.begin(), use.end());
    use.erase(unique(use.begin(), use.end()), use.end());
  
    vector<int> dp(N + 100, -1);
    dp[0] = 0;
    for (int i = 0; i <= N; i++) {
        if (dp[i] >= 0) {
            for (int j = 0; j < use.size(); j++) {
                dp[i + use[j]] = max(dp[i + use[j]], dp[i] + 1);
            }
        }
    }
 
    string ans = "";
    int remain = N;
    int digit = dp[N];
    while (remain > 0) {
        for (int i = M - 1; i >= 0; i--) {
            if (remain - m[A[i]] >= 0 && digit - dp[remain - m[A[i]]] == 1) {
                ans += (char) ('0' + A[i]);
                remain -= m[A[i]];
                digit--;
                break;
            }
        }
    }

    print(ans);

    return 0;
}


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

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  string input(s);
  REP(i, 3) cout << s[i];
  cout << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i< n; i++){
    cin >> vec.at(i);
  }
  
  int sum = 0;
  
  for (int i = 0; i < n; i++){
    for (int j = i + 1; j < n; j++){
      sum += vec.at(i) * vec.at(j);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint N;
int main() {
	cin >> N;
	if (N >= 30) cout << "Yes";
	else cout << "No";
}


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

int main(){
    int K;
    cin >> K;
    bool flag=false;
    long long seven=7;
    int num=0;
    if(K%2==0 || K%5==0){
        flag=true;
    }
    while(flag==false){
        num++;
        if(seven%K==0){
            flag=true;
        }
        seven=(seven*10+7)%K;
    }
    if(num==0){
        cout << -1 << endl;
    } else {
        cout << num << endl;
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18

priority_queue<llint,vector<llint>,greater<llint>> que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint n;
llint x[200005],tmp[200005];

void solve(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x[i];
		tmp[i]=x[i];
	}
	sort(x,x+n);
	int a=n/2-1;
	int b=n/2;
	llint c1=x[a];
	llint c2=x[b];
	for(int i=0;i<n;i++){
		if(tmp[i]>=c2)cout << c1 << endl;
		else cout << c2 << endl;
	}

}

int main(int argc, char *argv[]) {
  solve();
  return 0;
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int gcd(int a,int b){
  if(a<b){
    int tmp=b;
    b=a;
    a=tmp;
  }
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}
int main(){
  int n,x;
  cin>>n>>x;
  vector<int> v;
  REP(i,n){
    int tmp;
    cin>>tmp;
    tmp=abs(tmp-x);
    v.push_back(tmp);
  }
  int ans=v[0];
  sort(ALL(v));
  REP(i,n){
    ans=gcd(ans,v[i]);
  }
  cout<<ans<<endl;
}


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

bool Check(int N,int pos){
    return (bool)(N & (1<<pos));
}
int Set(int N,int pos){	return N=N | (1<<pos);}

int N =1000000,prime[1000000];
int status[1000000/32];
void sieve()
{
     int i, j, sqrtN;
     sqrtN = int( sqrt( N ) );
     for( i = 3; i <= sqrtN; i += 2 )
     {
		 if( Check(status[i/32],i%32)==0)
		 {
	 		 for( j = i*i; j <= N; j += 2*i )
			 {
				 status[j/32]=Set(status[j/32],j % 32)   ;
	 		 }
		 }
	 }
	 prime[0]=2;
	 for(i=3,j=1;i<=N;i+=2)
		 if( Check(status[i/32],i%32)==0)
	 	 {
	 	     prime[j]=i;
	 	     j++;
	 	 }
}



int decomp(int n)
{
    int sqrtn=sqrt(n),cnt;
    int f=1;

    for(int i=0;prime[i]<=sqrtn;i++)
    {

        cnt=0;
        if(n%prime[i]==0)
        {
            while(n%prime[i]==0)
            {
                cnt++;
                n=n/prime[i];
            }
        }
        if(cnt>0)
        {
            f=f*(cnt+1);

        }
        sqrtn=sqrt(n);
    }
    if(n!=1)
    {
        f=f*2;
    }

    return f;
}


int main()
{
    sieve();

    int n;
    cin>>n;

    int s=0;

    for(int i=1 ; i<n ; i++){
        s=s+decomp(i);
    }

    cout<<s<<endl;
    return 0;
}


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

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

    char a[2];
    char b[2];
    int count=0;

    rep(i, 3) cin >> a[i];
    rep(i, 3) cin >> b[i];

    rep(i, 3)
    {
        if (a[i] == b[i])
        {
            ++count;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))

    ans = 0
    H = A[0]
    for a in A:
        if a >= H:
            ans += 1

        H = max(H, a)

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ABC_117
{
    class B
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] ls = ReadInts();
            Array.Sort(ls);
            int sum = 0;
            for (int i = 0; i < n - 1; i++) sum += ls[i];
            Console.WriteLine(ls[n - 1] < sum ? "Yes" : "No");
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
hon_call = ["2","4","5","7","9"]
pon_call = ["0","1","6","8"]
bon_call = ["3"]
N = input()
last= N[-1]
if last in hon_call:
    print("hon")
elif last in pon_call:
    print("pon")
elif last in bon_call:
    print("bon")


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

int main() {

  int N, K;
  cin >> N >> K;

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

  int answer = 0;

  if (N == K) {
    answer = 1;
  } else {
    answer = ceil((double) (N - 1) / (K - 1));
  }

  cout << answer << endl;

  return 0;

}

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

#define int long long 

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 
#define pb push_back

const int maxn = 1e5+10;
const int inf = 1e9;
const lf eps = 1e-8;

int n;

vector<int > s,t;

signed main() {
    read(n);int p=101;n++;
    while(n>1) {if(n&1) t.pb(--p),n--;else s.pb(--p),n>>=1;}
    int m=s.size()+t.size();printf("%lld\n",m<<1);
    for(int i=0;i<(int)t.size();i++) printf("%lld ",t[i]);
    for(int i=s.size()-1;~i;i--) printf("%lld ",s[i]);
    for(int i=100-m+1;i<=100;i++) printf("%lld ",i);
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
const int N=1000050,mo=1e9+7;
using namespace std;
int gi(){
  char ch=getchar(); int x=0,q=0;
  while(ch<'0' || ch>'9') (ch=='-'?q=1:0),ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int dp[N][2],st[N<<1],ans;
int main(){
  int n=gi(),s;
  dp[0][0]=1;
  for (int i=0; i<n; ++i){
    if (i) (st[i]+=st[i-1])%=mo;
    (dp[i][1]+=st[i])%=mo;
    s=(dp[i][0]+dp[i][1])%mo;
    (dp[i+1][0]+=s)%=mo;
    if (i!=n-1){
      (st[i+3]+=s)%=mo;
      (st[i+n+2]-=s)%=mo;
    }
    else ans+=1ll*s*n%mo-s;
  }
  (st[n]+=st[n-1])%=mo;
  (dp[n][1]+=st[n])%=mo;
  for (int i=n+1; i<=(n<<1); ++i){
    (st[i]+=st[i-1])%=mo;
    (ans+=1ll*n*st[i]%mo)%=mo;
  }
  for (int i=1; i<=n; ++i)
    (ans+=1ll*(n-1)*dp[i][1]%mo)%=mo;
  (ans+=(dp[n][0]+dp[n][1])%mo)%=mo;
  cout<<ans;
  return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


ll num[33];


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



  cin >> n;
  cin >> s;
  rep(i, n) {
    ll c = s[i] - 'a';
    num[c]++;
  }
  ans = 1;
  rep(i, 26) (ans *= num[i] + 1) %= mod;
  cout << (ans - 1 + mod) % mod << endl;



  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		if (a % 2) cout << 0 << endl;
		else cout << -1 << endl;
		return 0;
	}
	int ans = 0;
	while (!(a % 2) && !(b % 2) && !(c % 2)) {
		int A = b / 2 + c / 2;
		int B = a / 2 + c / 2;
		int C = a / 2 + b / 2;
		a = A;
		b = B;
		c = C;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int N, i;
	char *S = (char *)malloc(sizeof(char) * 100001);
	scanf("%s", S);
	for(N = 0; S[N] != '\0'; N++){}
	for(i = 0; i < N; i++){
		if(S[i] == 'b'){
			if(S[N - 1 - i] != 'd'){
				printf("No\n");
				return 0;
			}
		}
		else if(S[i] == 'd'){
			if(S[N - 1 - i] != 'b'){
				printf("No\n");
				return 0;
			}
		}
		else if(S[i] == 'p'){
			if(S[N - 1 - i] != 'q'){
				printf("No\n");
				return 0;
			}
		}
		else{
			if(S[N - 1 - i] != 'p'){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
inline int read()
{int x=0,f=0;
char c=getchar();
while (c<'0'||c>'9') 
{if (c=='-') f=1;
c=getchar();
}
while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
if (f) x=-x;
return x;
}
int a,b,n;
int dp[105][105];
bool get(int a,int b)
{if (dp[a][b]!=0) return dp[a][b];
if (a==1&&b==2) return -1;
if (a==n&&b==n-1) return -1;
if (a-1!=0&&get(b,a-1)==-1) return dp[a][b]=1;
if (a+1!=n+1&&get(b,a+1)==-1) return dp[a][b]=1;
return dp[a][b]=-1;
}
int main (){
	scanf ("%d%d%d",&n,&a,&b);
	int p=abs(a-b);
	if (p&1) {puts("Borys");}
	else {puts("Alice");}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,y,z,k,s,ans=0;
	cin>>k>>s;
	for(x=0;x<=k;x++){
		for(y=0;y<=k;y++){
			z=s-x-y;
            if(x+y+z==s&&z<=k&&z>=0) ans++;
		}
	}
	cout<<ans;
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
using namespace std;
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
const int maxn = 30000 + 100;
const double eps = 1e-8;
typedef long long lint;

int sgn(double x) {
    return (x > eps) - (x < -eps);
}
struct P {
    double x, y;
    P() {}
    P(double _x, double _y): x(_x), y(_y) {}
    lint cross(const P &a, const P &b) const {
        return (a.x - x) * (b.y - y) - (a.y - y) * (b.x - x);
    }
    void input() {
        scanf("%lf%lf", &x, &y);
    }
};

int n, m, w, h, s;
int l[maxn], r[maxn];
double area[maxn];
int cnt[maxn];

int main() {
    while (scanf("%d%d%d%d%d", &n, &m, &w, &h, &s) == 5 && (n || m || w || h || s)) {
        for (int i = 1; i <= m; ++i) {
            scanf("%d%d", &l[i], &r[i]);
        }
        l[0] = r[0] = 0;
        l[m + 1] = r[m + 1] = h;
        
        for (int i = 0; i <= m; ++i) {
            area[i] = double(r[i + 1] - r[i] + l[i + 1] - l[i]) * w / 2;
            cnt[i] = 0;
        }
        for (int i = 0; i < n; ++i) {
            P pt;
            pt.input();
            int low = 0, high = m, res = -1;
            while (low <= high) {
                int mid = (low + high) / 2;
                if (sgn(P(0, l[mid]).cross(P(w, r[mid]), pt)) > 0) {
                    res = mid;
                    low = mid + 1;
                } else {
                    high = mid - 1;
                }
            }
            if (res == -1) while (1);
            if (res != -1) ++cnt[res];
        }
        //for (int i = 0; i <= m; ++i) printf("%lf ", area[i]); printf("\n");
        //for (int i = 0; i <= m; ++i) {
            //if (i == 0) sum[i] = cnt[i];
            //else sum[i] = sum[i - 1] + cnt[i];
        //}
        int ba = 0;
        double now = 0;
        int ct = 0;
        int ans = 0;
        for (int i = 0; i <= m; ++i) {
            now += area[i];
            ct += cnt[i];
            while (ba <= i && sgn(now - w * h + s) > 0) {
                now -= area[ba];
                ct -= cnt[ba];
                ++ba;
            }
            ans = max(ans, ct);
        }
        printf("%d\n", n - ans);
    }
    return 0;
}

Measured memory_bytes: 1508
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
 int main(){
     CIN(A);CIN(B);CIN(K);
     I vec;
     K--;
     FOR(a,A,B+1){
         if(A+K>=a||B-K<=a)vec.pb(a);
     }
     sort(ALL(vec));
     FOREACH(a,vec){
         COUT(a);
     }
  return 0;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

#define eb(x) emplace_back(x)

const int N = 2010;
int a[N];
vector<int> v[N];

int main(){
    IOS;
    int n,k,q;cin>>n>>k>>q;
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=0x3f3f3f3f;
    int cnt=1;
    for(int i=0;i<=n;i++){
        for(int j=1;j<=cnt;j++)v[j].clear();
        int tar=a[i];
        cnt=1;
        vector<int> vv;
        for(int j=1;j<=n;j++){
            if(a[j]<tar){
                if(a[j-1]>=tar)cnt++;
                continue;
            }
            v[cnt].eb(a[j]);
        }
        for(int j=cnt;j>=1;j--){
            if(v[j].size()<k)continue;
            sort(v[j].begin(),v[j].end());
            for(int z=1;z<=(int)v[j].size()-k+1;z++)vv.eb(v[j][z-1]);
        }
        if((int)vv.size()>=q){
            sort(vv.begin(),vv.end());
            ans=min(ans,vv[q-1]-vv[0]);
        }
    }
    cout<<ans<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(){
  int W,H,X,Y,N,n,x,y,count[101];
  cin >>n;

  for(int i=0; i<n;i++){
    count[i]=0;
    cin >> X >> Y >> W >> H;

    cin >> N;
    
    for(int j=0; j< N; j++){
      
      cin  >> x >> y;

      if(x >=X && y >= Y && x <= X+W && y<=Y+H ){

	count[i]++;}
  }
  }

    for(int i=0; i< n; i++){
      cout << count[i] << endl;}


    return 0;
  
}  
      

    

      

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
	int N,K,flag=0,count=0;
	scanf("%d%d",&N,&K);
	int num[N];
	for(int i=0;i<N;i++){
		for(int j=0;j<K;j++){
			if(i+j>N-1)flag=1;
		}
		if(flag==0)count++;
		else break;
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
# S = input()
A = list(map(int,input().split()))
# print(A)
# X2_list = [list(map(int,input().split())) for i in range(N)]
result = 0
cnt =1
for i in range(N):
    if A[i] == cnt:
        result+=1
        cnt+=1
if result == 0:
    print(-1)
    exit(0)
print(N-result)

Measured memory_bytes: 24744
import java.util.Scanner;

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

    int a = sc.nextInt();
    int b = sc.nextInt();

    int c = a * b;

    if (c % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }

  }
}

Measured memory_bytes: 21716
#include <iostream>
int main(){
    int min;
    std::cin >> min;
    int h = min / 3600;
    min = min % 3600;
    int s = min / 60;
    min = min % 60;
    std::cout << h << ":" << s << ":" << min << std::endl;
    return 0;
}


Measured memory_bytes: 3068
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
#define endl '\n'
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

struct Edge { // {{{
    int src, to;
    i64 cost;
    Edge(int src,  int to, i64 cost) : src(src), to(to), cost(cost) {}
    Edge(int to, i64 cost = 0) : Edge(-1, to, cost) {}
    bool operator< (const Edge &o) const { return cost < o.cost; }
    bool operator> (const Edge &o) const { return cost > o.cost; }
};
using Edges = vector<Edge>;
using WGraph = vector<vector<Edge>>;
using Ugraph = vector<vector<int>>;
// }}}

vector<i64> dijkstra(const WGraph &G, int src) // {{{
{
    vector<i64> dist(G.size(), LINF);
    priority_queue<pii, vector<pii>, greater<pii>> pq;

    dist[src] = 0;
    pq.emplace(0, src);

    while(!pq.empty()) {
        const i64 nowCost = pq.top().first;
        const int nowNode = pq.top().second;
        pq.pop();
        if (dist[nowNode] < nowCost) continue;

        for (const auto &e : G[nowNode]) {
            const i64 newCost = nowCost + e.cost;
            if (chmin(dist[e.to], newCost)) {
                pq.emplace(newCost, e.to);
            }
        }
    }

    return dist;
}
// }}}

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

    int N; cin >> N;

    WGraph G(N);

    for (int i = 0; i < N-1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        G[a].emplace_back(b, c);
        G[b].emplace_back(a, c);
    }

    int Q, K;
    cin >> Q >> K;
    --K;

    const auto dist = dijkstra(G, K);

    while(Q--) {
        int x, y;
        cin >> x >> y;
        --x , --y;

        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}


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

using namespace std;

inline long long read(){
   long long w=1,s=0;
   char ch=getchar();
   while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();} 
   while(ch>='0'&&ch<='9')  s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int a[1000000];

int main(){
    int n=read(),x=read(),maxx=0;
    for(int i=1;i<=n;i++){
        a[i]=read();
    }
    sort(a+1,a+n+1);
    int gg=0;
    if (n>=3) gg=__gcd(a[2]-a[1],a[3]-a[2]);
    for(int i=4;i<=n;i++){
    gg=__gcd(gg,a[i]-a[i-1]);    
    }
    for(int i=1;i<=n;i++) gg=__gcd(abs(x-a[i]),gg);
    cout<<gg;
    return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ull unsigned long long 
#define ul unsigned long
#define ll long long
#define pb push_back
#define sodayoda_C  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define f(i,a,b) for(int i = a;i<b;i++)
#define fb(i,a,b) for(int i = a;i>b;i--)
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define mp make_pair
//memset(name,'',size)
//reverse(s,begin(),s.end())

using namespace std;

int main(){	
	sodayoda_C;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	int t;
	//cin>>t;
	t = 1;
	while(t--){
		string s;
		cin>>s;
		ll sum = 0;
		f(i,0,s.length()){
			sum+=(s[i]-'0');
		}
		if(sum%9 == 0) cout<<"Yes";
		else cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3764
n, Y = map(int, input().split())
for x in range(n + 1):
    for y in range(n + 1 - x):
        z = n - x - y
        if z < 0:
            continue
        if x * 10000 + y * 5000 + z * 1000 == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)


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

// clang-format off
#define forn(i, x, y) for(int i = x; i < y; i++)
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL)
// clang-format on

using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

const long long MOD = 1000000007;

template <typename T>
void add(T &a, T b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
}

VVLL matMul(VVLL a, VVLL b)
{
  int n = a.size();
  VVLL ret(n, VLL(n));
  forn(i, 0, n) forn(j, 0, n) forn(k, 0, n)
      add<LL>(ret[i][j], a[i][k] * b[k][j] % MOD);
  return ret;
}

int main()
{
  LL N, K;
  cin >> N >> K;
  VVLL G(N, VLL(N));
  forn(i, 0, N) forn(j, 0, N) cin >> G[i][j];

  VVLL R(N, VLL(N));
  forn(i, 0, N) R[i][i] = 1;

  for (; K > 0; K >>= 1)
  {
    if (K & 1)
      R = matMul(R, G);

    G = matMul(G, G);
  }

  LL res = 0;
  forn(i, 0, N) forn(j, 0, N) add(res, R[i][j]);
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3680