akhauriyash/Code-Regression huggingface dataset:
n,m,c=map(int,input().split())
b=list(map(int,input().split())) 
a=[list(map(int,input().split()))for i in range(n)]
ans=0
for i in range(n):
  s=c
  for j in range(m):
    s+=b[j]*a[i][j]
  if s>0:
    ans+=1
print(ans)





Measured memory_bytes: 3060
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
    exit()
if (H * W) % 2 == 0:
    print(int(H * W / 2))
elif (H * W) % 2 == 1:
    print(int((H*W)//2+1))


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

int n,a[N],q[N]; ll ans[N];
bool cmp(int x,int y){ return a[x]<a[y]; }
int main(){
	scanf("%d",&n);
	int i,j,now;
	for (i=1; i<=n; i++) scanf("%d",&a[i]);
	for (i=1; i<=n; i++) q[i]=i;
	sort(q+1,q+n+1,cmp);
	for (i=n,now=1000000000; i; i=j){
		for (j=i; a[q[j]]==a[q[i]]; j--) now=min(now,q[j]);
		ans[now]+=(ll)(n-j)*(a[q[i]]-a[q[j]]);
	}
	for (i=1; i<=n; i++) printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b){
  if(a<b) swap(a,b);
  if(a%b) return gcd(b,a%b);
  else return b;
}
int main(){
  ll a,b;
  string s,t,c,d;
  cin>>a>>b>>s>>t;
  ll g=gcd(a,b);
  for(int i=0;i<a;i+=a/g) c.push_back(s[i]);
  for(int j=0;j<b;j+=b/g) d.push_back(t[j]);
  cout<<(c==d?a/g*b:-1);
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        int n, k;
        int ans = 1;
        scanf("%d%d", &n, &k);
        int cnt = n;
        while (cnt > 0 && ans * 2 < ans + k) {
                cnt --;
                ans *= 2;
        }
        ans += k * cnt;
        printf("%d\n", ans);
        return 0;
}



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

int main() {
  int64_t N;
  int ans=0;
  cin >> N;
  
  vector<int64_t> A(3,-1);
  int cnt0 = 0;
  int cnt1 = 0;
  int cnt2 = 0;
  int64_t ain;
  for( int64_t i=0; i<N; ++i) {
    cin >> ain;
    if( A[0] == -1 ) {
      A[0] = ain;
      cnt0++;
    } else if( A[1] == -1 ) {
      if ( A[0] == ain) {
        cnt0++;
      } else {
        A[1] = ain;
        cnt1++;
      }
    } else if( A[2] == -1 ) {
      if ( A[0] == ain) {
        cnt0++;
      } else if ( A[1] == ain) {
        cnt1++;
      } else if ( A[0] != ain && A[1] != ain) {
        A[2] = ain;
        cnt2++;
      }
    } else {
      if ( A[0] != ain && A[1] != ain && A[2] != ain ) {
        cout << "No" << endl;
        return 0;
      }
      if ( A[0] == ain) {
        cnt0++;
      } else if ( A[1] == ain) {
        cnt1++;
      } else {
        cnt2++;
      }
    }
  }

  if((cnt0 == cnt1) && (cnt0 == cnt2) && ( (A[0] ^ A[1]) == A[2])) {
    cout << "Yes" << endl;
  } else if( (cnt2 == 0) && (((cnt0 == cnt1*2) && (A[1] == 0)) ||
                             (cnt1 == cnt0*2) && (A[0] == 0) ) ) {
    cout << "Yes" << endl;
  } else if( (cnt2 == 0) && (cnt1==0) && (A[0] == 0)){
    cout << "Yes" << endl;
  } else{ 
    cout << "No" << endl;
  }
}


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

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string s;
	cin >>s;
	int S=0;
	Rep0(i, s.size())
		if ('1'==s.at(i))
			S++;
	cout <<S <<endl;
	return 0;
}



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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, D, A;
	cin >> N >> D >> A;
	vector<pair<int, int> > X(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> X[i].first >> X[i].second;
	}
	sort(X.begin(), X.end());
	vector<int> T(N + 1, 0);
	int INF = (int)1 << 60;
	for (int i = 0; i < N; i++) {
		if (i > 0) T[i] += T[i - 1];
		int rem = X[i].second - T[i];
		if (rem > 0) {
			int num = (rem + A - 1) / A;
			int r = upper_bound(X.begin(), X.end(), make_pair(X[i].first + 2 * D, INF)) - X.begin();
			T[i] += num * A;
			T[r] -= num * A;
			res += num;
		}
	}
	cout << res << endl;
}

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

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int d,n,i,p=1;
	scanf("%d %d",&d,&n);
	for(i=0;i<d;i++){
		p=p*100;
	}
	if(n==100)n=101;
	printf("%d",p*n);
	return 0;
}


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

