akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
using std::sort;
using std::binary_search;

#define MAX 100004
int cnt=0;
int t;
void dfs(long long  x,int flag){
    if(x>t){
        return;
    }
    if(flag==7){
        cnt++;
    }
    dfs(x*10+3,flag|1);
     dfs(x*10+5,flag|2);
     dfs(x*10+7,flag|4);

}
int main(){

//    printf("1\n");
    scanf("%d",&t);
    dfs(0,0);
    printf("%d",cnt);
}



Measured memory_bytes: 256
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
  int n; cin >> n;
  vi a(n);
  for(int &x : a) cin >> x;
  sort(all(a));
  bool yes = true;
  for(int i = 1; i < n; i++)
   if(a[i-1] == a[i]) yes = false;
   cout << (yes ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <ctype.h>
int main(void){
    // Your code here!
    int count[26]={0};
    char ch;
    int i,num;
    
    while(scanf("%c",&ch)!=EOF){
        if(islower(ch)){
            num=ch-'a';
        }else if(isupper(ch)){
            num=ch-'A';
        }else{
            continue;
        }
        count[num]++;
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n",'a'+i, count[i]);
    }
    return 0;
}



Measured memory_bytes: 2124
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

n, k, q = map(int, input().split())
point_list = [0]*n
S = []

for _ in range(q):
    ai = int(input())
    point_list[ai-1] += 1

for point in point_list:
    if k - (q - point) > 0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 10340
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    A, B = map(int, input().split())

    print(A - (B * 2) if A >= B * 2 else 0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
N = int(input())
dic1 = {} # S: i
dic2 = {} # i: P
for i in range(1, N+1):
    s, p = input().split()
    p = int(p)
    if s not in dic1.keys():
        dic1[s] = []
    dic1[s].append(i)
    dic2[i] = p

sorted_dic1 = sorted(dic1.items())

for key, i_list in sorted_dic1:
    p_list = []
    for i in i_list:
        p_list.append((dic2[i], i))
    p_list.sort(reverse=True)
    for ans_i in p_list:
        print(ans_i[1])

Measured memory_bytes: 38640
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int H = 12;
const int W = 6;

int my[] = {1, -1, 0, 0};
int mx[] = {0, 0, 1, -1};

void disp(vector<string> &v){
  REP(i, H) cout <<v[i] <<endl;
  cout <<"-----------" <<endl;
}

int count(vector<string> &v, vector< vector<bool> > &visited, int y, int x, char tar){
  visited[y][x] = 1;
  int res = 1;
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i];
    if(ny >= 0 && nx >= 0 && ny < H && nx < W && v[ny][nx] == tar && !visited[ny][nx]) res += count(v, visited, ny, nx, tar);
  }
  return res;
}

void remove(vector<string> &v, int y, int x, char tar){
  v[y][x] = '.';
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i];
    if(ny >= 0 && nx >= 0 && ny < H && nx < W){
      if(v[ny][nx] == tar) remove(v, ny, nx, tar);
      if(v[ny][nx] == 'O') v[ny][nx] = '.';
    }
  }
}

void fall(vector<string> &v){
  REP(x, W){
    for(int y = H - 1; y >= 0; --y){
      if(v[y][x] == '.') continue;
      int ty = y;
      while(ty < H - 1 && v[ty + 1][x] == '.') { swap(v[ty][x], v[ty + 1][x]); ++ty; }
    }
  }
}


int check(vector<string> &v){
  vector<string> bef = v;
  vector< vector<bool> > visited(H, vector<bool>(W, 0));
  REP(y, H){
    REP(x, W){
      if(visited[y][x] || v[y][x] == '.' || v[y][x] == 'O') continue;
      int cnt = count(v, visited, y, x, v[y][x]);
      if(cnt >= 4) remove(v, y, x, v[y][x]);
    }
  }
  fall(v);
  return v != bef;
}

