akhauriyash/Code-Regression huggingface dataset:
from functools import reduce
from collections import defaultdict
import sys
import math

input = sys.stdin.readline

# 素因数分解O(√n)


def primeFactor(n):
    res = defaultdict(lambda: 0)
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            res[i] += 1
            n = n // i
    if n != 1:
        res[n] = 1
    return res


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def main():
    N = int(input())
    A = list(map(int, input().split()))
    primes = defaultdict(lambda: 0)
    setp = True
    pairs = True
    if gcd(*A) != 1:
        setp = False
        pairs = False
    else:
        for i in range(N):
            pf = primeFactor(A[i])
            for k in pf.keys():
                primes[k] += 1
                if primes[k] != 1:
                    pairs = False
            if not pairs:
                break
    if pairs:
        print('pairwise coprime')
    elif setp:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()


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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> v(h);
    for(int i=0;i<h;i++)
        cin >> v[i];
    int dp[h+1][w+1];
    for(int i=0;i<h+1;i++) {
        for(int j=0;j<w+1;j++) {
            if(i == 0 || j == 0)
                dp[i][j] = 1e9;
            else {
                dp[i][j] = v[i-1][j-1] - '0';
            }
        }
    }

    dp[1][1] = stoi(v[0].substr(0, 1));
    for(int i=1;i<=h;i++) {
        for(int j=1;j<=w;j++) {
            if(i==1 && j==1) continue;
            dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + v[i-1][j-1] - '0';
        }
    }

    cout << dp[h][w] << endl;
}

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

using namespace std;

int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  
  --X;
  --Y;
  
  vector<int> c(N);
  for(int i=0; i<N; i++){
    for (int j=i+1; j<N; j++){
      int minv = j-i;
      minv = min(minv, abs(i-X) + 1 + abs(j-Y));
      minv = min(minv, abs(i-Y) + 1 + abs(j-X));
      ++c[minv];
    }
  }
  
  for(int i=1; i<=N-1; i++) cout << c[i] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,M;
    cin >> N >> M;
    ve<ve<int>> E(3*N);
    
    rep(i,M){
        int u,v;
        cin >> u >> v;
        u--,v--;
        rep(j,3){
            E[3*u].pb(3*v+1);
            E[3*u+1].pb(3*v+2);
            E[3*u+2].pb(3*v);
        }
    }
    int S,T;
    cin >> S >> T;
    
    S--,T--;
    S = 3*S;
    T = 3*T;
    
    ve<int> f(3*N,infi);
    f[S] = 0;
    
    queue<int> Q;
    Q.push(S);
    while (!Q.empty()) {
        int a = Q.front();
        Q.pop();
        for (int p : E[a]) {
            if(f[p] == infi){
                Q.push(p);
                f[p] = f[a]+1;
            }
        }
    }
    
    //outve(f);
    
    if(f[T] == infi) cout << -1 << endl;
    else if(f[T]) cout << f[T]/3 << endl;
    

    
    
    
    

    return 0;
}


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

