akhauriyash/Code-Regression huggingface dataset:
/*
            _ _  ___            __ _ _  _       _     
 _   _  ___| | |/ _ \__      __/ _| | || |  ___| |__  
| | | |/ _ \ | | | | \ \ /\ / / |_| | || |_/ __| '_ \ 
| |_| |  __/ | | |_| |\ V  V /|  _| |__   _\__ \ | | |
 \__, |\___|_|_|\___/  \_/\_/ |_| |_|  |_| |___/_| |_|
 |___/                 

 */

#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005


signed main(){
	fast
	// For(i, 0, 10){
	int n, temp;
	vector<int> v;
	cin>>n;
	For(i, 0, n){
		cin>>temp;
		v.pb(temp);
	}

	int dp[n+1];
	dp[0]=0;
	
	For(i, 1, n){
		if(i==1){
			dp[1] = abs(v[i]-v[i-1]);
		}else{
			dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
		}
	}

	cout<<dp[n-1]<<endl;
	// }
    return 0;
}
    



Measured memory_bytes: 1908
function main()
  
  (N,K) = map(x -> parse(Int,x), split(readline()))
  
  H = map(x -> parse(Int,x), split(readline()))
  sort!(H,rev = true)
  
  ans = 0

  for i in K+1:N
    
    ans += H[i]
    
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 142436
def main():
    from builtins import int, map, list, print, len
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    D = input_number()
    c = input_number_list()
    last = defaultdict(lambda: 0)
    s = []
    for i in range(D):
        s.append(input_number_list())
    for i in range(D):
        t_idx = 0
        t_pt = 0
        for j in range(len(s[i])):
            pt = s[i][j] + (i - last[j]) * c[j]
            if t_pt < pt:
                t_idx = j
                t_pt = pt
            elif t_pt == pt:
                if c[t_idx] < c[j]:
                    t_idx = j
                    t_pt = pt
        print(t_idx + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9844
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	int n;
	cin >> n;
	int n3200 = 0;
	vector<int> v(8, 0);
	rep(i, 0, n)
	{
		int r;
		cin >> r;
		if (r >= 1 && r <= 399)
			v[0]++;
		else if (r >= 400 && r <= 799)
			v[1]++;
		else if (r >= 800 && r <= 1199)
			v[2]++;
		else if (r >= 1200 && r <= 1599)
			v[3]++;
		else if (r >= 1600 && r <= 1999)
			v[4]++;
		else if (r >= 2000 && r <= 2399)
			v[5]++;
		else if (r >= 2400 && r <= 2799)
			v[6]++;
		else if (r >= 2800 && r <= 3199)
			v[7]++;
		else
			n3200++;
	}
	int minc = 0;
	for (int i = 0; i < 8; i++)
		if (v[i])
			minc++;
	int maxc = minc + n3200;
	minc = minc == 0 ? 1 : minc;
	cout << minc << " " << maxc;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}

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

