akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
  int i,j;
  int c[3][3];
  for(i=0;i<3;i++)cin>>c[i][0]>>c[i][1]>>c[i][2];
  bool ans=true;
  for(i=0;i<2;i++){
    for(j=0;j<2;j++){
      if(c[i][j]-c[i][j+1]!=c[i+1][j]-c[i+1][j+1])ans=false;
      if(c[i][j]-c[i+1][j]!=c[i][j+1]-c[i+1][j+1])ans=false;
    }
  }
  cout << (ans?"Yes\n":"No\n");
  return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main()
{
    int x,a,b;
    //char s[101];
    // 整数の入力
    scanf("%d %d %d", &x,&a,&b);

	if (b <= a) {
		printf("delicious");
	} else if (b > a && b <= a + x) {
		printf("safe");
	} else {
		printf("dangerous");
	}
	//scanf("%s",s);
    return 0;
}

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

template<typename T>
struct WarshallFloyd {
    const T INF = numeric_limits<T>::max();
    int n;
    vector<vector<T>> d;
    WarshallFloyd(int n) : n(n), d(n, vector<T>(n, INF)) {
        for (int i = 0; i < n; i++) d[i][i] = 0;
    }
    void add_edge(int s, int t, T w, bool directed) {
        d[s][t] = min(d[s][t], w);
        if (directed) d[t][s] = min(d[t][s], w);
        for (int k : {s, t})
            for (int i = 0; i < n; i++) if (d[i][k] != INF)
                for (int j = 0; j < n; j++) if (d[k][j] != INF)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    bool has_neg_cycle() {
        for (int i = 0; i < n; i++) if (d[i][i] < 0) return true;
        return false;
    }
    bool in_shortest_path(int s, int t, T w) {
        return d[s][t] >= w;
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    for (int i = 0; i < m; i++) cin >> a[i] >> b[i] >> c[i], a[i]--, b[i]--;
    WarshallFloyd<int> wf(n);
    for (int i = 0; i < m; i++) wf.add_edge(a[i], b[i], c[i], true);
    int cnt = 0;
    for (int i = 0; i < m; i++) cnt += !wf.in_shortest_path(a[i], b[i], c[i]);
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N,M = map(int,input().split())
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
uf = UnionFind(N)
for _ in range(M):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)
print(uf.group_count() - 1)

Measured memory_bytes: 13252
import java.io.*;
import java.util.Arrays;

public class Main{
	public static void main(String[] args) throws IOException{ 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String sc = br.readLine();
		int n = Integer.parseInt(sc);
		int[][][] con = new int[4][3][10];
		for (int i = 0; i<n ; i++ ) {
			String line = br.readLine();
			String[] split = line.split(" ");
			int building = Integer.parseInt(split[0]);
			int floor = Integer.parseInt(split[1]);
			int rank = Integer.parseInt(split[2]);
			int mem = Integer.parseInt(split[3]);
			con[(building-1)][(floor-1)][(rank-1)] += mem;

		}
		for (int i = 0; i<4 ; i++ ) {
			for (int j = 0; j < 3  ;j++ ) {
				for (int k = 0; k < 10 ; k++ ) {
					if ( k == 9) {
						System.out.print(" " + con[i][j][k] +"\n");
					}else{

					System.out.print(" " +con[i][j][k]);
					}
				}
			}
			if (i < 3) {
			System.out.println("####################");
			}
		}
	}
}

Measured memory_bytes: 24544
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
int main(void){
    // Your code here!
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<char> J(N);//zが0の最初, aが1の最初
    if(S.at(0) == '0'){
                J.at(0) = 'z';
    }
    else{
        J.at(0) = 'a'; 
    }
    
    for(int i = 1; i < N; i++){
        if(S.at(i-1) == '0' && S.at(i) == '1'){
            J.at(i) = 'a';
        }
        else if(S.at(i-1) == '1' && S.at(i) == '0'){
            J.at(i) = 'z';
        }
        else{
            J.at(i) = S.at(i);
        }
    }
    
    vector<int> M(0);
    int before = 0;
    
    for(int i = 0; i < N; i++){
        if(i != 0 && (J.at(i) == 'a' || J.at(i) == 'z')){
            M.push_back(i - before);
            before = i;
        }
    
    }
    
    
    int y = 0;//0の数
    for(int i = 0; i < N; i++){
        if(J.at(i) == 'z'){
            y++;
        }
    }
    
    
    M.push_back(N-before);
    int M_size = M.size();
    M.push_back(0);
    M.push_back(0);
    M.push_back(0);
    M.push_back(0);
    M.push_back(0);
    M.push_back(0);
    
    int Ans = 0;
    
    bool l;
    l = (S.at(0) == '1');//一文字目が１なら真
    
    //1から始まる時
    if(l){
        
        
        for(int i = 0; i <= M_size - 2 * K; i++){
            int ans = 0;
            if(i % 2 == 1)continue;
            for(int j = i; j < 2 * K + 1 + i; j++){
                //cout << j;
                ans += M.at(j);
            }
            //cout << endl;
            Ans = max(ans, Ans);
            //if(ans == 7)cout << M_size - 2 * K << endl;
        }
        
    }
    else{
        
        for(int i = 0; i <= M_size - 2 * K; i++){
            int ans = 0;
            if(i % 2 == 0)continue;
            for(int j = i; j < 2 * K + 1 + i; j++){
                ans += M.at(j);
            }
            Ans = max(ans, Ans);
        }
        
        int ans = 0;
        for(int i = 0; i < min(2 * K, M_size); i++){
            ans += M.at(i);
        }
        Ans = max(ans, Ans);
        
    }
    
    if(y <= K){
        Ans = N;
    }
    
    cout << Ans << endl;
}



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

using namespace std;

int main()
{
     long int n,cnt=0;
     scanf("%ld",&n);
    long int a[n+1],i,h[n+1];
    for(i=1;i<=n;++i)
    { scanf("%ld",&a[i]);
       h[i]=a[i];
    }
   
     for(i=1;i<=n;++i)
     {
       if(h[a[i]]==i)
          { cnt++;
            
          }
     }
           
     printf("%ld",cnt/2);
   
  
}

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


int main()
{
    int n,x,y;
    cin >> n >> x >> y;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) cin >> a[i];
    if(n == 1) cout << abs(a[0]-y) << endl;
    else cout << max(abs(a[n-1]-a[n-2]), abs(a[n-1]-y)) << endl;
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long 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 debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int MOD = 1e9 + 7; 



int main(void) 
{
	
	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
	#endif

	int n, k; 
	cin >> n >> k;
	if (k>=n) 
	{
		printf("0\n"); 
		return false; 
	}
	vector<ll> v(n); 
	for (int i=0; i<n; i++) cin >> v[i]; 
	sort(v.begin(), v.end());
	int pos = n-1; 

	for (int i=1; i<=k; i++) 
		v[pos--] = 0; 
	ll ans = 0; 
	for (int i=0; i<n; i++) 
		if (v[i]) 
			ans += v[i]; 
	cout << ans << '\n'; 
	return false;   


}


Measured memory_bytes: 1792
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif
struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

void solve(long long n, long long x, vector<long long> a){
	sort(a.begin(),a.end());	
	int ans=0;
	for(int i=0; i<n; ++i) {
		if (x>=a[i]) {
			x-=a[i];
		} else {
			cout<<i<<endl;
			return;
		}
	}
	if (x==0) {
		cout<<n<<endl;
	} else {
		cout<<n-1<<endl;
	}
}

int main(){	
#ifdef WAAUTOMATON
	//freopen("in.txt","r",stdin);
#endif
	long long x;
	long long N;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&x);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, a);
	return 0;
}



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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;





