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

void solve() {
    int k;
    std::string s;
    std::cin >> k >> s;

    if ((int)s.length() <= k) {
        std::cout << s << "\n";
    } else {
        std::cout << s.substr(0, k) << "...\n";
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

	static int n;
	static int d;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);


		n = sc.nextInt();
		d = sc.nextInt();

		int[][] x = new int[n][d];
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < d ; j++) {
				x[i][j] = sc.nextInt();
			}
		}
		int ans = 0;
		for(int i = 0 ; i < n ; i++) {
			for(int j = i + 1 ; j < n ; j++) {
				if(judge(x[i], x[j])) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}

	private static boolean judge(int[] y, int[] z) {
		int sum = 0;
		for(int i = 0 ; i < d ; i++) {
			sum += (z[i] - y[i]) * (z[i] - y[i]);
		}
		double root = Math.sqrt((double)sum);
		int hoge = (int)root;
		return root - hoge == 0.0d;
	}
}


Measured memory_bytes: 22612
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	sc.Split(bufio.ScanLines)

	s := make([]int, 10)
	for i := 0; i < 10; i++ {
		s[i], _ = strconv.Atoi(read())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(s)))
	fmt.Println(s[0])
	fmt.Println(s[1])
	fmt.Println(s[2])
}



Measured memory_bytes: 1120
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int N;
vector<int> l(10);
int A,B,C;
vector<int> used(10,-1);

int f(int n){
  int res=0;
  if(n == N){
    int sum_A=0,sum_B=0,sum_C=0;
    for(int i=0; i<N; i++){
      if(used[i] == 1){
        if(sum_A){
          res += 10;
        }
        sum_A += l[i];
      }else if(used[i] == 2){
        if(sum_B){
          res += 10;
        }
        sum_B += l[i];
      }else if(used[i] == 3){
        if(sum_C){
          res += 10;
        }
        sum_C += l[i];
      }
    }
    if(sum_A == 0 || sum_B == 0 || sum_C == 0){
      return 1e9;
    }
    res += abs(A-sum_A);
    res += abs(B-sum_B);
    res += abs(C-sum_C);
    return res;
  }
  res = 1e9;
  for(int i=0; i<4; i++){
    used[n] = i;
    chmin(res,f(n+1));
    used[n] = -1;
  }
  return res;
}
int main(){
  cin >> N;
  cin >> A >> B >> C;
  for(int i=0; i<N; i++){
    cin >> l[i];
  }
  cout << f(0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << "\n";
    return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	bs := NewBufScanner(in)
	bw := NewBufWriter(out)
	defer bw.w.Flush()
	n, s := bs.IntScan(), bs.Scan()

	rcount := 0
	bcount := 0
	gcount := 0

	for i:=1; i<=n; i++ {
		switch(s[i-1]){
		case 'R':
			rcount++
		case 'B':
			bcount++
		case 'G':
			gcount++
		}
	}

	if rcount == 0 || gcount == 0 || bcount == 0 {
		bw.Printf("0")
		return
	}

	sum := rcount * gcount * bcount
	for i:=0; i<n-2; i++ {
		for j:=i; i<n-1; j++ {
			k := 2*j-i
			if k >= n {
				break
			}
			if s[i] != s[j] && s[j] != s[k] && s[i] != s[k] {
				sum--
			}
		}
	}

	bw.Printf("%v", sum)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 1024), 1e+9)
	s.Split(bufio.ScanWords)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// IntScan Scan Data