int main() {
  int T; cin >>T;
  while(T--){
    vector<string> v(H);
    REP(i, H) cin >>v[i];
    int ans = 0;
    while(check(v)) ++ans;
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int

int main(void)
{
    ll n, k, count, m;
    int i, ls, j, lc = 0;
    int pos[200002];
    int fl[200002] = {0};

    scanf("%lld %lld", &n, &k);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &pos[i]);
        fl[i] = 1;
    }

    i = 0;
    count = 0;
    while (fl[i] != 0)
    {
        fl[i] = 0;
        i = pos[i] - 1;
        count++;
        if (count == k)
        {
            printf("%d\n", i + 1);
            return 0;
        }
    }
    //printf("%d %lld\n", i, count); //一度訪れた街に戻るまでの回数
    ls = 0;
    if (i != 0)
    {
        while (pos[ls] != i + 1) //手前の町まで移動
        {
            ls = pos[ls] - 1;
            lc++;
        }
        ls = pos[ls] - 1; //ループの頭の町に移動
        lc++;
    }
    //printf("%d %d\n", ls, lc);
    i = 0;
    m = (k - lc) % (count - lc);
    for (; i < m; i++)
    {
        ls = pos[ls] - 1;
    }
    printf("%d\n", ls + 1);
    return 0;
}

Measured memory_bytes: 3296
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	char sakoda;
	scanf("%c",&sakoda);
	if ( (sakoda >= 'A' ) && (sakoda <= 'Z' )) {
		printf("A");
		return 0;
	}
	printf("a");
	return 0;
}




Measured memory_bytes: 1588
#include<bits/stdc++.h>
using namespace std;
int main()
{int w,a,b;cin>>w>>a>>b;int x=abs(a-b);
if(w>0)
{
if(x>w)
{
if(a==b)
{cout<<"0";}
if(a>b)
{cout<<a-b-w;}
if(b>a)
{cout<<b-a-w;}
}
if(x<=w)
{cout<<"0";}
}

return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cout << "Case " << i << ":" << endl;
        int s;
        cin >> s;
        for(int j = 0; j < 10; j++) {
            s = s * s;
            string t(8, '0');
            for(int k = 7; s > 0; k--) {
                t[k] = '0' + (s % 10);
                s /= 10;
            }


            for(int k = 2; k < 6; k++) 
                s = s * 10 + (t[k] - '0');
            
            cout << s << endl;

        }
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        
        //与えられた数が素数か素数でないかを見分けるには，2からN−1までの整数で割り切れるかどうか
        for (int n=x; ; n++) {
            if (judgeNumber(n)) {
                System.out.println(n);
                break;
            }
        }
    }
    
    private static boolean judgeNumber(int n) {
        for (int i=2; i<=n-1; i++) {
            if (n%i == 0){
                return false;
            }
        }
        return true;
    }
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 0) {
    cout << "Even" << '\n';
  } else {
    cout << "Odd" << '\n';
  }
  return 0;
}


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

