akhauriyash/Code-Regression huggingface dataset:
a, b = map(int, input().split())
s = input()
ok = True
for i in range(a):
    if s[i] == '-':
        ok = False
ok = ok and s[a] == '-'
for i in range(b):
    if s[a + 1 + i] == '-':
        ok = False
if ok:
    print('Yes')
else:
    print('No')

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

string diff(string now,string bit)
{
  string ans="0000000";
  for(int i=0;i<7;i++){
    //  cout<<(now[i]-'0')<<endl;
   // cout<<(bit[i]-'0')<<endl; 
   // cout<<((now[i]-'0') ^ (bit[i]-'0'))<<endl; 
    ans[i]=((now[i]-'0') ^ (bit[i]-'0'))+'0'; 
  }  
  return ans;
}

int main()
{
  string bit[10]={
    "1111110",
    "0110000",
    "1101101",
    "1111001",
    "0110011",
    "1011011",
    "1011111",
    "1110010",
    "1111111",
    "1111011"
  };
  
  int n;
  for(;cin>>n,n!=-1;)
    {
      string now="00000000";
      for(int i=0;i<n;i++)
	{
	  int tar;
	  cin>>tar;
	  string s=diff(now,bit[tar]);
	  reverse(s.begin(), s.end());
	  cout<<s<<endl;
	  now=bit[tar];
	}
    }

}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
LL a,b;
int32_t main(void) {
    boost;
    cin>>a>>b;
    if(a%b==0) cout<<"-1\n";
    else cout<<a<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define plll pair<ll, pll>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
const ll MOD = (ll)1e9+7;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t x){
	if(was_output)cout << " ";
	was_output = true;
	cout << x;
}

void outendl(){
	was_output = false;
	cout << endl;
}

ll n, k;
vector<ll> cost;
vector<ll> food;

bool func(ll max_time){
	ll usek = 0;
	rep(i, n){
		ll need = max_time / food[i];
		usek += max(0ll, cost[i]-need);
	}
	return usek <= k;
}

int main(){
	cin >> n >> k;
	
	cost.resize(n);
	food.resize(n);
	foreach(i, cost)cin>>i;
	foreach(i, food)cin>>i;
	sort(all(cost));
	sort(all(food), greater<ll>());

	ll lp = 0;
	ll rp = 1e13;
	while(lp<rp){
		ll mid = (lp + rp) / 2;
		if(func(mid)){
			rp = mid;
		}else{
			lp = mid + 1;
		}
	}

	cout << lp << endl;

	return 0;
}



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

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

signed main(){
    int N;
    string S,T;
    cin>>N>>S>>T;
    for(int i=S.size();i>=0;i--){
        if(S.substr(S.size()-i,i)==T.substr(0,i)){
            cout<<S.size()*2-i<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#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, a, b;
  cin >> n >> a >> b;
  cout << min(n*a, b) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
int a[100000];
int main() {
    int n = 0;
    s(n);
    int maxi = 0;
    int sum = 0;
    for(int i = 0; i < n; i ++){
        s(a[i]);
        if(maxi < a[i]){
            maxi = a[i];
        }
        sum += a[i];
    }
    sum -= maxi/2;
    p(sum) pn
    return 0;
}



Measured memory_bytes: 256
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.List             (unfoldr)
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  as <- readInts
  print $ solve n as

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> [Int] -> Int
solve n as = length $ unfoldr unfolder as

unfolder :: [Int] -> Maybe ((), [Int])
unfolder as
  | all even as = Just ((), map (`div` 2) as)
  | otherwise = Nothing


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <math.h>

typedef long long ll;
using namespace std;
typedef vector<vector<int>> Grid;

int main() {
    int h, w;
    cin >> h >> w;
    Grid a(h, vector<int>(w));
    Grid b(h, vector<int>(w));

    for (auto &y: a) {
        for (auto &x: y) {
            cin >> x;
        }
    }
    for (auto &y: b) {
        for (auto &x: y) {
            cin >> x;
        }
    }

    int maxD = 0;

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            maxD = max(maxD, abs(a[y][x] - b[y][x]));
        }
    }

    maxD = maxD * (w + h - 1) + 1;
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(maxD, false)));

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int dif = abs(a[y][x] - b[y][x]);
            for (int k = 0; k < maxD; k++) {
                if (y == 0 && x == 0) {
                    dp[y][x][dif] = true;
                    break;
                }
                if (y == 0) {
                    dp[0][x][k] = dp[0][x - 1][abs(k - dif)] || (k + dif < maxD) && dp[0][x - 1][k + dif];
                } else if (x == 0) {
                    dp[y][0][k] = dp[y-1][0][abs(k - dif)] || (k + dif < maxD) && dp[y - 1][0][k + dif];
                } else {
                    bool ans1;
                    bool ans2;
                    ans1 = dp[y][x - 1][abs(k - dif)] || (k + dif < maxD) && dp[y][x - 1][k + dif];
                    ans2 = dp[y-1][x][abs(k - dif)] || (k + dif < maxD) && dp[y - 1][x][k + dif];
                    dp[y][x][k] = ans1 || ans2;
                }
            }

        }
    }
    int ans = 0;
    for(int i = 0 ; i <= maxD;i++){
        if(dp[h-1][w-1][i]){
            ans = i;
            break;
        }

    }
    cout << ans;

    return 0;
}



