akhauriyash/Code-Regression huggingface dataset:
#include <cstdint>
#include <iostream>

uint64_t gcd(uint64_t b, uint64_t d) {
  if (b < d)
    return gcd(d, b);
  if (b % d)
    return gcd(d, b % d);
  return d;
}

int main() {
  uint64_t A, B, C, D;
  int T;
  std::cin >> T;
  for (int i = 0; i < T; ++i) {
    std::cin >> A >> B >> C >> D; /*
     bool succ = true;
     for (uint64_t n = 0; n < B; ++n) {
       if ((A + n * D) % B > C) {
         succ = false;
         break;
       }
     }*/
    auto m = A % B + (B - A % B) / gcd(B, D) * gcd(B, D);
    if (A < B || B > D || A % B > C || C + gcd(B, D) < B)
      std::cout << "No" << std::endl;
    else
      std::cout << "Yes" << std::endl; /*
       if (succ)
         std::cout << "Yes" << std::endl;
       else
         std::cout << "No" << std::endl;*/
  }
  return 0;
}


Measured memory_bytes: 256
'''A - Transfer
https://atcoder.jp/contests/abc136/tasks/abc136_a

>>> main(6, 4, 3)
1
>>> main(8, 3, 9)
4
>>> main(12, 3, 7)
0
'''


def main(a, b, c):
    print(max(c - (a - b), 0))