int main(void){
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    int x, y;
    x = x2 - x1;
    y = y2 - y1;
    
    cout << x2 - y << " ";
    cout << y2 + x << " ";
    cout << (x2 - y) - x << " ";
    cout << (y2 + x) - y << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <numeric>
using namespace std;

int main()
{
  int N;
  cin>>N;
  vector <int> L(N);
  string ans="No";
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
  sort(L.begin(),L.end());
  if (accumulate(L.begin(),L.end(),0)>2*L[N-1]) ans="Yes";
  cout<< ans <<endl;
}


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

void solve(long long N){
    long long first = 2;
    long long second = 1;
    long long ans = 3;
    REP(i, N - 1) {
        ans = first + second;
        first = second;
        second = ans;
    }
    if (N == 0) cout << 2 << '\n';
    else if (N == 1) cout << 1 << '\n';
    else cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	ll n;
	cin >> n;

	ll c = -2*n;

	ll root1 = (-1.0 + sqrt(1.0 - 4.0 * 1 * c)) / (2.0);
	ll root2 = (-1.0 - sqrt(1.0 - 4.0 * 1 * c)) / (2.0);
	
	ll ans = max(root1 , root2);
	
	if( (ans*(ans+1)) / 2 == n)
	    cout << ans;
	else
	    cout << ans+1;

	return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	as := scanInts(n + 1)
	bs := scanInts(n)

	var cnt int
	for i := 0; i < n; i++ {
		if bs[n-1-i] > as[n-i] {
			cnt += as[n-i] + min(as[n-1-i], bs[n-1-i]-as[n-i])
			as[n-1-i] = max(as[n-1-i]-(bs[n-1-i]-as[n-i]), 0)
		} else {
			cnt += bs[n-1-i]
		}
	}

	fmt.Println(cnt)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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


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

using namespace std;

int main(){

  int N;
  vector<int> p(4);
  vector<int> t(4);
  int min = 100000000;
  
  cin >> N;
  cin >> p[0] >> p[1] >> p[2] >> p[3];
  cin >> t[0] >> t[1] >> t[2] >> t[3];
  
  for(int i = 0;i <= N;++i){
    for(int j = 0;j <= N;++j){
      for(int k = 0;k <= N;++k){
	for(int l = 0;l <= N;++l){
	  if(i*t[0] + j*t[1] + k*t[2] + l*t[3] >= N && min > i*p[0] + j*p[1] + k*p[2] + l*p[3])
	    min = i*p[0] + j*p[1] + k*p[2] + l*p[3];
	}
      }
    }
  }   
    
  cout << min << endl;
  
}



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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int D, tmp;
    cin >> D;
    vector<vector<int>> list(D, vector<int>(26));
    vector<int> C(26);
    vector<int> contest(D);

    for (int i = 0; i < 26; i++)
        cin >> C[i];
    for (int i = 0; i < D; i++)
        for (int j = 0; j < 26; j++)
            cin >> list[i][j];
    for (int i = 0; i < D; i++)
    {
        cin >> tmp;
        contest[i] = tmp - 1;
    }

    vector<int> last(26, -1);
    int ans = 0;

    for (int i = 0; i < D; i++)
    {
        ans += list[i][contest[i]];
        last[contest[i]] = i;
        for (int j = 0; j < 26; j++)
            ans -= C[j] * (i - last[j]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Echo
            int N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            if (IsEcho(N, S))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }

        static bool IsEcho(int N, string S)
        {
            if (N % 2 == 0)
            {
                var s = S.Substring(0, N / 2);

                if (S.Replace(s, "") == "")
                {
                    return true;
                }
            }

            return false;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  vector<ll> v(N);
  vector<ll> sum(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < N - 1; i++) {
    sum[N - 2 - i] += sum[N - 1 - i] + v[N - 1 - i];
    sum[N - 2 - i] %= mod;
  }
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ans += v[i] * sum[i];
    ans %= mod;
  }
  cout << ans << endl;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	string D, a;
	for (int i = 0; i < K; ++i) {
		cin >> D;
		a += D;
	}
	while (string::npos != to_string(N).find_first_of(a)) ++N;
	cout << N;
}

Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll dp[MAXn];
ll d[MAXn];

int main()
{
    IOS();
    ll n, k;
    cin>>n>>k;
    REP1(i,n)cin>>d[i];
    dp[1] = 0;
    for(int i = 2;i <= n;i ++)
    {
        dp[i] = INF;
        for(int j = i-1;j >= 1 && i - j <= k;j--)dp[i] = min(dp[i], dp[j] + abs(d[i] - d[j]));
    }
    cout<<dp[n]<<endl;
}


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

int main() {
    int r, g, b, n;
    int count = 0;
    cin >> r >> g >> b >> n;
    for (int i = 0; i <= n; i += r) {
        for (int j = 0; j <= n; j += g) {
            if (n - i - j >= 0 && (n - i - j) % b == 0) {
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import copy
def make(n, data):
    out = []
    # print(ord(data[-1]) + 1 - ord("a"))
    key = data[1]
    for i in range(key + 1):
        # print(key)
        out.append([data[0] + chr(ord("a") + i), max(key, i + 1)])
    return out

n = int(input())
ans = [["a", 1]]
for i in range(1, n):
    tmp = []

    for j in range(len(ans)):
        tmp += make(i + 1, ans[j])
            # print
    if len(tmp) >= 1:
        ans = copy.deepcopy(tmp)
    # print(ans)

for i in ans:
    print(i[0])

Measured memory_bytes: 51272
using System;

public class ITP1_2_A
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

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

        var a = int.Parse(str[0]);
        var b = int.Parse(str[1]);

        Solve(a, b);
    }

    private static void Solve(int a, int b)
    {
        if (a < b)
        {
            Console.WriteLine("a < b");
        }
        else if (a > b)
        {
            Console.WriteLine("a > b");
        }
        else
        {
            Console.WriteLine("a == b");
        }
    }
}



Measured memory_bytes: 15952
s = [int(input())]
c = 1
while 1:
  if s[-1]%2==0:
    s.append(int(s[-1]/2))
  else:
    s.append(3*s[-1]+1)
  c += 1  
  if len(s)-len(set(s)):
    print(c)
    exit()

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
std::vector<std::string> split(const std::string &str, const char delemiter) {std::vector<std::string> res;std::stringstream ss(str);std::string buffer; while( std::getline(ss, buffer, delemiter) ) res.push_back(buffer); return res;}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int X; cin >> X;
    Yn(X>=30);    
    return 0;
}


Measured memory_bytes: 3628
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def main():
    N = II()
    a_list = []

    for i in range(N):
        a = II()
        a_list.append(a)


    from bisect import bisect_left
    from collections import deque
    g = deque()

    for i in range(N):
        a = a_list[i]
        if len(g) == 0:
            g.appendleft(a)
        else:
            pos = bisect_left(g, a)
            dprint(g, a, pos)
            if pos >= 1:
                g[pos-1] = a
            else:
                #g.insert(0, a)
                g.appendleft(a)
    dprint(g)
    print(len(g))
main()

Measured memory_bytes: 8092
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    double m[N];
    string B[N];
    double sum =0;
    for(int i=0;i<N;i++)
    {
        cin >> m[i] >> B[i];
        if(B[i] == "JPY")
        {
            sum += m[i];
        }
        else
        {
            sum += m[i] * 380000;
        }
        
    }
    cout << sum << endl;
}


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

int main(){
    int n;
    cin >> n;
    int w[n];
    int count=0;
    for(int i=0;i<n;i++){cin >> w[i];count+=w[i];}
    int ans=0;
    int a;
    for(int i=0;i<n;i++){
        ans+=w[i];count-=w[i];
        if(count<=ans){
            a=w[i];
            break;
        }
    }
    if(abs(count-ans)>abs(count-ans+2*a)){
        cout << abs(count-ans+2*a) << endl;
        return 0;
    }
    else{
        cout << abs(count-ans) << endl;
        return 0;
    }
}

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  double A[N];
  for(int i = 0; i < N; i++)
    cin>>A[i];
  sort(A, A+N);
  double sum = A[0];
  
  for(int j = 1; j < N; j++) 
      sum = (sum + A[j]) /2;
   cout<<sum;
   return 0;
 }

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    string s,t;
    cin >> s >> t;
    int cnt=0;
    F0R(i,sz(s))
        cnt+=(s[i]!=t[i]);
    cout << cnt;

    return 0;
}