func (b *BufScanner) IntScan() int {
	v, err := strconv.Atoi(b.Scan())
	if err != nil {
		panic(err)
	}
	return v
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

Measured memory_bytes: 1800
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> v(N);

    rep(i,0,N) cin >> v[i];

    if(v[0] != 0){
        cout << -1 << endl;
        return 0;
    }
    ll ans = 0;
    int tapi = 0;
    for(int i = N - 1; i >= 0; i--){
        if(i == N - 1){
            ans += v[i];
            tapi = v[i] - 1;
        }else{
            if(v[i] > tapi){
                ans += v[i];
                tapi = v[i] - 1;
            }else if(v[i] == tapi){
                tapi--;
            }else{
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;




    return 0;
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll r;
    cin >> r;
    cout << 2*r*acos(-1);
    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main(void) {

    int n;
    vvi a(3,vi(3));
    rep(i,3)rep(j,3)cin>>a[i][j];
    cin>>n;
    set<int> s;
    rep(i,n){
        int b;
        cin>>b;
        s.insert(b);
    }
    rep(i,3)rep(j,3){
        if(s.count(a[i][j])==1){
            a[i][j]=-1;
        }
    }
    rep(i,3){
        if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1){
            fin("Yes");
            return 0;
        }
    }
    rep(i,3){
        if(a[0][i]==-1&&a[1][i]==-1&&a[2][i]==-1){
            fin("Yes");
            return 0;
        }
    }
    if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1){
        fin("Yes");
        return 0;
    }
    if(a[2][0]==-1&&a[1][1]==-1&&a[0][2]==-1){
        fin("Yes");
        return 0;
    }
    fin("No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define INF 999999999
typedef long long ll;
using VI = vector<int>;
using Int = long long int;
ll gcd(ll a,ll b){
  return b ? gcd(b,a%b) : a;
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int n;cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  ll m =a[0];
  rep(i,n) m = lcm(m,a[i]);
  cout << m << endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    s = input()
    l = len(s) - 2

    print(s[0] + str(l) + s[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 61864
S = int(input())
ans = 0
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 4  
fact = [1, 1] 
factinv = [1, 1]  
inv = [0, 1]  
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in range(1,S//3+1):
    ans += fact[S-2*i-1]*factinv[i-1]*factinv[S-3*i]

print(ans%p)

Measured memory_bytes: 67748
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    vector<vector<int> > v;
    vector<int> k, l;
    k.push_back(1);
    l.push_back(1);
    v.push_back(k);
    v.push_back(l);
    int count=2;
    if(n==1){
        yes;
    cout<<v.size()<<"\n";
    for(int i=0;i<v.size();i++){
        cout<<v[i].size()<<" ";
        for(int j=0;j<v[i].size();j++){
            cout<<v[i][j]<<" ";
        }
        cout<<"\n";
    }
        return 0;
    }
    while(true){
        vector<int> v1;
        v.push_back(v1);
        for(int j=0;j<v.size()-1;j++, count++){
            if(count>=n+1){
                no;
                return 0;
            }
            v[j].push_back(count);
            v[v.size()-1].push_back(count);
        }
        if(count==n+1){
            break;
        }
    }
    yes;
    cout<<v.size()<<"\n";
    for(int i=0;i<v.size();i++){
        cout<<v[i].size()<<" ";
        for(int j=0;j<v[i].size();j++){
            cout<<v[i][j]<<" ";
        }
        cout<<"\n";
    }
    
}


Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) return gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main() {

	int n;
	cin >> n;
	vector<int> ij;
	ll ans = 0;
	FOR(i, 1, n + 1) {
		FOR(j, 1, n + 1) {
			ij.push_back(gcd(i, j));
		}
	}

	FOR(i,1, n+1) {
		rep(j, n * n) {
			ans += gcd(ij[j], i);
		}
	}

	cout << ans << endl;
}




Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d>0?i<n:i>n;i+=d)
#define endl "\n"
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    string S, T; cin >> S >> T;
    sort(S.begin(), S.end());
    sort(T.rbegin(), T.rend());
    cout << (S < T ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#define ll long long
using namespace std;
ll a[200010];
ll b[200010];
ll sum;
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		b[i] = a[i] - i;
	}
	sort(b + 1, b + n + 1);
	ll x = b[(n + 1) / 2];
	for (int i = 1; i <= n; i++) {
		sum += abs(a[i] - i - x);
	}
	printf("%lld\n", sum);
}

Measured memory_bytes: 3328
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
n=int(input())
a=[]
for i in range(n):
  a.append([int(input()),i])
a=sorted(a, key=lambda m: m[0])
counter=0
for i in range(n):
  if (a[i][1]-i)%2==1:
    counter+=1
c=counter//2
if (c+1)*2<=counter:
  c+=1
print(c)

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

using i64 = long long int;

vector<int> graph[200005];

int main(){
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    bool flag = false;
    for(auto from : graph[1]){
        for(auto to : graph[from]){
            if(to == n){
                flag = true;
                break;
            }
        }
        if(flag)break;
    }

    cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}


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

int main() {
  int N, M, C;

  cin >> N >> M >> C;

  int A[N][M];  
  int B[M];
  int count = 0;
  int result;

  for (int j = 0; j < M; j++) {
    cin >> B[j];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
       cin >> A[i][j];
    }
  }
  
  
  for (int i = 0; i < N; i++) {
    result = 0;
    for (int j = 0; j < M; j++) {
      result += A[i][j] * B[j];
    }

    result += C;
    if (result > 0) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	
	queue<int> q,nq;

	rep(i,1<<n){
		int tmp;
		cin >> tmp;
		q.push(tmp);
	}

	while(q.size()>1){

		while(!q.empty()){
			int x=q.front();q.pop();
			int y=q.front();q.pop();
			int z=abs(x-y);
			if(z==0) z=x;
			nq.push(z);	
		}
		swap(q,nq);
	}

	cout << q.front() << endl;
	return 0;
}

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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i++)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

vector<char> boin = {'a','i','u','e','o'};
vector<char> alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main(){
    int N;
    cin >> N;
    int A[N];
    vector<int> cnt(N,0);
    ll DP[N+1];
    DP[0] = 1;
    Rep(i,N){
        cin >> A[i];
        cnt[A[i]]++;
        if(A[i] != 0){
            DP[i+1] = DP[i]*(cnt[A[i]-1]-cnt[A[i]]+1);
        }else{
            DP[i+1] = DP[i]*(4-cnt[A[i]]);
        }
        DP[i+1] %= MOD;
        //cout << DP[i+1] << endl;
    }
    cout << DP[N] << endl;
    //cin >> N;
}


Measured memory_bytes: 1792
d = ["dream", "dreamer", "erase", "eraser"]

def getDevidedString(s):
    i = 0
    while i < 4:
        position = len(d[i]) * -1
        str = s[position:]
        if str == d[i]:
           return s[0:position]
        i += 1
    return s

S = input()

while len(S) != 0:
    tmp = getDevidedString(S)
    if len(S) != len(tmp):
        S = tmp
    else:
        break

if len(S)== 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    ll n,m;
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1 << endl;
    }
    else if(n == 1){
        cout << m-2 << endl;
    }else if(m == 1){
        cout << n-2 << endl;
    }else {
        cout << (m-2)*(n-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
 
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b%a == 0){
            System.out.println(a+b);
        }else{
            System.out.println(b-a);
        }
    }
}


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

int main() {
    int N; cin >> N;
    int64_t ans = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = i; j <= N; j += i) {
            ans += j;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int h, w, n, x, y;
char a[maxn], b[maxn];
void no() { puts("NO"); exit(0);}
int main()
{
	scanf("%d%d%d", &h, &w, &n);
	scanf("%d%d", &x, &y);
	scanf("%s%s", a + 1, b + 1);
	int s = 1, t = w;
	for(int i = n; i; --i)
	{
		if(b[i] == 'L') t = min(t + 1, w);
		if(b[i] == 'R') s = max(s - 1, 1);
		if(a[i] == 'L') ++s;
		if(a[i] == 'R') --t;
		if(s > t) no();
	}
	if(y > t || y < s) no();
	s = 1, t = h;
	for(int i = n; i; --i)
	{
		if(b[i] == 'U') t = min(t + 1, h);
		if(b[i] == 'D') s = max(s - 1, 1);
		if(a[i] == 'U') ++s;
		if(a[i] == 'D') --t;
		if(s > t) no();
	}
	if(x > t || x < s) no();
	puts("YES");
	return 0;
}
		

Measured memory_bytes: 640
package main

import (
	"fmt"
	"os"
)

func gcd(a, b int) int {
	if b == 0 {
		return a
	}

	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func run() int {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	fmt.Println(lcm(a, b))

	return 0
}

func main() {
	os.Exit(run())
}


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

using namespace std;

int main(){
        int n,r;
        cin >> n >> r;

        if(10 > n){
                cout << r + 100 * (10 - n) << endl;
        }
        else if (n >= 10){
                cout << r << endl;
        }
        return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (int r = (aa)-1; r >= (bb); r--)
#define be(x) (x.begin(), x.end())
#define pb(t) push_back(t)
#define ll long long
#define mp(a, b) make_pair(a, b)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll n,c=1,ans=0;
	cin>>n;
	while(n){
		ans+=c;
		c*=2;
		n/=2;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

template<typename T>
class DAG{
  private:
    int v;
    std::vector<std::vector<std::pair<int,T>>> to;
    std::vector<int> rank;
    std::vector<T> dp;
  public:
    DAG(int v,const T &x=T(0)):v(v){
        to.resize(v);
        rank.resize(v);
        dp.resize(v,x);
        std::iota(rank.begin(),rank.end(),0);
    }
    void add(int a,int b,const T &c=0){
        to[a].push_back(std::make_pair(b,c));
        if(rank[a]>rank[b]) std::swap(rank[a],rank[b]);
    }
    void set(int i,const T &x){
        dp[i]=x;
    }
    std::vector<T> calc(std::function<T(T,T)> f,std::function<T(ll,T)> h=[](ll a,T b){return b;},std::function<T(T,T)> g = std::plus<T>()){
        std::vector<int> vertex(v);
        std::vector<T> tmp=dp;
        for(int i=0;i<v;++i) vertex[rank[i]]=i;
        for(int i=0;i<v;++i){
            ll sz=to[vertex[i]].size();
            for(const auto &e:to[vertex[i]]){
                tmp[e.first]=f(tmp[e.first],g(h(sz,tmp[i]),e.second));
            }
        }
        return tmp;
    }
};

int main(){
    int N,W;cin>>N>>W;
    DAG<ll> D((N+1)*(W+1));
    REP(i,N){
        int w,v;cin>>w>>v;
        REP(j,W+1){
            D.add((W+1)*i+j,(W+1)*(i+1)+j,0);
            if(j+w<=W) D.add((W+1)*i+j,(W+1)*(i+1)+j+w,v);
        }
    }
    vector<ll> res = D.calc([](ll a,ll b){return max(a,b);});
    ll ans=0;
    REP(i,W+1) ans=max(ans,res[(W+1)*N+i]);
    cout<<ans<<endl;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

class BIT {
private:
	int* FT;
	int n;
public:
	void updateBIT(int index , int val) {
		index += 1;
		while (index <= n) {
			FT[index] += val;
			index += (index & (-index));
		}
	}

	int getSum(int index) {
		index += 1;
		int sum = 0 ;
		while (index > 0) {
			sum += FT[index];
			index -= (index & (-index));
		}
		return sum;
	}


	BIT(int* a , int v) {
		n = v ;
		FT = new int[n + 1];
		for (int i = 1 ; i <= n ; i++) {
			FT[i] = 0 ;
		}
		for (int i = 0 ; i < n ; i++) {
			updateBIT(i, a[i]);
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}

int32_t main() {
	FIO;



	int n ;
	cin >> n;

	if (n & 1) {
		cout << (2 * n);
	}
	else {
		cout << n;
	}


	return 0;
}


Measured memory_bytes: 3580
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from collections import deque


mod = 1000000007

if __name__ == "__main__":
    d={}
    n = int(sys.stdin.readline())
    for i in range(n):
        l= list(sys.stdin.readline().split())
        cmd = l[0]
        if len(l)==2:
            text = l[1]
        if cmd == "insert":
            d[text]=1
        elif cmd == "find":
            if text in d:
                print("yes")
            else:
                print("no")

# import sys
# n = int(sys.stdin.readline())
# d = {}
# for i in range(n):
#     line = sys.stdin.readline().split()
#     cmd = line[0]
#     if len(line) == 2:
#         value = line[1]
#     if cmd == "insert":
#         d[value] = 1
#     elif cmd == "find":
#         if value in d:
#             print("yes")
#         else:
#             print("no")    



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


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

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

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}



int check(int n) {

	int temp = n + 9;

	temp = temp / 10;
	return temp * 10;



}

bool comp(pair<string, pair<int, int>> a , pair<string, pair<int, int>> b) {


	// return a % 10 > b % 10;
	if (a.F != b.F)
		return a.F < b.F;
	return a.S.F > b.S.F;

}
bool check(int a, int b, int c) {

	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);

	auto it = s.begin();
	it++;
	// cout<<*it<<endl;
	if (b == *it)
		return true;
	return false;



}
bool isPerfectSquare(ll n) 
{ 
    for (ll i = 1; i * i <= n; i++) { 
  
        // If (i * i = n) 
        if ((n % i == 0) && (n / i == i)) { 
            return true; 
        } 
    } 
    return false; 
}

int main() {
	int i, n, m, k, c = 0;
	c_p_c();
	cin>>n>>m;


	m=2*m+1;
	cout<<(n+m-1)/m<<endl;


	return 0;
}



Measured memory_bytes: 3544
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	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++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll mi=4*(inf-7)*(inf-7);
    ll n,kk;cin>>n>>kk;
    vector<pll>p(n);
    rep(i,n){
        ll x,y;cin>>x>>y;
        p[i]=mp(x,y);
    }
    if(kk==2){
        rep(i,n){
            REP(j,i+1,n){
                mi=min(mi,abs((p[i].first-p[j].first)*(p[i].second-p[j].second)));
            }
        }
        cout<<mi<<endl;
        return 0;
    }
    if(kk==3){
        rep(i,n){
            REP(j,i+1,n){
                REP(k,j+1,n){
                    ll X=max(max(p[i].first,p[j].first),p[k].first);
                    ll Y=max(max(p[i].second,p[j].second),p[k].second);
                    ll x=min(min(p[i].first,p[j].first),p[k].first);
                    ll y=min(min(p[i].second,p[j].second),p[k].second);
                    mi=min((X-x)*(Y-y),mi);
                }
            }
        }
        cout<<mi<<endl;
        return 0;
    }
    rep(i,n){
        REP(j,i+1,n){
            REP(k,j+1,n){
                REP(l,k+1,n){
                    ll X=max(max(p[i].first,p[j].first),max(p[k].first,p[l].first));
                    ll Y=max(max(p[i].second,p[j].second),max(p[k].second,p[l].second));
                    ll x=min(min(p[i].first,p[j].first),min(p[k].first,p[l].first));
                    ll y=min(min(p[i].second,p[j].second),min(p[k].second,p[l].second));
                    ll cnt=0;
                    rep(m,n){
                        if(p[m].first<=X&&p[m].first>=x&&p[m].second>=y&&p[m].second<=Y)cnt++;
                    }
                    if(cnt==kk)mi=min((X-x)*(Y-y),mi);
                }
            }
        }
    }
    cout<<mi<<endl;
}

Measured memory_bytes: 256
def warshall_floyd(graph):
    n_nodes = len(graph)

    froms = []
    for i in range(len(graph)):
        froms.append([])
        for j in range(len(graph[i])):
            if i == j:
                froms[i].append(0)
            elif graph[i][j] < float("inf"):
                froms[i].append(i)
            else:
                froms[i].append(None)

    for k in range(n_nodes):
        for i in range(n_nodes):
            for j in range(n_nodes):
                adj_cost = graph[i][k] + graph[k][j]
                if adj_cost < graph[i][j]:
                    graph[i][j] = adj_cost
                    froms[i][j] = froms[k][j]
    
    has_negative_loop = False
    for i in range(n_nodes):
        if graph[i][i] < 0:
            has_negative_loop = True
            break

    return graph, froms, has_negative_loop

def restore_path(froms, start, goal):
    path = []
    cur = goal
    path.append(goal)
    while cur != start:
        prev = froms[start][cur]
        path.append(prev)
        cur = prev
    path.reverse()
    return path

def resolve():
    N, M = list(map(int, input().split()))
    graph = [[float("inf") for _ in range(N)] for __ in range(N)]
    import copy
    exists = [[False for _ in range(N)] for __ in range(N)]
    for i in range(M):
        a, b, c = list(map(int, input().split()))
        graph[a-1][b-1] = c
        graph[b-1][a-1] = c
        exists[a-1][b-1] = True
        exists[b-1][a-1] = True
    costs, froms, _ = warshall_floyd(graph)
    # print(froms)

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            path = restore_path(froms, i, j)
            # print("{} to {}".format(i, j))
            # print(path)
            src = 0
            for dst in range(1, len(path)):
                exists[path[src]][path[dst]] = False
                exists[path[dst]][path[src]] = False
                src = dst
    
    print(sum(sum(exists, []))//2)



if __name__ == '__main__':
    resolve()

Measured memory_bytes: 75604
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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;
}

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll A, B;
  cin >> A >> B;

  if (A <= 5) {
    COUT(0);
  } else if (6 <= A && A <= 12) {
    COUT(B / 2);
  } else {
    COUT(B);
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
INF = float("inf")
M = [[INF for _ in range(n)] for _ in range(n)]
for _ in range(n):
    a,*b = map(int,input().split())
    if b[0] != 0:
        c = b[1:]
        for i in range(len(c)//2):
            k,w = c[2*i],c[2*i+1]
            M[a][k] = w
searched = [0]*n
d = [INF]*n
p = [None]*n
d[0] = 0
p[0] = -1
while 1:
    mc = INF
    for i in range(n):
        if not searched[i] and d[i] < mc:
            mc = d[i]
            u = i
    if mc == INF:
        break
    searched[u] = 1
    for v in range(n):
        if not searched[v] and M[u][v] != INF:
            if d[u]+M[u][v] < d[v]:
                d[v] = d[u]+M[u][v]
                p[v] = u
for i in range(n):
    print(i,d[i])


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    char C;
    cin>>C;
    int t = C - 'a';
    if(t>=0&&t<26) cout<<'a'<<endl;
    else cout<<'A'<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#define mod 1000000007
long long ans=0;
long long s[3000][2000]={0};

int main(){
	int n;int i,j;
	scanf("%d",&n);
    for (i=3;i<=n;i++){
     s[i][1]=1;
     for (j=2;j<=i/3;j++)
     	for (int k=i-3;k>=0;k--){
     		s[i][j]=(s[i][j]+s[k][j-1])% mod;
     		if (s[k][j-1]==0) break;
		 }
		 }	 
	long long ans=0;	 
    for (i=1;i<=n/3;i++){
    	ans=(ans+s[n][i])%mod;
	}
	printf("%lld",ans);
}
	 

Measured memory_bytes: 14864
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	ll n; ll a;
	cin>>n>>a;
	ll ans=1;
	ll cnt=a/n;
	while(cnt>0){
		if((a-(cnt*n))%cnt==0){
			ans=cnt;
			break;
		}
		cnt--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll x, y;
    cin>>x>>y;

    if(x < y){
        swap(x, y);
    }
    while(y != 0){
        ll r = x % y;
        x = y;
        y = r;
    }
    ll ans = x;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, b;
  string s;
  cin >>n >>a >>b >>s;
  
  int pass = 0, bcount = 0;
  for (int i = 0; i < n; i++) {
    
    if (s[i]=='a') {
      if (pass < a+b) {
        cout << "Yes" << endl;
        pass ++;
      }
      else
        cout << "No" << endl;
    }
    
    else if (s[i]=='b') {
      bcount ++;
      if (pass < a+b && bcount <= b) {
        cout << "Yes" << endl;
        pass ++;
      }
      else
        cout << "No" << endl;
    }
    
    else
      cout << "No" << endl;
    
  }

}

Measured memory_bytes: 3764
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int n, m;
long long a[100000];
vector<int> a_inv[100001];

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

    long long cost = 0;
    for(int i = 0; i + 1 < n; i++){
        cost += min((a[i+1] + m - a[i]) % m, (a[i+1] + m - 1) % m + 1);
    }
    //cout << cost << endl;
    long long ans = cost;

    int between_i[100002] = {};
    for(int i = 1; i < n; i++){
        a_inv[a[i]].push_back(i);
        if(a[i-1] < a[i]){
            between_i[a[i-1]+1]++;
            between_i[a[i]]--;
        }else if(a[i-1] == a[i]){
        }else{
            between_i[1]++;
            between_i[a[i]]--;
            between_i[a[i-1] + 1]++;
        }
    }
    for(int i = 1; i <= m; i++){
        between_i[i] += between_i[i-1];
    }

    for(int i = 1; i <= m; i++){
        //cout << between_i[i] << endl;
    }
    for(int x = 2; x <= m; x++){
        cost -= between_i[x-1];
        for(int i = 0; i < a_inv[x-1].size(); i++){
            int pos = a_inv[x-1][i];
            cost -= (a[pos] + m - (x-1)) % m + 1;
            cost += (a[pos] + m - a[pos-1]) % m;
        }
        //cout << cost << endl;
        ans = min(ans, cost);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string x,y;
    cin >> x >> y;
    if(x<y){
        cout << "<" << endl;
    }else if(x==y){
        cout << "=" << endl;
    }else{
        cout << ">" << endl;
    }
    
}

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

int main() {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int y = 0; y < H; y++) {
    for (int x = 0; x < W; x++) {
      if (y < B && x < A) cout << "0";
      else if (y < B && x >= A) cout << "1";
      else if (y >= B && x < A) cout << "1";
      else cout << "0";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
# coding: utf-8

K, N = (int(x) for x in input().strip().split())
A = list(map(int, input().strip().split()))

ans = K
for i in range(N):
    if i == 0:
        dist = A[N - 1] - A[0]
    else:
        dist = A[i - 1] + K - A[i]
    if ans > dist:
        ans = dist

print(ans)

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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    ll count1 = 0, count2 = 0;
    FOR(i,1,n) {
        if(i%k == 0) count2++;
        else if(k%2 == 0 && (i%k) == (k/2) ) count1++; 
    }

    ll ans;
    if(k%2) {
        ans = count2*count2*count2;
    } else {
        ans = count1*count1*count1 + count2*count2*count2;
    }
    cout<<ans;
	return 0;
}






Measured memory_bytes: 384
#include <stdio.h>
int main(void) {
	char s[5];
	scanf("%s", s);

	if ((s[0] == s[1] && s[2] == s[3])||
		(s[0] == s[2] && s[1] == s[3])||
		(s[0] == s[3] && s[1] == s[2])) {
		if ((s[0] == s[1]) && (s[1] == s[2]) && (s[2] == s[3])) {
			printf("No");
		}
		else {
			printf("Yes");
		}
	}
	else {
		printf("No");
	}
	getchar();

	getchar();

	return 0;
}


Measured memory_bytes: 128