if __name__ == '__main__':
    a, b, c = map(int, input().split(' '))
    main(a, b, c)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  char s[100001];
  cin >> s;
  if(s[0] == s[1]){
    cout << 1 << " " << 2 << endl;
    return 0;
  }
  for(int i=2; i<strlen(s); i++){
    if(s[i]==s[i-1]){
      cout << i << " " << i+1 << endl;
      return 0;
    }else if(s[i]==s[i-2]){
      cout << i-1 << " " << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>

int main (int argc, char const *argv[])
{
    char S[(int)2e5 + 1], T[(int)2e5 + 1];
    char v['z' - 'a' + 1] = {0};
    size_t len;

    gets(S);
    gets(T);

    len = strlen(S);

    for (int i = 0; i < len; i++) {
        if (v[S[i] - 'a'] == 0) {
            v[S[i] - 'a'] = T[i];
        } else {
            if ((v[S[i] - 'a']) != T[i]) {
                puts("No");
                return 0;
            }
        }
    }

    for (int i = 0; i < ('z' - 'a' + 1); i++) {
        for (int j = (i + 1); j < ('z' - 'a' + 1); j++) {
            if (v[i] == 0) continue;
            if (v[i] == v[j]) {
                puts("No");
                return 0;
            }
        }
    }

    puts("Yes");
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int inputNum = in.nextInt();
		System.out.println(getNowShakkin(inputNum));
	}

	public static int getNowShakkin(int weekInterval) {
		double result = 100;

		for (int i = 0; i < weekInterval; i++) {
			result = result*1.05;
			result = (Math.ceil((double) result));
		}

		return (int)result * 1000;
	}
}

Measured memory_bytes: 25948
from itertools import*
N,K,Q,*A=map(int,open(0).read().split())
s=sorted
print(min((s(sum((v[:max(0,-~(len(v)-K))]for v in(k*s(v)for k,v in groupby(A,lambda a:a>=Y))),[]))[Q-1:]or[2e9])[0]-Y for Y in A))

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

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;

using ll =long long;

using namespace std;

signed main() {
    int N, x;cin >> N >> x;
    vector<int> v;
    for(int i = 0;i < N;i++){
        int a;cin >> a;
        v.push_back(a);
    }
    ll ans = 0;
    if(v.front() >= x){
        ans += v.front() - x;
        v.front() = x;
    }
    for(int i = 1;i < N;i++){
        if(v[i - 1] + v[i] >= x){
            ans += v[i] + v[i - 1] - x;
            v[i] -= v[i] + v[i - 1] - x;
        }
    }
    cout<<ans<<endl;
}




Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
 
struct Edge {
  int v, w;
};
 
typedef vector<vector<Edge> > Graph;
typedef pair<int, int> Pair;
 
const int INF = 1<<28;
 
int n, m, N, L;
Graph g;
 
vector<int> dijkstra(int src, int scost) {
  vector<int> cost(n, INF);
  priority_queue<Pair, vector<Pair>, greater<Pair> > que;
  cost[src] = scost;
  que.push(Pair(scost, src));
  while(que.size()) {
    const Pair s = que.top(); que.pop();
    if(cost[s.second] < s.first) continue;
    for(int i = 0; i < g[s.second].size(); ++i) {
      const Edge &e = g[s.second][i];
      if(s.first && !e.w) continue; //
      const Pair t(s.first + e.w, e.v);
      if(cost[t.second] <= t.first) continue;
      cost[t.second] = t.first;
      que.push(t);
    }
  }
  return cost;
}
 
struct State {
  int v, f, cost;
  bool operator < (const State &s) const {
    return cost > s.cost;
  }
};
 
int main() {
  int T; cin >> T;
  while(T--) {
    cin >> n >> m;
    ++n;
    cin >> N >> L;
    g = Graph(n);
    for(int i = 0; i < m; ++i) {
      int a, b; char c;
      cin >> a >> b >> c;
      g[a].push_back((Edge){b, c == 'N'});
      g[b].push_back((Edge){a, c == 'N'});
    }
    vector<int> fromN = dijkstra(N, 1);
    vector<int> fromL = dijkstra(L, 0);
    vector<int> fromS = dijkstra(0, 0);
    if(fromL[0] == 0) {
      cout << 0 << endl;
      continue;
    }
    int res = INF;
    for(int i = 0; i < n; ++i) {
      res = min(res, fromN[i] + fromL[i] + fromS[i] - 1);
    }
    cout << res << endl;
  }
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int ans = 0;
  
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    
    int distance;
    if (x <= K) {
      distance = K - x;
    } else {
      distance = x - K;
    }
    
    if (x <= distance) {
      ans += 2 * x;
    } else {
      ans += 2 * distance;
    }
  }
  
  cout << ans << endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    unsigned int result = 0,x;
    vector<unsigned int> A(N);
    for(int i = 0 ; i < N;i++){
        cin >> A[i];
        result ^= A[i];
    }
    for(auto i : A){
        cout << (result ^ i) << "\t";
    }
    return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b;
  cin >> a >> b;
  rep(i, 0, a) {
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}


Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	std::string C;
	std::cin >> C;
	++C[0];
	std::cout << C << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
const int maxn=1000010;
int prime[maxn];
bool isprime[maxn];

int prime_cnt(int n)
    {
        int p=0;
        memset(isprime,true,sizeof(isprime));
        isprime[0]=false;
        isprime[1]=false;
        for (int i=2;i<=n;i++)
            {
                if(isprime[i])
                    {
                        prime[p++]=i;
                        for (int j=2*i;j<=n;j+=i)
                            isprime[j]=false;
                    }
            }
        return p;
    }
int main()
    {
        int n;
        while (cin>>n)
            {
                cout<<prime_cnt(n)<<endl;
            }
        return 0;
    }



Measured memory_bytes: 4380
A = [tuple(map(int, input().split())) for i in range(3)]
for x, y in zip(A, A[1:]):
	if not (y[0] - x[0] == y[1] - x[1] == y[2] - x[2]):
		print("No")
		exit()
for x in range(2):
	if not (A[0][x+1] - A[0][x] == A[1][x+1] - A[1][x] == A[2][x+1] - A[2][x]):
		print("No")
		exit()
if A[0][0] + A[2][2] != A[0][2] + A[2][0]:
	print("No")
	exit()
print("Yes")

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
	int n,m;
	string s,s2;
	cin>>n;
if(n<1000)
	cout<<"ABC"<<endl;
else
	cout<<"ABD"<<endl;
  return 0;
}


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

//GCD,LCM
ll gcd(ll a, ll b){ return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){ return a/gcd(a,b)*b;}

