akhauriyash/Code-Regression huggingface dataset:
N = int(input())
X = list(map(lambda x: int(x)-1, input().split()))
Ans = [0] * (N*N)
for i, x in enumerate(X, 1):
    Ans[x] = i
Y = list(range(1, N+1))
Y.sort(key=lambda y: X[y-1])
q1 = []
q1_cnt = [0] * (N+1)
for y in Y:
    q1 += [y] * (y-1)
    q1_cnt[y] += y-1
q1.reverse()
q2 = []
for i, a in enumerate(Ans[:]):
    if a==0:
        if q1:
            v = q1.pop()
            Ans[i] = v
            q1_cnt[v] -= 1
        elif q2:
            Ans[i] = q2.pop()
        else:
            print("No")
            exit()
    else:
        if q1_cnt[a] > 0:
            print("No")
            exit()
        q2 += [a] * (N-a)
print("Yes")
print(" ".join(map(str, Ans)))


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

int main() {
    string str;
    cin >> str;

    if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
ans=0
XY=[]
for i in range(N):
    X,Y = list(map(int,input().split()))
    for xy in XY:
        ans += ((xy[0]-X)**2+(xy[1]-Y)**2)**0.5
    XY.append((X,Y))
print(ans*2/N)

Measured memory_bytes: 3060
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: usize = iterator.next().unwrap().parse().unwrap();
    if s <= 2 {
        return "0".to_string();
    }

    const MOD: usize = 1_000_000_007;
    let mut dp: Vec<usize> = vec![0; s + 1];
    dp[0] = 1;
    for i in 3..=s {
        for j in 0..=(i - 3) {
            dp[i] += dp[j];
            dp[i] %= MOD;
        }
    }
    dp[s].to_string()
}


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

const int MAXN = 200010;
const int mod = 1000000007;
void reduce(int & x) { x += x >> 31 & mod; }
typedef std::pair<int, int> pi;
pi A[MAXN]; int n, L[MAXN], R[MAXN], QL[MAXN];
int st[MAXN], top;
int dp[MAXN];
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> A[i].first >> A[i].second;
	std::sort(A + 1, A + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (A[i].second > A[st[top]].second) L[i] = st[++top] = i;
		else for (int l = 1, r = top, m; l <= r;
		A[st[m = l + r >> 1]].second <= A[i].second ? l = m + 1 : (L[i] = st[m], r = m - 1)) ;
	}
	for (int i = n - (top = 0); i; --i) {
		if (!top || A[i].second < A[st[top]].second) R[i] = st[++top] = i;
		else for (int l = 1, r = top, m; l <= r;
		A[st[m = l + r >> 1]].second >= A[i].second ? l = m + 1 : (R[i] = st[m], r = m - 1)) ;
	}
	for (int i = 1; i <= n; ++i) QL[R[i]] = std::max(QL[R[i]], L[i]);
	for (int i = 1; i <= n; ++i) QL[i] = std::max(QL[i], QL[i - 1]);
	int sm = 1; dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		int f = sm, g = dp[i - 1];
		if (QL[i]) reduce(g -= dp[QL[i] - 1]);
		reduce(dp[i] = dp[i - 1] + f - mod);
		reduce(sm = f + g - mod);
	}
	std::cout << sm << std::endl;
	return 0;
}


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    string s;
    cin>>s;
    ll pos1=0;
    ll pos2=0;
    if(((s[0]-'0')*10+s[1]-'0')<=12 && (((s[0]-'0')*10+s[1]-'0'))>0)
    pos1=1;
    if(((s[2]-'0')*10+s[3]-'0')<=12 && (((s[2]-'0')*10+s[3]-'0'))>0)
    pos2=1;
    if(pos1==1 && pos2==1)
    cout<<"AMBIGUOUS";
    else if(pos1==1)
    cout<<"MMYY";
    else if(pos2==1)
    cout<<"YYMM";
    else
    cout<<"NA";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S; cin >> S;
	vector<bool> v(30);
	REP(i, S.size()){
		v[S[i]-'a'] = true;
	}
	REP(i, 26){
		if(v[i] == false) { printf("%c\n", i+'a'); return 0;}
	}
	cout << "None" << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  bool ans = false;
  for (int i = 0; i < B; i++) {
    if ((A * i) % B == C ) {
      ans = true;
      break;
    }
  }
  if (ans) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 200005
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,ans;
char s[maxn];