Measured memory_bytes: 13300
def cal_digit(n):

    digit = 0

    while(n > 0):
        n //= 10
        digit += 1

    return digit

def solve(N):

    ans = 0

    for i in range(1, N+1):

        if(cal_digit(i)%2 == 1):
            ans += 1
        
        #print(cal_digit(i))
    
    return ans

N = int(input())
print(solve(N))







Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,x;
	cin>>n>>x;
	
	vi a(n);
	REP(i,n) cin>>a[i];
	
	llong cnt=0;
	for(int i=1;i<n;++i){
		if(a[i-1]+a[i]>x){
			cnt+=a[i-1]+a[i]-x;
			if(a[i-1]>x) a[i]=0;
			else a[i]=x-a[i-1];
		}
	}
	
	cout<<cnt<<endl;
}

Measured memory_bytes: 640
#include <iostream>
 
using namespace std;
 
int main()
{
   int N,L;
   cin >> N >> L;
 
   int minus = L;
 
   int sum = 0;
   int taste[N];
   for (int i = 0; i < N; i++)
   {
       taste[i] = L;
       if (L == 0)
       {
           minus = 0;
       }
       else if (i == (N-1) && L < 0)
       {
           minus = L;
       }
       
       sum += L;
       L++;
   }
 
   cout << sum-minus << endl;
   return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int f(int n)
{
    return ((n & 1) ? 3 * n + 1 : n / 2);
}

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

    set<int> se;
    se.insert(s);

    int cnt = 1;
    int res = 1;

    while (1)
    {
        res++;
        se.insert(f(s));
        if (cnt == se.size())
        {
            cout << res << '\n';
            break;
        }
        cnt = se.size();
        s = f(s);
    }

    return 0;
}


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

