akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        int K = cin.nextint;
        var A = cin.scanint;

        var dp = new bool[K + 1];
        for (int i = 1; i <= K; i++)
        {
            foreach (var v in A)
            {
                dp[i] |= i - v >= 0 ? !dp[i - v] : false;
            }
        }
        WriteLine(dp[K] ? "First" : "Second");
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 13140
n, m = map(int, input().split()) #n: 展望台の数, m: 道の数
height = list(map(int, input().split())) #高さリスト.nコある.
ans_set = set(range(1, n+1))

for i in range(m):
  a, b = map(int, input().split())
  if height[a-1] >= height[b-1]:
    ans_set.discard(b)	#setのdiscardは存在しない場合は何もしない.
  if height[a-1] <= height[b-1]:
    ans_set.discard(a)
    
print(len(ans_set))

Measured memory_bytes: 91452
object Main{
  def main(args:Array[String]) = {
    io.Source.stdin.mkString.toCharArray.foreach(x => print(swap_case_as_int(x.toInt).toChar))
  }
  def swap_case_as_int(int: Int) : Int ={
    if (65 <= int && int <= 90) int + 32
    else if (97 <= int && int <= 122) int - 32
    else  int
  }
}

Measured memory_bytes: 44152
//R<3S
#include <bits/stdc++.h>
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);commands}
#define ll long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {

    ll n,a,b;
    cin>>n>>a>>b;
    ll sum=a+b;
    ll div=n/sum;
    ll mod=n%sum;
    ll ans=div*a+min(a,mod);cout<<ans;
  }



int main()
{
   FAST
   // #ifndef ONLINE_JUDGE
   //   freopen("input.txt","r",stdin);
   //   freopen("output.txt","w",stdout);
   // #endif
   int t;
   t=1;
   //cin>>t;
   while(t--)
  {
      solve();
  }


   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        int H = sc.nextInt();
        int W = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(H*W - (h*W+(H-h)*w));
    }
}


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

int main() {
  int N, K; cin >> N >> K;
  vector<long long> V(N);
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    cin >> V[i];
  }
  for(int l = 0; l <= K; ++l) {
    for(int r = 0; r <= K-l; ++r) {
      if(l+r > N) continue;
      int d = K - l - r;
      int now = 0;
      vector<int> h;
      for(int i = 0; i < l; ++i) {
        now += V[i];
        h.push_back(V[i]);
      }
      for(int i = N-r; i < N; ++i) {
        now += V[i];
        h.push_back(V[i]);
      }
      sort(h.begin(), h.end());
      for(int i = 0; i < d; ++i) {
        if(i >= h.size()) break;
        if(h[i] >= 0) break;
        now -= h[i];
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
total = 0

c = Counter(a)

for r in list(c.values()):
    total += (r*(r-1))/2

#print(l)
#print(total)

for i in a:
    score = total - (c[i]-1)
    print(int(score))


Measured memory_bytes: 26780
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	string S;
	cin >> S;

	int len = (int)(S.length()), cnt = 0;
	for (int i = 0; i < len; i++) cnt += S[i] - '0';

	cout << min(2 * (len - cnt), 2 * cnt);

	return 0;
}

Measured memory_bytes: 512
import * as fs from "fs";

const input = fs
  .readFileSync("/dev/stdin", "utf8")
  .split(" ")
  .map(Number);
// Xは今の座標
// Kは回数
// Dは移動距離
let X,K,D;

[X, K, D] = input;
// 負の場合も考えて絶対値に
X = Math.abs(X);
let ans;
// 原点を跨がないパターン
if(X >= D * K) {
  ans = X - K * D;
} else {
  // 往復までの回数
  let e = Math.floor(X/D);
  // 往復までにかかった分を引く
  K -= e;
  // 往復のポイント
  X -= e * D;
  // 跨ぐパターン
  if(K % 2 == 1){ 
    ans = Math.abs(X - D);
  } else {
  	ans = X;
  }
  
}
console.log(ans);

Measured memory_bytes: 29656
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace at
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = 0;
            var N = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var a = new List<int>(){0};

            for (int i = 0; i < N; i++)
            {
                if((s[i]).ToString() == "I") a.Add(x = x + 1);
                if((s[i]).ToString() == "D") a.Add(x = x - 1);
            }
            Console.WriteLine(a.Max());
        }        
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int result;
vector<int> strands[100];
bool used[100];

void rec(int k, int d, int ub) {
  if (result < d) result = d;
  used[k] = 1;
  for (int i = 0; i < strands[k].size(); i++)
    if (!used[strands[k][i]]) ub--;
  ub++;
  if (result < ub)
    for (int i = 0; i < strands[k].size(); i++) {
      int j = strands[k][i];
      if (!used[j]) rec(j, d+1, ub);
    }
  used[k] = 0;
}

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    for (int i = 0; i < 100; i++)
      strands[i].clear();
    fill(used, used+100, false);
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      strands[a].push_back(b);
      strands[b].push_back(a);
    }
    result = 0;
    for (int i = 0; i < 100; i++)
      rec(i, 1, n+1);
    cout << result << endl;
  }
}

Measured memory_bytes: 912
#include <bits/stdc++.h> 
/*#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif
*/