using namespace std;
ll sum;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    ll n;
    cin>>n;
    ll height[n];
    for(auto i=0;i<n;i++) cin>>height[i];
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(height[0]-height[1]);
    for(auto i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
ll dp[1005][10005];
ll getans(ll *a,ll *b,ll n,ll pos,ll h)
{
	if(h <= 0)
	return 0LL;
	if(pos == n)
	return 1000000000LL;
	
	if(dp[pos][h] != -1)
	return dp[pos][h];

	ll ans = INT_MAX,val;
	
	ans = getans(a,b,n,pos+1,h);
	
	val = getans(a,b,n,pos,h-a[pos])*1LL + b[pos];
	
	ans = min(ans,val);
	
	dp[pos][h] = ans;
		
	return dp[pos][h];
}
int main()
{
	ll h,n,i,j,ans;
	cin>>h>>n;
	memset(dp,-1,sizeof(dp));
	
	
	ll a[n],b[n];
	for(i = 0;i<n;i++)
	cin>>a[i]>>b[i];
	
	cout<<getans(a,b,n,0,h);
	
	
}

Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
long long a,b;
int main()
{
	cin>>a>>b;
	if(!(a%3)||!(b%3)||!((a+b)%3))
	{
		cout<<"Possible"<<endl;
	}
	else
	{
		cout<<"Impossible"<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,m,p,x,i,sum,s;
	int a[110];
	scanf("%d",&n);
	sum=0;
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	scanf("%d",&m);
	s=sum;
	while(m--)
	{
		scanf("%d%d",&p,&x);
		if(x>=a[p-1])
		  sum+=(x-a[p-1]);
		else
		  sum-=(a[p-1]-x);
		printf("%d\n",sum);
		sum=s;
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n, w;
  cin >> n >> w;
  P items[n+1];
  REP2(i,1,n+1){
    int v, w;
    cin >> v >> w;
    items[i] = make_pair(v,w);
  }

  int dp[n+1][w+1];
  REP(i,n+1)REP(j,w+1){
    dp[i][j] = 0;
  }
  REP2(i,1,n+1){
    REP2(j,1,w+1){

      if(j < items[i].second){
        dp[i][j] = dp[i-1][j];
      }
      else{
        dp[i][j] = max({dp[i-1][j],
                  dp[i-1][j-items[i].second] + items[i].first,
                  dp[i][j-items[i].second] + items[i].first});
      }

    }
  }

  cout << dp[n][w] << endl;

  return 0;
}



Measured memory_bytes: 7016
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
h = list(li())

dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(1,n-1):
    dp[i+1] = min(dp[i-1] + abs(h[i+1]-h[i-1]),
                  dp[i] + abs(h[i+1]-h[i]))
    
print(dp[-1])

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

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    cout << (int)(b * (floor(double(c + 0.5) / double(a)))) << endl;
    
	return 0;
}


Measured memory_bytes: 256
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/11.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,m;
    cin>>n>>m;
    vector<ll>c[100001];
    vector<ll>path1,path2;
    int visited[100001];
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        c[a].push_back(b);
        c[b].push_back(a);
    }
    memset(visited,0,sizeof(visited));
    ll x,y;
    x=0;
    y=c[0][0];
    visited[x]=1;
    visited[y]=1;
    
    path1.push_back(x);
    path2.push_back(y);
    
    ll perx=x,pery=y;
    while(1){
        bool update=0;
        for(int i=0;i<c[x].size();i++){
            if(c[x][i]==perx)continue;
            if(!visited[c[x][i]]){
                
                visited[c[x][i]]=1;
                path1.push_back(c[x][i]);
                perx=x;
                x=c[x][i];
                update=1;
                break;
            }
        }
        if(!update)
            break;
    }
    while(1){
        bool update=0;
        for(int i=0;i<c[y].size();i++){
            if(c[y][i]==pery)continue;
            if(!visited[c[y][i]]){
                
                visited[c[y][i]]=1;
                path2.push_back(c[y][i]);
                pery=y;
                y=c[y][i];
                update=1;
                break;
            }
        }
        if(!update)
            break;
    }
    cout<<path1.size()+path2.size()<<endl;
    for(int i=path1.size()-1;i>=0;i--){
        cout<<path1[i]+1<<" ";
    }
    for(int i=0;i<path2.size();i++){
        cout<<path2[i]+1<<" ";
    }
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



Measured memory_bytes: 7668
#include <iostream>

using namespace std;

int main(){
int n,a;
cin >> n; 
for(int i = n; i<1000; i++){
if(i==111){a=111; break;}
else if(i==222){a=222; break;}
else if(i==333){a=333; break;}
else if(i==444){a=444; break;}
else if(i==555){a=555; break;}
else if(i==666){a=666; break;}
else if(i==777){a=777; break;}
else if(i==888){a=888; break;}
else if(i==999){a=999; break;}
}
cout << a << endl;
return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = in.nextInt();
        long a = in.nextLong();
        int b = in.nextInt();
        long cur = in.nextLong();
        long c = 0;long dif;
        for(int i =1;i<n;i++){
            long next = in.nextLong();
            dif = next-cur;
            cur = next;
            c+= Math.min(b,dif*a);
        }
        System.out.println(c);

    }
}


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

int ans;
string s;

int main()
{
	cin >> s;
  	if(s[0]=='1') ans++;
  	if(s[1]=='1') ans++;
  	if(s[2]=='1') ans++;
  	cout << ans++ << endl;
  
}


Measured memory_bytes: 256
def main():
    n = int(input())
    if n%2==1:
        print(0)
        return 
    
    ans = 0
    bunbo = 10
    while bunbo <= n:
        ans += n // bunbo
        bunbo *= 5
    print(ans)
 
 