vector<int> ans;
vector<int> to[200005];
void dfs(int x,int p=-1){
  for(int i : to[x]){
    if(p == i) continue;
    ans[i] += ans[x];
    dfs(i,x);
  }
}

int main(){
  int n,q;
  cin>>n>>q;
  rep(i,n-1){
    int a,b;
    cin>>a>>b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin>>p>>x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << endl;
}

Measured memory_bytes: 23552
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main() {
  uint32_t a, b, c;
  cin >> a >> b >> c;

  int32_t time = -1;
  for (uint32_t i = c; i <= (a + b) * 60; i += 60) {
    if (i % (a + b) <= a) {
      time = i;
      break;
    }
  }

  cout << time << endl;

  return 0;
}

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

namespace ProjectContest
{
    public  class DS
    {
        public int key { get; set; }
        public int value { get; set; }
    }
    class Test
    {
        static void Main()
        {
            
            int n = Convert.ToInt32(Console.ReadLine());
            int t = 0;
            List<DS> ls = new List<DS>();
            while (n-- > 0)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
                int a = ab[0], b = ab[1];
                DS ds = new DS();
                ds.key = a;ds.value = b;
                ls.Add(ds);
            }
            var dicSort = ls.OrderBy(x => x.value).ThenBy(x => x.key).Select(x=>x);
            foreach (var v in dicSort)
            {
                t += v.key;
                if (t > v.value)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }

    }
}

Measured memory_bytes: 31528
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    vector<int> a(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += a[i];
    }
    cout << ans << '\n';

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	ll c = 1;
	for (int i = 1; i <= n; i++) {
		c *= i;
		c %= 1000000007;
	}
	cout << c << endl;
}

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

/*int main(){//B
        string S;
        cin>>S;
        rep(i,0,S.size()){
            if(i%2==0){
                if(S[i]!='R'&&S[i]!='U'&&S[i]!='D') {
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            if(i%2!=0){
                if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
        cout<<"Yes"<<endl;
        return 0;
    }*/

/*int main(){
        int N,K,Q;
        cin>>N>>K>>Q;
        vector<int> A(N,K-Q);
        //vector<int> B(Q);
        int c=N;
        rep(i,0,Q){
            int b; 
            cin>>b;
            A[b-1]++;
        }
        rep(i,0,N) {if(A[i]>0) cout<<"Yes"<<endl;
                    else cout<<"No"<<endl;
        }
        return 0;
    }*/

int main()
{
  long long N, M;
  cin >> N >> M;
  long long c = 0;
  priority_queue<long long> A;
  rep(i, 0, N)
  {
    long long a;
    cin >> a;
    A.push(a);
  }
  rep(i, 0, M)
  {
    long long b;
    b = A.top();
    A.pop();
    A.push(b / 2);
  }
  rep(i, 0, N)
  {
    c += A.top();
    A.pop();
  }
  cout << c << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define Mod(n) n % 1000000007

long long GCD(long long A,long long B)
{
    return (B == 0) ? A : GCD(B , A % B);
}

void solve()
{
    long long N;
    cin >> N; 
    long long X;
    cin >> X;
    long long ans = 0;
    for(int i = 0;i < N;++i)
    {
        long long x;
        cin >> x;
        ans = GCD(ans,abs(X - x));
    }
    cout << ans << '\n';
}

int main()
{
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  
  int n,d;
  cin>>n>>d;
  
  if(n%(2*d+1)==0){
  
    cout<<n/(2*d+1)<<endl;
  }
  
  else{
  
    cout<<(n+2*d)/(2*d+1)<<endl;
  
  }
  
  
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int N = nextInt();
		int A = nextInt();
		int B = nextInt();

		int res = 0;
		if(A*N > B) {
			res = B;
		}else {
			res = A*N;
		}
		out.println(res);
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long int
#define ld double
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
int main()
{
	boost;
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a * b, a - b));
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        sb.Append(((int.Parse(str[0])+int.Parse(str[1])) % 24)+"\n");
    }
}

Measured memory_bytes: 13140
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define debug(args...){ string _s = #args;replace(_s.begin(),_s.end(),',', ' ');stringstream _ss(_s);istream_iterator<string>_it(_ss);err(_it, args);}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb              push_back
#define eb              emplace_back
#define ff              first
#define ss              second
#define NL              printf("\n");
#define bug(a)          cout<<#a<<" "<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **



ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
bitset<N>B;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc=1,in,loc,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
//cin>>tc;
rep(t,tc)
{
    cin>>m;
    n=m*3;
    rep(i,n)cin>>x[i];
    sort(x+1,x+n+1, greater<ll>());

    for(i=2,j=0;j<m;j++,i+=2)
    {
        ans+=x[i];
    }
    cout<<ans<<endl;
}
}
    return 0;
}