int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);


	string s;

	cin >> s;

	if (s == "AAA" || s == "BBB")
		cout << "No\n";
	else
		cout << "Yes\n";


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int c;
  c = s[1];

  if ((s[0]==c&&s[2]==c)||(s[2]==c&&s[3]==c)) {
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 300
#define mp make_pair
#define pb push_back
#define ll long long
#define uint unsigned int
#define pii pair<int, int>
#define ull unsigned long long
#define sz(v) ((int)(v).size())
#define foreach(it, v) for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); it++)
#define gc() fgetc(stdin)
template<typename T> void read(T &a) {
	register int b = 1, c; a = 0;
	for (c=gc(); c > 57 || c < 48; c=gc()) if (c == 45) b = -1;
	for (; c >= 48 && c <= 57; c=gc()) a = a * 10 + c - 48;
	a *= b;
}
#ifdef DEBUG
struct Timer {
	int Stime;
	Timer() { Stime = clock(); }
	~Timer() {
		printf("\nTimer Report : Current Running Time = %dms\n", clock() - Stime);
		system("pause");
	}
}Timer0;
#endif

int n;
char c[N + 5];
string s[N + 5], t[N + 5];

int main() {
	read(n);
//	n = 300;
	for (int i = 0; i < n; i++) {
		scanf("%s", c);
		s[i] = c;
//		s[i] = string(300, 'a');
	}
	int ans = 0;
	for (int A = 0; A < 1; A++) {
		for (int B = A; B < n; B++) {
			for (int i = 0; i < n; i++) {
				t[i] = "";
				for (int j = 0; j < n; j++) {
					t[i] += s[(i + A) % n][(j + B) % n];
				}
			}
			bool flag = 1;
			for (int i = 0; i < n; i++) {
				for (int j = 0; j <= i; j++) {
					if (t[i][j] != t[j][i]) {
						flag = 0; break;
					}
				}
			}
			if (flag) ans++;
		}
	}
	printf("%d\n", ans * n);
	return 0;
}


Measured memory_bytes: 512
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A = [int(sys.stdin.buffer.readline().rstrip()) for _ in range(2)]
    print('Yes' if N%500 <= A else 'No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
# 忘れないように
import sys
sys.setrecursionlimit(10**9)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)


# 0は未着色を表す
color = [0] * N


# 二部グラフ判定dfs
def dfs(v, c):
    color[v] = c
    for to in G[v]:
        if color[to] == c:
            return False

        if color[to] == 0 and not dfs(to, -c):
            return False

    return True


Bipartite = dfs(0, 1)

if Bipartite:
    White = color.count(1)
    Black = color.count(-1)
    print(White * Black - M)

else:
    print(N * (N - 1) // 2 - M)


Measured memory_bytes: 31156
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
using namespace std;




int main()
{
	int k;
	cin >> k;
	int a, b;
	a = k / 2;
	b = k - a;
	cout << a * b << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000001;

using namespace std;



int main(void) {
	int n, m;
	int p = 1;
	cin >> n;
	vector<int>d(n + 1);
	FOR(i, 1, n) {
		cin >> d[i];
	}
	cin >> m;
	vector<int>t(m + 1);
	FOR(i, 1, m) {
		cin >> t[i];
	}
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	FOR(i, 1, m) {
		FOR(u, p, n) {
			if (t[i] == d[u]) {
				p = u + 1;
				if (i == m) {
					cout << "YES" << endl;
					goto warp;
				}
				break;
			}
			if (u == n) {
				cout << "NO" << endl;
				goto warp;
			}
		}
	}
	warp:
	return 0;
}

Measured memory_bytes: 1792
def gcd(x,y):
  x,y = max(x,y),min(x,y)
  while x%y != 0:
    x,y = y,x%y
  return y

def lcm(x,y):
  # x*y = lcm(x,y) *gcd(x,y)
  return x*y // gcd(x,y)

N = int(input())
lst = []
res = None 
for _ in range(N):
  n = int(input())
  if res is None:
    res = n
  else:
    res = lcm(res, n)

print(res)

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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left  (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)

#define mod %
#define N 13
#define MOD (ll)(1e9 + 7)
#define test if(!true)


int main()
{
	int x;
	cin >> x;
	cout << (3 * (x * x)) << "\n";
    return 0;
}




Measured memory_bytes: 256
def ismonth(a):
    return 0 < a < 13
# 入力の受け取り
s = input()

#前後2つに分ける
a, b = int(s[:2]), int(s[2:])
if ismonth(a) and ismonth(b):
    print('AMBIGUOUS')
elif ismonth(a):
    print('MMYY')
elif ismonth(b):
    print('YYMM')
else:
     print('NA')



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int s1 = 0, s2 = 0;
  for (int i = 0; i < n; ++i)
    if (s[i] == 'E') ++s2;
  int ans = INF;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'E') --s2;
    ans = min(ans, s1 + s2);
    if (s[i] == 'W') ++s1;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

	int c = -1000001;

	if (a + b >= c) {
		c = a + b;
	}
	if (a - b >= c) {
		c = a - b;
	}
	if (a*b >= c) {
		c = a * b;
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
using namespace std;
#define int long long
//#define double long double
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii > pip;
typedef pair<pii, pii > piipii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define all(vec) vec.begin(), vec.end()
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60)
#define mod 1000000007
#define se second
#define fi first

struct edge{
    int to, cost;
};

int N;
vector<edge> G[100100];
int dist[100100];

void dfs1(int idx, int par){
    for(auto& e : G[idx]){
        if(e.to == par)continue;
        dfs1(e.to, idx);
        dist[idx] = max(dist[idx], dist[e.to] + e.cost);
    }
}

int dfs2(int idx, int d_par, int par){
    vector<pair<int, int>> d_child;
    d_child.push_back(mk(0, -1));
    for(auto& e : G[idx]){
        if(e.to == par)d_child.push_back(mk(d_par + e.cost, par));
        else d_child.push_back(mk(dist[e.to] + e.cost, e.to));
    }
    sort(d_child.rbegin(), d_child.rend());
    int ret = d_child[0].first + d_child[1].first;
    for(auto& e : G[idx]){
        if(e.to == par)continue;
        //e.toが最大値の子と被ったとき次の最大値がd_parになる
        int nxt = (int)(d_child[0].second == e.to);
        ret = max(ret, dfs2(e.to, d_child[nxt].first, idx));//最大値が子で完結しているかもしれない
    }
    return ret;
}

signed main(){
    cin >> N;
    for(int i = 0; i < N - 1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        G[a].push_back((edge){b, c});
        G[b].push_back((edge){a, c});
    }
    dfs1(0, -1);
    cout << dfs2(0, 0, -1) << endl;
    
    return 0;
}

/*

*/


Measured memory_bytes: 32836
# -*- coding: utf-8 -*-
n = int(input())
p = list(map(int, input().split()))

count = 0
for i in range(1, n-1):
    if p[i-1] < p[i] < p[i+1]:
        count += 1
    elif p[i-1] > p[i] > p[i+1]:
        count += 1
print(count)


Measured memory_bytes: 3060
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
HW = []
i = 1
while i<N:
  if A[i]==A[i-1]:
    n = A.count(A[i])
    HW += [A[i]]*(min(n//2,2))
    i = i + n -1
  else:
    i = i + 1
  if len(HW)>=2:
    break
if len(HW)<2:
  print(0)
else:
  print(HW[0]*HW[1])

Measured memory_bytes: 14252
while 1:
	try:
		h=[input() for i in [1]*5]
		if 1 in h and 2 in h:w=1
		elif 1 in h:w=3
		else:w=2
		if len(set(h))!=2:
			for i in h:print 3
		else:
			for i in h:print 1 if i==w else 2
	except:break

Measured memory_bytes: 4208
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = 1000000000000000;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */

int main() {
	int a,b,c;cin>>a>>b>>c;
	cout << max(0,c-(a-b)) << endl;
	return 0;
}


Measured memory_bytes: 256
import copy

def cnt(a, m, i):
    if a[i] < m:
        a[i] += 1
    else:
        a = cnt(a, m, i-1)
        a[i] = copy.deepcopy(a[i-1])
    return a

def check(a, ab):
    score = 0
    for i in range(q):
        ai, bi = ab[i][0], ab[i][1]
        if a[bi] - a[ai] == ab[i][2]:
            score += ab[i][3]
    return score
  
n, m, q = map(int,input().split())
ab = []
for i in range(q):
    ab.append(list(map(int,input().split())))

a = [1] * (n+1)
a[0] = 0
ans = 0
while a[0] == 0:
    x = check(a, ab)
    ans = max(ans, x)
    # print(a, ans)
    a = cnt(a, m, -1)
print(ans)


Measured memory_bytes: 81576
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

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

  int sum = 0;
  for (int i = 0; i < N; i++) {
    int L; cin >> L;
    sum += L;
    Input[i] = L;
  }
  for (int i = 0; i < N; i++) {
    if (Input[i] >= sum - Input[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 764
/*  -*- coding: utf-8 -*-
 *
 * e.cc: E - Colorful Hats 2
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MOD = 1000000007;

/* typedef */

struct Trpl {
  int r, g, b;
  Trpl() {}
  Trpl(int _r, int _g, int _b): r(_r), g(_g), b(_b) {}
  bool operator<(const Trpl &t) const {
    return r < t.r || (r == t.r && (g < t.g || (g == t.g && b < t.b)));
  }
};

typedef map<Trpl,int> mti;

/* global variables */

int as[MAX_N];
mti tmap0, tmap1;

/* subroutines */

inline void addmod(int &a, int b) { a = (a + b) % MOD; }

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  tmap0[Trpl(0, 0, 0)] = 1;
  for (int i = 0; i < n; i++) {
    int ai = as[i];
    tmap1.clear();

    for (mti::iterator mit = tmap0.begin(); mit != tmap0.end(); mit++) {
      Trpl t = mit->first;
      int k = mit->second;

      if (t.r == ai) addmod(tmap1[Trpl(t.r + 1, t.g, t.b)], k);
      if (t.g == ai) addmod(tmap1[Trpl(t.r, t.g + 1, t.b)], k);
      if (t.b == ai) addmod(tmap1[Trpl(t.r, t.g, t.b + 1)], k);
    }

    swap(tmap0, tmap1);
  }

  int sum = 0;
  for (mti::iterator mit = tmap0.begin(); mit != tmap0.end(); mit++)
    addmod(sum, mit->second);

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 640
# -*- coding:utf-8 -*-
import math, itertools, operator
ABC = list(map(int,input().split()))
itr = list(itertools.accumulate(ABC, operator.mul))
if itr[len(itr)-1] == 0:
    print(0)
else:
    maximum = max(max(ABC[0],ABC[1]), ABC[2])
    ABC.remove(maximum)
    a = math.floor(maximum/2)
    b = maximum-a
    c = list(itertools.accumulate(ABC, operator.mul))
    print(abs( (c[len(c)-1]*a) - (c[len(c)-1]*b)) )

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
#define TMP template<typename
// #define DEBUG
#ifdef DEBUG
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP 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...);
}
#endif
// TMP Arg1>
// void oup(Arg1 arg1){
// (cout << arg1 <<"\n");
// }
// TMP... T>
// void oup(T&... args){
// ((cout << args <<"\n") , ...);
// }

typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define F first
#define S second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define frb(i,j, n) for (auto (i) = (j); (i) >= (n); (i)--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define ra(a) for(int &x : (a)) in(x)
#define pa(a) for(int &x : (a)) cout << (x) << " ";cout << "\n"
#define pb emplace_back
#define mp make_pair
#define vi vector<int>
#define vlli vector<lli>

/*----------fast input-------------*/
#define ff
#ifdef ff
TMP T>
inline void in(T &x)
    {
    register T c = getchar_unlocked();
    x = 0;
    T neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }

#else
TMP... T>
void in(T&... args){
((cin >> args) , ...);
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int  k,n;
  in(k);
  in(n);
  frb(i,k-1,1){
    cout << (n-i) << " ";
  }
  cout << n << " ";
  frie(i,1,k-1){
    cout << (n+i) << " ";
  }

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
//int dx[4] = { 1,0,0,-1 };
//int dy[4] = { 0,1,-1,0 };
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9 + 7;


int main() {


	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, q;
	cin >> n >> q;
	vector<ll> A(ARRAY_MAX, 0), S(ARRAY_MAX, 0), Sdiv(ARRAY_MAX, 0);
	vector<pll> X(ARRAY_MAX);
	vector<ll> ans(ARRAY_MAX, 0);

	for (int i = 1; i <= n; i++)
	{
		cin >> A[i];
		S[i] = S[i - 1] + A[i];
		Sdiv[i] = A[i];

		if (i >= 3)
		{
			//奇数、偶数番号分けて累積和を取る
			Sdiv[i] += Sdiv[i - 2];
		}
	}

	for (ll i = 0; i < q; i++)
	{
		cin >> X[i].first;
		X[i].second = i;
	}

	sort(X.begin(), X.begin() + q);

	ll y = 1;//高橋君が上から取れる要素番号

	for (ll i = 0; i < q; i++)
	{
		ll x = X[i].first;

		while (y <= n)
		{
			if (A[y] < x)
			{
				//xより大きい要素の取り方を調べるのでx未満のものは無視
				//x以下についてはまだ考えない
				y++;
			}
			else
			{
				ll upper = n - y + 1;//高橋君がy番目のカードを何枚目に取るか
				ll lower = y - (lower_bound(A.begin(), A.begin()+ n + 1, max(1LL, 2LL * x - A[y])) - A.begin()) + 1;//青木君y番目のカードを何枚目に取るか
				
				if (lower < upper)
				{
					y++;
				}
				else
				{
					//y番目のカードを取る時の枚数が逆転してしまうのでここが境界となる
					break;
				}
	
			}
		}

		ll cnt = S[n] - S[y - 1];//高橋君が上から取る部分
		ll first = n - (n - y + 1) * 2;//交互に取る場所へ移動（上から取る）[
		if (first > 0)
		{
			cnt += Sdiv[first];
		}
		ans[X[i].second] = cnt;
	}


	for (int i = 0; i < q; i++)
	{
		cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 6400
ans' v d = sum $ map (\i -> if i > v then v else i) d

ans ([0,0]:_) = []
ans ([n,m]:d:r) =
  (ans' (div m n) d):(ans r)

main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Int]]
      o = ans i
  mapM_ print o



Measured memory_bytes: 4788
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n, k = nm()
    d = []
    a = []
    for _ in range(k):
        temp1 = ni()
        d.append(temp1)
        temp2 = nl()
        a.append(temp2)
    
    ans = [0] * (n + 1)

    for arr in a:
        for value in arr:
            ans[value] += 1
    out = 0 
    for value in ans:
        if value == 0 :
            out += 1
    print(out - 1)


if __name__ == '__main__':
    main()

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

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 200000;
int N, T;
int t[MAX_N];

int main() {
  cin >> N >> T;
  rep(i,N) cin >> t[i];

  ll ans = 0;
  for (int i = 0; i < N-1; ++i) {
    if (t[i+1]-t[i] >= T) ans += T;
    else ans += t[i+1]-t[i];
  }
  ans += T;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,cnt=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		if(x>=k) cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
/*input
BBB

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;cin>>s;
    //cout<<s<<endl;
    int ans[2] = {0};
    for(auto i:s){
    	if(i=='B')
    	ans[1]++;
    	else
    	ans[0]++;
    }
    //cout<<ans[0]<<ans[1]<<endl;
    if(ans[0]!=0 && ans[1]!=0){
    	cout<<"Yes"<<endl;
    }
    else{
    	cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;

int main() {
	vvi c(3, vi(3));
	REP(i, 3) {
		REP(j, 3) {
			cin >> c[i][j];
		}
	}
	
	if (!(c[0][0] - c[1][0] == c[0][1] - c[1][1] && c[0][1] - c[1][1] == c[0][2] - c[1][2])) {
		cout << "No" << endl;
		return 0;
	}
	if (!(c[1][0] - c[2][0] == c[1][1] - c[2][1] && c[1][1] - c[2][1] == c[1][2] - c[2][2])) {
		cout << "No" << endl;
		return 0;
	}
	if (!(c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[1][0] - c[1][1] == c[2][0] - c[2][1])) {
		cout << "No" << endl;
		return 0;
	}
	if (!(c[0][1] - c[0][2] == c[1][1] - c[1][2] && c[1][1] - c[1][2] == c[2][1] - c[2][2])) {
		cout << "No" << endl;
		return 0;
	}
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <limits.h>
using namespace std;
typedef long long LL;
const int N=2010;

int n,u,v,ans;
int dp1[N],dp2[N],sz[N];
char s[N];
vector<int> G[N];

void dfs(int u,int f) {
	sz[u]=(s[u]=='1');
	vector<int> tmp;
	int mx=-1,p=-1,o1,o2,son=0;
	for(int v: G[u]) {
		if(v==f) continue;
		dfs(v,u);
		sz[u]+=sz[v];
		o1=dp1[v]+sz[v];
		o2=dp2[v]+sz[v];
		dp1[u]+=o1;
		if(o2>mx) {
			mx=o2;p=v;
		}
		son++;
	}
	if(son==0) return;
	
	o1=dp1[u]-(dp1[p]+sz[p]);
	if(mx>o1) {
		dp2[u]=mx-o1;
	}
	else {
		dp2[u]=(dp1[u]%2);
	}
}

int main() {
	scanf("%d %s",&n,s+1);
	for(int i=1;i<n;i++) {
		scanf("%d %d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	ans=-1;
	for(int u=1;u<=n;u++) {
		memset(sz,0,sizeof(sz));
		memset(dp1,0,sizeof(dp1));
		memset(dp2,0,sizeof(dp2));
		dfs(u,0);
		if(dp2[u]==0) {
			if(ans==-1 || dp1[u]/2<ans) {
				ans=dp1[u]/2;
			}
		}
	}
	printf("%d\n",ans);
}

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

int main()
{

        string S;

        cin >> S;

        int len = S.length();

        int n = 0;
        int s = 0;
        int w = 0;
        int e = 0;
        for (int i = 0; i < len; ++i) {
                if (S[i] == 'N') n++;
                if (S[i] == 'S') s++;
                if (S[i] == 'W') w++;
                if (S[i] == 'E') e++;
        }
        bool ok = false;

        if (n && s) {
                ok = true;
        }
        else if (n && s ==0) {
                ok = false;
                cout << "No" << endl;
                return 0;
        }
        else if (n == 0 && s) {
                ok = false;
                cout << "No" << endl;
                return 0;
        }
        if (e == 0 && w == 0) {
                ok = true;
        }
        else if (e && w == 0) {
                cout << "No" << endl;
                return 0;
        }
        else if (e == 0 && w) {
                cout << "No" << endl;
                return 0;
        }
        else if (e && w) {
                ok = true;
        }
        if (ok) {
                cout << "Yes" << endl;
        }





}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;


int main() {
    int n;
    cin>>n;
    vector<ll> x(n),y(n),h(n);
    rep(i,n) cin>>x[i]>>y[i]>>h[i];

    rep(cx,101){
        rep(cy,101){
            ll H=0;
            rep(i,n){
                if(h[i]==0) continue;
                H=h[i]+abs(x[i]-cx)+abs(y[i]-cy);
                break;
            }
            bool ok=true;
            rep(i,n){
                ll tmp=max(H-abs(x[i]-cx)-abs(y[i]-cy),0LL);
                if(tmp!=h[i]) ok=false;
            }
            if(ok){
                cout<<cx<<" "<<cy<<" "<<H<<endl;
            }
        }
    }
}

Measured memory_bytes: 3612
N = gets.to_i
Ts = gets.split.map(&:to_i)
M = gets.to_i
PXs = M.times.map{gets.split.map(&:to_i)}
sum = Ts.inject(:+)

PXs.each do |px|
    index = px[0]
    puts sum + px[1] - Ts[index -1]
end

Measured memory_bytes: 1916
S=list(input())
k=int(input())
Ans=[0]*len(S)
c=0
for i in range(len(S)):
  if (26-(ord(S[i])-97))%26<=k:
    Ans[i]="a"
    k=k-(26-(ord(S[i])-97))%26
    c=c+(26-(ord(S[i])-97))%26
  else:
    Ans[i]=S[i]
  if i==len(S)-1:
    c=ord(Ans[i])+k%26
    if ord(Ans[i])+k%26>=123:
      c=c-26
    Ans[i]=chr(c)
print("".join(Ans))

Measured memory_bytes: 4920
#include <iostream>
using namespace std;
using ulli = unsigned long long;

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

    int sevens = 7;
    for (int i = 1; i < 2'000'000; ++i) {
        if (sevens % K == 0) {
            cout << i << '\n';
            return 0;
        }
        sevens *= 10UL;
        sevens += 7UL;
        sevens %= K;
    }

    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

	string s;
	cin >> s;

	vector<int> c(s.size() + 1, false);
	int h = 0;
	c[0] = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		switch (s[i])
		{
		case '_': break;
		case '\\': h -= 1; break;
		case '/': h += 1; break;
		}
		c[i + 1] = h;
	}

	int sum = 0;
	vector<int> area;
	stack<bool> d;
	for (int i = 0; i < s.size(); ++i)
	{
		switch (s[i])
		{
		case '_':
			sum += (1 * d.size());
			break;

		case '\\':
			for (int j = i + 1; j <= s.size(); ++j)
				if (c[i] <= c[j]) { d.push(true); break; }
			break;

		case '/':
			if (!d.empty())
				sum += 2 * d.size() - 1, d.pop();
			break;
		}

		if (d.empty() && sum != 0)
			area.push_back(sum), sum = 0;
	}

	cout << accumulate(area.begin(), area.end(), 0) << endl;
	cout << area.size();
	for (auto a : area)
		cout << " " << a;
	cout << endl;

	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool areSame(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int N;
int X[15],Y[15],A[15];

double ei[1<<15];
double dp[1<<15];


signed main(){
    cin>>N;
    rep(i,N)cin>>X[i]>>Y[i]>>A[i];

    for(int i=1;i<1<<N;i++){
        vector<tuple<int,int,int>>es;
        rep(j,N){
            if(~i>>j&1)continue;
            for(int k=j+1;k<N;k++){
                if(~i>>k&1)continue;
                int d=(X[j]-X[k])*(X[j]-X[k])+(Y[j]-Y[k])*(Y[j]-Y[k]);
                es.pb(make_tuple(d,j,k));
            }
        }
        sort(all(es));
        UnionFindTree uf(N);
        double sum=0;
        rep(j,N)if(i>>j&1)sum+=A[j];
        for(auto &w:es){
            int d,u,v;
            tie(d,u,v)=w;
            if(uf.areSame(u,v))continue;
            uf.unite(u,v);
            sum-=sqrt(d);
        }
        ei[i]=sum/__builtin_popcount(i);
    }

    dp[0]=1e20;
    rep(i,1<<N){
        int sup=(1<<N)-1-i;
        for(int j=sup;j;j=(j-1)&sup){
            chmax(dp[i|j],min(dp[i],ei[j]));
        }
    }


    printf("%.20f\n",dp[(1<<N)-1]);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;


int main(void){
    double L;
    cin >> L;

    cout << fixed << L*L*L/27.0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
     int s;
     cin>>s;
     map<int,int>a;
     int cnt=0;
     while(1){
         a[s]++;
         cnt++;
         if(a[s]>=2)break;
         if(s%2==0)s/=2;
         else s=3*s+1;
     }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
main = interact $ unlines . map (show . short_phrase) . read' . lines
 where
  read' ("0":_) = []
  read' (n:xs) = take (read n) xs : read' (drop (read n) xs)

short_phrase fs = short_phrase' 1 [5,7,5,7,7] fs
 where
  short_phrase' s [] _ = s
  short_phrase' s (n:ns) (f:fs')
   | length f > n = short_phrase' (s+1) [5,7,5,7,7] (drop s fs)
   | length f == n = short_phrase' s ns fs'
   | otherwise = short_phrase' s (n-(length f):ns) fs'

Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
     
     
//#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sd(x) scanf("%d",&x)
#define sld(x) scanf("%lld",&x)
#define pld(x) printf("%lld\n",x)
#define pd(x) printf("%d\n",x)
     
     
int main(){

	int r , d ; 

	ll x , xnext;

	sd(r); sd(d); sld(x);

	for(int i = 2001 ; i <= 2010 ; i++){
		xnext = r*x - d;
		x = xnext;
		pld(xnext);
	}           
           
             
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main(){
    int n,k;
    int snk[N];
    int trick=0;

    int i,j;
    int s;
    int t[N];

    for(i=0;i<N;i++) snk[i]=0;

    scanf("%d %d",&n,&k);

    for(i=0;i<k;i++){
        scanf("%d",&s);
        for(j=0;j<s;j++){
            scanf("%d",&t[j]);
            snk[t[j]-1]++;
        }
    }

    for(i=0;i<n;i++)
        if(snk[i]==0) trick++;
    printf("%d\n",trick);


}

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

int main() {
  int h, w;
  cin >> h >> w;
  char c[h][w];
  int i, j, k;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      cin >> c[i][j];
    }
  }
  for (i = 0; i < h; i++) {
    for (j = 0; j < 2; j++) {
      for (k = 0; k < w; k++) {
        cout << c[i][k];
      }
      cout << endl;
    }
  }
  return 0;
}


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

int main() {
    int n, m, a, b, c, d, temp, index;
    cin >> n >> m;
    vector<pair<int, int>> student(n), place(m);
    rep(i, n) cin >> student.at(i).first >> student.at(i).second;
    rep(i, m) cin >> place.at(i).first >> place.at(i).second;
    rep(i, n) {
        temp = INT_MAX;
        rep(j, m) if(temp > abs(student.at(i).first - place.at(j).first) + abs(student.at(i).second - place.at(j).second)) {
            temp = abs(student.at(i).first - place.at(j).first) + abs(student.at(i).second - place.at(j).second);
            index = j + 1;
        }
        cout << index << endl;
    } 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int min_cost(int h[],int n,int k){
    int dp[n],minn=0;
    dp[0]=0,dp[1]=abs(h[0]-h[1]);
   for(int i=2;i<n;i++){
       dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
       if(i-k >=0 ){
       for(int j=i-k;j<i;j++){
           minn=dp[j]+abs(h[j]-h[i]);
           if(minn < dp[i]) dp[i]=minn;
       }
       }
       else{
           for(int j=0;j<i;j++){
               minn=dp[j]+abs(h[j]-h[i]);
               if(minn < dp[i]) dp[i]=minn;
           }
       }
   }
    return dp[n-1];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++) cin>>h[i];
    cout<<min_cost(h,n,k);
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  n %= 10;
  if (n == 3)
    cout << "bon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
  return 0;
}

Measured memory_bytes: 3520