using namespace std;
#define z 1000000001
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repb(i,a,b) for(int i=a;i>=b;--i)
#define repv(arr)  for(auto it=arr[i].begin();it!=arr[i].end();++it)  
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define ssortA(arr)   stable_sort(arr.begin(),arr.end())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long
#define mp make_pair 
#define LCM(a,b) boost::math::lcm(a,b)
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vi a(n+1);
    int c=0;
    rep(i,1,n+1){
        cin>>a[i];
        if(i%2!=0&&a[i]%2!=0)
        ++c;
    }
    cout<<c<<endl;
    
    
}


Measured memory_bytes: 3608
//File Name: A.cpp
  //Author: long
  //Mail: 736726758@qq.com
  //Created Time: 2016年11月13日 星期日 20时10分44秒
                                   
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int MAXN = 10;
char a[MAXN];
int main(){
	int n,m,s = 0;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%s",a);
		for(int j=0;j<m;j++)
			if(a[j] == '#')
				s++;
	}
	if(s == n + m - 1) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int n;
int p[105000];

int main()
{
	cin >> n;
	int q;
	vector<int> a;
	for (int i = 0; i < n; i++) {
		cin >> q;
		q--;
		if (q == i)a.push_back(i);
	}

	int i = 0;
	int ope = 0;
	int ans = 0;
	int k;
	if (!a.empty()) {
		while (i < a.size() - 1) {
			k = i;
			if (a[i] == a[i + 1] - 1) {
				ans++;
				i += 2;
				ope = 1;
			}
			else {
				ans++;
				i++;
				ope = 0;
			}
		}
		if (ope == 1 && k == a.size()-3)ans++;
		if (ope == 0)ans++;
	}

	cout << ans << endl;
	

	return 0;
}

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

typedef long long ll;

using namespace std;

int isPrime(ll x) {
  for(ll i=2; i*i<=x; i++) {
    if(x%i == 0) return false;
  }
  
  return true;
}

int main() {
  ll n, N;
  
  cin >> N;
  cout << N << ":";

  if(isPrime(N)) {
    cout << ' ' << N << endl;
    return 0;
  }
  
  n = N;
  
  ll cnt = 2;

  while(1) {
    if(n <= 1) break;
    for(ll j = cnt; j<=N; j++) {
      if(n % j == 0) {
	cout << " " << j;
	n/=j;
	cnt = j;
	break;
      }
    }
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}


pair<int, int> E[200001];
int H[200001];
int kotae[100001];
int Vis[100001];
void sagasu(int P, int D, int C) {
	if (D == 0 && kotae[P] == 0) kotae[P] = C;
	else if (Vis[P] < D) {
		Vis[P] = D;
		if (kotae[P] == 0) kotae[P] = C;
		for (int p = H[P]; p; p = E[p].second) {
			sagasu(E[p].first, D - 1, C);
		}
	}
}

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


	int N, M, Q;
	Cin(N, M);
	for (int i = 1; i < 2 * M; i += 2) {
		int a, b; Cin(a, b);
		E[i] = mp(a, H[b]);
		H[b] = i;
		E[i + 1] = mp(b, H[a]);
		H[a] = i + 1;
	}
	Cin(Q);
	int v[100000], d[100000], c[100000];
	rep(i, Q) {
		Cin(v[i], d[i], c[i]);
	}
	for (int i = Q - 1; i >= 0; i--) {
		sagasu(v[i], d[i], c[i]);
	}
	rep1(i, N) {
		Cout(kotae[i], '\n');
	}

	Would you please return 0;
}


Measured memory_bytes: 5504
#include <iostream>
#include <iomanip>

using namespace std;

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

int N;
int count[3];

double dp[310][310][310];

double expec(int c[]) {
    double rsum = 0.0;
    REP(i, 3) {
        if (c[i] > 0) {
            int ic[3] = {c[0], c[1], c[2]};
            ic[i] -= 1;
            if (i>=1) ic[i-1] += 1;

            if (dp[ic[0]][ic[1]][ic[2]] < 0) {
                dp[ic[0]][ic[1]][ic[2]] = expec(ic);
            }
            rsum += dp[ic[0]][ic[1]][ic[2]] * (double) c[i];
        }
    }

    return ((double) N + rsum) / (double) (c[0]+c[1]+c[2]);
}

int main() {
    cin >> N;

    REP(i, 3) {
        count[i] = 0;
    }

    REP(i, N) {
        int a;
        cin >> a;
        count[a-1] += 1;
    }

    REP(i, N+1) {
        REP(j, N+1) {
            REP(k, N+1) {
                dp[i][j][k] = -1;
            }
        }
    }
    dp[0][0][0] = 0;

    cout << fixed << setprecision(10) << expec(count) << endl;
}


Measured memory_bytes: 227584
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip()

from collections import defaultdict

INF = 10**9
dp = defaultdict(lambda:INF)
dp[0] = 0

cum = 0
for x in S:
    cum ^= 1<<(x-97)
    x = min(dp[cum^(1<<i)] for i in range(26)) + 1
    if dp[cum] > x:
        dp[cum] = x

answer = max(1,dp[cum])
print(answer)