/*


*/
/// Check for constraint 0 or 1?
/// Division MOD needs BigMod(a,n-2)
/// long long or double? sqrt or division will work fine??
/// sort(begin(v), end(v), [] (int a, int b) { return a > b; });    /// Lambda Function for manual Sort


Measured memory_bytes: 4352
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数

N = iin()
a = iln_r()

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

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


public class Main {

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

        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) nums[i] = scanner.nextInt();

        bubbleSort(n, nums);
    }

    private static void bubbleSort(int n, int[] a) {
    	boolean flg = true;
    	int i = 0;
    	int sw = 0;
    	while (flg) {
    		flg = false;
    		for (int j = n - 1; j > i; j--) {
    			if (a[j] < a[j-1]) {
    				int w = a[j];
    				a[j] = a[j-1];
    				a[j-1] = w;
    				sw++;
    				flg = true;
    			}
    		}
    		i++;
    	}
    	trace(a);
    	System.out.println(sw);
    }

    private static void trace(int[] nums) {
    	System.out.println(Arrays.toString(nums).replaceAll("[\\[\\],]", ""));
    }

}


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

int c[8];

class DICE{
public:
    void setdice(char a);
};

void DICE::setdice(char a){
    if(a == 'S'){
        c[7] = c[1];
        c[1] = c[5];
        c[5] = c[6];
        c[6] = c[2];
        c[2] = c[7];
    }
    else if(a == 'W'){
        c[7] = c[1];
        c[1] = c[3];
        c[3] = c[6];
        c[6] = c[4];
        c[4] = c[7];
    }
    else if(a == 'N'){
        c[7] = c[1];
        c[1] = c[2];
        c[2] = c[6];
        c[6] = c[5];
        c[5] = c[7];
    }
    else{
        c[7] = c[1];
        c[1] = c[4];
        c[4] = c[6];
        c[6] = c[3];
        c[3] = c[7];
    }
}

int main(void){
    DICE dice;
    int n, a, b;
    for(int i = 1; i <= 6; i++){
        cin >> c[i];
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a == c[3] || a == c[4]){
            while(c[1] != a)    dice.setdice('E');
        }
        else{
            while(c[1] != a)    dice.setdice('S');
        }
        dice.setdice('N');
        while(c[1] != b)    dice.setdice('W');
        dice.setdice('S');
        cout << c[3] << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 3100
#include<stdio.h>
int main(void)
{
     int h,m,s,S;
     scanf("%d",&S);
     
     h=S/3600;
     m=S%3600/60;
     s=S%3600%60;
     
     printf("%d:%d:%d\n",h,m,s);
     
     return 0;
}


Measured memory_bytes: 2136
A=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())-1
print(A[K])

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

int main()
{
  int n,m;cin>>n>>m;
  int sum=0;
  int t;
  for(int i=0;i<m;i++){cin>>t;sum+=t;}
  
  if(sum>n)cout<<-1<<endl;
  else
    cout<<n-sum<<endl;
  return 0;
}

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


using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e3 + 5;
bool isPrime[MAXN];

void sevie() {
    memset(isPrime, 1, sizeof(isPrime));
    isPrime[0] = isPrime[1] = 0;
    for (ll i = 2; i * i <= MAXN; i++) {
        if (isPrime[i]) {
            for (ll j = i * 2; j <= MAXN; j += i) {
                isPrime[j] = 0;

            }
        }
    }
}

ll fastPow(ll x, ll b) {
    if (b == 0)
        return 1;
    else if (!(b & 1)) {
        return fastPow(x * x, b / 2);
    } else
        return x * fastPow(x * x, (b - 1) / 2);
}