int main() {
	int n;
    cin >> n;
    ll l[n];
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(l, l+n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            for (int k = j+1; k < n; ++k) {
                if(l[i] == l[j] || l[j] == l[k]) continue;
                if(l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3520
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	int ans;
	for (int i = (min(x, y)); i >= 1; i--) {
		if (x%i == 0 && y%i == 0) {
			ans = i;
			break;
		}
	}
	return ans;
}
int yakusuunowa(int n) {
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if (n%i == 0)ans += i;
	}
	return ans;
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int ketanowa(int n) {
	int cnt = 0, sum = 0;
	for (int i = 10; i <= n * 10; i *= 10) {
		if (i == 10)cnt += n % i;
		else sum += (n%i - n % (i / 10)) / (i / 10);
	}
	return cnt + sum;
}
int sanada[114];
signed main() {
	int n, a, b,cnta=0,cntb=0,cntc=0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> sanada[i];
	for (int i = 0; i < n; i++) {
		if (sanada[i] <= a)cnta++;
		else if (sanada[i] > a&&sanada[i] <= b)cntb++;
		else cntc++;
	}
	cout << min({ cnta,cntb,cntc }) << endl;
	ll
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename M>
bool rMax(M &a, M b) {
    return b > a ? a = b, true : false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, w;
    cin>>n>>w;
    vector<long long> dp(w+1, 0);
    vector<long long> nextDP(w+1);
    for(int i = 0; i< n; i++){
        long long a, b;
        cin>>a>>b;
        for(int j = 0; j<=w; j++){
            nextDP[j] = dp[j];
            if(j - a < 0) continue;
            if(dp[j-a] || j - a == 0) 
                rMax(nextDP[j], dp[j-a] + b);
        }
        dp = nextDP;
    }
    cout<<*max_element(dp.begin(), dp.end())<<"\n";
}


Measured memory_bytes: 4732
A, B = map(int,input("").split(" "))
value = int(A*12.5) -1
ans = -1
while True:
  value += 1
  tax_1 = int(value*0.08)
  tax_2 = int(value*0.10)
  if tax_1 == A and tax_2 == B:
    ans = value
    break
  elif tax_1 > A and tax_2 > B:
    break
print(ans)
  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<vector<int>> cnt(10, vector<int>(10, 0));
  for (int i = 1; i <= N; i++){
    string S = to_string(i);
    cnt[S[0] - '0'][S[S.size() - 1] - '0']++;
  }
  long long ans = 0;
  for (int i = 0; i < 10; i++){
    for (int j = 0; j < 10; j++){
      ans += cnt[i][j] * cnt[j][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = int(input())
    s = input()
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cntW = 0
    for i in range(1, n):
        if s[i] == "W":
            cntW += 1

    cntmax = cntW
    for i in range(1, n):
        if s[i-1] == "E":
            cntW += 1
        if s[i] == "W":
            cntW -= 1
        if cntmax < cntW:
            cntmax = cntW

    print(n - cntmax -1)


resolve()

Measured memory_bytes: 40816
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << n / 3 << endl;
}

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

#define int             long long int
#define ld              long double
#define ff              first
#define ss              second
#define mp              make_pair
#define pb              push_back
#define si              set <int>
#define vi              vector <int>
#define pii             pair <int, int>
#define vpii            vector <pii>
#define vpp             vector <pair<int, pii>>
#define mii             map <int, int>
#define mpi             map <pii, int>
#define msi             map < string, int >
#define loop(i,s,e)     for(int i=s;i<e;i++)
#define rloop(i,e,s)    for(int i=e;i>=s;i--)
#define mset(a,f)       memset(a,f,sizeof(a))
#define spi             set <pii>
#define endl            "\n"
#define M               1000000007
#define sz(x)           ((int) x.size())
#define all(p)          p.begin(), p.end()
#define que_max         priority_queue <int>
#define que_min         priority_queue <int, vi, greater<int>>
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define Print(a,x,y)    for (int i=x; i<y; i++) cout<< a[i]<< " "; cout << endl

inline int power(int a, int b)
{
	int x = 1;
	while (b)
	{
		if (b & 1) x *= a;
		a *= a;
		b >>= 1;
	}
	return x;
}

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int N = 200005;
int arr[N];
int help(int x)
{
	int ans;

	if (x == 1) return 1;

	else {
		ans = help(x / 2);
	}
	return 2 * ans + 1;
}
void solve()
{
	int n;
	cin >> n;
    if(n==1)
    {
    cout<<1;
    return;
    }
	if (n % 2 != 0)n--;
	int ans = help(n);
	cout << ans;
	return;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


	clock_t z = clock();
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

def solve(s):
    ans = 0
    one = False
    i = 0
    n = len(s)

    while i < n:
        if i == n - 2 and  s[i] == s[i+1]:
            ans += 1
            break
        elif one and s[i] == s[i-1]:
            ans += 1
            i += 2
            one = False
        else:
            ans += 1
            i += 1
            one= True 

    return ans



def main():
    S = input()
    print(solve(S))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll x;
  cin >> x;
  if (x % 100 == 0) {
    cout << 1 << endl;
    return 0;
  }
  int s = x / 100;
  int r = x - s * 100;
  if (r <= s*5) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

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

Measured memory_bytes: 592
// Problem: B - Magic 2
// Contest: AtCoder - M-SOLUTIONS Programming Contest 2020
// URL: https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define elif else if
#define y2 y1919810
typedef pair <int, int> PII;
typedef vector <int> VI;
//#define int long long
#define all(x) x.begin(),  x.end()
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
    char c = getchar();
    int neg = 1;
    long long val = 0;
    while (c != '-' && !isdigit(c)) c = getchar();
    if (c == '-') c = getchar(), neg = -1;
    while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
    return neg * val;
}
int K, A, B, C;
void dfs(int k, int a, int b, int c) {
    if (k == K) {
        if (b > a && c > b) {
            puts("Yes");
            exit(0);
        }
        return;
    }
    dfs(k + 1, a * 2, b, c);
    dfs(k + 1, a, b * 2, c);
    dfs(k + 1, a, b, c * 2);
}
void solve() {
    A = qread(); B = qread(); C = qread(); K = qread();
    dfs(0, A, B, C);
    puts("No");
}
int main() {
    int T = 1;
    //T = qread();
    while (T--) solve();
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
using namespace std;
 
signed main(){
	fastio
		int n, k;
	cin >> n >> k;
	vector<int> c(n+1), p(n+1);
	vector<vector<int>> dp(n+1, vector<int>(1)), mx = dp;
	for(int i = 1; i <= n; i++)
		cin >> p[i];
	for(int i = 1; i <= n; i++)
		cin >> c[i];
	for(int i = 1; i <= n; i++) {
		int it = i;
		mx[i][0] = -1e18;
		it = p[it];
		while(true) {
			dp[i].push_back(dp[i].back()+c[it]); 
			mx[i].push_back(max(mx[i].back(), dp[i].back()));
			if(it == i)
				break;
			it = p[it];
		}
	}
	int ans = -1e18;
	for(int i = 1; i <= n; i++) {
		int x = dp[i].size()-1;
		int w = k/x, res = k%x;
		int cur = -1e18;
		if(dp[i][x] > 0) {
			cur = dp[i][x]*w+max<int>(0, mx[i][res]);
		}
		if(w) {
			cur = max(cur, dp[i][x]*(w-1) + mx[i][x]);
		}
		cur = max(cur, mx[i][min(x, k)]);
		ans = max(ans, cur);
	}
	cout << ans << '\n';
 
	return 0;
}

Measured memory_bytes: 434756
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define FFOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define rep(i,n) FOR(i,0,n-1)
#define int long long
#define MOD 998244353
#define MAXN  100005
#define P pair<int,int>


signed main(){
	
	int n;cin >>n;
	
	bool start = false;
	int zouka; // 1:増加　2:減少 3:未定
	int prea;
	int ans = 0;
	rep(i,n)
	{
		int a;cin>>a;
		if(i==0)
		{
			prea = a;
			zouka = 3;
			continue;
		}
		
		if(zouka == 3)
		{
			if(a<prea) zouka = 2;
			if(a>prea) zouka =1;
		}
		
		if((zouka == 1 and a<prea) or (zouka == 2 and a>prea))
		{
			ans++;
			zouka = 3;	
		}
		
		prea = a;
		
	}
	
	
	
	
	
	cout << ans+1 << endl;
		
	
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  
  ll n;
  cin >> n;
  cout << "ABC" << n << endl;
  
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 512 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	aStr := nextString()
	bStr := nextString()

	a, _ := new(big.Int).SetString(aStr, 10)
	b, _ := new(big.Int).SetString(bStr, 10)
	c := big.NewInt(0).Mul(a, b)

	fmt.Println(c)
}



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

typedef long long ll;

int main()
{
    int a,b,c;
    string s = "NO";
    cin >> a >> b >> c;
    if(a==5&&b==7&&c==5)
        s = "YES";
    if (a == 7 && b == 5 && c == 5)
        s = "YES";
    if (a == 5 && b == 5 && c == 7)
        s = "YES";
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    string s, t;
    cin >> s;
    cin >> t;
    if (SZ(t) == SZ(s) + 1 && t.substr(0, SZ(s)) == s) cout << "Yes";
    else cout << "No"; 
    return 0;
}


Measured memory_bytes: 3612
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int N;
int H[100005];
int dp[100005];

void solve() {
  dp[0] = 0;
  dp[1] = abs(H[0] - H[1]);
  for (int i = 2; i < N; i++) {
    dp[i] = min(dp[i-2] + abs(H[i] - H[i-2]), dp[i-1] + abs(H[i] - H[i-1]));
  }
  printf("%d\n", dp[N-1]);
}

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", H+i);
  }
  solve();
}


Measured memory_bytes: 2496
import java.util.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		int n=as.nextInt();
		int i=0;
		String a;
		int b;
		
		int card[][];
		card = new int[4][13];
		//Arrays.fill(card, 0);
		String str;
		
		
		while(i<n){
			
			a=as.next();
		    b=as.nextInt();
			
			switch(a){
			
			case"S":
				card[0][b-1]=1;
				break;
			
			case"H":
				card[1][b-1]=1;
				break;
				
			case"C":
				card[2][b-1]=1;
				break;
				
			case"D":
				card[3][b-1]=1;
				break;
				
			}
			i++;
			
		}
			
			
		for(i=0;i<4;i++){
			
			switch(i){
						
						case 0:
							for(int j=0;j<13;j++){
								
								if(card[0][j]==0){
									str="S "+(j+1);
									System.out.println(str);
								}
							}
							break;
						
						case 1:
							for(int j=0;j<13;j++){
								
								if(card[1][j]==0){
									str="H "+(j+1);
									System.out.println(str);
								}
							}
							break;
							
						case 2:
							for(int j=0;j<13;j++){
								
								if(card[2][j]==0){
									str="C "+(j+1);
									System.out.println(str);
								}
							}
							break;
							
						case 3:
							for(int j=0;j<13;j++){
								
								if(card[3][j]==0){
									str="D "+(j+1);
									System.out.println(str);
								}
							}
							break;
			}
						
		}
			
	}
		
		

}

Measured memory_bytes: 26180
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import qualified Data.Set              as S

main :: IO ()
main = do
  _ <- B.getLine
  a <- B.getLine
  b <- B.getLine
  c <- B.getLine
  print $ solve a b c

solve :: B.ByteString -> B.ByteString -> B.ByteString -> Int
solve a b c = go 0 a b c
  where
    go !k xs ys zs = case sequenceA [B.uncons xs, B.uncons ys, B.uncons zs] of
      Nothing                        -> k
      Just [(x,xs1),(y,ys1),(z,zs1)] -> go (k + l) xs1 ys1 zs1
        where
          l = pred $ S.size $ S.fromList [x, y, z]

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

struct Query {
    int v, c, d;

    void read() {
        scanf("%d %d %d", &v, &d, &c);
    }
};

const int N = 100009;

int n, m, q, color[N]={}, memo[N]={};
bool filled[N]={};
vector<Query> query;
vector<int> adj[N];

void fill(int u, int d, int c) {
    if(d < 0 || memo[u] >= d) return;

    memo[u] = d;
    if(!filled[u]) {
        color[u] = c;
        filled[u] = true;
    }

    for(int v : adj[u])
        fill(v, d-1, c);
}

int main() {
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++) {
        int x, y; scanf("%d %d", &x, &y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    scanf("%d", &q);
    query.resize(q);
    for(int i = 0; i < q; i++)
        query[i].read();

    reverse(query.begin(), query.end());
    memset(memo, -1, sizeof memo);

    for(Query q : query) {
        if(memo[q.v] >= q.d) continue;
        fill(q.v, q.d, q.c);
        memo[q.v] = q.d;
    }

    for(int i = 1; i <= n; i++)
        printf("%d\n", color[i]);
    return 0;
}


Measured memory_bytes: 8568
import random
import time
import numpy as np

def decrease(day, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(day):
        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (now - date[i])
        ret += tmp
        satisfy.append(tmp)

    return ret

def change(_from, _to, schedule, c, s, satisfy):
    ret = 0
    date = [0] * 26

    for d in range(_to):
        if d < _from:
            ret += satisfy[d]
            continue

        now = schedule[d] + 1
        date[now - 1] = d + 1
        tmp = 0
        for i in range(26):
            tmp += c[i] * (now - date[i])
        ret += tmp
        satisfy[d] = tmp

    return ret

def Main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]
    
    dissatisfy=[]
    schedule = []
    score = 0
    start = time.time()

    #最大値を足すだけ
    for i in range(D):
        schedule.append(np.argmax(s[i]))
        score += np.max(s[i])
    
    ans = score - decrease(D, schedule, c, s, dissatisfy)
    
    while time.time() - start < 1.8:
        contest = random.randint(0, 25)
        day = random.randint(0, D - 1)
        save = dissatisfy.copy()
        dec = change(day + 1, D, schedule, c, s, dissatisfy)
        score2 = score - s[day][schedule[day]] + s[day][contest]

        if ans < score2 - dec:
            ans = score2 - dec
            score = score2
            schedule[day] = contest
        else:
            dissatisfy = save
        
    for i in range(D):
        print(schedule[i] + 1)

if __name__ == "__main__":
    Main()

Measured memory_bytes: 27552
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> A(N);
    rep(i, N) cin >> A[i];
    
    sort(A.begin(), A.end());
    vector<long long> sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + A[i];
    
    for (int i = N; i > 0; --i) {
        if (sum[i - 1] * 3 < sum[i]) {
            cout << N - i + 1 << endl;
            return 0;
        }
    }
    cout << N << endl;
    return 0;
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 9000
char s[MX*2];
int N,X,Y,A,B,I,t=1,a,T;
vi O[2];
bitset<2*MX> D[MX];
bool ok(int u,int S){
    if(S<-8006||S>8006)return 0;
    if(u>=(int)O[t].size())return S==T;
    if(D[u][S+8006])return 0;
    D[u][S+8006]=1;
    return ok(u+1,S+O[t][u])|ok(u+1,S-O[t][u]);
}
int main(void){
    scanf("%s%d%d",s,&X,&Y),N=strlen(s);
    while(I<N&&s[I]=='F')++A,++I;
    if(I==N)return puts(A==X&&B==Y?"Yes":"No"),0;
    while(I<N){
        ++I,a=0;
        while(I<N&&s[I]=='F')++a,++I;
        if(a)O[t].PB(a);
        t=!t;
    }
    t=0;F(MX)D[i].reset();T=A-X;if(!ok(0,0))return puts("No"),0;
    t=1;F(MX)D[i].reset();T=B-Y;if(!ok(0,0))return puts("No"),0;
    puts("Yes");
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  
  int q;
  string s;
  set<int> ac;
  vector<int> wa(n+1, 0);
  for(int i=0; i<m; i++) {
    cin >> q >> s;
    if(ac.count(q)) continue;
    if(s=="AC") ac.insert(q);
    else wa[q]++;
  }
  
  for(int i=1; i<n+1; i++) if(!ac.count(i)) wa[i] = 0;
  cout << ac.size() << " " << accumulate(wa.begin(), wa.end(), 0) << endl;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W;
    ll h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;
    return 0;
}


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

namespace Programminng
{
    class AOJ_Volume0024
    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;

                double value = double.Parse(s);
                double min_t = value / 9.8;
                double just = 4.9 * min_t * min_t;
                int number = (int)((just + 10) / 5.0);
                Console.WriteLine(number);
            }
        }
    }
}

Measured memory_bytes: 5680
import sys
N=int(input())
t0=0
x0,y0=0,0
dt=0
dx,dy,d,n=0,0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    dt=t-t0
    dx=x-x0
    dy=y-y0
    d=abs(dx)+abs(dy)
    if d>t or dt%2!=d%2:
        n=n+1
    else:
        t0=t
        x0=x
        y0=y
if n>=1:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		// TODO 自動生成されたメソッド・スタブ
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		for(int k = n-1; k >= 0; k--)
			if (k != 0) System.out.print(a[k] + " ");
			else System.out.println(a[k]);
	}
}


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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n;
    string a,b,c;
    cin>>n;
    cin>>a>>b>>c;
    int count =0;
    for(int i=0;i<n;++i){
        if(a[i] == b[i]  && b[i] == c[i]){
            continue;
        }else if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i]){
            count++;
        }else{
            count += 2;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void){
	string s;
	cin>>s;
	int ans(0);
	char last_char = s[0];
	for(int i(1);i<s.size();i++){
		if(last_char != s[i]){
			last_char = s[i];
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> N;
  rep(i,1,N+1){
    string S=to_string(i);
    if(S.size()%2==1)D++;
  }
  Out(D);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	string s,no="zyxwvutsrqponmlkjihgfedcba",ans="";
	cin>>s;
	map<char,ll>check;
	int itr;
	if(s==no){
	    cout<<-1<<endl;
	    return 0;
	}
	for(int i=0;i<s.length();i++){
		check[s[i]]++;
	}
	char key='#';
	for(int i=0;i<='z'-'a';i++){
		if(check['a'+i]==0){
			key='a'+i;
			break;
		}
	}
	if(key=='#'){
	string cmp=s;
	next_permutation(s.begin(),s.end());
		for(int i=0;i<s.length();i++){
			if(cmp[i]!=s[i]){
				ans+=s.substr(0,i+1);
				break;
			}
			
		}
	}
	else{
		ans=s+key;
	}
	cout<<ans<<endl;	
}


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



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

const int MAX_NUM = 2000000;
const int MAX_VALUE = 10000;

void counting_sort(int* array1, int* array2, int n)
{
    int k = -1, count[MAX_VALUE] = {};
    for(int i=0;i<n;++i)
    {
        ++count[array1[i]];
        k = max(k, array1[i]);
    }
    for(int i=0;i<k;++i)
    {
        count[i+1] += count[i];
    }
    for(int i=0;i<n;++i)
    {
        array2[--count[array1[i]]] = array1[i];
    }
}

int main()
{
    int n, array1[MAX_NUM], array2[MAX_NUM];
    cin >> n;
    for(int i=0;i<n;++i) cin >> array1[i];
    counting_sort(array1, array2, n);
    for(int i=0;i<n;++i)
    {
        if(i) cout << " ";
        cout << array2[i];
    }
    cout << endl;
}



Measured memory_bytes: 18760
#include <iostream>
#include <string>

using namespace std;
 
int main() {
	string s;
	cin >> s;
	int mozi[26];
	int i,x=0;
	for(i=0;i<26;i++){
		mozi[i]=0;
	}
	for(i=0;i<s.length();i++){
		mozi[s[i]-'a']=1;
	}
	for(i=0;i<26;i++){
		if(mozi[i]==0){
			cout << (char)(i+'a')<<endl;
			x += 1;
			break;
		}
	}
	if(x==0){
		cout << "None" << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define vi vector < ll  int >
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007
    using namespace std;

void solve()
{
 ll i,j=1,k,n,m=0,f,s=0,x,c=1,t;
 cin>>n>>m;
vector< string > g(n);
rep(i,0,n) cin>>g[i];
vector < vector < ll > > dp(n,vector < ll > (m));
dp[0][0]=(g[0][0]=='#'?1:0);
rep(i,0,n)
{
    rep(j,0,m)
    {
        if(i>0 and !j)
        {   if(g[i][j]=='.' or g[i-1][j]=='#')
            dp[i][j]=dp[i-1][j];
            else dp[i][j]=dp[i-1][j]+1;
        }
        else if(!i and j>0)
        {
            if(g[i][j]=='.' or g[i][j-1]=='#')
                dp[i][j]=dp[i][j-1];
            else dp[i][j]=dp[i][j-1]+1;
        }
        else if(i>0 and j>0)
        {
            if(g[i][j]=='.')
            {
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            }
            else
            {
                if(g[i-1][j]=='.' and g[i][j-1]=='.') dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
                else if(g[i-1][j]=='#' and g[i][j-1]=='.') dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1);
                else if(g[i-1][j]=='.' and g[i][j-1]=='#') dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]);
                else dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            }
        }
        //cout<<dp[i][j]<<" ";
    }
    //cout<<endl;
}
cout<<dp[n-1][m-1];
}


 //}

    signed main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
         //cin>>t;
        while(t--)
        solve();
    }


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  int r,c,i,j;
  static int array[101][101];
    scanf("%d %d",&r,&c);
    for(i = 0 ;i <= r ; i++)
    {
        for(j = 0;j < c; j++)
        {
            scanf("%d",&array[i][j]);
            printf("%d ",array[i][j]);
            array[i][c] += array[i][j];
            array[r][j] += array[i][j];
        }
        printf("%d\n",array[i][c]);
    }
}


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