if __name__ == '__main__':
    main()

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

using namespace std;

int main(){
  int n;
  cin >> n;
  cin.ignore();

  n %= 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9){
    cout << "hon" << endl;
    return 0;
  } else if(n == 0 || n == 1 || n == 6 || n == 8){
    cout << "pon" << endl;
    return 0;
  } else {
    cout << "bon" << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    string S,T;
    cin>>S>>T;
    vector<int>a1;
    vector<int>b1;
    long long int f,g,i,j,t=0;
    map<char,int>a;
    for(i=0;S[i];i++)
        {f=a[S[i]];
        a[S[i]]++;
        a1.push_back(f+1);}
        sort(a1.begin(),a1.end());
             map<char,int>b;
     for(i=0;T[i];i++)
        {g=b[T[i]];
        b[T[i]]++;
        b1.push_back(g+1);}
        sort(b1.begin(),b1.end());
        for(j=0;j<i;j++)
        {
            if(a1[j]!=b1[j])
                {t=1;
            break;}
        }
       if(t==1)
            cout<<"No";
       else
        cout<<"Yes";

}




Measured memory_bytes: 6004
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

typedef struct Node * NodePointer;
NodePointer head;

NodePointer listSearch(int);
void init();
void printList();
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
void deleteKey(int);
void insert(int);

int main(){
    int temp, size;
    char tempS[12];
    int np = 0, nd = 0;
    scanf("%d", &size);
    init();
    for(int i = 0; i < size; i++){
        scanf("%s",tempS);
        if(!strcmp(tempS,"deleteLast"))
            deleteLast();
        else if(!strcmp(tempS,"deleteFirst"))
            deleteFirst();
        else{
            scanf("%d", &temp);
            if(!strcmp(tempS,"delete"))
                deleteKey(temp);
            else if(!strcmp(tempS,"insert")) 
                insert(temp);
        }
    }
    
    printList();
    
    return (EXIT_SUCCESS);
}


NodePointer listSearch(int key){
    NodePointer loc = head->next;
    while( loc != head && loc->key != key ){
        loc = loc->next;
    }
    return loc;
}

void init(){
    head = malloc(sizeof(struct Node));
    head->next = head;
    head->prev = head;
}

void printList(){
    struct Node *cur;
    cur = head->next;
    int isf = 0;

    while(1) {
        if (cur == head) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
    
void deleteNode(struct Node *temp) {
    if (temp == head) return;
    temp->prev->next = temp->next;
    temp->next->prev = temp->prev;
    free(temp);
}

void deleteFirst() {
    deleteNode(head->next);
}

void deleteLast() {
    deleteNode(head->prev);
}
void deleteKey(int val) {
    deleteNode(listSearch(val));
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct Node));
  x->key = key;
  x->next = head->next;
  head->next->prev = x;
  head->next = x;
  x->prev = head;
}



Measured memory_bytes: 32936
using System;
using System.Linq;

namespace AOJ.Volume0
{
    public class Palindrome
    {
        public static void Main()
        {
            int answer = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }
                int loop_end;
                if (input.Length % 2 == 0) { loop_end = input.Length / 2; }
                else { loop_end = (int)(input.Length / 2) + 1; }