//__builtin_popcount ();
bool isPrim(int n) {
    if (n == 1 || n == 0)
        return false;
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main() {
    FAST
int n;
    cin>>n;
    string h;
    cin>>h;
    int c=0;
    for(int i=0;i<n-2;i++)
    {
        if(h.substr(i,3)=="ABC")
            c++;
    }
    cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 + b % 2 + c % 2) cout << 0 << endl;
  else if (a == b && b == c) cout << -1 << endl;
  else {
    ll cnt = 0;
    ll x = abs(a - b), y = abs(b - c), z = abs(c - a);
    while (x % 2 == 0 && y % 2 == 0 && z % 2 == 0) {
      x /= 2;
      y /= 2;
      z /= 2;
      cnt++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 256
sd = input()
t = input()
sn = len(sd)
tn = len(t)
s = []
for i in range(sn-tn, -1, -1):
    t_kamo = sd[i: i+tn]
    for j in range(tn+ 1):
        if j == tn:
            print((sd[:i] + t + sd[i+tn:]).replace("?", "a"))
            exit()
        elif t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break
print("UNRESTORABLE")

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  ll a, b;
  cin >> n >> a >> b;
  vector<ll> x(n);
  REP(i, n) cin >> x[i];
  ll ans = 0;
  REP(i, n - 1) ans += min(a * (x[i + 1] - x[i]), b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
N, Y = gets.split.map(&:to_i)

x=0
y=0
z=0

x = Y / 10000
y = Y % 10000 / 5000
z = Y % 5000 / 1000

temp=N-(x+y+z)

if temp < 0 then
    x=-1
    y=-1
    z=-1
end
while temp!=0
    if temp>0 then
        if temp>=4 then
            if y>0 then
                y-=1
                z+=5
                temp-=4
            elsif x>0 then
                x-=1
                y+=2
                temp-=1
            else 
                x=-1
                y=-1
                z=-1
                break
            end
        elsif x>0 then
            x-=1
            y+=2
            temp-=1
        else 
            x=-1
            y=-1
            z=-1
            break
        end
    else 
        x=-1
        y=-1
        z=-1
        break
    end
end
puts ("#{x} #{y} #{z}")

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll dp[105][100005];

int main(){
  ll N, W;
  cin >> N >> W;
  vector<vector<ll>> v;
  rep(i,N){
    ll a, b;
    cin >> a >> b;
    v.push_back({a,b});
  }

  dp[0][v[0][0]] = v[0][1];
  REP(i,1,N){
    rep(j,100005){
      dp[i][j] = dp[i-1][j];
      if(j-v[i][0] >=0 && dp[i][j] < dp[i-1][j-v[i][0]] + v[i][1]){
        dp[i][j] = dp[i-1][j-v[i][0]] + v[i][1];
      }
    }
  }

  ll ret = 0;
  rep(i,W+1){
    ret = max(ret, dp[N-1][i]);
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {
       


       ll h,w;

       cn h>>w;
       

       if(h==1 || w==1){
       	ct 1;
       	return 0;
       }
       ll b=w/2+w%2;
       
       ll c;

       if(w%2==0)c=b;
       else c=b-1;

       ct (h/2 +h%2)*b+(h/2)*c;





       





    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define fid(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define pii pair<int,int>
#define TTT "Vacation"
#define maxn 100005
using namespace std;
int n, f[maxn][3];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(TTT".inp", "r", stdin);
    freopen(TTT".out", "w", stdout);
    #endif // ONLINE_JUDGE
    cin >> n;
    int x;
    fi(i, 1, n)
    fi(j, 0, 2)
    {
        cin >> x;
        fi(k, 0, 2)
        if(j != k)
            f[i][j] = max(f[i][j], f[i - 1][k] + x);
    }
    cout << max(f[n][0], max(f[n][1], f[n][2]));
}


Measured memory_bytes: 4808
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 const int NINE=1000000000;
 
 
int main(){
string a;
  cin>>a;
  ll k;
  cin>>k;
  ll a1=0;
  ll n=a.size();
  ll t=1;
  rep(i,n-1){
  if(a[i]==a[i+1]) t++;
  else {
  a1=a1+t/2;
    t=1;
  
  }
  }
  a1=a1+t/2;
  ll a2=0;
  t=1;
  string c=a+a;
    rep(i,2*n-1){
  if(c[i]==c[i+1]) t++;
  else {
  a2=a2+t/2;
    t=1;
  
  }
  }
  a2=a2+t/2;
    ll a3=0;
  t=1;
  string d=a+a+a;
    rep(i,3*n-1){
  if(d[i]==d[i+1]) t++;
  else {
  a3=a3+t/2;
    t=1;
  
  }
  }
  a3=a3+t/2;
  if(t==3*n) cout<<n*k/2;
  else{
  if(k==1) cout<<a1;
  else if(k==2) cout<<a2;
  else if(k==3) cout<<a3;
  else cout<<a2+(a3-a2)*(k-2);
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int W[] = new int[10];
                int K[] = new int[10];
                for (int i = 0; i < 10; i++) {
                        W[i] = sc.nextInt();
                }
                for (int i = 0; i < 10; i++) {
                        K[i] = sc.nextInt();
                }
                Arrays.sort(W);
                Arrays.sort(K);
                System.out.println(W[9] + W[8] + W[7] + " " + (K[9] + K[8] + K[7]));
        }
}

Measured memory_bytes: 26080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while(true){
			str = br.readLine();
			if(str.equals("-")){
				break;
			}
			StringBuffer sb = new StringBuffer();
			sb.append(str);
			int count = Integer.parseInt(br.readLine());

			for(int i = 0; i < count; i++){
				int indexNum = Integer.parseInt(br.readLine());

				sb.append(sb.substring(0, indexNum));
				sb.delete(0, indexNum);

			}
			System.out.println(sb.toString());
		}
	}
}

Measured memory_bytes: 24328
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

// assume that n >= 0;
ll mod_pow(const ll x, ll n, const ll mod) {
    ll res = 1;
    if (n == 0) return 1;
    if (n & 1) res = x;
    ll y = mod_pow(x, n >> 1, mod);
    res = (res * (y * y % mod)) % mod;
    return res;
}

int main(void) {
    const ll mod = 1000000007LL;
    ll x, n;
    cin >> x >> n;

    cout << mod_pow(x, n, mod) << endl;

    return 0;
}



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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 n, k, l, r;
    cin >> n >> k >> l >> r;
    akari<i64> as(n), vs[n + 1];
    for (int i = 0; i < n; i++)
    {
        cin >> as[i];
    }
    int ofs = n / 2, res = n - ofs;
    for (int s = 0; s < 1 << ofs; s++)
    {
        i64 val = 0;
        for (int i = 0; i < ofs; i++)
        {
            if (s >> i & 1)
            {
                val += as[i];
            }
        }
        vs[__builtin_popcount(s)].push_back(val);
    }
    for (int i = 0; i <= n; i++)
    {
        sort(vs[i].begin(), vs[i].end());
    }
    i64 ans = 0;
    for (int s = 0; s < 1 << res; s++)
    {
        i64 val = 0;
        for (int i = 0; i < res; i++)
        {
            if (s >> i & 1)
            {
                val += as[ofs + i];
            }
        }
        int i = __builtin_popcount(s);
        if (i > k)
            continue;
        ans += distance(lower_bound(vs[k - i].begin(), vs[k - i].end(), l - val), upper_bound(vs[k - i].begin(), vs[k - i].end(), r - val));
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 12192
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  int n, m, k;
  cin >> n >> m;
  vector<vector<int>> a(m);
  vector<int> c(m);
  //電球の数だけ回す
  rep(i,m)
  {
    cin >> k;
    vector<int> b(k);
    //k個の繋がるスイッチ
    rep(j,k)
    {
      cin >> b[j];
    }
    a[i] = b;
  }
  rep(i,m)
  {
    cin >> c[i];
  }
  int onoff, tmp, sum = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    tmp = 0;
    rep(i,m)
    {
      onoff = 0;
      vector<int> b = a[i];
      rep(j,b.size())
      {
        if (bit & 1 << (b[j] - 1)) {
          onoff++;
        }
      }
      if (c[i] == onoff % 2) {
        tmp++;
      }
    }
    if (tmp == m) {
      sum++;
    }
  }
  cout << sum;
}

Measured memory_bytes: 256
require 'pp'

MOD = 1000000007

n = gets.chomp!.to_i
s1 = gets.chomp!.chars
s2 = gets.chomp!.chars

index = 0
dirs = []
while s1[index] != nil
    if s1[index + 1] == nil
        dirs << :tate
        index += 1
    elsif s1[index] == s1[index+1]
        dirs << :yoko
        index += 2
    else
        dirs << :tate
        index += 1
    end
end

before = dirs.shift
sum = (before == :tate ? 3 : 6)

while dirs.empty?.!
    d = dirs.shift
    if before == :tate && d == :yoko
        sum = (sum * 2) % MOD
    elsif before == :tate && d == :tate
        sum = (sum * 2) % MOD
    elsif before == :yoko && d == :yoko
        sum = (sum * 3) % MOD
    end

    before = d
end

puts sum


Measured memory_bytes: 2172
#include<cstdio>
#include<cmath>

int main(void){
int n,i,k=0;
double h[256];
while(1){
	scanf("%d",&n);
	if(n==0) break;
	double s[n],sum=0,average,bunsan=0;

	for(i=0;i<n;i++){
		scanf("%lf",&s[i]);
		sum=sum+s[i];
	}
	average=sum/n;
	for(i=0;i<n;i++){
		bunsan=bunsan+(s[i]-average)*(s[i]-average);
	}
	bunsan=bunsan/n;
	h[k]=sqrt(bunsan);
	k++;
}
for(i=0;i<k;i++){
	printf("%f\n",h[i]);
}
return 0;
}

		

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

using namespace std;

int main() {
    int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

    int x, y;
    cin >> x >> y;

    if (a[x] == a[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
int main(){
int n,tmp,s=0;
cin>>n;
tmp=n;
while(tmp){
	s+=tmp%10;
	tmp/=10;
}
if(n%s==0)cout<<"Yes";
else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=5005;
const int M=1000000007;
typedef long long ll;
int p[maxn],n,ans,f[maxn],cc,dp[maxn],pre[maxn],sz[maxn],cy[maxn],a[maxn],jc[maxn];
void sub(int &x,int y){x-=y;if (x<0) x+=M;}
void add(int &x,int y){x+=y;if (x>=M)x-=M;}
int ffind(int x){
    if (pre[x]==x) return x;
    return pre[x]=ffind(pre[x]);
}
void _union(int x,int y){
    x=ffind(x); y=ffind(y);
    if (x==y) {cy[x]=1;return;}
    pre[y]=x; sz[x]+=sz[y]; cy[x]|=cy[y];
}
int main(){
    cin >> n;
    jc[0]=1; for (int i=1;i<=n;i++) jc[i]=1ll*jc[i-1]*i%M;
    for (int i=1;i<=n;i++) cin >> p[i];
    for (int i=1;i<=n;i++) pre[i]=i,cy[i]=0,sz[i]=1;
    for (int i=1;i<=n;i++) if (p[i]!=-1) _union(i,p[i]);
    f[0]=1; for (int i=1;i<=n;i++) f[i]=1ll*f[i-1]*(n-1)%M;
    int zt=0;
    for (int i=1;i<=n;i++) if (ffind(i)==i){
        if (cy[i]) {++zt;continue;}
        a[++cc]=sz[i];
    }
    ans=1ll*f[cc]*(n-zt)%M;
    dp[0]=1;
    for (int i=1;i<=cc;i++){
        for (int j=i;j;j--) add(dp[j],1ll*dp[j-1]*a[i]%M);
    }
    for (int i=2;i<=cc;i++) sub(ans,1ll*f[cc-i]*jc[i-1]%M*dp[i]%M);
    for (int i=1;i<=cc;i++) sub(ans,1ll*f[cc-1]*(a[i]-1)%M);
    cout << ans << endl;
    return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n)
    {
        cin >> a[i];
    }

    sort(all(a));
    reverse(all(a));
    int ans = 0;
    queue<int> q;
    q.push(a[0]);
    rep1(i, a.size())
    {
        int temp = q.front();
        ans += temp;
        q.push(a[i]);
        q.push(a[i]);
        q.pop();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6428
#include <stdio.h>
 
int main(void){
  int i,j,n;
  int sum = 0,flag = 1;
  int array[10000];
 
  scanf("%d",&n);
 
  for( i = 0 ; i < n ; i++ ){
    scanf("%d",&array[i]);
  }
 
  for( i = 0 ; i < n ; i++ ){
    flag = 1;
    for( j = 2 ; j*j <= array[i] ; j++ ){
      if( (array[i] % j) == 0 ){
        flag = 0;
        break;
      }
    }
    if( flag == 1 ) sum++;
  }
  printf("%d\n",sum);
  return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K; cin >> N >> K;
    int pos_one = -1;
    int A[N];
    rep(i, N){
        cin >> A[i];
        if(A[i] == 1) pos_one = i;
    }
    //K-1個ずつ伸ばせる. 左にpos_one個あるので最初はa = pos_one % (K-1)個だけ左に伸ばして右に(K-1)-a個伸ばす
    //右にはN-1-pos_one個ある
    int ans = 1;
    int a = pos_one % (K-1);
    if(pos_one > 0 && a == 0) a = K-1;
    int left_rem = pos_one-a, right_rem = (N-1-pos_one) - (K-1-a);
    ans += left_rem/(K-1); ans += (right_rem + (K-2))/(K-1);
    //cout << left_rem << " " << right_rem << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    string w;
    cin >> w;
    int i;
    vector<int> array(26,0);
    for(i = 0;i < w.size();++i){
        ++array.at((int)w.at(i)-97);
    }
    for(i = 0;i < 26;++i){
        if(array.at(i)%2 == 0){
            continue;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
Module Program
    Sub Main(args As String())
        Dim DTS = Console.ReadLine().Split(" ").Select(Function(i)
                                                           Return Integer.Parse(i)
                                                       End Function).ToArray()
        Dim D = DTS(0), T = DTS(1), S = DTS(2)

        If T * S >= D Then
            Console.WriteLine("Yes")
        Else
            Console.WriteLine("No")
        End If
    End Sub
End Module


Measured memory_bytes: 28216
# Problem C - Multiplication 3

import math

# input
A, B = input().split()
A = int(A)

# initialization
b_1 = int(B[0])
b_2 = int(B[2])
b_3 = int(B[3])
tmp_1 = A * b_1 * 100
tmp_2 = A * b_2 * 10
tmp_3 = A * b_3
ans = math.floor((tmp_1 + tmp_2 + tmp_3) // 100)

# output
print(ans)


Measured memory_bytes: 9168
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<iostream>
#include<map>
#include<cstring>
#define INF 1e9+10
using namespace std;
vector <int>adj[55];
int n,m,a,b;
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=1;i<=n;i++){
        printf("%lu\n",adj[i].size());
    }
    
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1e8+7;
ll add(ll a,ll b){
  return (a+b)%mod;
}
ll mul(ll a,ll b){
  return (a*b)%mod;
}
ll mpow(ll a,ll b){
  if(b==0)return 1;
  ll res=mpow( mul(a,a) , b/2);
  if(b&1)res=mul(res,a);
  return res;
}
ll divi(ll a,ll b){
  return mul(a, mpow(b,mod-2) );
}

ll fact[10000];
ll nCr(ll n,ll r){
  return divi( fact[n] , mul(fact[r],fact[n-r]));
}


ll H,W,a,b,x,y;

int main(){
  fact[0]=1;
  for(int i=1;i<10000;i++)fact[i]=mul(fact[i-1],i);
  cin>>W>>H>>a>>b>>x>>y;
  ll dx=min( abs(a-x) , W - abs(a-x) );
  ll dy=min( abs(b-y) , H - abs(b-y) );
  ll ans=nCr(dx+dy,dx);
  if( abs(a-x)*2 == W ) ans=mul(ans,2);
  if( abs(b-y)*2 == H ) ans=mul(ans,2);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<pair<int, int>, int> p;

#define MOD 1000000007

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

    int L;
    cin >> L;

    int N = int(log2(L)) + 1;
    int M = int(log2(L)) * 2;

    vector<bool> b(log2(L));
    vector<int> c(log2(L));

    for(int i = 0; i < int(log2(L)); i++) {
        if(L & 1 << (int(log2(L)) - i - 1)) {
            b[i] = true;
        }    
        c[i] = 1 << (int(log2(L)) - i - 1);
    }

    vector<p> ans;

    for(int i = 0; i < int(log2(L)); i++) {
        ans.push_back(make_pair(make_pair(i + 1, i + 2), 0));
        ans.push_back(make_pair(make_pair(i + 1, i + 2), c[i]));
    }

    int count = 1 << int(log2(L));

    for(int i = 0; i < int(log2(L)); i++) {
        if(b[i]) {
            ans.push_back(make_pair(make_pair(1, i + 2), count));
            count += c[i];
            M++;
        }
    }

    cout << N << " " << M << endl;

    for(int i = 0; i < M; i++) {
        cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second << endl;
    }
}

Measured memory_bytes: 3796
#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); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans;
  int dx = tx - sx;
  int dy = ty - sy;
  string R(dx, 'R'), L(dx, 'L'), U(dy, 'U'), D(dy, 'D');
  
  if(sx != tx && sy != ty){
    
    ans += R + U + L + D;
    ans += "D"+ R + "R" +U+"ULU"+L+"LD"+D+"R";
  }
  else if(sx == tx){
    ans += R+ "U" + L + "DD" + R+"URDDLL" + L + "UUR";
  }
  else{
    ans += U + "L"+D+"RR"+U+"LURRDD"+D+"LLU";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };

int N;
int p[100005];

signed main(){
    cin>>N;
    for(int i=0;i<N;++i)cin>>p[i];
    sort(p,p+N,greater<int>());
    int a[200000]={0};
    int t=0;
    for(int i=0;i<N-1;++i){
        if(p[i]==p[i+1]){
            a[t] = p[i];
            i++;
            t++;
        }
    }
    cout<<a[0]*a[1]<<endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll INF = 1e10;

int main()
{
	int x;
	cin >> x;
	co(x*x*x);
	return 0;
}


Measured memory_bytes: 3040
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
  ll H,W;
  cin >> H >> W;
  if(H == 1 or W == 1){
    cout << 1 << endl;
    return 0;
  }
  ll ans = H*W;
  ans++;
  ans /= 2;
  cout << ans << endl;
  return 0;
}


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

int main(){
  int m,n_min,n_max,gap,temp=0;
  while(1){
    cin >> m >> n_min >> n_max;
    if(m==0 && n_min==0 && n_max==0){break;}
    int P[m+1];
    P[0]=-1;
    for(int i=1;i<=m;i++){
      cin >> P[i];
    }
    gap=0;
    for(int i=n_min;i<=n_max;i++){
      if(P[i]-P[i+1]>=gap){
        gap=P[i]-P[i+1];
        temp=i;
      }
    }
    cout << temp << endl;
  }
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;

li a[100100];
map<li, li>cnt;

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

	return 0;
}

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

typedef long long ll;

int main() {
    ll N, x;
    map<int, int>A;
    vector<ll>l;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        A[x]++;
        if (A[x] == 2 || A[x] == 4) {
            l.push_back(x);
        }
    }

    sort(l.begin(), l.end(), greater<ll>());

    if (l.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << l[0]*l[1] << endl;
    }
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#include<tuple>
using namespace std;
typedef vector<int> vi;
const int INF=1e9;
int w,h;
typedef tuple<int,int,pair<int,int> > tup;//コスト,どの向きから来た?,pair(Y座標,X座標)
int d[35][35][4];//[Y座標][X座標][どの向きから来た?]　0:右,1:下,2:左,3:上
int board[35][35];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int c[4];
int ans;
template<typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
  std::fill( (T*)array,(T*)(array+N),val );
}

const int MAX_V=1e5+5;
void dijkstra()
{
  for(int i=1;i<=h;i++)
    {
      for(int j=1;j<=w;j++)
	{
	  for(int k=0;k<4;k++)
	    {
	      d[i][j][k]=INF;
	    }
	}
    }
  priority_queue<tup,vector<tup>,greater<tup> > que;
  d[1][1][0]=0;
  que.push(make_tuple(0,0,make_pair(1,1)));
  while(!que.empty())
    {
      int cost,dir;
      pair<int,int> p;
      tie(cost,dir,p)=que.top();que.pop();
      int y=p.first;
      int x=p.second;
      if(d[y][x][dir]<cost) continue;
      for(int i=0;i<4;i++)
	{
	  int ndir=(dir+i)%4;
	  int ny=y+dy[ndir];
	  int nx=x+dx[ndir];
	  if(ny<=0 || ny>h || nx<=0 || nx>w) continue;
	  if(i==board[y][x])
	    {
	      if(cost<d[ny][nx][ndir])
		{
		  d[ny][nx][ndir]=cost;
		  que.push(make_tuple(d[ny][nx][ndir],ndir,make_pair(ny,nx)));
		}
	    }
	  else
	    {
	      if(cost+c[i]<d[ny][nx][ndir])
		{
		  d[ny][nx][ndir]=cost+c[i];
		  que.push(make_tuple(d[ny][nx][ndir],ndir,make_pair(ny,nx)));
		}
	    }
	}
    }
}

int main(void)
{
  while(cin >> w >> h && w)
    {
      for (int i = 1; i <= h; ++i)
	{
	  for (int j = 1; j<= w; ++j)
	    {
	      cin >> board[i][j];
	    }
	}
      for (int i = 0; i < 4; ++i)
	{
	  cin >> c[i];
	}
      ans=INF;
      dijkstra();
      for(int i=0;i<4;i++)
	{
	  ans=min(ans,d[h][w][i]);
	}
      cout << ans << endl;
    }
  return 0;
 
}



Measured memory_bytes: 3168
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    map<int,int> num={};
    int a;
    for(int i=0;i<N;i++){
        cin >> a;
        auto it=num.find(a);
        if(it!=num.end()){
            it->second++;
        }else{
            num[a]=1;
        }
    }
    auto itr=num.begin();
    int sum,ma=0;
    for(int i=0;i<num.size();i++){
        sum=0;
        int a=itr->first;
        sum+=itr->second;
        auto it1=num.find(a+1);
        auto it2=num.find(a+2);
        if(it1!=num.end()) sum+=it1->second;
        if(it2!=num.end()) sum+=it2->second;
        ma=max(sum,ma);
        itr=next(itr,1);
    }
    cout << ma << endl;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    ll d; cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) cin >> s[i][j];
    }
    vector<ll> t(d);
    for (ll i = 0; i < d; i++) {cin >> t[i]; t[i]--;}
    
    auto score = [&] () {
        ll ret = 0;
        vector<ll> v(26, -1);
        for (ll i = 0; i < d; i++) {
            v[t[i]] = i;
            ret += s[i][t[i]];
            for (ll j = 0; j < 26; j++) ret -= c[j] * (i - v[j]);
            cout << ret << endl;
        }
        return ret;
    };
    
    score();
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    //N+1!!!!!!!!!!!!!!!!!!!
    int n;
    cin >> n;
    VL v(n + 1);
    VL num(n + 1, 0);
    rep(i, n + 1)
    {
        cin >> v[i];
    }
    ll cur = 0;
    for (int i = n; i >= 0; i--)
    {
        cur += v[i];
        num[i] += cur;
    }
    cur = 1;
    ll ans = 0;

    rep(i, n)
    {
        ans += cur;
        cerr << cur << " " << num[i] << endl;
        cur -= v[i];
        if (cur <= 0)
        {
            cout << -1 << endl;
            return 0;
        }
        cur *= 2;
        chmin(cur, num[i + 1]);
    }
    if (cur < v[n])
    {
        cout << -1 << endl;
        return 0;
    }
    ans += cur;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4824
r, g, b, n = list(map(int, input().split()))

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        nb = (n - (i*r+j*g))

        if (nb >= 0):
            if (nb % b == 0):
                cnt += 1
        else:
            break

print(cnt)

Measured memory_bytes: 9064