akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 1005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int a[MAXN];
char _map[MAXN][MAXN];
struct Node {
    int r, c;
    int dist;
    bool operator<(const Node& node) const { return dist > node.dist; }
};
int dist[MAXN][MAXN];
bool vis[MAXN][MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    int startR = read<int>(), startC = read<int>();
    int dstR = read<int>(), dstC = read<int>();
    for (int i = 1; i <= n; i++) {
        scanf("%s", _map[i] + 1);
    }
    priority_queue<Node> PQ;
    memset(dist, 0x3f, sizeof(dist));
    PQ.push({startR, startC, 0});
    dist[startR][startC] = 0;
    while (!PQ.empty()) {
        auto u = PQ.top();
        PQ.pop();
        if (vis[u.r][u.c]) continue;
        vis[u.r][u.c] = true;
        for (int i = 0; i < 4; i++) {
            int nr = u.r + dr[i];
            int nc = u.c + dc[i];
            if (nr > 0 && nr <= n && nc > 0 && nc <= m && _map[nr][nc] == '.') {
                if (dist[nr][nc] > dist[u.r][u.c]) {
                    dist[nr][nc] = dist[u.r][u.c];
                    PQ.push({nr, nc, dist[nr][nc]});
                }
            }
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                if (!i && !j) continue;
                int nr = u.r + i;
                int nc = u.c + j;
                if (nr > 0 && nr <= n && nc > 0 && nc <= m &&
                    _map[nr][nc] == '.') {
                    if (dist[nr][nc] > dist[u.r][u.c] + 1) {
                        dist[nr][nc] = dist[u.r][u.c] + 1;
                        PQ.push({nr, nc, dist[nr][nc]});
                    }
                }
            }
        }
    }
    int ans = dist[dstR][dstC];
    printf("%d\n", ans == INF2 ? -1 : ans);
    return 0;
}

Measured memory_bytes: 9844
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  int N; cin >>N;
  vi B(N-1);
  rep(i,0,N-1) {cin >>B[i];}

  vi A(N,-1);
  int x=0,y=0;
  for (auto a : B) {
    y=x+1;
    if (A[x]==-1) {
      A[x]=a;
      A[y]=a;
    } else {
      if (a<A[x]) {
        A[x]=a;
      }
      A[y]=a;
    }
    x++;
  }

  cout <<accumulate(all(A),0) <<endl;
  return 0;
}


Measured memory_bytes: 3664
from fractions import gcd
a,b,c,d=map(int,input().split())

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

def ans_cnt(i,y,z):
    return i - (i//y + i//z - i//lcm(y,z))

print(ans_cnt(b,c,d)-ans_cnt(a-1,c,d))

Measured memory_bytes: 5076
//In The Name Of GOD

#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const ll mod = 998244353;
const ll inf = 2000000000;
const ll infll = (ll)2*1000*1000*1000*1000*1000*1000;
const ll maxn = 100*1000+1;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);