Measured memory_bytes: 3804
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    res = A[0]
    for i in range(1, N):
        if i % 2 == 0:
            res += A[i]
        else:
            res -= A[i]

    ans = [0 for _ in range(N)]
    ans[0] = res // 2
    for i in range(0, N - 1):
        ans[i + 1] = A[i] - ans[i]
    ans[N - 1] = A[N - 1] - ans[0]
    ans = [2 * a for a in ans]
    print(*ans)


Measured memory_bytes: 66836
sl = list(input())

n = len(sl)

if n == 2:
   if sl[0] == sl[1]:
      print(1)
      print(2)
   else:
      print(-1)
      print(-1)
   import sys
   sys.exit()
else:
   for i in range(n-2):
      a = [sl[i], sl[i+1], sl[i+2]]
      if len(set(a)) <= 2:
         print(i+1)
         print(i+3)
         import sys
         sys.exit()
   print(-1)
   print(-1)

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll k;
  cin >> k;
  
  ll sum = 0;
  rep(i, 1, k+1) {
    rep(j, 1, k+1) {
      rep(l, 1, k+1) {
        sum += gcd(i, gcd(j, l));
      }
    }
  }
        
  cout << sum << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";
  
  //cout << fixed << setprecision(15) << n << "\n";

}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 998244353;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);


    ll n, s;
    cin >> n >> s;
    vector<int> dp(s+1);
    dp[0] = 1;
    for(ll i=1; i<=n; i++) {
        ll a;
        cin >> a;
        for(ll j=s; j>=0; j--) {
            (dp[j] = dp[j] * 2) %= MOD;
            if(j-a>=0)
                (dp[j] += dp[j-a]) %= MOD;
        }
    }
    cout << dp[s] << endl;
}


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

using namespace std;