using namespace std;

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

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

int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 0 && m == 0) break;
    vector<int> p(n);
    REP(i, n) cin >> p[i];
    sort(ALL(p));
    reverse(ALL(p));
    int ans = 0;
    REP(i, n) {
      if ((i + 1) % m == 0) continue;
      ans += p[i];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main() {
  int N; cin >> N;
  long a =1,b =1;
  
  for (int i =0; i<N; i++) {
    long T,A; cin >> T >> A;
    long tmpT = a/T, tmpA = b/A;
    long k = max(max((long)1,tmpT), max((long)1,tmpA));
    while (T * k < a || A * k < b) k++;
    a = T * k; b = A * k;
  }
  cout << a + b << endl;
}

Measured memory_bytes: 3612
#include <cmath>
#include <iostream>
#include <string>
#include <time.h>
#include <stdio.h>
using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c)
    {
        printf("%d %d %d\n", a, b, c);
    }
    else if (b < a && a <= c)
    {
        printf("%d %d %d\n", b, a, c);
    }
    else if (b <= c && c < a)
    {
        printf("%d %d %d\n", b, c, a);
    }
    else if (c < a && a <= b)
    {
        printf("%d %d %d\n", c, a, b);
    }
    else if (c <= a && a < b)
    {
        printf("%d %d %d\n", c, a, b);
    }
    else if (c < b && b < a)
    {
        printf("%d %d %d\n", c, b, a);
    }
}