int main(){
  IO;
  int n,a,ans=0;
  cin>>n;
  map<int,int> mp;
  for(int i=0;i<n;i++){
    cin>>a;
    mp[a]++;
  }
  for(auto p:mp){
    if(p.Y<p.X){
      ans+=p.Y;
    }else{
      ans+=p.Y-p.X;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 4736
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b)
    swap(a, b);
  if (a <= c && c <= b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int  arr[82], n;


void solve()
{
	cin >> n;
	lop(i, 0, n) cin >> arr[i];

	int i = 0, ans = 1000, initial = 1000;
	while (i < n)
	{
		int j = i;
		while (j < n - 1  and arr[j] <= arr[j + 1] )j++;

		int cash = initial;
		int total = cash / arr[i];
		cash -= total * arr[i];

		cash += arr[j] * total;
		initial = cash;
		

		i = j + 1;
	}

	cout << initial << endl;

}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}





















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

int main() {
  int n;
  long long ans = 0;
  cin >> n;
  vector<long long>a(n);
  vector<long long>b(n);
  vector<long long>c(n);
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  for(int i = 0;i < n;i++){
    cin >> b[i];
  }
  for(int i = 0;i < n;i++){
    cin >> c[i];
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  for(int i = 0;i < n;i++){
    auto aa = lower_bound(a.begin(),a.end(),b[i]);
    auto cc = upper_bound(c.begin(),c.end(),b[i]);
    ans += (aa-a.begin())*(c.end()-cc);
  }
  cout << ans << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<string> s(n);
  rep(i, n)cin>>s[i];
  map<string ,int> m;
  int maxc = 0;
  rep(i,n){
    m[s[i]]++;
    maxc = max(maxc, m[s[i]]);
  }

  vector<string>results;
  for(auto p:m){
    if(p.second==maxc)results.push_back(p.first);
  }

  sort(results.begin(), results.end());
  rep(i, results.size())cout<<results[i]<<endl;

  return 0;
}

Measured memory_bytes: 28404
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

int main() {
	int n, a[100000];
	std::cin >> n;
	for (int i = 1;i <= n;i++) {
		std::cin >> a[i];
	}
	int nSum = 0;
	for (int i = 1;i <= n;i++) {
		if (i == a[a[i]]) {
			nSum += 1;
		}
	}
	std::cout << nSum/2 << std::endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#define p pair <int,int>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
#define MAXUF 100005
int n,m;
ll q,l[100005],r[100005],table[100005];

struct UnionFind
{
  int par[MAXUF];
  int rank[MAXUF];
  int diff_weight[MAXUF];

  UnionFind(int n=0)
  {
    for(int i=0;i<n;i++)
      {
	par[i]=i,rank[i]=0,diff_weight[i]=0;
      }
  }

  void init(int n)
  {
    for(int i=0;i<n;i++)
      {
	par[i]=i,rank[i]=0,diff_weight[i]=0;
      }
  }

  int root(int x)
  {
    if(par[x]==x)
      {
	return x;
      }
    else
      {
	int r=root(par[x]);
	diff_weight[x]+=diff_weight[par[x]];
	return par[x]=r;
      }
  }

  int weight(int x)
  {
    root(x);
    return diff_weight[x];
  }

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

  bool unite(int x,int y,int w)
  {
    w+=weight(x);w-=weight(y);
    x=root(x);y=root(y);
    if(x==y) return false;
    if(rank[x]<rank[y])swap(x,y),w=-w;
    if(rank[x]==rank[y])rank[x]++;
    par[y]=x;
    diff_weight[y]=w;
    return true;
  }

  int diff(int x,int y)
  {
    return weight(y)-weight(x);
  }
} uf;

int main(int argc,char const* argv[])
{
  cin >> n >> m;
  uf.init(n);
  for(int i=0;i<m;i++)
    {
      int left,right,dis;
      cin >> left >> right >> dis;
      left--,right--;
      if(uf.isSame(left,right))
	{
	  int diff=uf.diff(left,right);
	  if(diff!=dis)
	    {
	      cout << "No" << endl;
	      return 0;
	    }
	}
      else
	{
	  uf.unite(left,right,dis);
	}
    }
  cout << "Yes" << endl;
  return 0;
}
  


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int h, w, k; cin >> h >> w >> k;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];
    
    int ans = inf;
    for (int bits = 0; bits < (1 << (h - 1)); bits++) {
        int res = __builtin_popcount(bits);
        int n = __builtin_popcount(bits) + 1;
        vector<int> count(n, 0);
        int pos = 0;
        for (int j = 0; j < w; j++) {
            int idx = 0;
            for (int i = 0; i < h; i++) {
                if (s[i][j] == '1') count[idx]++;
                if (i < h - 1 && ((bits >> i) & 1)) idx++;
            }
            if (*max_element(count.begin(), count.end()) > k) {
                if (j == pos) {
                    res = inf; break;
                }
                res++, pos = j--;
                fill(count.begin(), count.end(), 0);
            }
        }
        ans = min(ans, res);
    }
    cout << ans << endl;
    return 0;
}


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

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

int N,M;
int a[100];

signed main(){
    cin>>N>>M;
    rep(i,N)cin>>a[i];

    for(int k=1;k<=M;k++){
        rep(i,N-1){
            if(a[i]%k>a[i+1]%k)swap(a[i],a[i+1]);
        }
    }

    rep(i,N)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 3116
import sys
input=sys.stdin.readline
n,q=map(int,input().split())
s=input().replace("\n","")
cnt=[0 for i in range(n+1)]
for i in range(1,n+1):
    if s[i-1:i+1]=="AC":
        cnt[i]+=1
    cnt[i]+=cnt[i-1]
#print(cnt)
for i in range(q):
    a,b=map(int,input().split())
    print(cnt[b-1]-cnt[a-1])

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

using namespace std;

void insertSort(vector<int>& v, int n) {

	for (int i=0; i<n; i++) {

		int k = v[i];
		int j = i-1;

		while (j>=0 && (v[j] > k)) {
			v[j+1] = v[j];
			j--;
		}
		v[j+1] = k;

		for (int i=0; i<n; i++) {
			char c = (i == n-1) ? '\n' : ' ';
			cout << v[i] << c;
		}
	}
}

int main() {

	int n, s;
	vector<int> v;

	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> s; 
		v.push_back(s);
	}

	insertSort(v, n);
	return 0;
}

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

double sqrter(double s){
    double x = s / 2.0;
    double last_x = 0.0;

    while (x != last_x){
        last_x = x;
        x = (x + s / x) / 2.0;
    }
    return x;
}

int main(){
    unsigned long long  a,b,c;
    cin >> a >> b >> c;
    if(a+b >= c){
        cout << "No" << endl;
    }else{
    //out << sqrt(a) << endl;
        if(4*a*b < (c-a-b)*(c-a-b)){
            cout << "Yes"<<endl;
        }else{
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

int main(){
	int n ; 
	cin >> n ; 
	vector<ll> v(n) ; 
	for(ll &x : v){
		cin >> x ; 
	}
	sort(v.rbegin(),v.rend());
	ll ans = v[0] / 2 ; 
	for(int i=1;i<n;i++){
		ans += v[i] ; 
	}
	cout << ans << endl;
    return 0 ;
}


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

int main() {

	ll a, b, k; cin >> a >> b >> k;
	for (int i = 0; i < k; i++) {
		if (i % 2 == 0) {
			if (a % 2 == 1) {
				a--;				
			}
			b += a / 2;
			a /= 2;
		}
		else {
			if (b % 2 == 1) {
				b--;
			}
			a += b / 2;
			b /= 2;
		}
	}	
	cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
//#include "stdc++.h"
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<vector<pii>> v(n);
	rep(i, n) {
		int a;
		cin >> a;
		while (a--) {
			int x, y;
			cin >> x >> y;
			x--;
			v[i].push_back({x, y});
		}
	}
	int ans = 0;
	for (int b = 0; b < (1 << n); b++) {
		bitset<15> s(b);
		vector<int> honest(n, -1);
		bool ok = true;
		rep(i, n) {
			if (s.test(i)) {
				honest[i] = 1;
				for (int t = 0; t < n; t++) {
					if (honest[t] == 1) {
						for (auto p : v[t]) {
							int x = p.first;
							int y = p.second;
							if (honest[x] == -1 || honest[x] == y)
								honest[x] = y;
							else
								ok = false;
						}
					}
				}
			}
		}
		if (!ok) continue;
		for (int t = 0; t < n; t++) {
			if (honest[t] == 1) {
				for (auto p : v[t]) {
					int x = p.first;
					int y = p.second;
					if (honest[x] == -1 || honest[x] == y)
						honest[x] = y;
					else
						ok = false;
				}
			}
		}
		if (ok) {
			chmax(ans, __builtin_popcount(b));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>

using namespace std;
//4/N = 1/h + 1/n + 1/w 
//给定 N 
//输出一组 h n w 保证有一组h n w小于3500 z 


long long h,n,w;
int main()
{
	//scanf("%d",&n);
	cin>>n; 
	for(long long i=1;i<=3500;i++)
	{
		for(long long j=1;j<=3500;j++)
		{
			if((4*i*j-n*i-n*j)>0 && (n*i*j)%(4*i*j-n*i-n*j)==0)
			{
				cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-n*i-n*j);return 0;
			}
		}
	}
	return 0;
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        if(s.equals("AAA") ||s.equals("BBB")){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }

    }
    
}

Measured memory_bytes: 35520
def cul_even(x):
  return x // 2 * 25
def cul_odd(x):
  return x // 2 * 25 + 13
def main():
  a,b = map(int,input().split())
  if(a % 2 == 0):
    if(b == cul_even(a)//10):
      print(cul_even(a))
    elif(b == (cul_even(a)//10 + 1)):
      print((cul_even(a)+12)//10*10)
    else:
      print(-1)
  else:
    if(b == cul_odd(a)//10):
      print(cul_odd(a))
    elif(b == (cul_odd(a)//10 + 1)):
      print((cul_odd(a)+11)//10*10)
    else:
      print(-1)

if __name__ == '__main__':
  main()  


Measured memory_bytes: 3064
import sys
n = int(input())
ls = [str(input()) for i in range(n)]
if len(ls) != len(list(set(ls))):
    print("No")
    sys.exit()
for i in range(n):
    if i == 0:
        a = ls[0]
    else:
        if ls[i-1][-1] == ls[i][0]:
            continue
        else:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 3060
import collections

def solution():
    n = int(input().strip())
    d = collections.defaultdict(int)
    for _ in range(n):
        d[input().strip()] += 1
    maxValue = max(d.values())
    res = [x[0] for x in d.items() if x[1] == maxValue]
    res.sort()
    for x in res:
        print(x)

def main():    
    # T = int(input().strip())
    for _ in range(1):
        solution()
    

main()

Measured memory_bytes: 97848
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;


int K, X;

signed main()
{
	cin >> K >> X;

	int l = X - (K - 1);
	int r = X + (K - 1);

	for (int i = l; i <= r; i++)
	{
		cout << ((i == l) ? "" : " ") << i;
	}
	cout << endl;
}











Measured memory_bytes: 256
#include <iostream>
#define N_MAX 100
#include <string>
using namespace std;

int N,A,B,i,j,k;
string S;
int a[N_MAX];
int num[N_MAX] = {0};
int ans=0;
int r,g,b;

int main(){
  cin >> S;
  if (S[0] == S[1] && S[1] == S[2]) cout << "Yes" <<endl;
  else if(S[2] == S[1] && S[3] == S[2]) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int N;
string s = "abcdefghijklm";
char ans[10];

void dfs(int id, int d) {
    if(d == N) {
        for(int i = 0; i < N; i++) {
            cout << ans[i];
        }
        cout << endl;
        return;
    }

    for(int i = 0; i <= id + 1; i++) {
        ans[d] = s[i];
        dfs(max(id, i), d + 1);
    }

    return;
}

int main() {
    cin >> N;
    dfs(-1, 0);
    return 0;
}

Measured memory_bytes: 1536
fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt)
    var sign = "a == b"
    if (list[0] > list[1])
        sign="a > b"
    else if (list[0] < list[1])
        sign="a < b"
    println("%s".format(sign))
}


Measured memory_bytes: 33688
#include <bits/stdc++.h>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()
#define pb(c) push_back(c)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main(){
  ios::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << a*b << endl;

}

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

int main(){
  ll x, y;
  cin >> x >> y;
  if(x % y != 0) cout << x << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,d,x;
    cin>>r>>d>>x;
    for (int i=0;i<10;i++){
        x = r*x-d;
        cout<<x<<endl;
    }
}

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MX = 1000005;

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) {
    return f[x] == x;
  }
  vector<int> factorList(int x) {
    vector<int> res;
    while(x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) {
      return {};
    }
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  Sieve sieve(1e7);
  int n;
  cin >> n;
  ll sum = 1;
  for (int k = 2; k <= n; k++) {
    auto f = sieve.factor(k);
    ll s = 1;
    for (auto p : f) {
      s *= (p.second + 1);
    }
    sum += k * s;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 46340
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n, m;
	cin >> n >> m;
	int d = n - 1;
	REP1(i, m){
		cout << i << " " << i + d << endl;
		//cout << i << " " << i + d << " " << d << endl;
		if(d + d - 2 == n || (d - 2) * 2 == n)d -= 3;
		else d -= 2;
	}
	//cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    bool hai = 0, tya = 0, midori = 0, mizu = 0, ao = 0, ki = 0, dai = 0, aka = 0;
    int saikyo = 0;

    REP(i, n){
        int rate; cin >> rate;
        if(rate <= 399) hai = 1;
        else if(rate <= 799) tya = 1;
        else if(rate <= 1199) midori = 1;
        else if(rate <= 1599) mizu = 1;
        else if(rate <= 1999) ao = 1;
        else if(rate <= 2399) ki = 1;
        else if(rate <= 2799) dai = 1;
        else if(rate <= 3199) aka = 1;
        else saikyo++;
    }

    int res = 0;
    if(hai) res++;
    if(tya) res++;
    if(midori) res++;
    if(mizu) res++;
    if(ao) res++;
    if(ki) res++;
    if(dai) res++;
    if(aka) res++;

    if(res != 0) cout << res << " " << res + saikyo << endl;
    else cout << 1 << " " << saikyo << endl; 
}

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

// セグメントツリー
// 初期化 SegmentTree<typename> seg(列, 単位元);
template<typename T>
class SegmentTree {
private:
    Int n;
    vector<T> node;
    T ident;
    T f(T x, T y) {
        return max(x, y);
    }
public:
    SegmentTree(vector<T> in, T identity_element) : n(in.size()), ident(identity_element) {
        node.resize(n * 2);
        for (Int i = 0; i < n; i++) node[n + i] = in[i];
        for (Int i = n - 1; i >= 1; i--) node[i] = f(node[i<<1|0], node[i<<1|1]);
    }
    // i: 0-indexed
    void update(Int i, T value) {
        i += n;
        node[i] = value;
        while (i > 1) {
            i >>= 1;
            node[i] = f(node[i<<1|0], node[i<<1|1]);
        }
    }
    // [l, r), 0-indexed
    T query(Int l, Int r) {
        T ret = ident;
        l += n, r += n;
        while (l < r) {
            if (l & 1) ret = f(ret, node[l++]);
            if (r & 1) ret = f(ret, node[--r]);
            l >>= 1, r >>= 1;
        }
        return ret;
    }
};

void solve() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<Int> b(300002, 0);
    SegmentTree<Int> seg(b, 0);
    for (Int i = 0; i < n; i++) {
        Int l = max((Int)0, a[i] - k);
        Int r = min((Int)300000, a[i] + k);
        Int ma = seg.query(l, r + 1);
        seg.update(a[i], ma + 1);
    }
    print(seg.query(0, 300000 + 1));
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 14876
#include <iostream>
#include <cstdio>
using namespace std;
int i=1, j=1;
int main()
{
    for (i=1; i<=9; i++)
        for (j=1; j<=9; j++)
            printf("%dx%d=%d\n", i, j, i*j);
    return 0;
}


Measured memory_bytes: 3028
N = int(input())

evidences = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        evidences[i].append((x - 1, y))

result = 0
for i in range(1, 2**N):
    consistent = True
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        for x, y in evidences[j]:
            if (i >> x) & 1 != y:
                consistent = False
                break
        if not consistent:
            break
    if consistent:
        result = max(result, bin(i)[2:].count('1'))
print(result)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


def converter(a, b):
    larger = max(a, b)
    smaller = min(a, b)
    if smaller == 0:
        return larger
    else:
        return converter(smaller, larger % smaller)        


def main():
    a, b = [int(x) for x in raw_input().strip().split(' ')]
    print converter(a, b) 


if __name__ == '__main__':
    main()

Measured memory_bytes: 6432
import scala.io.StdIn

object Main extends App {
  val time = Array.ofDim[Boolean](100)
  val Array(a, b, c, d) = StdIn.readLine.split(" ").map(_.toInt)

  for {
    i <- a until b
    j <- c until d
    if i == j
  } { time(i) = true }

  val ans = time.count(_ == true)

  println(ans)
}

Measured memory_bytes: 27188
// verified (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B)
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;

struct MinCostFlow{
    using flow_t = int;
    using cost_t = int;
    const int INF=1e9;
    struct Edge{int to; flow_t cap; cost_t cost,rev;};
    vector<vector<Edge>> g;
    vector<cost_t> h,dist;
    vector<int> prevv,preve;
    int n;

    MinCostFlow(int n):n(n),g(n),h(n),dist(n),prevv(n),preve(n){}

    void add_edge(int from,int to,flow_t cap,cost_t cost){
        g[from].push_back((Edge){to,cap,cost,(int)g[to].size()});
        g[to].push_back((Edge){from,0,-cost,(int)g[from].size()-1});
    }

    cost_t run(int s,int t,flow_t f){
        cost_t res = 0;
        while(f>0){
            using Item=pair<cost_t,int>;
            priority_queue<Item,vector<Item>,greater<>> que;
            fill(begin(dist),end(dist),INF);
            dist[s] = 0;
            que.push(Item(0,s));
            while(!que.empty()){
                auto tmp = que.top(); que.pop();
                int v = tmp.second;
                if(dist[v]<tmp.first) continue;
                for(int i=0;i<g[v].size();i++){
                    Edge& e=g[v][i];
                    cost_t d = dist[v]+e.cost+h[v]-h[e.to];
                    if(e.cap>0 && dist[e.to]>d){
                        dist[e.to] = d;
                        prevv[e.to] = v;
                        preve[e.to] = i;
                        que.push(Item(dist[e.to],e.to));
                    }
                }
            }

            if(dist[t]==INF) return -1;
            for(int i=0;i<n;i++) h[i]+=dist[i];
            flow_t d = f;
            for(int v=t;v!=s;v=prevv[v]){
                d=min(d,g[prevv[v]][preve[v]].cap);
            }
            f -= d;
            res += d*h[t];
            for(int v=t;v!=s;v=prevv[v]){
                Edge& e = g[prevv[v]][preve[v]];
                e.cap -= d;
                g[v][e.rev].cap += d;
            }
        }
        return res;
    }
};
int main(){
    int V,E,F;
    cin>>V>>E>>F;
    MinCostFlow mcf(V);
    for(int i=0;i<E;i++){
        int u,v,c,d;
        cin>>u>>v>>c>>d;
        mcf.add_edge(u,v,c,d);
    }
    int ret = mcf.run(0,V-1,F);
    cout<<ret<<endl;
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100000+5
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
inline void read(ll &f){
	f=0;
    ll x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
} 
int n,m;
int main(){
    cin>>n>>m;
    int p=min(n,m);
    if(p==n){
        for(int i=1;i<=m;i++){
            cout<<n;
        }
        cout<<endl;
    }
    else{
        for(int i=1;i<=n;i++){
            cout<<m;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int n=sc.nextInt();
        int m=sc.nextInt();
        boolean acc[]=new boolean[n];
        int h[]=new int[n];
        for(int x=0;x<n;x++)
        {
            h[x]=sc.nextInt();
        }
        for(int x=0;x<m;x++)
        {
            int a=sc.nextInt()-1;
            int b=sc.nextInt()-1;
            if(h[a]>h[b])
            {
                acc[b]=true;
            }
            else if(h[a]<h[b])
            {
                acc[a]=true;
            }
            else
            {
                acc[a]=acc[b]=true;
            }
        }
        int c=0;
        for(int x=0;x<n;x++)
        {
            if(!acc[x])
            {
                c++;
            }
        }
        out.println(c);
        out.close();
    }

    public static void solve()
    {
    }

    static class Reader 
    { 
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    } 
}

Measured memory_bytes: 54672
N = int(input())
A = list(map(int,input().split(' ')))
GCD = A[0]

def alg_gcd(a,b):
  if a % b == 0:
    return b
  else:
    return alg_gcd(b,a%b)

for i in range(1,N):
  GCD = alg_gcd(GCD,A[i])
print(GCD)
  

Measured memory_bytes: 14224
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

string s;

int main()
{
    cin >> s;
    for(int i= 1; i < s.size(); i++){
        if(s[i] == 'C' && s[i-1] == 'A'){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
def a(n):
    return 2 ** (n + 2) - 3

def p(n):
    return 2 ** (n + 1) - 1

def f(l, x):
    if l == 0:
        return 1
    elif x == 1:
        return 0
    elif 1 < x <= 1 + a(l-1):
        return f(l-1, x-1)
    elif x == 2 + a(l-1):
        return p(l-1) + 1
    elif 2 + a(l-1) < x <= 2 + 2 * a(l-1):
        return p(l-1) + 1 + f(l-1, x - (2 + a(l-1)))
    else:
        return 2 * p(l-1) + 1

N, X = map(int, input().split())
print(f(N, X))

Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;
import std.range;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

struct S {
    int node;
    long cost;
}

long[] bfs(int k, int n, S[][int] adj) {
    auto cost = new long[n + 1];
    auto used = new bool[n + 1];

    S[] q = [S(k, 0)];
    while (q.length > 0) {
        auto d = q[0];
        q = q[1 .. $];

        if (used[d.node])
            continue;
        used[d.node] = true;
        cost[d.node] = d.cost;

        if (d.node !in adj)
            continue;
        foreach (s; adj[d.node]) {
            q ~= S(s.node, d.cost + s.cost);
        }
    }
    return cost;
}

void main() {
    int n = readint();

    S[][int] adj;
    for (int i = 0; i < n - 1; i++) {
        auto abc = readints();
        int a = abc[0], b = abc[1], c = abc[2];
        adj[a] ~= S(b, c);
        adj[b] ~= S(a, c);
    }

    auto qk = readints();
    int q = qk[0], k = qk[1];

    auto cost = bfs(k, n, adj);
    for (int i = 0; i < q; i++) {
        auto xy = readints();
        int x = xy[0], y = xy[1];

        auto ans = cost[x] + cost[y];
        writeln(ans);
    }
}


Measured memory_bytes: 37884
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int N = sc.nextInt(), L = sc.nextInt();
		//String[] array = new String[N];
		String s=sc.next(),t=sc.next(),buff="";
		int sum=0;
		for(int i=0;i<s.length();i++) {
			s=s.substring(s.length()-1,s.length())+s.substring(0, s.length()-1);
			if(t.equals(s)) {
				System.out.println("Yes");
				System.exit(0);
			}
		}
		/*if(Integer.parseInt(s)%sum==0) {
			System.out.println("Yes");//Yes or YES注意
		}else {
			System.out.println("No");
		}*/

		System.out.println("No");

	}
	public static int sample(int n) {
		return n;
	}

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
lli gcd(lli a,lli b){
	if(b==0)return a;
	return gcd(b,a%b);
}
 int main()
{	

	lli i,j,k,l,n,n1,a,b,m,q,count=0,flag=0;
	string s;
	cin >> n;
	for(i=1;i<=n;i++){for(j=1;j<=n;j++){for(k=1;k<=n;k++){
		count=count+ gcd(i,(gcd(j,k)));
	}
	}}
cout << count << '\n';
return 0;}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 2e5 + 10;
const ll INF = 1e18;
ll n, dp[MAXN];
ll h[MAXN];
int main(){
	IOS;
	memset(dp, 63, sizeof dp);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];
	dp[1] = 0;
	for (int i = 1; i <= n - 1; i++){
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	cout << dp[n];
	
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long l[100];
int main()
{
    char c;
    int a[4];
    for(int i=0;i<4;i++)
    {
        cin>>c;
        a[i]=c-'0';
    }
    int s=0;
    if(a[0]+a[1]+a[2]+a[3]==7)cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7";
    else if(a[0]+a[1]+a[2]-a[3]==7)cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7";
    else if(a[0]+a[1]-a[2]+a[3]==7)cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7";
    else if(a[0]+a[1]-a[2]-a[3]==7)cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7";
    else if(a[0]-a[1]+a[2]+a[3]==7)cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7";
    else if(a[0]-a[1]+a[2]-a[3]==7)cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7";
    else if(a[0]-a[1]-a[2]+a[3]==7)cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7";
    else if(a[0]-a[1]-a[2]-a[3]==7)cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7";
    cout<<endl;
return 0;
}


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

long long int pos[200005]={0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        long long int a;
        cin >> a;
        pos[a] = i;
    }

    set<long long int> st;
    st.insert(-1);
    st.insert(n);
    long long int ans = 0;
    for(int i=1;i<=n;++i){
        st.insert(pos[i]);
        auto itr = st.find(pos[i]);
        itr--;
        long long int l = *itr;
        itr++; itr++;
        long long int r = *itr;
        ans += (pos[i] - l) * (r - pos[i]) * i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>

static const int MAX = 100000;
static const int INFTY = (1 << 20);
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<vector<int>> d(N, vector<int>(2));
  for (int i = 0; i < N; i++)
  {
    cin >> d[i][0];
    cin >> d[i][1];
  }

  int count = 0;
  for (int i = 0; i < N; i++)
  {
    if (d[i][0] == d[i][1])
      count++;
    else
      count = 0;
    if (count >= 3)
    {
      printf("Yes");
      return 0;
    }
  }
  printf("No");
  return 0;
}

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

int main(){

  string s;
  bool a = false,b = false,c = false;

  cin >> s;

  for(int i=0;i<s.size();i++){
    if(s[i] <= '9' && s[i] >= '0') a = true;
    if(s[i] <= 'z' && s[i] >= 'a') b = true;
    if(s[i] <= 'Z' && s[i] >= 'A') c = true;
  }

  if(s.size() > 5 && a && b && c) cout << "VALID";
  else cout << "INVALID";
  cout << endl;

}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}

//to calculate p1^x  *  p2^x2  *p3^x3 ----------
//i.e. prime factorization and store pi and xi in vector 
vector<pair<ll, ll>> pFactor;

void factorize(long long n) 
{ 
    int count = 0; 
  
    // count the number of times 2 divides  
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    // if 2 divides it 
    if (count) 
        pFactor.pb({2,count}); 
  
    // check for all the possible numbers that can  
    // divide it 
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            pFactor.pb({i,count});
    } 
  
    // if n at the end is a prime number. 
    if (n > 2) 
        pFactor.pb({n,1}); 
} 



int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll a,b;
    cin>>a>>b;
    ll w[b];
    ll sum=0;
    lp(0,b){
        cin>>w[i];
        sum+=w[i];
    }
    if(sum>a){
        cout<<-1<<endl;
        return 0;
    }
    cout<<a-sum<<endl;
}

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

int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<7<<endl;
  if(s=="MON") cout<<6<<endl;
  if(s=="TUE") cout<<5<<endl;
  if(s=="WED") cout<<4<<endl;
  if(s=="THU") cout<<3<<endl;
  if(s=="FRI") cout<<2<<endl;
  if(s=="SAT") cout<<1<<endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define arrayLength(array) (size_t)((sizeof array) / (sizeof array[0]))

int main() {
  int n, m, x, y, z;

  char s[3][3];
  char p[255];

  //   scanf(" %d %d %d %d", &n, &m, &x, &y);
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%1s", &s[i][j]);
      if (i == j)
        printf("%c", s[i][i]);
    }
  }

  //   for (int i = 0; i < 3; i++) {
  //     printf("%c", s[i][i]);
  //   }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){

    while(true){
        size_t h, w;
        std::cin >> h >> w;

        if(h == 0 && w == 0) break;

        for(size_t i = 0; i < h; i++){
            for(size_t j = 0; j < w; j++){
                std::cout << '#';
            }std::cout << std::endl;
        }
        std::cout << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3104
N, M = map(int, input().split())
P = [i -1 for i in map(int,input().split())]
ss = set([])
point = 0
for i in range(N):
    if point in ss:
        break
    ss.add(point)
    point = P[point]
S = [0]
points = 0
for i in range(len(ss)-1):
    points = P[points]
    S.append(points)
loop = S[S.index(point):]
ll = len(S)
l = len(loop)
if ll > M:
    print(S[M]+1)
elif ll == M:
    print(point+1)
else:
    print(loop[(M-ll)%l]+1)


Measured memory_bytes: 32260
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,k=nii()
s=input()

happy=0
unhappy=0
for i in range(1,n):
  if s[i-1]==s[i]:
    happy+=1
  else:
    unhappy+=1

for i in range(k):
  if unhappy==1:
    happy+=1
    break
  happy+=2
  unhappy-=2

print(min(happy,n-1))

Measured memory_bytes: 9304