                bool pal = true;
                var input_array = input.ToArray();
                for (int i = 0; i < loop_end; i++)
                {
                    if (input_array[i] != input_array[input.Length - i - 1]) { pal = false; }
                }
                if (pal) { answer++; }
            }
            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 9412
N = int(input())
a = list(map(int,input().split()))
now = 0
for i in range(N):
    if a[i] % 4 == 0:
        now += 2
        continue
    if a[i] % 2 == 0:
        now += 1
if N%2 == 1:
    if now >= N-1:
        print("Yes")
    else:
        print("No")
else:
    if now >= N:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 19960
#include <stdio.h>
int main(void)
{
 char S[101];
 int A;
 int i;
 scanf("%s",S);
 A = strlen(S);
 for(i=0;i<A;i++)
 {
  printf("x");
 }
 printf("\n");
// printf("%d\n",A);
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--) 
#define Rep(i,a) for(int i = 0; i < a; i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ab(x) ((x) < 0 ? -(x) : (x))
using namespace std;
typedef long long LL;
typedef map<int, int>::iterator mit;
typedef set<int ,int>::iterator sit;
const int N = 300010;

int n, a[N]; 

LL wi[N], wo[N], f[N], g[N], s[N];

typedef pair<LL, LL> point;
#define x first
#define y second
point operator - (const point &a, const point &b) { return mp(a.x - b.x, a.y - b.y); }
LL operator * (const point a, const point b) { return a.x * b.y - a.y * b.x; }

point st[N]; int top;

void qry(int k) { while (top >= 2 && st[top].y - k * st[top].x < st[top - 1].y - k * st[top - 1].x) top--; }

void dp() {
	st[ top = 1 ] = mp(0LL, 0LL);
	rep(i,1,n) {
		//calc
		int k = 2 * i; qry(k);
		f[i] = max(f[i - 1], st[top].y - k * st[top].x - s[i] + 1LL * i * i + i);
		//add
		point x = mp((LL)i, f[i] + 1LL * i * i + s[i] - i);
		while (top >= 2 && (x - st[top]) * (st[top] - st[top - 1]) <= 0) top--;
		st[++top] = x;	
	}
}

void init() {
	rep(i,1,n / 2) swap(a[i], a[n - i + 1]);
	rep(i,1,n) s[i] = s[i - 1] + a[i];
	dp(); rep(i,1,n) g[i] = f[i];
	rep(i,1,n / 2) swap(a[i], a[n - i + 1]), swap(g[i], g[n - i + 1]);
	rep(i,1,n) s[i] = s[i - 1] + a[i];
	dp(); rep(i,1,n) wo[i] = f[i - 1] + g[i + 1];
}

LL t[N];
void build(int l, int r) {
	top = 0;
	rep(i,l,r) {
		point x = mp((LL)i, t[i]);
		while (top >= 2 && (x - st[top]) * (st[top] - st[top - 1]) <= 0) top--;
		st[++top] = x;
	}
}

LL tmp[N];
void work(int l, int r) {
	if (l == r) return;
	int mid = (l + r) >> 1;
	//left part
	rep(i,l,mid) t[i] = f[i] + 1LL * i * i + s[i] + 2 * i - i;
	build(l, mid);
	rep(i,mid + 1,r) {
		int k = 2 * i; qry(k);
		tmp[i] = st[top].y - k * st[top].x - s[i - 1] + 1LL * (i - 1) * (i - 1) + g[i] + (i - 1);
	}
	dep(i,r - 1,mid + 1) tmp[i] = max(tmp[i], tmp[i + 1]);
	rep(i,mid + 1,r - 1) wi[i] = max(wi[i], tmp[i + 1]);
	//right part
	rep(i,mid + 1,r) t[i] = g[i] + 1LL * (i - 1) * (i - 1) - s[i - 1] + (i - 1);
	build(mid + 1, r);
	rep(i,l,mid) {
		int k = 2 * i; qry(k);
		tmp[i] = st[top].y - k * st[top].x + s[i] + 1LL * i * i + f[i] + 2 * i - i;
	}
	rep(i,l + 1,mid) tmp[i] = max(tmp[i], tmp[i - 1]);
	rep(i,l + 1,mid) wi[i] = max(wi[i], tmp[i - 1]);
	work(l,mid), work(mid + 1, r);
}

const LL inf = 1LL << 60;

int main() {
	scanf("%d",&n);	rep(i,1,n) wi[i] = -inf;
	rep(i,1,n) scanf("%d",&a[i]), a[i] = a[i] * 2, s[i] = s[i - 1] + a[i];
	init(); work(0, n + 1);
	int m; scanf("%d",&m);
	rep(i,1,m) {
		int p, x; scanf("%d%d",&p,&x);
		printf("%lld\n",max(wo[p], wi[p] + a[p] - x * 2) / 2);
	}
	return 0;
}

Measured memory_bytes: 20224
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int w=sc.nextInt();
		int h=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		int r=sc.nextInt();

		if (0<=x-r&&x+r<=w&&0<=y-r&&y+r<=h) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

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

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s = 0;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n - 1);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < n - 1; i++)
    {
        cin >> c[i];
    }
    for(int i = 0; i < n; i++)
    {
        s += b[a[i] - 1];
        if(i > 0 && a[i] == a[i - 1] + 1)
        {
            s += c[a[i - 1] - 1];
        }
    }
    cout << s;

    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())