Measured memory_bytes: 3116
/******Old_school_@23******/
/******Why_would_a_compiler_lie?******/
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back 
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld d,t,s; cin>>d>>t>>s;
      lld ans=s*t;
      if(ans>=d)  cout<<"Yes\n";
      else  cout<<"No";
}


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

int main(){
	int n; cin >> n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=0;i<n;i++) cin >> b[i];
	vector<long long> bits(30,0);
	for(int k=0;k<bits.size();k++){
		long long T=1<<k;
		vector<int> ta(n),tb(b);
		for(int i=0;i<n;i++) {
			ta[i]=a[i]%(T*2);
			tb[i]=b[i]%(T*2);
		}
		sort(tb.begin(),tb.end());
		for(int i=0;i<n;i++){
			auto it1=lower_bound(tb.begin(),tb.end(),T-ta[i]);
			auto it2=lower_bound(tb.begin(),tb.end(),2*T-ta[i]);
			auto it3=lower_bound(tb.begin(),tb.end(),3*T-ta[i]);
			auto it4=lower_bound(tb.begin(),tb.end(),4*T-ta[i]);
			bits[k]+=(it2-it1)+(it4-it3);
		}
	}
	int ans=0;
	for(int k=0;k<bits.size();k++){
		ans+=((bits[k]%2)<<k);
	}
	cout << ans << endl;
}


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