Measured memory_bytes: 353420
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int Pi[]=new int[M];
		int Yi[]=new int[M];
		int count[]=new int[N];
		Map<Integer,Integer> map =new TreeMap<>();	
		for(int i=0;i<M;i++){
			Pi[i]=sc.nextInt();
			Yi[i]=sc.nextInt();
			map.put(Yi[i], i);
		}
		int num;
		int index=0;
		for (Integer value : map.values()) { 
			index=value;
			num=Pi[index]-1;
			if(count[num]==0) {				
				count[num]=1;
				Yi[index]=count[num];
			}else {
				count[num]++;
				Yi[index]=count[num];
			}
		}
		for(int i=0;i<M;i++) {
			System.out.println(String.format("%06d%06d",Pi[i],Yi[i]));
		}
		sc.close();
	}
}

Measured memory_bytes: 151040
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;
 
 
int main(){
    int x,a; cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
return 0;
}

Measured memory_bytes: 256
import itertools
import math

def all_comb(iterable):
    for i in range(0, len(iterable) + 1):
        comb = itertools.combinations(iterable, i)
        for pair in comb:
            yield(pair)

def min_solve(goal_point, solve, pc_list):
    solve_point = sum([pc[0] * pc[2] + pc[1] for pc in solve])
    solve_num = sum([pc[0] for pc in solve])
    nc_solve = set(pc_list) - set(solve)
    if solve_point >= goal_point:
        return solve_num
    nc_solve_max = max(nc_solve, key=lambda pc:pc[2])
    if solve_point + (nc_solve_max[0] - 1) * nc_solve_max[2]  >= goal_point:
        min_solve = int(math.ceil((goal_point - solve_point) / nc_solve_max[2] + solve_num))
        return min_solve
    else:
        return float('Inf')