int s[15],h[15],c[15],d[15];
int main()
{
    int n;
    cin >> n;
    char ch;
    int a;
    for(int i =0;i<n;i++){
        cin >> ch >> a;
        if(ch=='S') s[a] = 1;
        if(ch=='H') h[a] = 1;
        if(ch=='C') c[a] = 1;
        if(ch=='D') d[a] = 1;
    }

    for(int i = 1;i<=13;i++){
        if(s[i] == 0){
            printf("S %d\n",i);
        }
    }
    for(int i = 1;i<=13;i++){
        if(h[i] == 0){
            printf("H %d\n",i);
        }
    }
    for(int i = 1;i<=13;i++){
        if(c[i] == 0){
            printf("C %d\n",i);
        }
    }
    for(int i = 1;i<=13;i++){
        if(d[i] == 0){
            printf("D %d\n",i);
        }
    }
    
    return 0;
}




Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n;
ll x[105];
ll mn = 4e18;

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &x[i]);
    }
    for(ll i = 1; i <= 100; i++)
    {
        ll sum = 0;
        for(ll j = 0; j < n; j++)
        {
            sum += (x[j] - i) * (x[j] - i);
        }
        mn = min(mn, sum);
    }
    cout<<mn<<endl;
    return 0;
}


Measured memory_bytes: 256
"use-strict";
// import bigInt from 'big-integer'

const Main = input => {
  const nums = input.trim().split(" ");
  const num = nums[0] * nums[1];
  console.log(num % 2 === 0 ? "Even" : "Odd");
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 22208
#include<bits/stdc++.h>
using namespace std;
     
     
#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)
const int MOD = 1e9+7, N = 1e7 + 10;

int main(){
    int N,K;
    sd(N);
    sd(K);
    int ans = 0;
    if(K>1){
        ans = N-K;
    }
    pd(ans);
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

N = int(sys.stdin.readline())
h = tuple(map(int, sys.stdin.readline().split()))
cost = [None]*N

def DP(n):
    if cost[n] != None:
        return cost[n]
    
    if n==0:
        return 0
    elif(n > 1):
        cost[n] = min(DP(n-1) + abs(h[n] - h[n-1]), DP(n-2) + abs(h[n] - h[n-2]))
        return cost[n]
    else:
        cost[n] = DP(n-1) + abs(h[n] - h[n-1])
        return cost[n]


print(DP(N-1))

Measured memory_bytes: 122424
//url:
//problem name: 

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    string T = S;
    S = T.substr(0,N-1);
    int cnt = N-1;
    while(1) {
        //cout << cnt << endl;
        T = S.substr(0,cnt);
        if(T.size() %2 == 0 && T.substr(0,cnt/2) == T.substr(cnt/2,cnt/2)) {
            cout << T.size() << endl;
            return 0;
        }
        cnt--;
    }
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,y;
  cin >> x >> y;
  ll ans = 0;
  if(x == 1) ans += 300000;
  if(x == 2) ans += 200000;
  if(x == 3) ans += 100000;
  if(y == 1) ans += 300000;
  if(y == 2) ans += 200000;
  if(y == 3) ans += 100000;
  if(x == 1 && y == 1) ans+=400000;
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n; long long int k;
    cin >> n >> k;

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] -= 1;
    }

    vector<int> visited(n, -1);
    int current = 0, times = 0;
    while(1){
        if(visited[current] != -1) break;
        visited[current] = times;
        
        int next = a[current];
        current = next;
        times += 1;
    }

    if(k < (long long int)times){
        for(int i=0; i<n; i++){
            if(visited[i] == (int)k) cout << i+1 << endl;
        }
    }
    else{
        long long int rem = (k - visited[current]) % (long long int)(times - visited[current]);
        for(int i=0; i<n; i++){
            if(visited[i] == visited[current] + (int)rem) cout << i+1 << endl;
        }
    }
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int v[n+1], c[n+1];
	for(int i=1; i<=n; i++)
	   cin >> v[i];
	for(int i=1; i<=n; i++)
	   cin >> c[i];
	int best[n+1];
	for(int i=1; i<=n; i++)
	   best[i] = v[i]-c[i];
	   
	int sum=0;
	for(int i=1; i<=n; i++){
		if(best[i]>0) sum+=best[i];
	}
	cout << sum;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  bool flag = true;
  
  if(s[0] != 'A') flag = false;
  
  int cnt = 0, pos=-1;
  for(int i=2; i<s.length()-1; i++){
    if(s[i] == 'C'){
      cnt++;
      pos = i;
    }
  }
  if(cnt != 1) flag = false;
  
  for(int i=1; i<s.length(); i++){
    if(i != pos && isupper(s[i])) flag = false;
  }
     
  if(flag) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en) for(int i=st; i<en; i++)