int main()
{
    int N,S[110]={},ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>S[i];
        ans+=S[i];
    }

    if(ans%10==0){
        sort(S,S+N);
        int f=0;
        for(int i=0;i<N;i++){
            if(S[i]%10!=0){
                ans-=S[i];
                f=1;
                break;
            }
        }
        if(f==0)ans=0;
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll a[1000005],b[1000005];

int main()
{
    speed;

    ll n,ans=0;
    cin>>n;

    for(int i=1;i<=n;i++)
        cin>>a[i];

    sort(a+1,a+n+1);

    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
            b[a[i]]=1;
    }

    for(int i=1;i<=n;i++)
    {
        if(!b[a[i]])
            ans++;

        if(a[i]!=a[i-1])
        {
            for(int j=2*a[i];j<=1000005;j+=a[i])
                b[j]=1;
        }
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 13008
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,X,Y; cin>>N>>X>>Y;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans;
  if(N==1) ans=abs(A[0]-Y);
  else ans=max(abs(A[N-1]-A[N-2]),abs(A[N-1]-Y));
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    N, M = list(map(int, input().split(' ')))
    accepted = [0 for _ in range(N)]
    wa_count = [0 for _ in range(N)]
    for _ in range(M):
        p, S = input().split(' ')
        p = int(p) - 1
        if accepted[p] == 1:
            continue
        # non-accepted cases
        if S == 'WA':
            wa_count[p] += 1
        else:
            accepted[p] = 1
    score = sum(accepted)
    penalty = sum([is_ac * wa for is_ac, wa in zip(accepted, wa_count)])
    print('{} {}'.format(score, penalty))


if __name__ == '__main__':
    main()

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

int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  int ans = 0;
  for (int i=0; i<N; i++) {
    long long num = A[i];
    int cnt = 1;
    while (num == A[i+1] && i+1 < N) {
      cnt++;
      i++;
    }

    if (cnt % 2 != 0)
      ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

int N;
vector<vector<ll> > s;
vector<ll> ai(16,20e10);

int dfs(vector<ll> & di, int ni, int nn){
  if(ni==N){
    ll ans=0;
    for(int i=0;i<N;i++) ans+=s[i][2]*di[i];
    ai[nn]=min(ai[nn],ans);
    return 0;
  }
  {
    vector<ll> dt(N);
    copy(di.begin(),di.end(),dt.begin());
    dfs(dt,ni+1, nn);
  }
  for(int i=0;i<2;i++){
    vector<ll> dt(N);
    copy(di.begin(),di.end(),dt.begin());
    for(int j=0;j<N;j++) dt[j]=min(dt[j],abs(s[j][i]-s[ni][i]));
    dfs(dt,ni+1,nn+1);
  }
  return 0;
}

int main(){
  cin >> N;
  s.resize(N, vector<ll>(3));

  for(int i=0;i<N;i++) cin >> s[i][0] >> s[i][1] >> s[i][2];

  vector<ll> d(N,20000);

  for(int i=0;i<N;i++){
    d[i]=min(abs(s[i][0]),abs(s[i][1]));
  }

  dfs(d,0,0);

  for(int i=0;i<N+1;i++){
    cout << ai[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int infint = 1e9;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e3 + 7;
int n, a[MAXN];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < 2 * n; i++)
		cin >> a[i];
	sort(a, a + 2 * n);
	ll sum = 0;
	for (int i = 0; i < 2 * n; i += 2)
		sum += a[i];
	cout << sum;
}

Measured memory_bytes: 256
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N = int(input())
    #C:所要時間,S:開始後,F:間隔
    CSF = [list(map(int,input().split())) for _ in range(N-1)]

    for i in range(N):
        t = 0
        for c,s,f in CSF[i:]:
            if t<=s:
                t=s
            else:
                t=((t-s)//f if (t-s)%f==0 else (t-s)//f+1)*f+s
            t+=c
        print(t)

if __name__=='__main__':
    main()

Measured memory_bytes: 9092
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;


int main() 
{
    int w[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
    int n;
    while(cin >> n){
        vector<int> v;
        for(int i = 9; i >= 0; i--){
            if(n>=w[i]){
                v.push_back(w[i]);
                n-=w[i];
            }
        }
        reverse(v.begin(),v.end());
        for(int i = 0; i < v.size(); i++){
            cout << v[i];
            if(i!=v.size()-1){
                cout << ' ';
            }
        }
        cout << endl;
    }
}




Measured memory_bytes: 3112
#include <bits/stdc++.h>
//#include "Header.h"

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,m;
    cin>>n>>m;
    cout<<(2*m-n);
    
//code ends
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.size();++i){
		if(s[i]=='?'){
			cout<<'D';
		}
		else{
			cout<<s[i];
		}
	}
	cout<<'\n';
	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  int h,n; cin>>h>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++){
    h=h-a[i];
  }
  if(h>0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 640
/* AtCoder Panasonic Programming Contest 2020. Task B. */
#include <bits/stdc++.h>

using namespace std;

#define COUT_PRECISION 10

namespace abreto {

typedef long long int ll;

void main(void) {
    ll H, W;

    cin >> H >> W;

    if (1 == H || 1 == W) {
        cout << "1\n";
        return;
    }

    ll line_odd = (W + 1) >> 1;
    ll line_even = W >> 1;

    ll n_lines_odd = (H + 1) >> 1;
    ll n_lines_even = H >> 1;

    ll total = line_odd * n_lines_odd + line_even * n_lines_even;

    cout << total << '\n';
}

}

int main(void) {
    cin.sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(COUT_PRECISION);
    abreto::main();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A == B)
		cout << "Draw" << endl;
	else if (A == 1)
		cout << "Alice" << endl;
	else if (A > B&& B != 1)
		cout << "Alice" << endl;
	else
		cout << "Bob" << endl;
}

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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back

int n, k;
vector<vector<int>> road, G;
vector<int> c, r;

void make_graph(int s){
    vector<int> d(n, 1 << 30);
    queue<int> q;
    q.push(s);
    d[s] = 0;
    while(q.size()){
        int v = q.front();
        q.pop();
        if(d[v] == r[s]) continue;
        rep(j, road[v].size()){
            int to = road[v][j];
            if(d[to] == 1 << 30){
                q.push(to);
                d[to] = d[v] + 1;
                G[s].pb(to);
            }
        }
    }
}

int dijkstra(int from, int to){
    struct state {
        int v, d;
        bool operator<(const state& s) const{
            return d>s.d;
        }
    };

    vector<int> d(n, 1 << 30);
    vector<bool> vis(n, false);
    priority_queue<state> q;

    d[from] = 0;
    q.push({from, 0});

    while(q.size()){
        state s = q.top(); q.pop();
        if(d[s.v]<s.d) continue;
        vis[s.v] = true;
        rep(i, G[s.v].size()){
            int to = G[s.v][i];
            int cost = c[s.v];
            if(!vis[to] && d[to]>s.d + cost){
                d[to] = s.d + cost;
                q.push({to, d[to]});
            }
        }
    }
    return d[to];
}

int main(){
    cin >> n >> k;
    road.resize(n);
    G.resize(n);
    c.resize(n);
    r.resize(n);
    rep(i, n){
        int a, b; cin >> a >> b;
        c[i] = a; r[i] = b;
    }
    rep(i, k){
        int a, b; cin >> a >> b;
        road[a - 1].pb(b - 1);
        road[b - 1].pb(a - 1);
    }
    rep(i, n) make_graph(i);
    cout << dijkstra(0, n - 1) << endl;
}

Measured memory_bytes: 68848
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int i=1;
		do{
			int x=i;
			if(x%3==0){
				System.out.print(" "+i);
			}
			else{
				while(true){
					if(x%10==3){
						System.out.print(" "+i);
						break;
					}
					x/=10;
					if(x!=0) continue;
					else break;
				}
			}
		}while(++i<=n);
		System.out.println();
	}
}

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

int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;

  if (abs(a-c)<=d) {
    cout << "Yes" << endl;
  }
   else if(abs(a-b)<=d&&abs(b-c)<=d){
  cout << "Yes" << endl;
   }
  else{
    cout<<"No"<<endl;
  }
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    set<string> S;
    rep(i,n){
        string s; cin>>s;
        S.ins(s);
    }
    cout<<S.size()<<"\n";
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/27  Problem: ABC 125 D / Link: http://abc125.contest.atcoder.jp/tasks/abc125_d  ----- */

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

	LL N; cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	VVL dp(N + 1, VL(2, -LINF));
	dp[2][0] = a[0]+a[1];
	dp[2][1] = -a[0] - a[1];

	auto chmax = [](LL& a, const LL b) {
		a = max(a, b);
	};

	FOR(i, 2, N) {

		{
			chmax(dp[i + 1][0], dp[i][0] + a[i]); // 0 
			chmax(dp[i + 1][1], dp[i][0] - a[i] - 2 * a[i - 1]);
		}

		{
			chmax(dp[i + 1][0], dp[i][1] + a[i]); // 1
			chmax(dp[i + 1][1], dp[i][1] - a[i] + 2 * a[i - 1]);
		}
	}

	LL ans = max(dp[N][0], dp[N][1]);


	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int w=0,e=0;
    rep(i,n){
        if(s[i]=='W')w++;
        else e++;
    }
    
    int ans = n,aw=0,ae=0;
    rep(i,n){
        if(s[i]=='W'){
            w--;
            ans = min(ans,e+aw);
            aw++;
        }else{
            e--;
            ans = min(ans,e+aw);
            ae++;
        }
        //cout <<w<<" "<<aw<<" "<<e<<" "<<ae<<endl;       
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 900
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;

			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			//アルゴリズム1
			int x = a + b;
			int y = b + c;
			int z = c + a;

			//x、y、zの最小値
			s = x;
			if (y < s) s = y;
			if (z < s) s = z;

			//アルゴリズム2
			//a, b, cの最大値を求める			
			//int m = a;
			//if (b > m) m = b;
            //if (c > m) m = c;
			//最大値を除く金額の和
			//s = a + b + c - m;




			Console.WriteLine(s);

			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 27456
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N, M = map(int, line_input())
    ks = [[int(i) for i in line_input()] for j in range(M)]
    p = [int(i) for i in line_input()]
    ans = 0
    for i in range(2 ** N):
        onoff = str(format(i, "b").zfill(N))
        for m in range(M):
            onnum = 0
            for k in ks[m][1:]:
                if onoff[k-1] == "1": onnum += 1
            if onnum % 2 != p[m]: break
        else: ans += 1
    print(ans)
        
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3440
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;
struct edge { ll from; ll to; ll cost; };

void err() {
	cout << "0" << endl;
	exit(0);
}
int main() {
	ll n;
	cin >> n;
	vector<ll>t;
	vector<ll>a;

	rep(i, 0, n) {
		ll T;
		cin >> T;
		t.pb(T);
	}
	rep(i, 0, n) {
		ll A;
		cin >> A;
		a.pb(A);
	}


	//0:確定1:未確定
	vector<pair<ll,ll>>td;
	vector<pair<ll,ll>>ad;

	rep(i, 0, n) {
		if (i == 0) {
			td.pb({t[i],0});
		}
		else {
			if (t[i] > t[i - 1]) {
				td.pb({ t[i],0});
			}
			else {
				td.pb({t[i],1});
			}
		}
	}



	rrep(i, n - 1, 0) {
		if (i == n - 1) {
			ad.pb({a[i],0});
		}
		else {
			if (a[i] > a[i + 1]) {
				ad.pb({a[i],0});
			}
			else {
				ad.pb({a[i],1});
			}
		}
	}
	reverse(all(ad));


	ll ans = 1;
	rep(i, 0, n){
		ll tf = td[i].first;
		ll ts = td[i].second;
		ll af = ad[i].first;
		ll as = ad[i].second;
		if (ts == 1 && as == 1) {
			ans *= min(tf, af);
		}else if (ts == 0 && as == 1) {
			if (af < tf) {
				err();
			}
		}
		else if (ts == 1 && as == 0) {
			if (tf < af) {
				err();
			}
		}
		else {
			if (tf != af) {
				err();
			}
		}
		ans %= MOD;
	}


	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=1<<29,MOD=1e9+7;

int main(){
	int n,m; cin>>n>>m;
	int mul=pow(2,m);
	cout<<(n-m)*100*mul+1900*m*mul<<endl;
	return 0;
}


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

int main(){
  int a[3];
  int cou=0;
  for(int i=0;i<3;i++){
    cin >> a[i];
    if(a[i] == 1){
      cou++;
    }
  }
  if(a[2] == 1 || cou == 2){
    cout << "Open" << endl;
  }
  else {
    cout << "Close" << endl;
  }
}

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


int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i,s.size()) {
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  char s[4]; 
  int count =0;
  for(int i=0;i<3;i++){
  cin >> s[i];
    if(s[i]=='R'){
      count++;
    }
  }
 
   
    if(s[0]=='R'&&s[1]=='S'&&s[2]=='R'){
      count =1;
    }
    cout << count <<endl;
}


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

c, s, f = [], [], []
for _ in range(n-1):
    x,y,z = map(int,input().split())
    c.append(x)
    s.append(y)
    f.append(z)

anss =[]
for i in range(n-1):
    tmp = 0
    for j in range(i, n-1):
        for k in range(10**8):
            if tmp <= s[j] + f[j] * k:
                tmp = s[j] + f[j] * k + c[j]
                break
    else:
        anss.append(tmp)
else:
    anss += [0]

for ans in anss:
    print(ans)

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

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

	long long X, Y, A, B, C;
	scanf("%lld %lld %lld %lld %lld", &X, &Y, &A, &B, &C);

	vector<long long> P(A);
	for (int i = 0; i < A; i++) {
		scanf("%lld", &P[i]);
	}
	sort(P.begin(), P.end());
	reverse(P.begin(), P.end());
	// for (auto i : P) {
	// printf("%lld ", i);
	// }
	// printf("\n");

	vector<long long> Q(B);
	for (int i = 0; i < B; i++) {
		scanf("%lld", &Q[i]);
	}
	sort(Q.begin(), Q.end());
	reverse(Q.begin(), Q.end());
	// for (auto i : Q) {
	// printf("%lld ", i);
	// }
	// printf("\n");

	vector<long long> R(C);
	for (int i = 0; i < C; i++) {
		scanf("%lld", &R[i]);
	}
	sort(R.begin(), R.end());
	reverse(R.begin(), R.end());
	// for (auto i : R) {
	// printf("%lld ", i);
	// }
	// printf("\n");

	vector<long long> PQR = {};
	// for (auto i : PQR) {
	// printf("%lld ", i);
	// }
	// printf("\n");
	PQR.insert(PQR.end(), P.begin(), P.begin() += X);
	// for (auto i : PQR) {
	// printf("%lld ", i);
	// }
	// printf("\n");
	PQR.insert(PQR.end(), Q.begin(), Q.begin() += Y);
	// for (auto i : PQR) {
	// printf("%lld ", i);
	// }
	// printf("\n");

	PQR.insert(PQR.end(), R.begin(), R.end());

	sort(PQR.begin(), PQR.end());
	reverse(PQR.begin(), PQR.end());

	// for (auto i : PQR) {
	// printf("%lld ", i);
	// }
	// printf("\n");

	/*	long long sum = accumulate(PQR.begin(), PQR.begin() += (X + Y), 0);*/

	long long sum = 0;
	for (int i = 0; i < X + Y; i++) {
		sum += PQR[i];
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 6720
use input::*;
use std::cmp::*;
use std::collections::{HashMap, HashSet};
use std::io::*;
use std::num::*;
use std::str::*;

mod input {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn str() -> String {
        read()
    }
    pub fn s() -> Vec<char> {
        str().chars().collect()
    }
    pub fn i() -> i64 {
        read()
    }
    pub fn u() -> usize {
        read()
    }
    pub fn f() -> f64 {
        read()
    }
    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }
    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }
    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }
    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}

fn main() {
    let (h, w, k) = (u(), u(), u());
    let a = cmap(h);

    let mut sum = vec![vec![0; w]; h];

    let mut before = 1;
    for i in 0..h {
        if !a[i].contains(&'#') {
            continue;
        }

        let mut c = 0;
        for j in 0..w {
            if a[i][j] == '#' {
                c += 1;
                if c > 1 {
                    before += 1;
                }
            }
            sum[i][j] = before;
        }
        before += 1;
    }

    let mut stack = 0;
    let mut last = vec![0; w];
    for i in 0..h {
        if sum[i][0] == 0 {
            if last[0] == 0 {
                stack += 1;
            } else {
                for j in 0..w {
                    print!("{} ", &last[j]);
                }
                println!("");
            }
        } else {
            for j in 0..w {
                print!("{} ", &sum[i][j]);
            }
            println!("");
            last = (*sum[i]).to_owned();
            while stack > 0 {
                for j in 0..w {
                    print!("{} ", &last[j]);
                }
                println!("");
                stack -= 1;
            }
        }
    }
}


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

#define Gene template< class
#define Rics printer& operator,
Gene c> struct rge{c b, e;};
Gene c> rge<c> range(c i, c j){ return {i, j};}
struct printer{
    ~printer(){cerr<<endl;}
    Gene c >Rics(c x){ cerr<<boolalpha<<x; return *this;}
    Rics(string x){cerr<<x;return *this;}
    Gene c, class d >Rics(pair<c, d> x){ return *this,"(",x.first,", ",x.second,")";}
    Gene ... d, Gene ...> class c >Rics(c<d...> x){ return *this, range(begin(x), end(x));}
    Gene c >Rics(rge<c> x){
        *this,"["; for(auto it = x.b; it != x.e; ++it)
            *this,(it==x.b?"":", "),*it; return *this,"]";}
};
#define debug() cerr<<"LINE "<<__LINE__<<" >> ", printer()
#define dbg(x) "[",#x,": ",(x),"] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int my_rand(int l, int r) {
    return uniform_int_distribution<int>(l, r) (rng);
}