a = []
for i in range(n):
	a.append(int(input()))

b=sorted(a,reverse=True)
c=collections.Counter(a)
if c[b[0]] > 1:
	for i in range(n):
		print(b[0])
else:
	for i in range(n):
		if a[i] == b[0]:
			print(b[1])
		else:
			print(b[0])

Measured memory_bytes: 22120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n, m := intScanner(), intScanner()
	if n == m {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){

int A,B,C,day,sum=0;

cin>>A>>B>>C;

for(int i=1;i<=1000000;i++){
sum=sum+A;
if(i%7==0){
sum=sum+B;
}

if(sum >= C){
day=i;
break;
}
}

cout<<day<<endl;

return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
#define MAX 10000
int isPrime(int);
int main(){
  int i,N,A[MAX],count=0,total=0;
  scanf("%d",&N);
  
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    count=isPrime(A[i]);
    if(count!=0)total++;
  }
  
  printf("%d\n",total);
  
  return 0;
}
int isPrime(int x){
  int i;
  if(x==2)return 1;
  if(x<2||x%2==0)return 0;
  i=3;
  while(i*i<=x){
    if(x%i==0)return 0;
    i=i+2;
}
  return 1;
}



Measured memory_bytes: 2040
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define vel vector<int>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
signed main(){
	int n;double t; cin >> n >> t;
	double ans = 0;
	rep(i, n) {
		double x, h; cin >> x >> h;
		mmax(ans, h*t / x);
	}
	printf("%11.9lf\n", ans);
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int sum = 0;
  for(int i=0; S[i]!='\0'; i++){
    if(S[i] == 'o'){
      sum += 100;
    }
  }
  cout << 700 + sum << endl;
  return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, i;

    for(;sc.hasNext();){
      n = sc.nextInt();
      for(i = n - 1;;i--)if(isprime(i)){
        out.print(i + " "); break;
      }
      for(i = n + 1;;i++)if(isprime(i)){
        out.println(i); break;
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static boolean isprime(int p){
    int i;
    if(p == 1)return false;
    else for(i = 2;i * i <= p;i++)if(p % i == 0)return false;
    return true;
  }
}

Measured memory_bytes: 17172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var hn = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        Console.WriteLine(a.Sum() >= hn[0] ? "Yes" : "No");
    }
}

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

using namespace std;