#define eb emplace_back
#define pri1(a) cout<<a<<'\n'
#define pri2(a,n) rep(i,n)cout<<a[i]<<'\n'
#define pri3(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int n,m,_,x,y,q,key;
string s,sb;
bool ok;
Int dp[51][51][2501];

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

  cin>>n>>x; int a[n]; rep(i,n)cin>>a[i];
  dp[0][0][0]=1;
  rep(i,n){
    rep(j,n+1){
      rep(k,2501){
        if(j&&k>=a[i])dp[i+1][j][k]=dp[i][j-1][k-a[i]]+dp[i][j][k];
        else dp[i+1][j][k]=dp[i][j][k];
      }
    }
  }
  Int ans=0;
  rer(i,1,n+1){
    rep(j,2501)if(j==i*x)ans+=dp[n][i][j];
  }
  END
}

Measured memory_bytes: 50048
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

#define BIGNUM 1000000000000000000

int main(void) {
	unsigned long long A, B, C, K;
	cin >> A >> B >> C >> K;

	long long diff;
	diff = A - B;

	if (diff > BIGNUM || diff < -BIGNUM) {
		cout << "Unfair" << endl;
		return 0;
	}

	if(K%2 == 1){
		cout << -diff << endl;
		return 0;
	}

	cout << diff << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int m[3]={1000,500,100};
int main(){
  int a,b;
  while(cin>>a>>b,a||b){
    int tmp=b-a;
    int ans[3]={0};
    rep(i,3){
      while(tmp>=m[i]){
	tmp-=m[i];
	ans[i]++;
      }
    }
    cout<<ans[2]<<" "<<ans[1]<<" "<<ans[0]<<endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int L, R, d; cin >> L >> R >> d;
  int ans = 0;
  for(int i = L; i <= R; ++i) {
    if(i % d == 0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
n = int(input())
s = ["".join(sorted(str(input()))) for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Measured memory_bytes: 19400
#include<bits/stdc++.h>
using namespace std;
#define MN 25000
#define MK 400
#define MOD 1000000007
int a[MN+5],c[MK+5],A[MN+5][MK+5],B[MN+5][MK+5];
inline void rw(int&x,int y){if((x+=y)>=MOD)x-=MOD;}
inline int inv(int x)
{
	int r=1,y=MOD-2;
	for(;y;y>>=1,x=1LL*x*x%MOD)if(y&1)r=1LL*r*x%MOD;
	return r;
}
int main()
{
	int n,k,m,i,j,ans;
	scanf("%d%d%d",&n,&k,&m);
	for(i=1;i<=m;++i)scanf("%d",&a[i]);
	for(ans=n-m+1,i=1;i<=n-m;++i)ans=1LL*ans*k%MOD;
	for(i=1;i+k-1<=m;++i)
	{
		memset(c,0,sizeof(c));
		for(j=0;j<k;++j)if(c[a[i+j]]++)break;
		if(j==k){printf("%d",ans);return 0;}
	}
	memset(c,0,sizeof(c));
	for(i=1;i<=m;++i)if(c[a[i]]++)break;
	if(i>m)
	{
		A[0][0]=1;
		for(i=0;i<=n;++i)
		{
			for(j=1;j<k;++j)rw(A[i+1][j],A[i][j]),rw(B[i+1][j],B[i][j]);
			for(j=k;--j;)rw(A[i+1][j-1],A[i+1][j]),rw(B[i+1][j-1],B[i+1][j]);
			for(j=bool(i);j<k;++j)rw(A[i+1][j+1],1LL*A[i][j]*(k-j)%MOD),rw(B[i+1][j+1],1LL*B[i][j]*(k-j)%MOD);
			for(j=m;j<k;++j)rw(B[i+1][j],A[i+1][j]);
		}
		for(i=0,j=1;i<m;++i)j=1LL*j*(k-i)%MOD;
		rw(ans,MOD-1LL*B[n+1][0]*inv(j)%MOD);
		printf("%d",ans);
		return 0;
	}
	A[0][i-1]=1;
	memset(c,0,sizeof(c));
	for(i=m;i;--i)if(c[a[i]]++)break;
	B[0][m-i]=1;
	for(i=0;i<=n-m;++i)
	{
		for(j=1;j<k;++j)rw(A[i+1][j],A[i][j]),rw(B[i+1][j],B[i][j]);
		for(j=k;--j;)rw(A[i+1][j-1],A[i+1][j]),rw(B[i+1][j-1],B[i+1][j]);
		for(j=1;j<k;++j)rw(A[i+1][j+1],1LL*A[i][j]*(k-j)%MOD),rw(B[i+1][j+1],1LL*B[i][j]*(k-j)%MOD);
	}
	for(i=1;i<=n-m+1;++i)rw(ans,MOD-1LL*A[i][0]*B[n+2-i-m][0]%MOD);
	printf("%d",ans);
}

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

using namespace std;

int main(void){
  long a, b, c, d;
  long x, y;
  long z;
  cin >> a >> b >> c >> d;
  if (b >=0 && d >= 0){
    if (a * c <= b * d){
      x = b;
      y = d;
    } else {
      x = a;
      y = c;
    }
  } else if ((a < 0 && b >= 0 && c < 0 && d < 0) ||
            (a < 0 && b < 0 && c < 0 && d >= 0) ||
            (a < 0 && b < 0 && c < 0 && d < 0)){
    x = a;
    y = c;
  } else if (a >= 0 && b >= 0 && c < 0 && d < 0){
    x = a;
    y = d;
  } else if (a < 0 && b < 0 && c >= 0 && d >= 0){
    x = b;
    y = c;
  } 
  z = x * y;
  cout << z << endl;
}
    
    

Measured memory_bytes: 3644
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	int t;
	cin>>t;
	int ac=0,wa=0,tle=0,re=0;
	for(int t1 = 0;t1 < t;t1++)
	{
		char str[10];
		cin>>str;
		if(!strcmp(str,"AC"))
			ac++;
		else if(!strcmp(str,"WA"))
			wa++;
		else if(!strcmp(str,"TLE"))
			tle++;
		else if(!strcmp(str,"RE"))
			re++;
	}
	cout << "AC x "<<ac;
	cout << "\nWA x "<<wa;
	cout << "\nTLE x "<<tle;
	cout << "\nRE x " <<re<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int N=110;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,m,t,mod,f[N][N][N][2],g[N][N][N][2],C[N][N];

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int main() {
	n=gi(),m=gi(),t=gi(),mod=gi();
	f[1][0][0][0]=1;
	for(int i=0;i<=n||i<=m;i++) {
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	}
	for(int i=1;i<=t;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++) {
				int tmp=(qpow(i,m-k)-qpow(i-1,m-k)+mod)%mod;
				tmp=1ll*tmp*qpow(t-i+1,k)%mod;
				g[i][j][k][0]=qpow(tmp,j);
			}
	for(int i=1;i<=t;i++)
		for(int j=0;j<=m;j++)
			for(int k=0;k<=n;k++) {
				int tmp=(qpow(t-i+1,k)-qpow(t-i,k)+mod)%mod;
				tmp=1ll*tmp*qpow(i,n-k)%mod;
				g[i][j][k][1]=qpow(tmp,j);
			}
	for(int i=1;i<=t;i++)
		for(int j=0;j<=n;j++)
			for(int k=0;k<=m;k++) {
				if(f[i][j][k][0])
					for(int l=0;l+j<=n;l++)
						f[i][j+l][k][1]=(f[i][j+l][k][1]+1ll*f[i][j][k][0]*g[i][l][k][0]%mod*C[n-j][l])%mod;
				if(f[i][j][k][1])
					for(int l=0;l+k<=m;l++)
						f[i+1][j][k+l][0]=(f[i+1][j][k+l][0]+1ll*f[i][j][k][1]*g[i][l][j][1]%mod*C[m-k][l])%mod;
			}
	cout<<f[t+1][n][m][0];
	return 0;
}


Measured memory_bytes: 20608
large_p = 10**9 + 7

def main():
    n, m = map(int, input().split())
    if (abs(n-m)) >= 2:
        print(0)
    else:
        
        np = 1
        for i in range(n,0,-1):
            np = (np * i) % large_p
        mp = 1
        for i in range(m,0,-1):
            mp = (mp * i) % large_p

        if abs(n-m) == 1:
            r = (np * mp) % large_p
            print(r)
        else:
            r = ((np * mp) * 2) % large_p
            print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

const int MAX_N = 55;

ll V[MAX_N];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) cin >> V[i];
    ll ans = 0;
    for (int left = 0; left <= K; left++) {
        for (int right = 0; right <= K - left; right++) {
            if (left + right > N) continue;
            vector<ll> negative;
            ll sum = 0;
            for (int i = 0; i < left; i++) {
                if (V[i] < 0) negative.push_back(V[i]);
                else sum += V[i];
            }
            for (int i = 0; i < right; i++) {
                if (V[N - i - 1] < 0) negative.push_back(V[N - i - 1]);
                else sum += V[N - i - 1];
            }
            sort(negative.begin(), negative.end());
            for (int i = min(K - left - right, int(negative.size())); i < negative.size(); i++) {
                sum += negative[i];
            }
            ans = max(ans, sum);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = input()

lis = []
a = 0
b = -1
mae = 'L'

for i in n:
  if i != mae:
    mae = i
    a = 0
    b += 1
    lis.append([0,0])
  a += 1
  lis [b][0] = a

c = 0
while c < len(lis):
  lis[c][1] = (lis[c][0] // 2) + (lis[c][0] % 2) + (lis[c+1][0] // 2)
  lis[c+1][1] = (lis[c][0] // 2) + (lis[c+1][0] // 2) + (lis[c+1][0] % 2)
  c += 2

for i in range(0,len(lis),2):
  for k in range(lis[i][0]-1):
    print(0, end = ' ')
  print(lis[i][1], end = ' ')
  print(lis[i+1][1], end = ' ')
  for k in range(lis[i+1][0]-1):
    print(0, end = ' ')

Measured memory_bytes: 14192
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

int main() {
  string s; cin >> s;
  int n = (int)s.length();

  vector<string> t = {"dream", "dreamer" , "erase" , "eraser"};
  vector<bool> dp(n+1, false);

  dp[0] = true;
  REP(i, n+1){
    if(!dp[i]) continue;
    REP(j, 4){
      int m = (int)t[j].length();
      if(i + m > n) continue;
      dp[i + m] = dp[i + m] || s.substr(i, m) == t[j];
    }
  }

  cout << (dp[n]? "YES": "NO") << endl;
  
  return 0;
}


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
const ll inf = (ll)1e15;
const ll N = (ll)2e5+77;
const ll mod = (ll)1e9+7;

int a[4];
void go(int op, vector<char>& v, int ret) {
    if (op == 3 and ret == 7) {
        cout << a[0];
        forn(i, 3) cout << v[i] << a[i + 1];
        cout << "=7\n";
        exit(0);
    }
    if (op >= 3) return;
    v.push_back('+');
    ret += a[op + 1];
    go(op + 1, v, ret);
    v.pop_back();
    ret -= a[op + 1];

    v.push_back('-');
    ret -= a[op + 1];
    go(op + 1, v, ret);
    v.pop_back();
    ret += a[op + 1];
}

int main() {
    fast;
    char c;
    forn(i, 4) cin >> c, a[i] = c - '0';
    vector<char> v;
    int ret = a[0];
    go(0, v, ret);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
D = [map(int, input().split()) for _ in range(N)]
D1, D2 = [list(i) for i in zip(*D)]
ans = 0
for i in range(N-2):
    if D1[i] == D2[i] and D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2]:
        ans = 1
        break
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N*A, B) << endl;
}

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

int main()
{
  int n;
  cin >> n;
  int h[100001];
  for (int i = 0; i < n; ++i)
  {
    cin >> h[i];
  }
  
  int max = 0, cur = -1;
  int prev = 0;
  for (int x = 0; x < n; ++x)
  {
    if (prev < h[x])
    {
      max = max > cur ? max : cur;
      cur = 0;
    }
    else
    {
      ++cur;
    }
    prev = h[x];
  }
  if (cur > 0)
  {
    max = max > cur ? max : cur;
  }
  
  cout << max << endl;
  return 0;
}

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

int main(int argc, char const *argv[])
{
  int n;
  int MAX_N = 50;
  int MAX_S = 50;
  cin >> n;
  vector<string> str(n);
  for(int i = 0; i < n; i++)
    cin >> str[i];

  char ch[MAX_N][MAX_S + 1] = {};
  for(int i = 0; i < n; i++)
    str[i].copy(ch[i], str[i].size());

  char alpha = 'a';
  do
  {
    bool search;
    for(int i = 0; i < n; i++)
    {
      search = false;
      for(int j = 0; ch[i][j] != '\0'; j++)
      {
        if(ch[i][j] == alpha)
        {
          ch[i][j] = '-';
          search = true;
          break;
        }
      }
      if(!search)
        break;
    }
    if(search)
      cout << alpha << flush;
    else
      alpha++;
  }while(alpha <= 'z');

  return 0;
}


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

int main() {
    int N, A;
    cin >> N >> A;
    vector<int> x(N);
    rep(i, 0, N) cin >> x[i], x[i] -= A;
    vector<vector<long long>> dp(N + 1, vector<long long>(5555));
    int g = 2500;
    dp[0][g] = 1;
    rep(i, 0, N) rep(j, -g, g) {
        dp[i + 1][j + g] += dp[i][j + g];
        dp[i + 1][j + g + x[i]] += dp[i][j + g];
    }
    cout << dp[N][g] - 1 << endl;
    return 0;
}


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

int main(){
    string S, T;
	cin >> S;
    cin >> T;

    int ans=0;
    for(int i=0; i<S.size(); i++){
        if( S.at(i) != T.at(i) ){
            ans++;
        }    
    }

	cout << ans << endl;

}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
bool compare(pair<int,int> p1,pair<int,int> p2)
{
    if(p1.first==p2.first) return p1.second<p2.second;
    return p1.first<p2.first;
}
int32_t main()
{
    IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    int n,W,w,v;
    cin>>n>>W;
    vector<pair<int,int>> item;
    item.push_back({0,0});
    for(int i=0;i<n;i++) {cin>>w>>v; item.push_back(make_pair(w,v));}
    sort(item.begin(),item.end(),compare);
    // for(int i=1;i<=n;i++) cout<<item[i].first<<" "<<item[i].second<<endl;
    int dp[n+1][W+1];
    for(int i=0;i<=n;i++) dp[i][0]=0;
    for(int i=0;i<=W;i++) dp[0][i]=0;
    for(int i=1;i<=W;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i-item[j].first>=0) dp[j][i]=max(dp[j-1][i],item[j].second+dp[j-1][i-item[j].first]);
            else dp[j][i]=dp[j-1][i];
        }
    }
    // for(int i=0;i<=n;i++) {for(int j=0;j<=W;j++) cout<<dp[i][j]<<" "; cout<<endl;}
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 79232
import sys
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
for i in range(n):
    b = int(input())
    for s in range(3):
        for t in range(3):
            if a[s][t] == b:
                a[s][t] = -1
    for t in range(3):
        if all(a[t][s]==-1 for s in range(3)):
            print("Yes")
            sys.exit()
    for t in range(3):
        if all(a[s][t]==-1 for s in range(3)):
            print("Yes")
            sys.exit()
    if all(a[s][s]==-1 for s in range(3)):
        print("Yes")
        sys.exit()
    if a[0][2]==-1 and a[1][1]==-1 and a[2][0]==-1:
        print("Yes")
        sys.exit()
print("No")



Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

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

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int l, r;
	//区間[l,r]を走る列車について考える。これを二次元平面上の(y座標,x座標)=(l,r)
	//の点とみなすとこの列車を完全に含むような区間はy<=lかつr<=xの範囲全てになる
	int imos[550][550];//imos[y][x]でyからxまでの区間に含まれる列車の本数
	for (int i = 0; i < 550; ++i) {
		for (int j = 0; j < 550; ++j) {
			imos[i][j] = 0;
		}
	}
	for (int i = 0; i < M; ++i) {
		cin >> l >> r;
		imos[l][r]++;
	}
	for (int i = 510; i >0; --i) {
		for (int j = 0; j <510; ++j) {
			imos[i - 1][j] += imos[i][j];
		}
	}
	for (int i = 0; i < 510; ++i) {
		for (int j = 0; j < 510; ++j) {
			imos[i][j + 1] += imos[i][j];
		}
	}
	for (int i = 0; i < Q; ++i) {
		cin >> l >> r;
		cout << imos[l][r] << endl;
	}
	return 0;
}



Measured memory_bytes: 2048
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int a,b;
    int count=0;
    cin>>a>>b;
    rep(i,a){
        int c;
        cin>>c;
        if(c>=b){
            count++;
        }
    }
    cout<<count<<endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define per(i,x,y) for(in i=y;i>=(x);--i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const in maxn = 1e5+9;

in degrau[maxn],degrau2[maxn];
vector<in> v[maxn];

void bfs(in x)
{
	queue<in> q;
	q.push(x);
	degrau[x] = 1;
	while(!q.empty())
	{
		in agr = q.front();
		q.pop();
		rep(i,0,v[agr].size())
		{
			if(degrau[v[agr][i]] == 0)
			{
				degrau[v[agr][i]] = degrau[agr] + 1;
				q.push(v[agr][i]);
			}
		}
	}
}

int main()
{
	IOS;
	in n,a,b;
	cin >> n >> a >> b;
	rep(i,0,n-1)
	{
		in x,y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}
	bfs(a);
	rep(i,1,n+1)
	{
		degrau2[i] = degrau[i];
		degrau[i] = 0;
	}
	bfs(b);
	in fuga = a;
	rep(i,1,n+1)
	{
		if(degrau[fuga] < degrau[i])
		{
			if(degrau2[i] < degrau[i])
			{
				fuga = i;
			}
		}
	}
	in ans = degrau2[fuga]-1,posa = fuga, posb = b-ans,turn = 0;	
	while(degrau[fuga]-1 - ans > 0)
	{
		if(turn== 0)
		{
			degrau[fuga]--;
			turn = 1;
			if(degrau[fuga]-1 - ans <= 0) break;
			else
			{
				ans++;
			}
		}
		else
		{
			degrau[fuga]++;
			turn = 0;	
			ans++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 8064