int main(){
  scanf("%d",&n);
  scanf("%s",s + 1);
  int res = 0;
  for(int i = 1;i <= n;i++) if(s[i] == '.') res++;
  ans = res;
  for(int i = 1;i <= n;i++){
    if(s[i] == '.') res--;
    else res++;
    ans = min(ans,res);
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
文字列を01のリストに変換
010101 or 101010 の行列を作り、XORの演算
その結果1になった個数が、変更しなければいけない回数
"""
import numpy as np
S = np.array(list(map(int,list(input()))))  # 入力を0,1,のベクトルに
N=len(S)

ans_even = np.zeros(N)
ans_odd = np.zeros(N)
for i in range(N):
    if i %2 == 0:
        ans_even[i] = 1
    if i %2 == 1:
        ans_odd[i] = 1

a = np.sum(np.logical_xor(S, ans_even).astype(int))

b = np.sum(np.logical_xor(S, ans_odd).astype(int))

print(min(a,b))


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

int main(){
  int W, H, x, y, ans;
  cin >> W >> H >> x >> y;
  cout << double(W)*double(H)/2 << " ";
  if(2*x == W && 2*y == H) cout << 1 << endl;
  else cout << 0 << endl;
}

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

using namespace std;
using ll = long long;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	vector<vector<ll>> cnt(62, vector<ll>(62, 0));
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (find(s.begin(), s.end(), '.') == s.end()) s.push_back('.');
		int pos = 0;
		while (s[pos] != '.') pos++;
		s += string(10 - s.size() + pos, '0');
		ll y = 0;
		for (auto c : s) {
			if (isdigit(c)) y = y * 10 + c - '0';
		}
		int p2 = 0, p5 = 0;
		for (; y % 2 == 0; y /= 2, p2++);
		for (; y % 5 == 0; y /= 5, p5++);
		cnt[p2][p5]++;
	}
	ll ans = 0;
	for (int p2 = 0; p2 < 62; p2++) {
		for (int p5 = 0; p5 < 62; p5++) {
			for (int pp2 = 0; pp2 < 62; pp2++) {
				for (int pp5 = 0; pp5 < 62; pp5++)
					ans += cnt[p2][p5] * cnt[pp2][pp5] * (min(p2 + pp2, p5 + pp5) >= 18) *
					       (pair<int, int>{p2, p5} != pair<int, int>{pp2, pp5});
			}
		}
	}
	for (int p2 = 0; p2 < 62; p2++) {
		for (int p5 = 0; p5 < 62; p5++) ans += cnt[p2][p5] * (cnt[p2][p5] - 1) * (min(p2, p5) * 2 >= 18);
	}
	cout << ans / 2 << '\n';
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n+1);
  for (int i = 1; i <= n; i++) cin >> h[i];

  vector<bool> t(n+1, true);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (h[a] < h[b]) t[a] = false;
    else if (h[a] > h[b]) t[b] = false;
    else if (h[a] == h[b]) {
      t[a] = false;
      t[b] = false;
    }
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
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>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    string s;
    cin >> s;
    int n = sz(s);
    vl a;
    ll t = 0;
    REP(i, n) {
        if (i == 0 or s[i] == s[i - 1]) t++;
        else {
            a.emplace_back(t);
            t = 1;
        }
    }
    a.emplace_back(t);
    // printv(a);
    int m = sz(a);
    ll ans = 0;
    if (s[0] == '<') {
        for (int i = 0; i < m - 1; i += 2) {
            if (a[i] > a[i + 1]) swap(a[i], a[i + 1]);
            ans += a[i] * (a[i] - 1) / 2;
            ans += a[i + 1] * (a[i + 1] + 1) / 2;
        }
        if (m % 2 == 1) ans += a[m - 1] * (a[m - 1] + 1) / 2;
    } else {
        ans += a[0] * (a[0] + 1) / 2;
        for (int i = 1; i < m - 1; i += 2) {
            if (a[i] > a[i + 1]) swap(a[i], a[i + 1]);
            ans += a[i] * (a[i] - 1) / 2;
            ans += a[i + 1] * (a[i + 1] + 1) / 2;
        }
        if (m % 2 == 0) ans += a[m - 1] * (a[m - 1] + 1) / 2;

    }
    cout << ans << endl;
}


Measured memory_bytes: 3352
/*input
fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg
*/
#include <bits/stdc++.h>
#define ll long long int
#define lld long double
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	string str;cin>>str;
	int mark[27]={0};
	for(int i=0;i<str.length();i++){
		mark[(int)str[i]-97]=1;
	}
	for(int i=0;i<26;i++){
		if(mark[i]==0){
			cout<<(char)(i+97)<<endl;
			return 0;
		}
	}
		cout<<"None\n";
	return 0;
}

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

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

    int R, G, B, N, count = 0;
    cin >> R >> G >> B >> N;
    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            if (0 <= (N - R * i - G * j) / B && (N - R * i - G * j) / B <= 3000 && (N - R * i - G * j) % B == 0) {
                count++;
                // cout << i << j << (N - R * i - G * j) / B << endl;
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vpii = vector<pii>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
int cell[100001];
bool used[100001];
int moveto[100001];
int main() {
	int n;
	cin >> n;
	rep1(i, n)cin >> cell[i];
	rep1(i, n) {
		if (!cell[i]) {
			moveto[i] = i;
			continue;
		}
		if (moveto[i])continue;
		unordered_set<int> buf;
		int next = i;
		bool f;
		while (f = buf.insert(next).second) {
			next += cell[next];
			if (!cell[next])break;
			if (moveto[next]) {
				next = moveto[next];
				break;
			}
		}
		for (int a : buf)moveto[a] = f ? next : -1;
	}
	queue<pii> que;
	que.push(pii(1, 0));
	while (que.front().first != n) {
		pii a = que.front();
		que.pop();
		for (int i = 1; i < 7; i++) {
			int b = moveto[a.first + i];
			if (b != -1 && !used[b]) {
				que.push(pii(b, a.second + 1));
				used[b] = 1;
			}
		}
	}
	cout << que.front().second << endl;
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

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

using namespace std;

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

    int n;
    cin >> n;

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

    int b[n];
    for(int i = 0; i < n; i++) cin >> b[i];

    int c[n];
    for(int i = 0; i < n-1; i++) cin >> c[i];

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(i > 0) {
            if(a[i-1] == a[i]-1) {
                ans += c[a[i-1]-1];
            }
        }
        ans += b[a[i]-1];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char HA[1<<21], T[256];

int main() {
    unsigned int n, s, t;
    char c;
    T['A'] = 4;
    T['C'] = 3;
    T['G'] = 2;
    T['T'] = 1;
    scanf("%d", &n);
    getchar();
    while (n--) {
        s = 0;
        t = 1;
        int flag = ( c = getchar() ) == 'i';
        while ( ( c = getchar() ) != ' ' );
        while ( ( c = T[getchar()] ) != 0 ) {
            s += c * t;
            t *= 4;
        }
        if ( flag ) HA[s] = 1; else puts( HA[s] ? "yes" : "no" );
    }
    return 0;
}


Measured memory_bytes: 3036
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

inline uint64_t diff_abs(uint64_t x, uint64_t y)
{
  return (x > y) ? (x - y) : (y - x);
}

int main()
{
  uint64_t N, X, Y;
  cin >> N >> X >> Y;
  --X; --Y;

  uint64_t L = Y - X + 1;
  vector<vector<uint64_t>> dist(N, vector<uint64_t>(N, -1));
  map<uint64_t, uint64_t> counter;
  N_TIMES(i, N) {
    N_TIMES(j, N) {
      if (j < i) { continue; }
      dist[i][j] = min(
        diff_abs(i, j), 
        min(
          diff_abs(i, X) + diff_abs(j, Y), 
          diff_abs(i, Y) + diff_abs(j, X)
        ) + 1
      );
      ++counter[dist[i][j]];
    }
  }

  for (uint64_t k = 1; k <= N - 1; ++k) {
    cout << counter[k] << endl;
  }

  return 0;
}

Measured memory_bytes: 31744
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int64_t a, b, c, d, ans1, ans2, ans3, ans4;
    cin>>a>>b>>c>>d;
    ans1 = a*d;
    ans2 = a*c;
    ans3 = b*d;
    ans4 = b*c;
    cout<<max(ans1, max(ans2, max(ans3, ans4)));
    return 0;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n, q;
int a[MAXN];
bool good[MAXN];

bool read() {
    if (!(cin >> n >> q))
        return false;
    
    return true;
}

void solve() {
    good[0] = true;
    fill(a, a + n, 1);

    while (q --> 0) {
        int i, j;
        cin >> i >> j;
        ++a[j - 1];
        good[j - 1] |= good[i - 1];

        if (--a[i - 1] == 0)
            good[i - 1] = false;
    }

    cout << count(good, good + n, true) << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 768
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
ct1 = 0
ct2 = 0
for i in range(1, n + 1):
    if i % k == 0:
        ct1 += 1
if k % 2 == 1:
    print(ct1 ** 3)
else:
    for i in range(1, n + 1):
        if i % k == (k // 2):
            ct2 += 1
    print(ct1 ** 3 + ct2 ** 3)


Measured memory_bytes: 3064
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:i64,
    }
    if n & 1 == 1 {
        println!("{}", n * 2);
    } else {
        println!("{}", n);
    }
}


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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) cout << a + max(a - 1, b) << endl;
  else if (a < b) cout << b + max(a, b - 1) << endl;
  else cout << a + b << endl;
}

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

using namespace std;

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

int main(){
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  string ss = s;
  while(ss.size() < n + m){
    ss += s;
  }
  uint64_t p = (1ull << 56) - 5;
  uint64_t r = 0;
  uint64_t w = 1;
  REP(i, m){
    r = (r * 26 + t[i] - 'a') % p;
    (w *= 26) %= p;
  }
  vector<bool> match(n);
  uint64_t q = 0;
  REP(i, n + m){
    q = (q * 26 + ss[i] - 'a') % p;
    if(i >= m - 1){
      if(i >= m){
        q = (q + p * 26 - (ss[i - m] - 'a') * w) % p;
      }
      match[i - m + 1] = q == r;
    }
  }
  vector<bool> v(n);
  int ll = 0;
  REP(i, n) if(match[i] && !v[i]){
    int l = 1;
    v[i] = true;
    int p = i;
    while(match[(n + (p - m) % n) % n]){
      ++l;
      p = (n + (p - m) % n) % n;
      if(p == i){
        cout << -1 << endl;
        return 0;
      }
      v[p] = true;
    }
    p = i;
    while(match[(p + m) % n]){
      ++l;
      p = (p + m) % n;
      v[p] = true;
    }
    ll = max(ll, l);
  }
  cout << ll << endl;
  return 0;
}


Measured memory_bytes: 3336
mod = 998244353
n, k = map(int, input().split())
index_list = []
for _ in range(k):
    l, r = map(int, input().split())
    index_list.append([l, r])

dp = [0 for _ in range(n)]
dpsum = [0 for _ in range(n)]
dp[0] = 1
dpsum[0] = 1
for i in range(1, n):
    for l, r in index_list:
        l_index = max(i - r - 1, -1)
        r_index = i - l
        if r_index >= 0:
            dp[i] += dpsum[r_index]
            if (r_index > l_index) & (l_index >= 0):
                dp[i] -= dpsum[l_index]
    dp[i] = dp[i] % mod
    dpsum[i] = (dp[i] + dpsum[i - 1]) % mod
print(dp[-1])

Measured memory_bytes: 100500
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord
import qualified Data.Vector.Unboxed           as UV

import System.IO

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [a, b, c, d] <- readIntList
  putStrLn  $ if (c + b - 1) `div` b <= (a + d - 1) `div` d then "Yes" else "No"


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

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

  vector<vector<long long>> a(N, vector<long long>(N));
  for(auto& aa: a){
    for(auto& aaa: aa){
      cin >> aaa;
    }
  }

  // dp[0b00110] := the maximum score with rabbit 1 and 2.
  // ans = dp[(1 << N) - 1]
  vector<long long> dp(1 << N);
  for(int bit = 0; bit < (1 << N); bit++){
    vector<int> idx;
    for(int i = 0; i < N; i++){
      if((bit >> i) & 1){
        idx.push_back(i);
      }
    }
    /*
    cout << bit << '\t';
    for(auto i: idx){
      cout << i << ' ';
    }cout << endl;
    */
    for(int i = 0; i < idx.size(); i++){
      for(int j = i + 1; j < idx.size(); j++){
        dp[bit] += a[idx[i]][idx[j]];
      }
    }
  }
  /*
  for(int bit = 0; bit < (1 << N); bit++){
    cout << bit << '\t' << dp[bit] << endl;
  }
  */

  vector<bool> checked(1 << N);
  function<long long(int)> calc_dp;
  calc_dp = [&](int bit){
              if(checked[bit]){
                return dp[bit];
              }
              for(int subset_bit = (bit - 1) & bit; subset_bit > 0; subset_bit = (subset_bit - 1) & bit){
                int complement_bit = (~subset_bit) & bit;
                dp[bit] = max(dp[bit], calc_dp(subset_bit) + calc_dp(complement_bit));
              }
              checked[bit] = true;
              return dp[bit];
            };
  for(int bit = 0; bit < (1 << N); bit++){
    calc_dp(bit);
  }

  cout << dp[(1 << N) - 1] << endl;
}


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


int main() {
    int n;
    cin >> n;
    int tired[1002];
    int index[1002];
    int data[1002][1002];

    rep(i, n)tired[i]=false;
    rep(i, n)index[i]=0;

    rep(i, n){
        rep(j, n-1){
            int temp;
            cin >> temp;
            data[i][j] = temp - 1;
        }
    }

    int ans = 0;

    while(true){
        ans++;
        bool fight = false;

        rep(i, n)tired[i]=false;

        rep(i, n){
            if((!tired[i])&&index[i]!=n-1){
                int pair = data[i][index[i]];
                if(data[pair][index[pair]]==i&&!tired[pair]){
                    tired[i] = true;
                    tired[pair] = true;
                    index[i]++;
                    index[pair]++;
                    fight=true;
                    // cout << i << " vs " << pair << endl;
                }
            }
        }

        bool finished = true;

        //全員試合が終わったら終了
        rep(i, n){
            if(index[i]!=n-1){
                finished=false;
            };
        }

        if(finished){
            cout << ans << endl;
            return 0;
        }

        //試合できなかったら
        if(!fight){
            ans = -1;
            break;
        }

        // cout << "day:" << ans << " finished" << endl;

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define rep(i, c) for(int i = 0; i < (int)c; i++)
const int inf = 1000000000; // 10^9

int main(){
    int n;
    string s;
    map<string, int> memo;
    cin >> n;
    rep(i, n){
        cin >> s;
        memo[s] += 1;
    }
    bool cnt = false;
    for(const auto& x : memo){
        if(x.second > 1) cnt = true;
    }
    if(cnt) cout << "NO";
    else cout << "YES";

    return 0;
}

Measured memory_bytes: 24832
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int 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(){
    std::ios::sync_with_stdio(false);
    int n;
    string s;
    set<string> ss;
    cin >> n;
    for(int i=0;i<n;++i)
    {
        string tmp;
        cin >> tmp;
        ss.insert(tmp);
    }

    cout << ss.size() << endl;

}

Measured memory_bytes: 19248
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int x=0;
        if(b/10==0){
            x=a*10+b;

        }else if(b/100==0) {

            x = a*100+b;
        }else{
            x = a*1000+b;
        }
        //System.out.println(x);
        double y = Math.sqrt(x);
        if(y%1==0) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
using namespace std;

int main(){
	int n,q;
	while(1){
		pair<int,int> data[101]={};
		rep(i,0,101){
			data[i].second=-i;
		}
		cin>>n>>q;
		if(n==0 && q==0) break;
		rep(i,0,n){
			int m,d;
			cin>>m;
			rep(j,0,m){
				cin>>d;
				data[d].first++;
			}
		}
		sort(data,data+101);
		reverse(data,data+101);
		if(data[0].first<q) cout<<0<<endl;
		else cout<<-data[0].second<<endl;
	}
}

/*for(map<int,int>::iterator it=dat.begin();it!=dat.end();it++)
	if(it->second>Max){
		max=it->second;
		ans=it->first;
	}*/

Measured memory_bytes: 1160
# E - Camel Train
import sys
from heapq import heappop, heappush

readline = sys.stdin.buffer.readline


def maximize_happiness() -> int:
    res = 0
    lefty, righty = [], []

    N = int(readline())
    for _ in range(N):
        k, l, r = map(int, readline().split())
        if k == N or l == r:
            res += l
        elif l > r:
            res += l
            lefty.append((k, l - r))
        else:
            res += r
            righty.append((N - k, r - l))

    for camels in [lefty, righty]:
        camels.sort()
        heap = []
        for k, diff in camels:
            heappush(heap, diff)
            if k < len(heap):
                res -= heappop(heap)

    return res


def main():
    T = int(readline())
    res = [maximize_happiness() for _ in range(T)]
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


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

int main() {
  int p,q,r;
  cin >> p >> q >> r;
  cout << min(min(p+q,q+r),r+p) << endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))

min_diff = 10 ** 5
for i in range(n):
    s1 = sum(w[:i])
    s2 = sum(w[i:])
    diff = abs(s2 - s1)
    if diff < min_diff:
        min_diff = diff
print(min_diff)


Measured memory_bytes: 2940
def change(A,B,C):
    a=B/2+C/2
    b=A/2+C/2
    c=A/2+B/2
    return a,b,c
A,B,C=map(int,input().split())
a=A
b=B
c=C
if (A%2==1)|(B%2==1)|(C%2==1):
    print(0)
else:
    count=0
    while True:
        A,B,C=change(A,B,C)
        count+=1
        if (A%2==1)|(B%2==1)|(C%2==1):
            print(count)
            break
        elif (a==A)&(b==B)&(c==C):
            print(-1)
            break

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if (b % a == 0) {
			System.out.println(a+b);

		} else {
			System.out.println(b-a);
		}
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
const int lim = 600;

int a[lim][lim];

int main(){
    int h, w;
    cin >> h >> w;

    for(int y=0; y<h; y++){
        for(int x=0; x<w; x++) cin >> a[y][x];
    }

    int cnt = 0;
    vector<pair<int, int>> now, next;

    int y = 0;
    int x = 0;
    for(int iter=0; iter<h*w; iter++){
        bool swp = false;
        if(a[y][x]%2 == 1){
            swp = true;
        }

        int ny = y;
        int nx = x;

        if(x%2 == 0){
            if(y == h-1) x++;
            else y++;
        }
        else {
            if(y == 0) x++;
            else y--;
        }

        if(swp && y < h && x < w){
            cnt++;
            a[ny][nx]--;
            a[y][x]++;
            now.push_back({ny, nx});
            next.push_back({y, x});
        }

    }

    /*
    cout << "debug" << endl;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++) cout << a[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    */
    
    cout << cnt << endl;
    for(int i=0; i<now.size(); i++) cout << now[i].first+1 << " " << now[i].second+1 << " " << next[i].first+1 << " " << next[i].second+1 << endl;
}

Measured memory_bytes: 5484
/*総当たり*/
#include<bits/stdc++.h>
using namespace std;

vector<int> n_A(20);
int n=0;

int solve(int i,int m){
	if(m == 0) return 1;
	if(i >= n) return 0;
	
	int res = solve(i+1,m) || solve(i+1,m - n_A.at(i));
	return res;
	
}

int recComb(vector<int> &a,int b){
		//cout << a.at(1) << endl;
		int i=0,j=0;
		for(i=0;i<n;i++){
			if(solve(0,b)) return 1;
			else return 0;
		}
		
}


int main(){
	vector<int> m_i(200);
	int q;
	cin >> n;
	for(int i=0;i<n;i++)cin >> n_A.at(i);
	cin >> q;
	for(int i=0;i<q;i++)cin >> m_i.at(i);
	
	int i=0;
	while(i<q){
 	  if(recComb(n_A,m_i.at(i)))cout << "yes" << endl;
	  else cout << "no" << endl;
	  i++;
	}
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    char x,y; cin>>x>>y;
    if(x>y) cout<<'>'<<endl;
    else if(x<y) cout<<'<'<<endl;
    else cout<<'='<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

class graph
{
public:
    vector< vs32 > g;
    vs32 d;
    int num;

    graph() {}
    ~graph() {}
    graph(int size)
    : g(vector< vs32 >(size)), d(vs32(size, 1e9)), num(size)
    {}

    void dijkstra(int s)
    {
        vector< bool > reached(num, false);

        priority_queue< P > pq;
        pq.push(P{0, s});
        while (!pq.empty())
        {
            P du = pq.top(); pq.pop();
            int dist = -du.first;
            int u = du.second;

            if (reached[u]) continue;
            reached[u] = true;
            d[u] = dist;

            for (auto v : g[u])
            {
                if (!reached[v] && d[v] > dist + 1)
                {
                    pq.push(P{-(dist + 1), v});
                }
            }
        }
    }
};

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

    int n, m;
    cin >> n >> m;
    graph g(3 * n);
    int s, t;
    rep (i, m)
    {
        cin >> s >> t;
        --s; --t;
        g.g[s].push_back(t + n);
        g.g[s + n].push_back(t + 2 * n);
        g.g[s + 2 * n].push_back(t);
    }

    cin >> s >> t;
    --s; --t;
    g.dijkstra(s);

    int ans = (g.d[t] == 1e9 ? -1 : g.d[t] / 3);

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 17920
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){
    int h,w;
    cin>>h>>w;
    char a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    vector<bool> vertical(w,false);
    vector<bool> horizontal(h,false);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(!horizontal[i] && a[i][j]=='#'){
                horizontal[i]=true;
            }
        }
    }
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(!vertical[i] && a[j][i]=='#'){
                vertical[i]=true;
            }
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(horizontal[i] && vertical[j]){
                cout<<a[i][j];
            }
        }
        if(horizontal[i]) cout<<endl;
    }
}

Measured memory_bytes: 3592
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int lst[] = new int[n];
        int ans = 0;
        for(int i = 0; i < n; i++){
            lst[i] = Integer.parseInt(scan.next());
        }
        for(int i = 0; i < n-2; i++){
            if((lst[i+1]<lst[i]&&lst[i+2]<lst[i+1])||(lst[i+1]>lst[i]&&lst[i+2]>lst[i+1])){
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
import std.stdio, std.string, std.conv, std.math, std.algorithm;

void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], d = tmp[1];
    int[][] x = new int[][](n);
    foreach (i; 0 .. n) {
        x[i] = readln.split.to!(int[]);
    }
    int[] square;
    for (int i = 1; i * i <= 16000; ++i) {
        square ~= i * i;
    }
    int cnt;
    foreach (i; 0 .. n-1) {
        foreach (j; i+1 .. n) {
            int sed;
            foreach (k; 0 .. d) {
                sed += (x[i][k] - x[j][k]) ^^ 2;
            }
            if (square.canFind(sed)) ++cnt;
        }
    }
    cnt.writeln;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 

void solve()
{
   ll n,k;
   cin>>n>>k;
   ll h[n];
   f(i,0,n)
   cin>>h[i];
   ll dp[n];
   dp[0]=0;
   dp[1] = abs(h[1]-h[0]);
   f(i,2,n)
   {
       dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
       for(ll j=i-1;j>=0&&j>=i-k;j--)
       {
           dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]));
       }
   }
   cout<<dp[n-1]<<"\n"
;}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
 
int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x-r>=0 && x+r<=W && y+r>=0 && y+r<=H){
		cout <<"Yes\n";
	}
	else{
		cout << "No\n";
	}
 
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  
  int k=1;
  
  int w=a.at(0);
  
  for(int i=1;i<n;i++){
    if(a.at(i)<w){
      k++;
      w=a.at(i);
    }
  }
  
  cout << endl << k << endl;
  
}

Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ac=Counter(a)
count=0
temp=0
for i in ac:
    if ac[i]>=3:
        if ac[i]%2==0:
            count+=(ac[i]-2)
            ac[i]=2
        else:
            count+=(ac[i]-1)
            ac[i]=1

for j in ac:
    if ac[j]==2:
        temp+=1
if temp%2==0:
    count+=temp
else:
    count+=((temp+1))
print(n-count)
        

Measured memory_bytes: 21756
int main(){
  int n,h[100000];
  scanf("%d\n",&n);
  for(int i = 0;i<n;i++){
    scanf("%d ",&h[i]);
  }
  int m = 0,a = 0,s = 0;
  while(n>s+1){
    m=0;
    if(h[s]>=h[s+1] && n>s+1){
      while(h[s]>=h[s+1] && n>s+1){
        m++;
        s++;
      }
    }else{
      s++;
    }
    if(m>a){
      a=m;
    }
  }
  printf("%d\n",a);
  return 0;
}

Measured memory_bytes: 512
from math import factorial

N = int(input())
A = list(map(int, input().split()))

def comb(n, r):
    if n - r < 0:
        return 0
    else:
        return factorial(n) // (factorial(n - r) * factorial(r))

nums = [0] * (N + 1)
for i, v in enumerate(A):
    nums[v] += 1
combs = list(map(lambda n: comb(n, 2), nums))
total = sum(combs)

for k, val in enumerate(A):
    print(total - (nums[val] - 1))


Measured memory_bytes: 26140
parents = list(map(int,input().split(' ')))
L = parents[1]
if L>0:
    not_add = 0
elif abs(L) > parents[0]-1:
    not_add = parents[0]-1
else:
    not_add = abs(L)
sum = 0
for i in range(parents[0]):
    if not i == not_add:
        sum += (i+L)

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define f(i, k, n) for (int i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define len(s) s.size()
#define all(v) v.begin(), v.end()
#define tr(it, v) for (auto &it : v)
#define bit(x) __builtin_popcount(x)
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
    // =================
void impgraph(int n, int m);
void dfs(int u,int par);

const int mod = 1e7;
const int N = 3e5 + 1;

vi g[N];
int a[N];

void solve()
{
    int n, m, ans = 0, k=0;
    cin>>n;
    while(1) {
        ans+=n;
        k++;
        if(ans%360==0 ) {
            cout<<k;
            return;
        }
    }
}

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

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

void impgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u,int par)
{
    a[u] = 1;
    for (int v : g[u])
    {
        if (a[v])
            continue;
        dfs(v,0);
    }
}

Measured memory_bytes: 10632
h,n=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(n)]

dp=[float('inf')]*(h+1)
dp[0]=0
for a,b in AB:
  for i in range(h):
    if i+a>=h:
      dp[h]=min(dp[h],dp[i]+b)
    else:
      dp[i+a]=min(dp[i+a],dp[i]+b)
print(dp[h])

Measured memory_bytes: 51036
// https://atcoder.jp/contests/abc086/tasks/abc086_a

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int a, b;

  cin >> a >> b;

  if (a % 2 == 0 || b % 2 == 0)
    cout << "Even" << '\n';
  else
    cout << "Odd" << '\n';

  return 0;
}


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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
    int n; cin >> n;
    std::vector<int> a(n);
    for (int& x: a) {
        cin >> x;
    }

    std::vector<std::pair<int, int>> ans;

    int u = std::min_element(a.begin(), a.end()) - a.begin();
    int v = std::max_element(a.begin(), a.end()) - a.begin();

    if (a[u] < 0 && a[v] > 0) {
        if (std::abs(a[u]) <= std::abs(a[v])) {
            for (int i = 0; i < n; ++i) {
                if (i == v) continue;
                ans.emplace_back(v, i);
                a[i] += a[v];
            }
        } else {
            for (int i = 0; i < n; ++i) {
                if (i == u) continue;
                ans.emplace_back(u, i);
                a[i] += a[u];
            }
        }
    }

    u = std::min_element(a.begin(), a.end()) - a.begin();
    v = std::max_element(a.begin(), a.end()) - a.begin();

    if (a[u] < 0) {
        for (int i = n - 2; i >= 0; --i) {
            ans.emplace_back(i + 1, i);
            a[i] += a[i + 1];
        }
    } else {
        for (int i = 1; i < n; ++i) {
            ans.emplace_back(i - 1, i);
            a[i] += a[i - 1];
        }
    }

    cout << ans.size() << endl;
    for (auto p: ans) {
        cout << p.first + 1 << ' ' << p.second + 1 << endl;
    }
}


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

using namespace std;

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

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

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

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

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

  int N;
  cin >> N;
  vector<pair<string, int>> sp;
  map<int, int> mp;
  rep(i, N) {
    string s;
    int p;
    cin >> s >> p;
    sp.push_back(make_pair(s, -p));
    mp[p] = i + 1;
  }

  sort(all(sp));

  rep(i, N) { cout << mp[-sp[i].second] << endl; }

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int s, n, t;
string weekday, ti;
int p, m;
int match_weekday, match_time;
double pp;
const int ALL = 7, DAY = 8, NIGHT = 9;

void modify(int& day, int& time) {
	if(time >= 1440) {
		time -= 1440;
		day = (day + 1) % 7;
	}
}

bool match(int day, int time) {
	if(match_weekday == ALL || day == match_weekday) {
		if(match_time == ALL
		   || (match_time == DAY && (360 <= time && time < 1080))
		   || (match_time == NIGHT && (time < 360 || 1080 <= time)))
			return true;
	}

	return false;
}

double calc(int day, int time) {
	double res = 1.0;
	for(int i = 0; i < m; ++i) {
		int hatch_day = day, hatch_time = time + s;
		modify(hatch_day, hatch_time);
		
		if(match(day, time) && match(hatch_day, hatch_time)) {
			res *= pp;
		}

		time += t;
		modify(day, time);
	}

	return 1.0 - res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	map<string, int> conv;
	conv["Sun"] = 0;
	conv["Mon"] = 1;
	conv["Tue"] = 2;
	conv["Wed"] = 3;
	conv["Thu"] = 4;
	conv["Fri"] = 5;
	conv["Sat"] = 6;
	conv["All"] = ALL;
	conv["Day"] = DAY;
	conv["Night"] = NIGHT;

	while(cin >> s >> n >> t >> weekday >> ti >> p >> m, s) {
		pp = pow(1.0 - 1.0 / p, n);
		
		match_weekday = conv[weekday];
		match_time = conv[ti];
		double ans = 0.0;
		for(int i = 0; i < 7; ++i)
			for(int j = 0; j < 1440; ++j)
				ans = max(ans, calc(i, j));

		printf("%.15lf\n", ans);		
	}
		
	return EXIT_SUCCESS;
}

Measured memory_bytes: 1300
N, W = map(int, input().split())
v = [None] * N
w = [None] * N

for i in range(N):
  v[i], w[i] = map(int, input().split())

dp = [[None for _ in range(W+1)] for _ in range(N+1)]

# for i in range(N):
#  dp[i][0] = 0

for j in range(W+1):
  dp[0][j] = 0

# ナップザックDP
for i in range(N):
  for j in range(W+1):
    if j >= w[i]:
      dp[i+1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j])
    else:
      dp[i+1][j] = dp[i][j]
print(dp[N][W])


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

using namespace std;
typedef long long ll;


const int N=1e5+100;


int n,m,q;
int a[60],b[60],c[60],d[60];
vector <int>v;
int ans=0;
void dfs()
{
    if(v.size()==n)
    {
        int sum=0;
        for(int i=1; i<=q; i++)
        {
            if(v[b[i]]-v[a[i]]==c[i])
                sum+=d[i];
        }
        ans=max(ans,sum);
        return ;
    }
    for(int i=1; i<=m; i++)
    {
        if(!v.size())
        {
            v.push_back(i);
            dfs();
            v.pop_back();
        }
        else
        {
            if(i>=v.back())
            {
                v.push_back(i);
                dfs();
                v.pop_back();
            }
        }

    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1; i<=q; i++)
    {
        scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
        a[i]--,b[i]--;
    }
    dfs();
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3768
import numpy as np

import numpy as np
def Binary_Gen(n):
    bina = np.ones(2**n,dtype=object)
    for i in range(2**n):
        b = str(bin(i))[2:].zfill(n)
        bina[i] = b
    return bina


S =str(input())

add_ = Binary_Gen(len(S)-1)





count = 0

for i in add_:

    list_1 = [int(idx) for idx,j in enumerate(str(i)) if j == '1']

    if len(list_1)>0:
        comp = np.ones(len(list_1)+1)
        for k in range(len(comp)):
            if k==0:
                comp[k] = int(S[:list_1[k]+1])
            elif k == (len(comp)-1):
                comp[k] = int(S[list_1[k-1]+1:])
            else:
                comp[k] = int(S[list_1[k-1]+1:list_1[k]+1])

        count+= sum(comp)
    elif len(list_1)==0:
        count+=int(S)
        
print(int(count))

Measured memory_bytes: 21416