int main(){
	int n, y;
	cin >> n >> y;
	y /= 1000;
	for(int i = 0; i <= 4000; ++i){
		for(int j = 0; j <= 2000; ++j){
			int x = i * 5 + j * 10;
			int t = y - x;
			if(t >= 0 && i + j + t == n){
				cout << j << " " << i << " "  << t << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	long long N;
	cin >> N;
	long long x, y=0,t=0;
	for (long long i = 0; i < N; i++) {
		cin >> x;
		if (x > y) {
			y = x;
		}
		else if (x < y) {
			t += y - x;
		}
	}
	cout << t<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
signed main(void)
{
    int k;
    scanf("%d", &k);
    if (k % 2 == 0)
    {
        cout << "-1";
        return 0;
    }
    int x = 7 % k;
    for (int i = 1; i <= k; i++)
    {
        if (x == 0)
        {
            cout << i << endl;
            return 0;
        }
        x = (x * 10 + 7) % k;
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
double ab(int a, double b) {
	return a - b > 0 ? a - b : b - a;
}
int main() {
	int n;
	cin >> n;
	int a[n];
	for (int i = 0;i < n;i++) cin >> a[i];
	sort(a, a + n);
	double best = double(a[n - 1]) / 2;
	int ansnum = (1<<30) + (1<<29);
	for (int i = 0;i < n - 1;i++) {
		if (ab(a[i], best) < ab(ansnum, best)) {
			ansnum = a[i];
		}
	}
	cout << a[n - 1] << " " << ansnum << endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int h, w; cin >> h >> w;
    map<char, int> mp;
    rep(i, h){
        string s; cin >> s;
        for(char c: s) mp[c]++;
    }
    vector<int> count;
    for(auto m: mp) count.push_back(m.second);

    vector<int> query;
    rep(i, (h/2)*(w/2)) query.push_back(4);
    if(h%2==1 && w%2==1){
        rep(i, (h/2)+(w/2)) query.push_back(2);
        query.push_back(1);
    }else if(h%2==1 || w%2==1){
        int num = h%2==1 ? w : h;
        rep(i, num/2) query.push_back(2);
    }

    bool fg = true;
    for(int q: query){
        sort(all(count));
        auto iter = lower_bound(all(count), q);
        if(iter == count.end()){
            fg = false; break;
        }
        count[count.size()-1] -= q;
    }

    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    REV(s);

    int ans = 0;
    int u = 0;
    bool ok = false;
    REP(i, n) {
        int t = (int)(s[i] - '0');
        if (i == n - 1) {
            if (t + u >= 6) {
                ans += 10 - (t + u);
                u = 1;
            } else {
                ans += t + u;
                u = 0;
            }
            break;
        }
        if (t + u >= 6 || (t + u == 5 && (int)(s[i + 1] - '0') >= 5)) {
            ans += 10 - (t + u);
            u = 1;
        } else if (t + u < 10) {
            ans += t + u;
            u = 0;
        } else {
            u = 1;
        }
    }
    cout << ans + u << endl;
}


Measured memory_bytes: 1948
import java.io.*;
import java.math.*;
import java.util.*;


public class Main	 {
    public static void main(String[] args) throws IOException {
        	Scanner sc = new Scanner(System.in);
        	int h1 = sc.nextInt();        	
        	int m1 = sc.nextInt();
        	int h2 = sc.nextInt();
        	int m2 = sc.nextInt();
        	int k = sc.nextInt();
        	int a = h2-h1;
        	int b =0;
        	if(m2-m1<0) {
        		b = 60+(m2-m1);
        		a--;
        	}
        	else
        		b = m2-m1;
        	int minutes = a*60+b;
        	System.out.println(minutes-k);
    }
}


Measured memory_bytes: 35752
import bisect
pr=[]
for i in range(2,110000):
    for j in range(2,int(i**0.5)+1):
        if not i%j:break
    else:pr+=[i]
while 1:
    n,p=map(int,input().split())
    if n<0:break
    a=bisect.bisect_right(pr,n)
    print(sorted([pr[i]+pr[j] for i in range(a,a+p) for j in range(i,a+p)])[p-1])

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

namespace Algorithm
{
    class Program
    {
        const int Size = 2;
        private int[,] comb;
        
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            int n = line[0], m = line[1];
            var array = new int[(int) Math.Pow(2, n)][];

            var dfs = new DfsMaster(n, array);
            dfs.Execute(0);

            var list = new int[m][];
            for (var i = 0; i < m; i++)
            {
                list[i] = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();
            }

            var last = Console.ReadLine().Split().Select(z => int.Parse(z)).ToArray();

            var count = 0;

            foreach (var p in dfs.map)
            {
                var isTrue = true;

                for (var i = 0; i < m; i++)
                {
                    var total = 0;
                    for (var j = 1; j < list[i].Length; j++)
                    {
                        total += p[list[i][j]-1];
                    }
                    if (total % 2 != last[i])
                    {
                        isTrue = false;
                        break;
                    }
                }
                if (isTrue) count++;
            }

            Console.WriteLine(count);
        }
    }

    class DfsMaster
    {
        public int n { get; set; }
        public int y { get; set; }
        public int[] xmap { get; set; }
        public int[][] map { get; set; }

        public DfsMaster(int n, int[][] map)
        {
            this.n = n;
            this.map = map;
            xmap = new int[n];
        }

        public void Execute(int x)
        {
            if (x == n)
            {
                map[y] = xmap.Clone() as int[];
                y++;
                return;
            }

            xmap[x] = 1;
            Execute(x + 1);

            xmap[x] = 0;
            Execute(x + 1);
        }
    }
}

Measured memory_bytes: 13376
/* ex 9_2
   riverstone */

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem){
    //追加する分の領域を確保
    node *new = calloc(1, sizeof(node));
    if(new == NULL) exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first){
    char elem;
    node *tmp = *first;
    if(tmp == NULL) exit(1);
    elem = tmp->elem;
    *first = tmp->next;
    //取り出したノードのメモリを解放
    free(tmp);
    return elem;
}


int main(void){
    char tmp;
    //最初のノードの指す先
    node *first = NULL;
    int ret = 0;

    //1文字ずつ標準入力から受け取り以下を実行
    while(scanf("%c", &tmp) != EOF && tmp != '\n'){
        //まずスタックにノードを追加
        push(&first, tmp);
        
        //2個以上のキューブが積まれており、かつ、上から2個のキューブの色が異なるとき
        if((first->next != NULL) && (first->elem != first->next->elem)){
            //スタックから2つのデータを取り出し、取り除いたキューブの個数をカウントする
            pop(&first);
            pop(&first);
            ret += 2;
        }
    }
    printf("%d\n", ret);
    return 0;
}

Measured memory_bytes: 4780
def main():
    N = int(input())
    p = []
    for i in range(N):
        x,y,h = map(int,input().split())
        p.append([x,y,h])
 
    p.sort(key=lambda x: x[2])
    a,b,c = p[-1]
    for i in range(101):
        for j in range(101):
            H = c + abs(a - i) + abs(b - j)
            for x,y,h in p:
                if h != max(H - abs(x - i) - abs(y - j), 0):
                    break
            else:
                print(i,j,H)
                exit()


main()

Measured memory_bytes: 42224
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n==0) break;
            int[]s = new int[n];
            int sum=0;
            for(int i=0;i<n;i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            double x=0;
            for(int i=0;i<n;i++){
                x += (s[i]-((double)sum/n))*(s[i]-((double)sum/n));
            }
            double a=Math.sqrt(x/n);
            System.out.printf("%.8f\n",a);
        }
    }

}


Measured memory_bytes: 31780
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
   ll A[3][3];
   REP(i,3){
       REP(j,3){
           cin >> A[i][j];
       }
   } 

   ll N = 0;
   cin >> N;

   ll B[3][3];
   REP(i,3){
       REP(j,3){
           B[i][j]=0;
       }
   }
   REP(k,N){
       ll num = 0;
       cin >> num;
       REP(i,3){
           REP(j,3){
               if(A[i][j]==num) B[i][j]=1;
           }
       }
   }
   bool check = false;
   REP(i,3){
       ll cnt = 0;
       REP(j,3){
           cnt +=B[i][j];
       }
       if(cnt==3) check = true;
   }
   REP(i,3){
       ll cnt = 0;
       REP(j,3){
           cnt +=B[j][i];
       }
       if(cnt==3) check = true;
   }
   ll cnt2 = 0;
   REP(i,3){
       cnt2 +=B[i][i];
   }
   if(cnt2==3) check = true;
   ll cnt3 = 0;
   REP(i,3){
     cnt3 +=B[2-i][i];
   }
   if(cnt3==3) check = true;
   if(check) cout << "Yes";
   else cout << "No";
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

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

typedef long long ll;
#define vv(t) vector<t>

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}