int main(){
    int a,b,c,k,temp;
    std::cin >> a >> b >> c >> k;
    for(int i=0;i<k;i++){
        temp = std::max({a,b,c});
        if(temp == a) a *= 2;
        else if(temp == b) b *= 2;
        else c *= 2;
    }
    std::cout << a + b + c << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  
  int e=c-(d-b);
  int f=d+(c-a);
  
  int g=e-(c-a);
  int h=f-(d-b);
  
  
  
  
  
  
  cout<<e<<" "<<f<<" "<<g<<" "<<h<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int count;

		while ((count = scan.nextInt()) != 0) {

			int[] seiseki = new int[count];
			for (int i = 0; i < seiseki.length; i++) {
				for (int j = 0; j < 5; j++) {
					seiseki[i] += scan.nextInt();
				}
			}

			java.util.Arrays.sort(seiseki);
			if(seiseki.length == 1){
				System.out.println(seiseki[0] + " " + seiseki[0]);
			}else{
				System.out.println(seiseki[seiseki.length - 1] + " " + seiseki[0]);
			}

		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<bitset>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;
typedef pair<int,int> P;
int n;
int memo[(1<<25)][10];

bool rec(P *G,int used,int prev)
{
  if(__builtin_popcount(used) == n)return true;
  if(__builtin_popcount(used) >= n)return false;
  if(memo[used][prev] != -1)return memo[used][prev];

  rep(i,n)
    {
      if((used>>i)&1)continue;
      if(prev == G[i].first)if(rec(G,used|(1<<i),G[i].second))
			      {
				memo[used|(1<<i)][G[i].second] = true;
				return true;
			      }
      if(prev == G[i].second)if(rec(G,used|(1<<i),G[i].first))
			       {
				 memo[used|(1<<i)][G[i].first] = true;
				 return true;
			       }
    }
  memo[used][prev] = false;
  return false;
}

int main()
{
  while(cin >> n)
    {
      cin.ignore();
      rep(i,(1<<n))rep(j,10)memo[i][j] = -1;
      P G[n];
      rep(i,n)
	{
	  char a,b,c;
	  scanf("%c%c%c",&a,&b,&c);
	  G[i].first = a-'0';
	  G[i].second = b-'0';
	}

      rep(i,n)
	{
	  if(rec(G,(1<<i),G[i].second) || rec(G,(1<<i),G[i].first))
	    {
	      cout << "Yes" << endl;
	      goto F;
	    }
	}
      cout << "No" << endl;
    F:;
    }
  return 0;
}

Measured memory_bytes: 13468
def main():
    C1 = input()
    C2 = input()

    if(C1[0] == C2[2] and C1[1] == C2[1] and C2[0] == C1[2]):
        print("YES")
    else:
        print("NO")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[101][101],f,g,h,j,i,k;
	char z[101][101];
	scanf("%d %d",&a,&s);
	for(i=0;i<a;i++){
		scanf("%s",z[i]);
	}
	for(i=0;i<a;i++){
		for(j=0;j<s;j++){
		d[i][j]=-1;
		}
	}
	for(i=0;i<a;i++){
		for(j=0;j<s;j++){
			if(z[i][j]=='c'){
				d[i][j]=0;
				for(k=j+1;k<s;k++){
					if(z[i][k]=='.')
						d[i][k]=d[i][k-1]+1;
					else if(z[i][k]=='c') break;
				}
			}
		}
	}
	for(i=0;i<a;i++){
		for(j=0;j<s;j++){
			printf("%d",d[i][j]);
			if(j!=s-1)	printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2712
n, m = map(int, input().split())
x = list(map(int, input().split()))

if m == 1:
    print(n//2)
    exit()

lst = [{} for i in range(m)]
lst_num = [0 for i in range(m)]
for i in range(n):
    xi = x[i]
    amari = xi % m
    if xi in lst[amari]:
        lst[amari][xi] += 1
    else:
        lst[amari][xi] = 1
    lst_num[amari] += 1

lst_kisu = [0 for i in range(m)]
lst_gusu = [0 for i in range(m)]
for i in range(m):
    num = 0
    for value in lst[i].values():
        if value % 2 == 1:
            num += 1
    lst_kisu[i] = num
    lst_gusu[i] = lst_num[i] - num

ans = 0
ans += lst_num[0] // 2
for i in range(1, (m-1)//2+(m-1)%2+1):
    amari1 = i
    amari2 = m - i
    if amari1 == amari2:
        ans += lst_num[amari1] // 2
    else:
        if lst_num[amari1] <= lst_num[amari2]:
            ans += lst_num[amari1]
            if lst_num[amari1] <= lst_kisu[amari2]:
                ans += lst_gusu[amari2] // 2
            else:
                ans += (lst_gusu[amari2]-(lst_num[amari1]-lst_kisu[amari2])) // 2
        else:
            ans += lst_num[amari2]
            if lst_num[amari2] <= lst_kisu[amari1]:
                ans += lst_gusu[amari1] // 2
            else:
                ans += (lst_gusu[amari1]-(lst_num[amari2]-lst_kisu[amari1])) // 2
print(ans)

Measured memory_bytes: 86380
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    t = [str(sum([A[i][k] * B[k][j] for k in range(m)])) for j in range(l)]
    print(" ".join(t))

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

int main(){
	
	int a,b,c;
	
	for (a=1; a<10; a++){
		
		for (b=1; b<10; b++){
			
			c=a*b;
			cout << a <<"x"<< b <<"="<< c <<"\n";
			
		}
	
	}
	
	return 0;
	
}

Measured memory_bytes: 1108
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s, t;
	int n;
	cin >> n >> s >> t;
	forn(i, n){
		cout << s[i] << t[i];
	}
	cout << endl;
}		

Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    h,w=INTM()
    print(int((h-0.1)//w+1))
if __name__ == '__main__':
    do()

Measured memory_bytes: 3188
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void)
{
    int n;

    cin >> n;


    if (n % 4 == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    if (n % 7 == 0) {
        cout << "Yes" << endl;
        return 0;
    }

    int i = 0;
    int sum = 0;
    while (1) {
        i += 7;
        if (i > n) {
            break;
        }
        sum = i;
        while (sum <= n) {
            sum += 4;
            if (sum == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,d=0,x=0,y=0,z=0,c=0;
  string s="",t="";
  //

  // ここから
  IN4(a,b,c,d);
  IN(n);
  OUT((n/2)*min({8*a,4*b,2*c,d})+(n%2)*min({4*a,2*b,c}));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M,A,B;
  cin >> N >> M;
  vector<int> height(N);
  vector<int> count(N);
  
  for(int i = 0; i < N; i++) {
    cin >> height.at(i);
  }
  
  for(int j = 0; j < M; j++) {
    cin >> A >> B;
    	
    	if (height.at(A-1) == height.at(B-1)) {
          count.at(A-1) =1;
          count.at(B-1) =1;
        }
    	else if(height.at(A-1) <= height.at(B-1)) {
          count.at(A-1) = 1;
        }
    	else if(height.at(A-1) >= height.at(B-1)) {
          count.at(B-1) = 1;
        } 
  }
                
  int c = 0;
  for(int k = 0; k < N; k++){
    c += count.at(k);
  }
  cout << N - c << endl;
}

Measured memory_bytes: 3984
import heapq as hp

N = int(input())
graph = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, d = map(int, input().split())
    graph[a-1].append((d, b-1))
    graph[b-1].append((d, a-1))

Q, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(Q)]

INF = int(1E17)

D = [INF for _ in range(N)] # 頂点iへの最短距離がD[i]
D[K-1] = 0 
q = [] # しまっていく優先度付きキュー
hp.heappush(q, (0, K-1))

while q:
    nd, np = hp.heappop(q) # 一番距離が近いものを取ってくる
    if D[np] < nd: # 追加した後の残骸は見ない
        continue
    for d, p in graph[np]:
        if D[p] > D[np] + d: # 隣接するやつの中で今よりも近くなれるなら更新
            D[p] = D[np] + d
            hp.heappush(q, (D[p], p))

for x, y in XY:
    print(D[x-1]+D[y-1])


Measured memory_bytes: 70700
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    string t[4] = {"dream","dreamer","erase","eraser"};
    rep(i,0,4){
        reverse(all(t[i]));
    }
    string s;
    cin >> s;
    reverse(all(s));
    int i;
    for(i = 0; i < s.size();){
        int step = -1;
        rep(j,0,4){
            if(s.substr(i,t[j].size()) == t[j]){
                step = j;
            }
        }
        if(step == -1) break;
        else{
            i += t[step].size();
        }
    }
    if( i == s.size()){
//        cout <<
    }
    cout << (i == s.size() ? "YES" : "NO") << endl;


    return 0;
}


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

int main()
{
  int n, m;
  cin >> n;
  vector<int> T(n), buf(n);
  for (int i = 0; i < n; i++)
  {
    cin >> T.at(i);
  }
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    int p, x, sum = 0;
    buf = T;
    cin >> p >> x;
    buf.at(p - 1) = x;
    for (int j = 0; j < n; j++)
    {
      sum += buf.at(j);
    }
    cout << sum << endl;
  }
}


Measured memory_bytes: 3632
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	ll k,a,b;
	cin>>k>>a>>b;
	ll bis = 1;
	if(a<=k-1) {
		k-=(a-1);
		bis=a;
	}
	if(b-a>1&&bis>=a) {
		bis+=(k/2)*(b-a);
		k-=2*(k/2);
	}
	if(k>0)bis+=k;
	cout<<bis;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3620
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int m, n;
	boolean map[][];
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			m = sc.nextInt();
			n = sc.nextInt();
			if( (n|m) == 0 ) break;
			int[] b = new int[m];
			int[] r = new int[n];
			for(int i=0;i<m;i++) b[i] = sc.nextInt();
			for(int j=0;j<n;j++) r[j] = sc.nextInt();
			map = new boolean[m][n];
			for(int i=0;i<m;i++) for(int j=0;j<n;j++) {
				map[i][j] = gcd( b[i], r[j] );
			}
			System.out.println(matching());
		}
	}
	
	boolean augument(int u, int[] matchTo, boolean[] visited) {
		if( u < 0 ) return true;
		for(int i=0;i<n;i++) {
			if(map[u][i] & !visited[i]) {
				visited[i] = true;
				if( augument(matchTo[i], matchTo, visited) ) {
					matchTo[i] = u;
					return true;
				}
			}
		}
		
		return false;
	}
	
	int matching() {
		int[] matchTo = new int[n];
		fill(matchTo, -1);
		int match = 0;
		for(int i=0;i<m;i++) {
			boolean[] visited = new boolean[n];
			if(augument(i, matchTo, visited)) match++;
		}
		
		return match;
	}
	
	boolean gcd(int x, int y) {
		if(y==0) {
			return x != 1;
		}
		else return gcd(y, x%y);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define re register
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

signed main(void){
	double r = read();r*=2;
	double pai = 3.14159265358;
	printf("%lf\n",pai*r);
	return 0;
}

Measured memory_bytes: 3764
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int N = ReadLineParseInt();
        Dictionary<KeyValuePair<int, int>, int> dic = new Dictionary<KeyValuePair<int, int>, int>();
        KeyValuePair<int, int>[] pos = new KeyValuePair<int, int>[N];
        for (int i = 0; i < N; i++)
        {
            int[] vs = ReadLineParseIntArray();
            pos[i] = new KeyValuePair<int, int>(vs[0], vs[1]);
        }
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
            {
                if (i == j) continue;
                KeyValuePair<int, int> d = new KeyValuePair<int, int>(pos[i].Key - pos[j].Key, pos[i].Value - pos[j].Value);
                if (dic.ContainsKey(d))
                {
                    dic[d]++;
                }
                else
                {
                    dic.Add(d, 1);
                }
            }
        int max = 0;
        foreach (int count in dic.Values)
        {
            if (count > max)
                max = count;
        }
        WriteLine(Max(1, N - max));
    } 
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 13504
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>

using namespace std;


int main() {
  cin.tie(0);

  long n;
  long pepole[5];
  long keep[5];
  keep[0]=pepole[0];
  cin >> n;
  for(int i = 0;i < 5; i++){
    cin >> pepole[i];
  }
  long minNum = pepole[0];
  int minIndex = 0;
  for(int i = 1; i < 5; i++){
    if(minNum > pepole[i]){
      minIndex = i;
      minNum = pepole[i];
    }
  }
  long ans = (n-1)/minNum + 5;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,z,w;
Vi a;



int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>z>>w;
    a.resize(n);
    rep(i,n)cin>>a[i];
    ll ans ;
    if(n>=2)ans = max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));
    else ans = abs(a[0]-w);
    print(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
int main ()
{
        int a,b,c,x,y;
        int temp,temp2,temp3,sum;
        while(cin>>a>>b>>c>>x>>y)
        {
                sum=0;
                if(x<y)
                {
                        temp=x;
                        temp2=y;
                        temp3=b;
                }
                else
                {
                        temp=y;
                        temp2=x;
                        temp3=a;
                }
                if(2*c<a+b)
                {
                                sum+=c*(temp*2);
                                sum+=temp3*(temp2-temp);
                        if(temp2*2*c<sum)
                        {
                                sum=temp2*2*c;
                        }
                }
                else
                {
                                sum+=a*x;
                                sum+=b*y;
                }
                cout<<sum<<endl;
        }
}


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

using Int = long long;
using ll = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;};

template<typename T> void drop(T x){cout<<x<<endl;exit(0);}


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

  Int n,m;
  cin>>n>>m;
  vector<Int> ls(n),rs(n);
  for(Int i=0;i<n;i++) cin>>ls[i]>>rs[i];

  vector<Int> vs;
  for(Int l:ls){
    vs.emplace_back(l-1);
    vs.emplace_back(l);
    vs.emplace_back(l+1);
  }
  for(Int r:rs){
    vs.emplace_back(r-1);
    vs.emplace_back(r);
    vs.emplace_back(r+1);
  }
  vs.emplace_back(0);
  vs.emplace_back(1);
  vs.emplace_back(m-1);
  vs.emplace_back(m);

  sort(vs.begin(),vs.end());
  vs.erase(unique(vs.begin(),vs.end()),vs.end());

  Int sz=vs.size();
  vector<Int> acc(sz+1,0);
  for(Int i=0;i<n;i++){
    Int p=lower_bound(vs.begin(),vs.end(),ls[i])-vs.begin();
    Int q=lower_bound(vs.begin(),vs.end(),rs[i])-vs.begin();
    acc[p]++;
    acc[q+1]--;
  }
  for(Int i=0;i<sz;i++) acc[i+1]+=acc[i];

  Int num=*max_element(acc.begin(),acc.end());

  //cout<<num<<endl;

  if(num&1){
    Int rgh=0;
    for(Int i=0;i<sz;i++)
      if(acc[i]==num) rgh=i;
    cout<<m*(num-1)+vs[rgh]<<endl;
  }else{
    Int lft=0;
    for(Int i=sz;i>=0;i--)
      if(acc[i]==num) lft=i;
    cout<<m*(num-1)+(m-vs[lft])<<endl;
  }

  return 0;
}



Measured memory_bytes: 24980
#include <stdio.h>
#include <string.h>

int main(void) {
    int N;
    int s[101];
    scanf("%d", &N);
    for (int i = 0; i < N; i ++) {
        scanf("%d", &s[i]);
    }
    int sum = 0;
    int min = 1000;
    for (int i = 0; i < N; i ++) {
        sum += s[i];
        if (min > s[i] && s[i] % 10 != 0) {
            min = s[i];
        }
    }
    if (sum % 10 != 0) {
        printf("%d\n", sum);
    } else if (min != 1000) {
        printf("%d\n", sum - min);
    } else {
        printf("%d\n", 0);
    }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define ull unsigned long long
#define INF (1 << 29)
#define LLINF (1LL << 61)
#define MOD7 1000000007
#define MOD9 1000000009
#define eps 1e-9
#define P pair<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }

class UnionFind {
	vector<int> data;
public:

	UnionFind(int size = 0) {
		resize(size);
	}
	void resize(int size) {
		data.resize(size, -1);
	}

	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}

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

		if (data[y] < data[x])
			swap(x, y);
		data[x] += data[y];
		data[y] = x;
	}

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

int main() {
	int n, q, c, x, y;
	cin >> n >> q;

	UnionFind uf(n);
	while (q--) {
		cin >> c >> x >> y;
		if (c)
			cout << uf.same(x, y) << endl;
		else
			uf.unite(x, y);
	}

	return 0;
}

Measured memory_bytes: 3136
n = int(input())
a = [int(i) for i in input().split(" ")]

d = [0, 0, 0, 0, 0, 0, 0, 0, 0]


for i in a:
  if i < 400:
    d[0] = 1
    continue
  elif i < 800:
    d[1] = 1
  elif i < 1200:
    d[2] = 1
  elif i < 1600:
    d[3] = 1
  elif i < 2000:
    d[4] = 1
  elif i < 2400:
    d[5] = 1
  elif i < 2800:
    d[6] = 1
  elif i < 3200:
    d[7] = 1
  else:
    d[8] += 1
    
min = sum(d[:-1])
if min == 0:
  min = 1
max = sum(d)
print(min, max)


Measured memory_bytes: 3188
#include<stdio.h>

int main(){
  int i,j,v,N,a,b,c;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(a=0;a<N;a++){
    if(a==N-1){
      printf("%d\n",A[a]);
    }
    else  printf("%d ",A[a]);
    
  }
  
  
  for(i=1;i<=N-1;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] =v;
    for(a=0;a<N;a++){
      if(a==N-1){
      printf("%d\n",A[a]);
    }
    else  printf("%d ",A[a]);
    }
    
  }
  return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int h;
    while(1==1)
    {
        scanf("%d\n",&h);
        if(h==0)break;
        int ban[15][5]={};
        int del=0;
        long int ans=0;
        REP(y,h)REP(x,5)scanf("%d ",&ban[y][x]);
        do{
            del=0;
            REP(y,h)
            {
                int center=ban[y][2];
                int centnum=1;
                if(ban[y][1]==center)
                {
                    centnum++;
                    if(ban[y][0]==center)centnum++;
                }
                if(ban[y][3]==center)
                {
                    centnum++;
                    if(ban[y][4]==center)centnum++;
                }
                if(centnum>=3 && center!=0)
                {
                    ban[y][2]=0;
                    if(ban[y][1]==center)
                    {
                        ban[y][1]=0;
                        if(ban[y][0]==center)ban[y][0]=0;
                    }
                    if(ban[y][3]==center)
                    {
                        ban[y][3]=0;
                        if(ban[y][4]==center)ban[y][4]=0;
                    }
                    ans+=centnum*center;
                    del++;
                }
            }
            REP(x,5)REP(i,1000)REP(y,h-1)if(ban[y][x]!=0&&ban[y+1][x]==0)swap(ban[y][x],ban[y+1][x]);
            /*
            REP(y,h)
            {
                REP(x,5)
                {
                    printf("%d ",ban[y][x]);
                }
                printf("\n");
            }
            printf("###\n");
            */
        }while(del>0);
        printf("%ld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3208
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
using namespace std;
const ll N=1e5+5;

int main() {
	fio;
	ll a,b;
	cin>>a>>b;
	cout<<a*b;
	return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define ls rt<<1
#define rs (rt<<1)+1
#define PI acos(-1)
#define eps 1e-8
#define ll long long
#define fuck(x) cout<<#x<<"     "<<x<<endl;
typedef pair<int,int> pii;
const int maxn=1e6+10;
int d[4][2]={1,0,-1,0,0,1,0,-1};
//int lowbit(int x){return x&-x;}
//void add(int x,int v){while(x<=n)bit[x]+=v,x+=lowbit(x);}
//int sum(int x){int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
struct node{
    int st,num;
    node(int st=0,int num=0){
        this->st=st;
        this->num=num;
    }
};
vector<node>v;
char s[maxn];
int main(){

    int n,k,tmp,ans;
    scanf("%d%d%s",&n,&k,s+1);
    s[n+1]='p';
    tmp=1;
    for(int i=2;i<=n+1;i++){
        if(s[i]!=s[tmp])
        {
            v.push_back(node(tmp,i-tmp));
            tmp=i;
            if(i==n+1)
                break;
        }
    }
    tmp=v.size();
    if(tmp==1){
        cout<<n-1<<endl;
        return 0;
    }

    for(int i=1;i<=v.size()-1;i++)
    {
        if(!k) break;
        if(i%2){
            tmp-=2;
            if(i==v.size()-1)
                tmp++;
            k--;
        }
    }
    cout<<n-tmp<<endl;
    return 0;

}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
 
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 ll INF = 10010001010;
const int inf = 1000034000;
 
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
int main() {
    ll N;
    cin >> N;
    vector<int> A(N);
    int count = 1;
    int now = 0;
    for(int i = 0;i < N;i++){
            cin >> A[i];
    }
    bool inc = false;
    int D = 0;
    for(int i = 0;i < N-1;i++){
        if(D == 1){
            if(A[i] > A[i+1]){
                count++;
                D = 0;
            }
        }
        else if(D == -1){
            if(A[i] < A[i+1]){
                count++;
                D = 0;
            }
        }
        else{
            if(A[i] > A[i+1]){
                D= -1;
            }
            else if(A[i] < A[i+1]){
                D = 1;
            }
            else{
                D = 0;
            }
        }
    }
    cout<< count << endl;
} 

Measured memory_bytes: 3700
#include <stdio.h>
#include <string.h>
int main()
{
    char  c;
    scanf("%c",&c);
    if(c=='A')
        printf("T");
    if(c=='C')
        printf("G");
    if(c=='G')
        printf("C");
        if(c=='T')
        printf("A");
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
using namespace std;

int N;
int ai[110], bi[110];
int ci[110], di[110];
vector<vector<int> > G(110);
int match[110];
int vis[110];
int res;

int dfs(int u)
{
	int i, v;
	for(i=0; i<G[u].size(); i++){
		v = G[u][i];
		if(vis[v]==0){
			vis[v] = 1;
			int t = match[v];
			if(match[v]==-1 || dfs(match[v])==1){
				match[v] = u;
				return 1;
			}
			else
				match[v] = t;
		}
	}
	return 0;
}

void solve()
{
	int i, j;
	for(i=0; i<N; i++){
		for(j=0; j<N; j++){
			if(ai[i]<ci[j] && bi[i]<di[j])
				G[i].push_back(j);
		}
	}
	for(i=0; i<N; i++)
		match[i] = -1;
	for(i=0; i<N; i++){
		for(j=0; j<N; j++)
			vis[j] = 0;
		if(dfs(i) )
			res ++;
	}
	printf("%d\n", res);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	int i;
	scanf("%d", &N);
	for(i=0; i<N; i++)
		scanf("%d%d", &ai[i], &bi[i]);
	for(i=0; i<N; i++)
		scanf("%d%d", &ci[i], &di[i]);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T = int, T mod = 1'000'000'007, typename U = long long>
struct umod{
        T val;
        umod(): val(0){}
        umod(U x){ x %= mod; if(x < 0) x += mod; val = x;}
        umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
	umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
	umod& operator *= (umod oth){ val = ((U)val) * oth.val % mod; return *this; }
	umod& operator /= (umod oth){ return *this *= oth.inverse(); }
        umod& operator ^= (U oth){ return *this = pwr(*this, oth); }
	umod operator + (umod oth) const { return umod(*this) += oth; }
	umod operator - (umod oth) const { return umod(*this) -= oth; }
	umod operator * (umod oth) const { return umod(*this) *= oth; }
	umod operator / (umod oth) const { return umod(*this) /= oth; }
        umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
	bool operator < (umod oth) const { return val < oth.val; }
	bool operator > (umod oth) const { return val > oth.val; }
	bool operator <= (umod oth) const { return val <= oth.val; }
	bool operator >= (umod oth) const { return val >= oth.val; }
	bool operator == (umod oth) const { return val == oth.val; }
	bool operator != (umod oth) const { return val != oth.val; }
        umod pwr(umod a, U b) const { umod r = 1; for(; b; a *= a, b >>= 1) if(b&1) r *= a; return r; }
        umod inverse() const {
		U a = val, b = mod, u = 1, v = 0;
		while(b){
			U t = a/b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		if(u < 0)
			u += mod;
		return u;
        }
};
using U = umod<>;
const int maxn = 2020;
U f[maxn][maxn][2], ans;
int main(){
	int n, k; cin >> n >> k;
	f[0][0][0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = i; j >= 0; j--){
			for(int r = 0; r < 2; r++){
				if(!f[i][j][r].val) continue;
				if(i - j == k - 1){
					ans += f[i][j][r];
					continue;
				}
				f[i + 1][j][0] += f[i][j][r];
				f[i + 1][j + 1][1] += f[i][j][r];
				if(!r && j > 0){
					f[i][j - 1][0] += f[i][j][r];
				}
			}
		}
	}	
	for(int j = 0; j < n - k - 1; j++) ans *= 2;
	cout << ans.val << endl;
	return 0;
}


Measured memory_bytes: 32128
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    ls = [0] * 65
    for v in a:
        tt = bin(v)
        for i in range(len(tt)-2):
            ls[i] += int(tt[-i-1])
    t = 0
    for i in range(len(ls)):
        t += 2 ** i * (n - ls[i]) * ls[i]
        t %= mod
    print(t)


if __name__ == '__main__':
    solve()


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

using ll = long long;

const ll MOD = 998244353;

int main() {
    int N, A;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        cin >> A;
        if (mp.find(A) != mp.end()) mp[A]++;
        else mp[A] = 1;
    }
    int s = mp.size();
    if (s == 1 && mp[0] == N) {
        cout << "Yes" << endl;
        return 0;
    }
    if (N % 3 != 0) {
        cout << "No" << endl;
        return 0;
    }
    if (s == 2 && mp[0] == N / 3) {
        cout << "Yes" << endl;
        return 0;
    }
    if (s != 3) {
        cout << "No" << endl;
        return 0;
    }
    vector<int> b(0), c(0);
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        b.push_back(itr->first);
        c.push_back(itr->second);
    }
    if ((b[0] ^ b[1]) != b[2]) {
        cout << "No" << endl;
        return 0;
    }
    if (c[0] == c[1] && c[1] == c[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3840
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int N; cin >> N;

  int ans = 0;

  if (N < 10){
    ans = N;
  }else if(N < 100){
    ans = 9;
  }else if(N < 1000){
    ans = N - 90;
  }else if(N < 10000){
    ans = 9999 - 90 - 9000;
  }else if(N < 100000){
    ans = N - 90 - 9000;
  }else{
    ans = 99999 - 90 - 9000;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func max(a int, b int) int {
	if a >= b {
		return a
	}
	return b
}

type Node struct {
	Index     int
	Value     int
	Neighbors []*Node
	Len       int
	IsSearched  bool
}

var nodes []*Node
var already map[int]bool

// dp[i]: 長さiの増加部分列において最後の値の最小値
func search(n *Node, dp []int) {
	if n.IsSearched {
		return
	}
	n.IsSearched = true

	idx := sort.SearchInts(dp, n.Value)
	befVal := dp[idx]
	dp[idx] = n.Value
	n.Len = sort.SearchInts(dp, MAX_INT)
	for _, to := range n.Neighbors {
		search(to, dp)
	}
	dp[idx] = befVal
}

var N int
var h []int

func main() {
	sc.Split(bufio.ScanWords)
	nextInt(&N)
	h = make([]int, N)
	nextInts(&h)

	plus := make([]int, N)
	minusMap := map[int]int{}
	for i := 0; i < N; i++ {
		plus[i] = i + h[i]
		minusMap[i-h[i]]++
	}
	var ans int

	for i := 0; i < N; i++ {
		ans += minusMap[plus[i]]
	}
	fmt.Printf("%d", ans)
}




const MAX_INT int = 1_000_000_000
var sc = bufio.NewScanner(os.Stdin)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)

func nextLine() string {
	buffer := make([]byte, 0)
	for true {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func nextInt(A ...*int) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.Atoi(L[i])
	}
}
func nextInts(A *[]int) {
	L := strings.Split(nextLine(), " ")
	(*A) = make([]int, len(L))
	for i, l := range L {
		(*A)[i], _ = strconv.Atoi(l)
	}
}

func nextInt64(A ...*int64) {
	L := strings.Split(nextLine(), " ")
	for i, a := range A {
		*a, _ = strconv.ParseInt(L[i], 0, 64)
	}
}


Measured memory_bytes: 22472