if __name__=='__main__':
    D, G = map(int, input().split())
    pc_list = []
    for i in range(D):
        (p, c) = map(int, input().split())
        pc_list.append((p, c, (i + 1) * 100))
    min_num = min([min_solve(G, solve, pc_list) for solve in all_comb(pc_list)])
    print(min_num)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n+1] = {0};
  REP(i,n){
    ll b;
    cin >> b;
    a[b]++;
  }
  sort(a,a+n+1);
  ll num = 0;
  REP(i,n+1){
    if(a[i] != 0){
      num++;
    }
  }
  /*REP(i,n+1){
    cout << a[i] << endl;
    }*/
  //cout << num << endl;
  ll sum = 0;
  for(int i = n+1-num;i < n+1-num+(num-k);i++){
    sum += a[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 1005;
int in[maxn];
int main() {
    int n, t, a;
    scanf("%d%d%d", &n, &t, &a);
    for (int i = 0; i < n; i++)
        scanf("%d", &in[i]);
    int minIndex = -1;
    double minn = 1e9;
    for (int i = 0; i < n; i++) {
        if (fabs(t - in[i] * 6e-3 - a) < minn) {
            minn = fabs(t - in[i] * 6e-3 - a);
            minIndex = i;
        }
    }
    printf("%d", minIndex + 1);
    return 0;
}


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

int main() {
  int x;
  cin >> x;
  if(x <1200) cout <<"ABC" << endl;
  else cout <<"ARC" << endl;
 }

Measured memory_bytes: 3620
n=io.read("*n")
a=io.read("*n")
b=io.read("*n")
function solve()
	if a > b then
		return 0
	end
	if n == 1 then
		if a == b then
			return 1
		else
			return 0
		end
	end
	return a + (n - 1) * b - ( b + (n - 1) * a ) + 1
end

print(solve())

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// g++ -std=c++17 -Wshadow -Wall sol.cpp -o  s -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vvi = vector< vi > ;
using ld = long double;
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3fll;
template<typename T> T abs (T x) { return x < 0 ? -x : x; }
template<typename T> void max_self(T &a, T b) {  a = max(a, b); }
template<typename T> void min_self(T &a, T b) {  a = min(a, b); }
const int MAX = 3e3+10;
ll dp[MAX][MAX][2];
ll go(int i, int j, int p, const vector<ll> &v) {
  if(i == j)return v[i]; 
  if(i > j)return 0;
  ll &res = dp[i][j][p];
  if(res != -1)return res;
  res = v[i] + min(go(i+2, j, 1-p, v) , go(i+1, j-1, 1-p, v));
  max_self(res, v[j] + min(go(i+1, j-1, 1-p, v) , go(i, j-2, 1-p, v)));
  return res;
}
void solve(int tc) {
  int n;
  cin >> n;
  vector<ll>v(n);
  ll tot = 0;
  memset(dp, -1, sizeof(dp));
  for(auto &x: v){
    cin >> x;
    tot+=x;
  }
  ll res = go(0, n-1, 0, v);//dp[0][n-1][0]
  cout << res - (tot-res) << endl;
  // dp[i][j][k] = max points of player k in (i,j) state
}

int main() {
  int tc = 1;
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cin >> tc;
  for(int i = 1; i <= tc; ++i)solve(i);
  return 0;
}

Measured memory_bytes: 142080
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int L = scanner.nextInt();
    int m;
    if (L >= 0) m = L;
    else if (L + N <= 0) m = L + N - 1;
    else m = 0;
    System.out.println((L + L + N - 1) * N / 2 - m);
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>


int main(){
    int N, M;
    std::cin >> N >> M;
    std::vector<std::vector<bool>> graph(N, std::vector<bool>(N, false));
    for(int i = 0; i < M; i++){
        int a, b;
        std::cin >> a >> b;
        a--; b--; // to 0 origin
        graph[a][b] = true;
        graph[b][a] = true;
    }


    std::vector<int> order(N);
    for(int i = 0; i < N; i++) order[i] = i;
    int cnt = 0;

    // orderの左端は常に0であることに注意
    do{
        bool isReached = true;
        for(int i = 0; i < N - 1; i++){
            if(!graph[order[i]][order[i + 1]]){
                isReached = false;
                break;
            }
        }

        if(isReached) cnt++;
    }while(std::next_permutation(order.begin() + 1, order.end()));

    std::cout << cnt << std::endl;

    return 0;
}

Measured memory_bytes: 256
int main()
{
	int		A;
	int		hun;
	int		V = 0;
 	scanf("%d", &A);
	hun = A / 500;
	if (A % 500 != 0)
	{
		V = (A % 500) / 5;
	}
	printf("%d",(hun*1000)+(V*5));
	return 0;
}

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

const int mxn = 500000 + 2;
char a[mxn];
int st[4*mxn][26];
//si = segment index
//ss = segment start, se = segment end
void buildTree(int si, int ss, int se){
    if(ss==se){
        st[si][a[ss]-'a'] = 1;
        return;
    }

    int mid = (ss+se)/2;
    buildTree(2*si, ss, mid);
    buildTree(2*si+1, mid+1, se);

    for(int i = 0; i<26; i++){
        st[si][i] = st[2*si][i]+st[1+2*si][i];
    }
}

int query(int si, int ss, int se, int qs, int qe, int get){
    if(qs>se || qe<ss) return 0;

    if(ss>=qs && se<=qe) return st[si][get];

    int mid = (ss+se)/2;
    int l = query(2*si, ss, mid, qs, qe, get);
    int r = query(2*si+1, mid+1, se, qs, qe, get);

    return (l+r);
}

void update(int si, int ss, int se, int upd_index, char c, int k){
    if(ss==se){
        st[si][c-'a'] += k;
        return;
    }

    int mid = (ss+se)/2;
    if(upd_index<=mid) update(2*si, ss, mid, upd_index, c, k);
    else update(2*si+1, mid+1, se, upd_index, c, k);

    for(int i = 0; i<26; i++){
        st[si][i] = st[2*si][i]+st[1+2*si][i];
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    //good luck kittu!
    int n, q, x, y, qt, qs, qe;
    char c;
    string s;
    cin>>n>>s;
    for(int i = 0; i<n; i++) a[i+1] = s[i];
    buildTree(1, 1, n);

    cin>>q;
    while(q--){
        cin>>qt;
        if(qt==2){
            cin>>qs>>qe;
            int count = 0;
            for(int i = 0; i<26; i++){
                count += (query(1, 1, n, qs, qe, i)>0);
            }
            cout<<count<<"\n";
        }
        else{
            cin>>qs>>c;
            update(1, 1, n, qs, a[qs], -1);
            a[qs] = c;
            update(1, 1, n, qs, c, 1);
        }
    }
    return 0;
}

Measured memory_bytes: 109980
import sys
from collections import Counter

input = sys.stdin.readline

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

t=0

a = Counter(A)
total=0
n = len(a)
if n-K > 0:
    for i, j in zip(range(n-K),a.most_common()[::-1]):
        total +=j[1]
    print(total)
else:print(0)

Measured memory_bytes: 39524
// ctrl+shift+b
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll mod_inverse(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}

void Main() {
    ll N; cin >> N;
    vector<ll> A(N); rep(i, N){cin >> A.at(i);}
    ll A_sum = 0;
    rep(i, N){A_sum = (A_sum + A.at(i)) % MOD;}
    ll A_prod = 0;
    rep(i, N){A_prod = (A_prod + A.at(i) * A.at(i) % MOD) % MOD;}
    ll ans = (A_sum * A_sum % MOD - A_prod) % MOD * mod_inverse(2, MOD) % MOD;
    if (ans < 0){
        cout << ans + MOD << endl;
    } else {
        cout << ans << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4748
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll int
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define fur(i,x,y) for(i=x;i<=y;i++)
#define fdr(i,x,y) for(i=x;i>=y;i--)
#define Fur(i,x,y) for(ll i=x;i<=y;i++)
#define Fdr(x,y) for(ll i=x;i>=y;i--)
#define in2(x,y) in(x);in(y)
#define in3(x,y,z) in2(x,y);in(z)
#define in4(a,b,c,d) in2(a,b);in2(c,d)
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
/*---------------------------------------*/

namespace fib{char b[300000]= {},*f=b;}
#define gc ((*fib::f)?(*(fib ::f++)):(fgets(fib::b,sizeof(fib::b),stdin)?(fib::f=fib::b,*(fib::f++)):-1))
inline void in(ll &x){x=0;char c;bool f=0;while((c=gc)>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=gc)<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
namespace fob{char b[300000]= {},*f=b,*g=b+300000-2;}
#define pob (fwrite(fob::b,sizeof(char),fob::f-fob::b,stdout),fob::f=fob::b,0)
#define pc(x) (*(fob::f++)=(x),(fob::f==fob::g)?pob:0)
struct foce{~foce(){pob;fflush(stdout);}} _foce;
namespace ib{char b[100];}
inline void out(ll x){if(x==0){pc(48);return;}if(x<0){pc('-');x=-x;}char *s=ib::b;while(x) *(++s)=x%10,x/=10;while(s!=ib::b) pc((*(s--))+48);}
inline void outn(ll x){out(x);pc('\n');}
inline void swap(ll &x,ll &y){ll t=x;x=y;y=t;}
/*------------------------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------------------------*/
#define N 101
int main(){
	ll n;in(n);
	char c;
	while(n--){cin>>c;if(c=='Y'){printf("Four\n");return 0;}}
	printf("Three\n");
}

/*

*/

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

K = int(input())

arr = [i for i in range(1, 10)]

for i in range(100001):
    one = arr[i]%10
    if one == 0:
        arr.append(arr[i]*10 + 0)
        arr.append(arr[i]*10 + 1)
    elif one == 9:
        arr.append(arr[i]*10 + 8)
        arr.append(arr[i]*10 + 9)
    else:
        arr.append(arr[i]*10 + one - 1)
        arr.append(arr[i]*10 + one)
        arr.append(arr[i]*10 + one + 1)

arr.sort()
print(arr[K-1])

Measured memory_bytes: 15880
'use strict'
 
function Main(input) {
	const ipts = input.split('\n');
	const H = Number(ipts[0].split(' ')[0]);
	const W = Number(ipts[0].split(' ')[1]);
	let list = ipts.slice(1, H+1).map(x => x.split(''));
	let flag = false;

	for(let a=0; a<H; a++) {
		list[a].push('');
		list[a].unshift('');
	}

	list.push([]);
	list.unshift([]);

	for(let b=0; b<W+2; b++) {
		list[0].push('');
		list[H+1].push('');
	}

	//console.log(list);

	
	for(let i=1; i<H+1; i++) {
		for(let j=1; j<W+1; j++) {
			if(list[i][j] == '#') {
				if(list[i+1][j] != '#' && list[i-1][j] != '#' && list[i][j+1] != '#' && list[i][j-1] != '#') {
					flag = true;
					break;
				}
			}
		}
		if(flag) {
			break;
		}
	}

	if(flag) {
		console.log('No');
	} else {
		console.log('Yes');
	}

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

Measured memory_bytes: 7500
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <functional>
#include <numeric>
#include <vector>
using namespace std;

const double PI=acos(-1);

int main(){
    long n, x;
    cin >> n >> x;

    vector<long> l(n, 0);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }

    if(x > std::accumulate(l.begin(), l.end(), 0L)) cout << n-1 << endl;
    else if(x == std::accumulate(l.begin(), l.end(), 0L)) cout << n << endl;
    else{
        sort(l.begin(), l.end());
        int cnt = 0;
        for(int i = 0; i < n; i++, cnt++){
            x -= l[i];
            if(x < 0){
                cout << cnt << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        q : [(usize,usize);m],
    }

    let mut l: Vec<usize> = vec![];
    let mut r: Vec<usize> = vec![];

    for e in q {
        l.push(e.0);
        r.push(e.1);
    }

    let l_max = l.iter().max().unwrap();
    let r_min = r.iter().min().unwrap();
    let mut ans =0 ;

    if r_min >= l_max {
      ans = r_min - l_max + 1;
    }else{
      ans = 0;
    }

    println!("{}", ans);

}


Measured memory_bytes: 6464
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      
      int a = sc.nextInt();
      int[] h = new int[a];
      for(int i = 0; i < a; i++) {
         h[i] = sc.nextInt();
      }
      System.out.println(answer(h, a));
   }
   
   public static int answer(int[] h, int minIndex) {
      if(minIndex == 0)
         return 0;
      if(minIndex == 1)
         return h[0];
      int min = 100000;
      int ind = 0;
      for(int i = 0; i < minIndex; i++) {
         if(min > h[i]) {
            min = h[i];
            ind = i;
         }
      }
      int[] a = new int[ind];
      for(int i = 0; i < ind; i++) {
         a[i] = h[i] - min;
      }
      int[] b = new int[minIndex - ind - 1];
      for(int i = ind + 1; i < minIndex; i++) {
         b[i - ind - 1] = h[i] - min;
      } 
      return answer(a, ind) + answer(b, minIndex - ind - 1) + min;
   }
}

Measured memory_bytes: 21844
import math
A,B = map(int,input().split())
sol1 = math.ceil(A/0.08)
sol2 = math.ceil(B/0.10)
ans = lambda x1,x2 : x1 if x1 == x2 else -1
flagA = True
flagB = True
while True:
    if(sol1 * 0.08 < A and flagA):
        flagA = False
        if(math.floor((sol1+1)*0.10) == B):
            print(sol1+1)
            break
    sol1 -= 1
    if(sol2 * 0.10 < B and flagB):
        flagB = False
        if(math.floor((sol2+1)*0.08) == A):
            print(sol2+1)
            break
    if(not flagA and not flagB):
        print(-1)
        break
    sol2 -= 1

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

int64_t qkey(int warp,int y,int x)
{
	return (int64_t)warp*1024*1024+y*1024+x;
}
int qwarp(int64_t key)
{
	return key/(1024*1024);
}
int qy(int64_t key)
{
	return (key%(1024*1024))/1024;
}
int qx(int64_t key)
{
	return key%1024;
}

int main()
{
	int h,w;
	cin >> h >> w;
	int ch,cw,dh,dw;
	cin >> ch >> cw >> dh >> dw;
	
	vector<vector<int>> s(h+1,vector<int>(w+1));
	for (int i=1;i<=h;++i)
	{
		for (int j=1;j<=w;++j)
		{
			char c;
			cin >> c;
			if (c=='.')
			{
				s[i][j]=-1; // not searched
			}
			else
			{
				s[i][j]=-2; // wall
			}
		}
	}

	s[ch][cw]=0;
	priority_queue<int64_t,vector<int64_t>,greater<int64_t> > pq;
	pq.push(qkey(0,ch,cw));

	while (pq.empty()==false)
	{
		int warp,x,y;
		int64_t key=pq.top();
		pq.pop();
		warp=qwarp(key);
		x=qx(key);
		y=qy(key);
		//fprintf(stderr,"warp,y,x %d %d %d\n",warp,y,x);

		if ((s[y][x]!=-1)&&(s[y][x]<warp))
		{
			continue;
		}

		if ( (y==dh) && (x==dw) )
		{
			// destination
			cout << warp << endl;
			return 0;
		}

		// up
		if (y>=2)
		{
			if ((s[y-1][x]==-1)||(s[y-1][x]>warp))
			{
				s[y-1][x]=warp;
				pq.push(qkey(warp,y-1,x));
			}
		}

		// down
		if (y<=h-1)
		{
			if ((s[y+1][x]==-1)||(s[y+1][x]>warp))
			{
				s[y+1][x]=warp;
				pq.push(qkey(warp,y+1,x));
			}
		}

		// left
		if (x>=2)
		{
			if ((s[y][x-1]==-1)||(s[y][x-1]>warp))
			{
				s[y][x-1]=warp;
				pq.push(qkey(warp,y,x-1));
			}
		}

		// right
		if (x<=w-1)
		{
			if ((s[y][x+1]==-1)||(s[y][x+1]>warp))
			{
				s[y][x+1]=warp;
				pq.push(qkey(warp,y,x+1));
			}
		}

		// warp
		for (int dy=-2;dy<=2;++dy)
		{
			for (int dx=-2;dx<=2;++dx)
			{
				if ((dx==0)&&(dy==0))
				{
					continue;
				}

				if ( (y+dy>=1) && (y+dy<=h) && (x+dx>=1) && (x+dx<=w) && ( (s[y+dy][x+dx]==-1) || (s[y+dy][x+dx]>warp+1) ) )
				{
					s[y+dy][x+dx]=warp+1;
					pq.push(qkey(warp+1,y+dy,x+dx));
				}
			}
		}
	}
	cout << -1 << endl;
}



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

int main()
{
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size(), ans = 2000;
  for (int i = 0; i <= n - m; i++)
  {
    int c = 0;
    for (int j = 0; j < m; j++)
    {
      if (s.at(i + j) != t.at(j))
        c++;
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long lld;
typedef long double Lf;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define A(x) (int)abs(x)

int main() {
	int n, x, y, a[2000] = { 0 };
	scanf("%d%d%d", &n, &x, &y);
	Rep(i, 1, n)Rep(j, i + 1, n + 1)a[mi(abs(x - i) + abs(y - j) + 1, mi(abs(y - i) + abs(x - j) + 1, j - i))]++;
	Rep(i, 1, n)printf("%d\n", a[i]);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define print(x) cout<<x;
#define printl(x) cout<<x<<endl;
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
typedef long long int ll;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=0;
    if(n%2){cout<<0;return 0;}
    n/=2;
    long long int count = 0; 

	// Keep dividing n by powers of 
	// 5 and update count 
	for (long long int i = 5; n / i >= 1; i *= 5) 
		count += n / i; 
    cout<<count;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String time = sc.next();
        int yyyy = Integer.valueOf(time.substring(0,4)).intValue();
        int mm = Integer.valueOf(time.substring(5,7)).intValue();
        int dd = Integer.valueOf(time.substring(8,10)).intValue();
//        System.out.println(yyyy);
//        System.out.println(mm);
//        System.out.println(dd);

        if (2019 < yyyy) {
            System.out.println("TBD");
        } else if (2019 == yyyy) {
            if (4 < mm) {
                System.out.println("TBD");
            } else {
                System.out.println("Heisei");
            }
        } else {
            System.out.println("Heisei");
        }

    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll power(ll n, ll p, ll mod) {
    ll ans = 1;
    while (p > 0) {
        if (p & 1) ans = ans * n % mod;
        n = n * n % mod;
        p >>= 1;
    }
    return ans;
}

class CombinationN {
   public:
    CombinationN(int n, int maxk) {
        N = n; K = maxk + 1; 
        fac = new ll[K];
        numerator = new ll[K];

        fac[0] = 1; numerator[0] = 1;
        REP(i, 1, K) {
            fac[i] = fac[i - 1] * i % MOD;
            numerator[i] = numerator[i - 1] * (n - i + 1) % MOD; 
        }
    }

    ll cnr(int k) {
        if (N - k < k) return cnr(N - k);
        return numerator[k] * power(fac[k], MOD - 2, MOD) % MOD;
    }

   private:
    int N, K;
    ll *fac, *numerator;
};

int main() {
    int n, a, b; cin >> n >> a >> b;
    CombinationN comb(n, max(a, b));

    ll ans = power(2, n, MOD) - 1 - (comb.cnr(a) + comb.cnr(b)) % MOD;
    cout << (ans + MOD) % MOD << endl;

    return 0;
}

Measured memory_bytes: 3328
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;
 
public class Main {
 
	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;
 
	static void solve() {
		int a=in.nextInt();
		int b=in.nextInt();
		if(a>b)out.println("a > b");
		else if(a<b)out.println("a < b");
		else out.println("a == b");
	}
 
	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();
 
		solve();
		out.flush();
 
		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}
 
	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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



long long mod = 1000000007;



long long cnt[1000005];
int main(){
	//freopen("i.txt","r",stdin);
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cnt[0] = 3;
	long long ans = 1;
	for(int i = 0;i < n;i++){
		long long x;
		cin >> x;
		x++;
		
		if(cnt[x-1] <= 0){
			cout << 0;
			return 0;
		}
		
		ans *= cnt[x-1];
		cnt[x]++;
		cnt[x-1]--;
		ans %= mod;
		
	}
	
	cout << ans;
	
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
vector<int> A;
vector<int> B;
//=============================
void input()
{
    cin>>N>>M;

}
//=============================
void func(){}
//=============================
void solve()
{
    cout<<(N*M%2 ? "Odd" : "Even")<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

if x not in p_list:
    print(x)
    exit()

i = 1
while True:
    low_x = x - i
    if low_x not in p_list:
        print(low_x)
        break
    
    high_x = x + i
    if high_x not in p_list:
        print(high_x)
        break

    i += 1

Measured memory_bytes: 9184
#include<stdio.h>

int main(void)
{
	int H, W, i, j;

	for (;;)
	{
		scanf("%d %d", &H, &W);

		if (H != 0 && W != 0)
		{
			for (i = 0; i < H; i++)
			{
				for (j = 0; j < W; j++)
				{
					printf("#");
				}
				printf("\n");
			}
			printf("\n");
		}
		else
		{
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 572
S= input()
max_len = 0
l = 0
for i in range(len(S)):
    s = S[i]
    if s == 'A' or s == 'T'  or s == 'G' or s == 'C' :
        l += 1
        if l > max_len:
            max_len = l
    else:
        l = 0
print(max_len)

Measured memory_bytes: 3060
class treeNode:
    def __init__(self, x):
        self.val = x
        self.children = []
    
n = int(input())
rootL = list(range(n))
hashMap = {}
index = 0
while index < n:
    listI = list(map(int, input().split()))
    if listI[0] in hashMap:
        node = hashMap[listI[0]]
        childrenL = []
        if listI[1] == 0:
            pass
        else:
            for child in listI[2:]:
                rootL.remove(child)
                if child in hashMap:
                    childN = hashMap[child]
                else:
                    childN = treeNode(child)
                childrenL.append(childN)
                hashMap[child] = childN
        node.children = childrenL
    else:
        hashMap[listI[0]] = treeNode(listI[0])
        childrenL = []
        for child in listI[2:]:
            rootL.remove(child)
            if child in hashMap:
                childN = hashMap[child]
            else:
                childN = treeNode(child)
            childrenL.append(childN)
            hashMap[child] = childN
        hashMap[listI[0]].children = childrenL
    index+=1

root = hashMap[rootL[0]]
answerL = ['']*n

def lookNode(node, parentV, depth):
    answer = ''
    answer+='node '+str(node.val)+': '
    answer+='parent = '+str(parentV)+', '
    answer+='depth = '+str(depth)+', '
    if depth == 0:
        answer+='root,'
    elif node.children == []:
        answer+='leaf,'
    else:
        answer+='internal node,'
    childrenL = []
    for child in node.children:
        childrenL.append(child.val)
    answerL[node.val] = [answer, childrenL]
    for child in node.children:
        lookNode(child, node.val, depth+1)
lookNode(root, -1, 0)
for ans in answerL:
    print(ans[0], ans[1])


Measured memory_bytes: 65588
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    while(N){
        vector<int> V(N);
        rep(i,0,N)cin >> V[i];
        ll sum = 0;
        rep(i,0,N)sum += V[i];
        int cnt = 0;
        rep(i,0,N)if(V[i] <= sum / N)cnt++;
        cout << cnt << endl;
        cin >> N;
    }
}


Measured memory_bytes: 3144
import scala.io.StdIn
import java.util.Arrays

object Main {
  def main(args: Array[String]): Unit = {
    while(true) {
      val n :: m :: _res = StdIn.readLine().split(" ").map(_.toInt).toList
      if(n == 0) { return; }
      val prices = StdIn.readLine().split(" ").map(_.toInt).toSeq


      println(solve(m, prices).map(_.toString).getOrElse("NONE"))
    }
  }

  def solve(max: Int, prices: Seq[Int]): Option[Int] = {
    val ps = prices.toArray
    Arrays.sort(ps)

    var current: Int = 0

    for {
      (p, i) <- ps.zipWithIndex
      (q, j) <- ps.zipWithIndex
      if i < j
    } {
      val add = p + q
      if(add <= max) {
        if(current < add) {
          current = add
        }
      }
    }

    if(current == 0) {
      None
    } else {
      Some(current)
    }
  }
}

Measured memory_bytes: 441208
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){
		
		double x = 0, y = 0;
		int a, dt;
		int t = 0;
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			Scanner str = new Scanner(sc.nextLine());
			str.useDelimiter(",");
			
			a = str.nextInt();
			dt = str.nextInt();
			if(a == dt && a == 0) break;
			
			x += a * Math.sin((double) t/ 360 * 2 * Math.PI);
			y += a * Math.cos((double) t/ 360 * 2 * Math.PI);	
			t += dt;
			str.close();
			
		}
		sc.close();
		
		System.out.println((int)x);
		System.out.println((int)y);
	}
	
}

Measured memory_bytes: 19268
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	string s; cin >> s;
	int ans = 0, groups = 0;
	for(int i = 0, j = 0; i < n; i = j){
		while(j < n && s[i] == s[j]) j++;
		ans += j - i - 1;
		groups++;
	}
	while(groups >= 3 && k > 0){
		groups -= 2;
		ans += 2;
		k--;
	}
	if(k > 0 && groups == 2){
		groups--;
		ans++;
		k--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import numpy as np

A = np.array([])

A = np.append(A, int(input()))
A = np.append(A, int(input()))
A = np.append(A, int(input()))
A = np.append(A, int(input()))
A = np.append(A, int(input()))
k = int(input())

if (np.max(A)-np.min(A)) > k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 12500
#include "bits/stdc++.h"

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define printlist(l) for(auto x: l) cout << x << ' '; cout << endl;

#define mod 1000000007
#define maxn 100005

ll n, x, y, m, q, t, k, a[maxn];
vector<pll> b[maxn];

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

	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		for (int j = 0; j < a[i]; ++j) {
			ll xi, yi;
			cin >> xi >> yi;
			xi--;
			b[i].push_back(make_pair(xi, yi));
		}
	}

	ll ans = 0;
	for (ll i = 0; i < (1 << n); i++) {
		int ok = 1;
		ll cnt = 0;
		for (ll j = 0; j < n; ++j) {
			ll bit = (i / (1 << j)) % 2;
			//cout << i << ' ' << j << ' ' << bit << endl;
			if (bit) {
				cnt++;
				for (int k = 0; k < b[j].size(); ++k) {
					ll xi = b[j][k].first;
					ll yi = b[j][k].second;
					ll bit1 = (i / (1 << xi)) % 2;
					if (bit1 != yi) {
						ok = 0;
						break;
					}
				}
			}

			if (!ok)
				break;
		}

		//cout << i << ' ' << ans << endl;

		if (ok)
			ans = max(ans, cnt);
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long int
#define vi vector<int>
#define vvll vector<ll>
#define vll(a) vector<ll> a(MAXN)
#define pb push_back
#define fo(a) for(auto&a1:(a))
#define fd(a,b) for(int i=(a);i>=(b);i--)
#define fk(a,b) for(int k=(a);k<(b);k++)
#define fj(a,b) for(int j=(a);j<(b);j++)
#define f(a,b) for(ll i=(a);i<(b);i++)
#define forni(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define fdk(a,b) for(int k=(a);k>=(b);k--)
#define fdj(a,b) for(int j=(a);j>=(b);j--)
#define ri(n) scanf("%d",&(n));
#define rll(n) scanf("%lld",&(n));
#define T(t) int t;scanf("%d",&(t));while((t)--)
#define MAXN 10000001
#define MAXN2 10000005
#define pll pair<ll,ll>
#define PI 3.14159265
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll mod=1000000007;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n];
    f(0,n)
    cin>>h[i];
    ll dp[n]={INT_MAX};
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    f(2,n)
    {
        ll mi=dp[i-1]+abs(h[i]-h[i-1]);
        for(ll j=i-1;(j>=0 && (i-j)<=k);j--)
        mi=min(mi,dp[j]+abs(h[i]-h[j]));
        dp[i]=mi;
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 5140
import java.util.*;
class Main {
  public static void main (String[] args) throws Exception {
    
    Scanner sc = new Scanner(System.in);
    
    int n=sc.nextInt();
    int x=sc.nextInt();
    int y=sc.nextInt();
    
    int[] ans =new int[n];
    
    for(int i=1; i<n+1; i++){
        for(int j=i+1; j<n+1; j++){
          int tmp =Math.min(Math.min(j-i, Math.abs(x-i)+1+Math.abs(y-j)),Math.abs(y-i)+1+Math.abs(x-j));
          ans[tmp-1]++;
          

        }
      }
for(int i=0; i<n-1; i++){
    System.out.println(ans[i]);
}
  }
}


Measured memory_bytes: 22608