int main() {
//    freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> a(n);
    long long sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if(n == 1) {
        cout << "YES" << endl;
        return 0;
    }
    long long each = 1ll*n*(n+1)/2;
    if(sum % each > 0) {
        cout << "NO" << endl;
        return 0;
    }
    else {
        if(n == 2) {
            if(2 * min(a[0], a[1]) <= max(a[0], a[1])) {
                cout << "YES" << endl;
            }
            else {
                cout << "NO" << endl;
            }
            return 0;
        }
        long long tot_moves = sum/each;
        for(int i = 0; i < n; i++) {
            long long dif = a[(i+1)%n] - a[i];
            debug(), dbg(dif);
            if(tot_moves - dif < 0) {
                cout << "NO" << endl;
                return 0;
            }
            if((tot_moves - dif) % n > 0) {
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    cout << "YES" << endl;
}





Measured memory_bytes: 3712
int check[30];

int c, n, a;

int main() {
  n = 0;
  while (1) {
    c = getchar_unlocked();
    if ('0' <= c && c <= '9')
      n = n * 10 + c - '0';
    else
      break;
  }

  int xor_sum = 0;
  for (int i = 0; i < n; i++) {
    a = 0;
    while (1) {
      c = getchar_unlocked();
      if ('0' <= c && c <= '9')
        a = a * 10 + c - '0';
      else
        break;
    }
    xor_sum ^= a;
    a = a ^ (a - 1);

    switch (a) {
    case 1073741823:
      check[29] = 1;
      break;
    case 536870911:
      check[28] = 1;
      break;
    case 268435455:
      check[27] = 1;
      break;
    case 134217727:
      check[26] = 1;
      break;
    case 67108863:
      check[25] = 1;
      break;
    case 33554431:
      check[24] = 1;
      break;
    case 16777215:
      check[23] = 1;
      break;
    case 8388607:
      check[22] = 1;
      break;
    case 4194303:
      check[21] = 1;
      break;
    case 2097151:
      check[20] = 1;
      break;
    case 1048575:
      check[19] = 1;
      break;
    case 524287:
      check[18] = 1;
      break;
    case 262143:
      check[17] = 1;
      break;
    case 131071:
      check[16] = 1;
      break;
    case 65535:
      check[15] = 1;
      break;
    case 32767:
      check[14] = 1;
      break;
    case 16383:
      check[13] = 1;
      break;
    case 8191:
      check[12] = 1;
      break;
    case 4095:
      check[11] = 1;
      break;
    case 2047:
      check[10] = 1;
      break;
    case 1023:
      check[9] = 1;
      break;
    case 511:
      check[8] = 1;
      break;
    case 255:
      check[7] = 1;
      break;
    case 127:
      check[6] = 1;
      break;
    case 63:
      check[5] = 1;
      break;
    case 31:
      check[4] = 1;
      break;
    case 15:
      check[3] = 1;
      break;
    case 7:
      check[2] = 1;
      break;
    case 3:
      check[1] = 1;
      break;
    case 1:
      check[0] = 1;
      break;
    }
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (check[bit] > 0) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1000000007;
using Graph = vector<vector<int>>;

signed main() {
  int N, M;
  cin >> N >> M;

  vector<int> H(N);
  for( int i = 0; i < N; i++ ) cin >> H.at(i);
  
  map<int, int> hi;
  for( int i = 0; i < M; i++ ){
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    if( hi.count(A) ) hi[A] = max(hi[A], H.at(B));
    else hi[A] = H.at(B);
    if( hi.count(B) ) hi[B] = max(hi[B], H.at(A));
    else hi[B] = H.at(A);
  }
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    if( hi.count(i) ){
      if( hi[i] < H.at(i) ) ans++;
    }else ans++;
  }
  cout << ans << endl;

}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
  }
  int ans = 0;
  rep2(i, 1, n-1) {
    if ((v[i - 1] < v[i] && v[i] < v[i+1]) ||
        (v[i - 1] > v[i] && v[i] > v[i+1])) {
      ans++; 
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    string b;
    int c1,c2,c3,c4,n;
    c1=c2=c3=c4=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b;
        if(b=="AC")
            c1++;
        else if(b=="WA")
            c2++;
        else if(b=="TLE")
            c3++;
        else
            c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;
    return 0;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define sz(a) (int)a.size()
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
}
template<typename T, typename U> static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
}
 
ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;} 

int n;
// vi adj[26];
string temp="abcdefghijklmnopqrstuvwxyz";
void find(string s,vi used,int pos){
	if(pos==n) {cout<<s<<endl;}
	// int last=26;
	else for(int i=0;i<26;i++){
		if(used[i]==0){
			used[i]=1;
			string t=s+temp[i];
			find(t,used,pos+1);
			break;
		}
		else{
			string t=s+temp[i];
			find(t,used,pos+1);
		}
	}

}
int solve(){
	// string s;cin>>s;
	cin>>n;
	// n=s.size();
	string s="a";
	vi used(26,0);
	used[0]=1;
	find(s,used,1);




    return 0;
}
signed main(){
    asdf
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


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


int main() {
    string S; cin >> S;
    int N = S.size();
    for(int i = 0; i < N-1; i++){
        if(S[i] == S[i+1]){
            cout << i+1 << " " << i+1+1 << endl;
            return 0;
        }
    }

    for(int i = 0; i < N-2; i++){
        if(S[i] == S[i+2]){
            cout << i+1 << " " << i+2+1 << endl;
            return 0;
        }
    }
    cout << -1 << " " << -1 << endl;



}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    string s,t; cin >> s >> t;
    ll cnt=0;
    REP(i,s.size()){
        if(s[i]!=t[i]) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3864
import itertools

H, W = map(int, input().split())
S = [input() for _ in range(H)]

SS = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
	for w in range(W):
		if '#' in S[h][w] : SS[h][w] = -1

for h in range(H):
	for w in range(W):
		if SS[h][w] == -1:
			for y, x in itertools.product([-1, 0, 1], [-1, 0, 1]):
				if 0 <= h+y < H and 0 <= w+x < W:
					if SS[h+y][w+x] != -1 :
						SS[h+y][w+x] += 1

for h in range(H):
	for w in range(W):
		if SS[h][w] == -1:print('#', end="")
		else : print(SS[h][w], end="")
	print()

Measured memory_bytes: 69540
def main():
  n,m=map(int,input().split())
  a=sorted(list(map(int,input().split())))
  bc=[list(map(int,input().split())) for _ in range(m)]
  for i in range(n):
    bc.append([1,a[i]])
  bc.sort(key=lambda x:x[1],reverse=True)
  ans,cnt=0,0
  for i in range(n):
    ans+=bc[i][0]*bc[i][1]
    cnt+=bc[i][0]
    if cnt>=n:
      ans-=(cnt-n)*bc[i][1]
      break
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 42940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	swap(a,b),swap(a,c);
	printf("%d %d %d\n",a,b,c);
	return 0;
}

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

constexpr int nax = 1e5;

int n;
int dp[nax][3];
int tab[nax][3];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> tab[i][j];

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
        {
            if (i == 0) dp[i][j] = tab[i][j];
            else
            {
                for (int k = 0; k < 3; ++k)
                    if (j != k)
                        dp[i][j] = max(dp[i][j], tab[i][j] + dp[i - 1][k]);
            }
        }

    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}) << '\n';
}