int main(){
    int N,M;
    cin >> N >> M;
    vv(ll) A(N);
    double sum = 0;
    REP(i, N){
        cin >> A[i];
        sum += A[i];
    }
    ll m=0;
    eprintf("%d\n", (int)sum);
    REP(i, N){
        eprintf("%d\n", (int)A[i] * 4 * M);
        if(sum <= A[i] * 4 * M)
            m++;
    }
    eprintf("%d", (int)m);
    if(M > m){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}


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

int N, W, w[100];
long long v[100], dp[100][100001];
int main(){
    scanf("%d%d", &N, &W);
    for(int i=0; i<N; i++) scanf("%d%d", w+i, v+i);
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            dp[i][j] = max(i!=0 ? dp[i-1][j] : 0LL, j>=w[i] ? (i!=0 ? dp[i-1][j-w[i]] : 0LL)+v[i] : 0LL);
        }
    }
    long long ans = 0;
    for(int i=0; i<=W; i++) ans = max(ans, dp[N-1][i]);
    printf("%lld\n", ans);
}

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

int main(){
	int i;
	int count;
	int a[200],b[200],sum[200];
	int temp = 0;

	while(cin >> a[temp] >> b[temp])
	{
		sum[temp] = a[temp] + b[temp];
		temp++;	
	}

	for (i = 0; i < temp; i++)
	{
		count = 0;

		while(sum[i] > 0){
			sum[i] = sum[i] / 10;
			count++;
		}

		cout << count << endl;

	}

	return 0;

}