function main()
	n = readline() |> parseInt
	d = readline() |> split |> parseMap
	d = sort(d)
  	println(d[div(n,2)+1]-d[div(n,2)])
end

main()


Measured memory_bytes: 166048
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

int match(long long &x, long long &y, string t, string h)
{
    if (t > h)
    {
        x += 3;
    }
    else if (h > t)
    {
        y += 3;
    }
    else
    {
        x++;
        y++;
    }
    return 0;
}

int main()
{
    long long c, x = 0, y = 0;
    cin >> c;
    for (int i = 0; i < c; i++)
    {
        string t, h;
        cin >> t >> h;
        match(x, y, t, h);
    }
    cout << x  << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
 
int main() {
    string S;
    cin >> S;
    if(S.at(1)=='R'){
        S.at(1)='B' ;
    }
    else{
        S.at(1) ='R';
    }
    cout << S << endl;
}

Measured memory_bytes: 3588
def keisan(lis):
    ans =abs(lis[0]-A)
    ans += abs(lis[1]-B)
    ans += abs(lis[2]-C)
    return ans

N,A,B,C =[int(i)for i in input().split()]
l =[int(input())for _ in range(N)]

answ = 10000

for i in range(4**N):
    len =[0]*4
    wa = 0
    for j in range(N):
        amari = i % 4
        i = i//4
        if amari != 3 and len[amari]!=0:
            wa += 10
        len[amari] += l[j]

    if len[0]*len[1]*len[2] != 0:
        wa += keisan(len)
        if wa < answ:
            answ = wa
print(answ)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k - 1] << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> xy_t; 
xy_t p[22];
char c;
double x, y;
double sum;
int n;
int main()
{
	sum=0.0;
	n=0;
	//while(scanf("%lf,%lf", &x, &y)!=EOF)
	while(cin >> x >> c >> y)
	{
		n++;
		p[n]=xy_t(x, y);
	}
	p[n+1]=p[1];
	for(int i=1; i<=n; i++)
	{
		sum+=(conj(p[i])*p[i+1]).imag()/2;
	}
	cout << abs(sum) << endl;
	return 0;
}

Measured memory_bytes: 3276
W,H,N = map(int,input().split())
xya = []
hx = W
lx = 0
hy = H
ly = 0
for i in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        lx = max(lx,x)
    if a == 2:
        hx = min(hx,x)
    if a == 3:
        ly = max(ly,y)
    if a == 4:
        hy = min(hy,y)
print(max(0,max(0,(hx-lx))*max(0,(hy-ly))))

Measured memory_bytes: 3064