Measured memory_bytes: 2560
#include<bits/stdc++.h> 
#define ll long long
using namespace std; 
int main() { ll a,b,c,d=0, i,j,k,l;
    l=0;
    cin>>a;
    for(i=1;i<=a;i++)
     {
    for(j=1;j<=a;j++)
    {
    for(k=1;k<=a;k++)
    {
    c=__gcd(__gcd(i,j),k);d+=c;
                
    }
    }
    }cout<<d<<endl;
    }


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

const int maxn = 1010;
const int dx[] = {-1, 1, 0, 0}, dy[] = {0, 0, -1, 1};
int h, w;
char s[maxn][maxn];
bool vis[maxn][maxn];

int main() {
    scanf("%d %d", &h, &w);
    queue<tuple<int, int, int>> q;
    for (int i = 1; i <= h; i++) {
        scanf("%s", s[i] + 1);
        for (int j = 1; j <= w; j++) if (s[i][j] == '#') {
            q.push(make_tuple(i, j, 0)), vis[i][j] = 1;
        }
    }
    int ans = 0;
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        ans = max(ans, get<2>(p));
        int x = get<0>(p), y = get<1>(p);
        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 1 || nx > h || ny < 1 || ny > w || vis[nx][ny]) continue;
            q.push(make_tuple(nx, ny, get<2>(p) + 1)), vis[nx][ny] = 1;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 14352