Measured memory_bytes: 3080
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <stack>
#include <deque>
#include <list>
#include <cassert>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define pb push_back
#define mp make_pair
#ifdef GRAPH
typedef pair <int, int> Edge;
#define v first
#define w second
#endif
#if __cplusplus >= 201103L
using LL = long long;
using ULL = unsigned long long;
#else
#define LL long long
#define ULL unsigned long long
#endif
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define rep(i, n) for (int (i) = 0; (i) < n; (i)++)
#define until(x) while (!x)
#define fail(s) assert(!s)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;

int main() {
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	if (n >= 3200 )cout << s << endl;
	else cout << "red" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int a,b;
 int plus, minus, multi;
 int max;
 cin >> a >> b;
  
 plus = a + b;
 minus = a - b;
 multi = a * b;
 
 max = plus;
 
 if (minus > max){
   max = minus;
 }
 if (multi > max){
   max = multi;
 }
  
  cout << max << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(n) for(int i=0;i<(n);i++)
#define rep1(n) for(int i=1;i<=(n);i++)
#define all(n) n.begin(),n.end()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define pb push_back
const ll mod = 1000000007;
vector<int> E[100005];
ll dp[100005][2];
void dfs(int x,int p=-1){
   dp[x][0] = dp[x][1] = 1;
   for(auto i:E[x]){
      if(i==p)continue;
      dfs(i,x);
      dp[x][0] *= dp[i][1];
      dp[x][1] *= (dp[i][0] + dp[i][1]);

      dp[x][0] %= mod;
      dp[x][1] %= mod;
   }
}

int main(){
    	int n;
    	cin>>n;
    	for(int i=1,a,b;i<n;i++){
          cin>>a>>b;
          E[b].pb(a);
          E[a].pb(b);
    	}
      dfs(1);

      cout<< (dp[1][0] + dp[1][1])%mod <<'\n';
}


Measured memory_bytes: 14208
/*                   
                                             ::                     ::       
                                             ':                     :        
                                              :.                    :        
                                           ;' ::                   ::  '     
                                          .'  ';                   ;'  '.    
                                         ::    :;                 ;:    ::   
                                         ;      :;.             ,;:     ::   
                                         :;      :;:           ,;"      ::   
                                         ::.      ':;  ..,.;  ;:'     ,.;:   
                                          "'"...   '::,::::: ;:   .;.;""'    
                                              '"""....;:::::;,;.;"""         
                                          .:::.....'"':::::::'",...;::::;.   
                                         ;:' '""'"";.,;:::::;.'""""""  ':;   
                                        ::'         ;::;:::;::..         :;  
                                       ::         ,;:::::::::::;:..       :: 
                                       ;'     ,;;:;::::::::::::::;";..    ':.
                                      ::     ;:"  ::::::"""'::::::  ":     ::
                                       :.    ::   ::::::;  :::::::   :     ; 
                                        ;    ::   :::::::  :::::::   :    ;  
                                         '   ::   ::::::....:::::'  ,:   '   
                                          '  ::    :::::::::::::"   ::       
                                             ::     ':::::::::"'    ::       
                                             ':       """""""'      ::       
                                              ::                   ;:        
                                              ':;                 ;:"        


                                                     P_r_A_d_Y
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18
const int N = 300005;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void cs(int &x)
{
  cout<<"Case #"<<x<<": ";
}
bool cmp(int a,int b)
{
  return a>b;
}
int32_t main()
{
  fastIO;
  // int t;cin>>t;
  // int x=1;
  // while(t--)
  // {
     int n;cin >> n;
     int c=0;

     if(n%2==0)
      {cout<<-1<<endl;return 0;}

     int num=0;
     while(num<n)
     {
      num*=10;
      num+=7;
      c++;
     }
     //cout<<c<<endl;
     while(1)
     {
        int d=num%n;
        if(d==0) break;
         while(d<n)
         {
          d*=10;
          d+=7;
          c++;
         }
         num=d;
         if(c>1000000)
          break;
     }
     if(c>1000000)
      cout<<-1<<endl;
    else
     cout<<c<<endl;



     

  //}
  return 0;
}

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

int main() {
 int n;
  cin >>n;
  if(n==22)
    cout <<"Christmas Eve Eve Eve";
  if(n==23)
    cout <<"Christmas Eve Eve";
  if(n==24)
    cout <<"Christmas Eve";
  if(n==25)
    cout <<"Christmas";
}


Measured memory_bytes: 256