akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2e5 + 5;
ll x[N], y[N], a[N], b[N];
int len, n;

ll solve() {
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		int j = n - i;
		if (j <= i) {
			ans = max(ans, (a[i] - a[i - j]) * 2 + b[j] * 2 - y[j]);
			ans = max(ans, (a[i] - a[i - j]) * 2 + b[j] * 2 - x[i]);
		}
	}

	for (int i = 1; i < n; i++) {
		int j = n - i;
		if (i - 1 >= j) {
			ans = max(ans, (a[i] - a[i - j - 1]) * 2 - x[i] + b[j] * 2);
		}
	}

	for (int i = 1; i < n; i++) {
		int j = n - i;
		if (i >= j - 1) {
			ans = max(ans, (a[i] - a[i - j + 1]) * 2 + b[j] * 2 - y[j]);
		}
	}

	return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> len >> n;

    for (int i = 1; i <= n; i++) {
    	cin >> x[i];
    	y[i] = len - x[i];
    }

    reverse(y + 1, y + n + 1);

    for (int i = 1; i <= n; i++) {
		a[i] = a[i - 1] + x[i];
	}

	for (int i = 1; i <= n; i++) {
		b[i] = b[i - 1] + y[i];
	}

	ll ans = max(x[n], y[n]);

	ans = max(ans, solve());

	for (int i = 1; i <= n; i++) {
		swap(a[i], b[i]);
		swap(x[i], y[i]);
	}

	ans = max(ans, solve());

	cout << ans;
 
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
using namespace std;
using ll = long long;

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

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

  ll sum = 0;
  for(int a=1;a<=k;a++){
    for(int b=1;b<=k;b++){
      int gab = gcd(a,b);
      for(int c=1;c<=k;c++){
        int gabc = gcd(gab,c);
        sum += gabc;
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3624
s= input()
t= input()

atmp=2000
for i in range(len(s) - len(t) + 1):
    s1=s[i:i+len(t)]
    #print(s1)
    tmp=0
    for j in range(len(t)):
        if s1[j]!=t[j]:
            tmp+=1
    atmp=min(atmp,tmp)
        
print(atmp)

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

int main() {
  int N, M, a;
  cin>>N>>M;
  vector<int> A(N);
  for (int i=0; i<M*2; i++){
    cin>>a;
    A.at(a-1)++;
  }
  for (int i=0; i<N; i++)
    cout<<A.at(i)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll A,B,C,K,N,M,X,Y;
string S;
vector<ll> vec;

void solve() {
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad";
		return;
	}

	cout << "Good";
	return;

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long

using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    ll n; cin>>n;
    map<string,ll> m;
    for(ll i=0;i<n;i++)
    {
        string s; cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}


Measured memory_bytes: 3660
#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[i];
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] != a[j] and a[j] != a[k] and a[i] != a[k] and a[i] + a[j] > a[k]) {
					++ans;
				}
			}
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
    using namespace std;
    int main()
    {
     string N;
      int sum=0;
      cin>>N;
      for (int i=0;i<N.length();i++)
      {
        sum+=N[i]-48;
      }
      
      if (sum%9==0)
      {
        cout<<"Yes";
      }
      
      else
      {
        cout<<"No";
      }
      
      return 0;
    }


Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(ll i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    ll n;
    cin >> n;
    int t;
    ll n_tmp=n;
    int count;
    int j;
    ll ans=0;
    FOR(i,sqrtl(n)+1,2){
        count=0;
        while(n_tmp%i==0){
            n_tmp/=i;
            count++;
        }
        j=1;
        while(count>=j){
            count-=j;
            j++;
            ans++;
        }
    }
    if(n_tmp==n&&n!=1){
        ans=1;
        cout << ans << endl;
        return 0;
    }else if(n==1){
        ans=0;
        cout << ans << endl;
        return 0;
    }
    n=n_tmp;
    FOR(i,sqrtl(n)+1,2){
        while(n_tmp%i==0){
            n_tmp/=i;
        }
    }
    if(n==n_tmp&&n!=1){
        ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3648
#include<stdio.h>
int main(){
	char o[51],s[51];
	scanf("%s%s",o,s);
	int i,j,so=1,ss=1;
	while(o[so] != '\0'){so++;}
	while(s[ss] != '\0'){ss++;}
	if(so == ss){
		for(i = 0;i < so;i++){
			printf("%c",o[i]);
			printf("%c",s[i]);
		}
	}
	else if(so - ss == 1){
		for(j = 0;j < ss;j++){
			printf("%c",o[j]);
			printf("%c",s[j]);
		}
		printf("%c",o[so-1]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    private static long max(long x, long y) {
        if (x > y) {
            return x;
        } else {
            return y;
        }
    }

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

        int N = sc.nextInt();
        int W = sc.nextInt();

        long[][] dp = new long[N + 1][W + 1];
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= W; j++) {
                dp[i][j] = -1;
            }
        }

        dp[0][0] = 0;
        for (int i = 0; i < N; i++) {
            int w = sc.nextInt();
            int v = sc.nextInt();
            for (int j = 0; j <= W; j++) {
                if (dp[i][j] == -1) {
                    continue;
                }
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
                if (j + w <= W) {
                    dp[i + 1][j + w] = max(dp[i + 1][j + w], dp[i][j] + v);
                }
            }
        }

        long result = 0;
        for (int j = 0; j <= W; j++) {
            if (dp[N][j] > result) {
                result = dp[N][j];
            }
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 127444
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++)cin>>d[i];

    sort(d.begin(),d.end());

    cout<<-(d[N/2-1]-d[N/2])<<endl;
}


Measured memory_bytes: 640
# include <stdio.h>
# include <stdlib.h>
int main(){
	int i,n,j,k;
	double *arr,**ans,res=0;
	scanf ("%d",&n);
	arr=(double*)malloc(n*sizeof(double));
	for(i=0;i<n;i++) scanf ("%lf",&arr[i]);
	ans=(double**)malloc(n*sizeof(double*));
	for(i=0;i<n;i++) ans[i]=(double*)malloc((n+2)*sizeof(double));
	for(i=0;i<n;i++){
		for(j=0;j<n+2;j++) ans[i][j]=0;
	}
	ans[0][0]=1-arr[0];
	ans[0][1]=arr[0];
	for(i=1;i<n;i++){
    	for (j=0;j<i+2;j++){
        	if (j==0) ans[i][j]=ans[i-1][j]*(1-arr[i]);
        	else ans[i][j]=ans[i-1][j]*(1-arr[i])+ans[i-1][j-1]*arr[i];
        }
    }
    for(i=n;i>n/2;i--){
    	res+=ans[n-1][i];
	}
	printf ("%.10lf\n",res);
    return 0;	
}

Measured memory_bytes: 72112
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let t: String = read();
    let s: Vec<_> = s.chars().collect();
    let t: Vec<_> = t.chars().collect();
    let mut ans = 0;
    for (i, c) in s.iter().enumerate() {
        if *c == t[i] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;
 
typedef long long lo;
 
template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
namespace {
    const int mo = 998244353;
    inline int add(int x, int y) { x += y; return x >= mo ? x - mo : x; }
    inline int sub(int x, int y) { x -= y; return x < 0 ? x + mo : x; }
    inline int mul(int x, int y) { return (lo) x * y % mo; }
    inline int power(int a, int k = mo - 2) {
		int ans = 1;
		for (; k; k >>= 1, a = mul(a, a))
			if (k & 1) ans = mul(ans, a);
		return ans;
    }
	inline void U(int &x, int y) { x = add(x, y); } 
}

string str;
map <string, int> mp; 

string operator & (string a, string b) {
	re0 (i, b.length()) a[i] = a[i] & b[i];
	return a;
}

inline int gao(string str) {
	int n = str.length();
	if (n == 0) return 1;
	if (mp.count(str)) return mp[str];
	int &ans = mp[str] = 0;
	U(ans, mul(str[0] == 1 ? 2 : 1, gao(str.substr(1, n - 1))));
	for (int len = 1; len <= n; len++) {
		string t = str.substr(0, len);
		for (int i = len; i + len <= n; i += len) {
			t = t & str.substr(i, len);
			U(ans, mul(gao(t), gao(str.substr(i + len, n - (i + len)))));
		}
	}
	return ans;
}

int main(void) {
	cin >> str;
	re0 (i, str.length()) str[i] -= '0';
	cout << gao(str) << "\n";
}


Measured memory_bytes: 5632
s = input()
n = len(s)
if s != s[::-1]:
    print("No")
else:
    t = s[:int((n - 1) / 2)]
    u = s[int((n + 1) / 2):]
    if t == t[::-1] and u == u[::-1]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 9060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100];

int main(void){
	int n,t,i,ans=0;
	ll d = 0ll,mn = INFLL;
	cin >> n >> t;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		d = max(d,a[i]-mn);
		mn = min(mn,a[i]);
	}
	mn = INFLL;
	for(i=0; i<n; ++i){
		if(d == a[i] - mn){
			++ans;
		}
		mn = min(mn,a[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, m, a, b;
    cin >> n >> m;
    vector<int> A(n, 0);
    vector<int> B(n, 0);
    vector<vector<int>> sched;
    for(int i = 0; i < n; i++) {
        cin >> a >> b;
        sched.push_back({b, m-a}); // latest start day, reward
    }
    sort(sched.begin(), sched.end(), [](vector<int>& x, vector<int>& y){
        if (x[0] == y[0]) {
            return x[1] < y[1];
        } else {
            return x[0] > y[0];
        }
    });
    /*
    for(int i = 0; i < n; i++) {
        cout << sched[i][0] << " " << sched[i][1] << endl;
    }*/
    ll ans = 0;
    set<int> avail;
    for(int i = 0; i < m; i++)
        avail.insert(i);
    for(int i = 0; i < n; i++) {
        int reward = sched[i][0];
        int start_day = sched[i][1];
        auto it = avail.upper_bound(start_day);
        if (it != avail.begin()) {
            ans += reward;
            avail.erase(prev(it));
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 11568
N,*E=map(int,open(0).read().split())
E=sorted((e,2*(i<N)-1)for i,e in enumerate(E))
a,c=1,0
for _,d in E:
	if c*d<0:a=abs(a*c)%(10**9+7)
	c+=d
print(a)

Measured memory_bytes: 28140
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

vector<ll> a(mx);
vector<ll> f(mx);
ll n,k;

bool finish(ll x){
  ll cnt=0;
  rep(i,n){
    if(a[i]*f[i]<=x) continue;
    if(f[i]>x){ cnt += a[i]; continue; }
    cnt += a[i]-(x/f[i]);
  }
  return cnt<=k;
}
 
int main(){
  cin >> n >> k;
  a.resize(n);
  f.resize(n);
  ll sum = 0;
  rep(i,n){ cin >> a[i]; sum += a[i]; }
  rep(i,n) cin >> f[i];
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());

  if(sum<=k){ cout << 0 << endl; return 0; }

  ll l=0,r=1e12,mid=(r+l)/2;
  while(r-l>1){
    mid=(r+l)/2;
    if(finish(mid)){ r=mid; }else{ l=mid; }
  }
  ll ans = r;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
import java.io.*;
import java.util.*;

public class Main{
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int h = in.ni(), w = in.ni();
        char[][] map = new char[h][w];
        int[][] dist = new int[h][w];
        for (int i = 0; i < h; i++) {
            map[i] = in.ns().toCharArray();
        }
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if(i == 0&&j == 0){
                    if(map[0][0]=='#') dist[0][0] = 1;
                }else if(i == 0){
                    dist[i][j] = dist[i][j-1];
                    if(map[i][j]=='#'&&map[i][j-1]=='.') dist[i][j]++;
                }else if(j == 0){
                    dist[i][j] = dist[i-1][j];
                    if(map[i][j]=='#'&&map[i-1][j]=='.') dist[i][j]++;
                }else{
                    int a = dist[i-1][j];
                    int b = dist[i][j-1];
                    if(map[i][j]=='#'&&map[i-1][j]=='.') a++;
                    if(map[i][j]=='#'&&map[i][j-1]=='.') b++;
                    dist[i][j] = Math.min(a,b);
                }
            }
        }
        out.println(dist[h-1][w-1]);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = (int) 1e5 + 100;
const int LOG = 40;
int a[N];
int cnt[LOG];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i] );
	int x = 0;
	for (int i = 0; i < n; i++)
		x ^= a[i];

	for (int i = 0; i < n; i++)
	{
		int cur = 1;
		int id = 0;
		while (a[i] % (2 * cur) == 0)
		{
			id++;
			cur *= 2;
		}
		cnt[id] = 1;
	}
	int ans = 0;
	for (int i = 30; i >= 0; i--)
	{
		if (x & (1 << i) )
		{
			if (cnt[i] == 0)
			{
				printf("-1\n");
				return 0;
			}
			x ^= (1 << (i + 1) ) - 1;
			ans++;
		}
	}
	printf("%d\n", ans);
	
	

	return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

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

    int res=1001;
    for(int i=0;i<n;i++){
        int t_c,t_t;cin >> t_c >> t_t;
        if(t_t<=t) res=min(res,t_c);
    }
    if(res!=1001) p(res)
    else p("TLE")
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define lint long int
int main(void) {
	lint a1 = 2,a2 = 1,a3;
	int c1;
	std::cin >> c1;
	for (int l1 = 0; l1 < c1; l1++) {
		a3 = a1 + a2;
		a1 = a2;
		a2 = a3;
	}
	std::cout << a1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define N 1011

using namespace std;
const int MOD = (int)1e9 + 7;

int h, w, cnt[N][N];
string arr[N];

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> h >> w;
	for(int i=0; i<h; i++) {
		cin >> arr[i];
	}
	for(int i=h-1; i>=0; i--) {
		for(int j=w-1; j>=0; j--) {
			if(i == h-1 && j == w-1) cnt[i][j] = 1;
			else if(arr[i][j] == '#') cnt[i][j] = 0;
			else if(i == h-1) cnt[i][j] = cnt[i][j+1];
			else if(j == w-1) cnt[i][j] = cnt[i+1][j];
			else cnt[i][j] = (cnt[i+1][j] + cnt[i][j+1]) % MOD;
		}
	}
	cout << cnt[0][0] << endl;
	return 0;
}


Measured memory_bytes: 9216
from collections import deque
N, L = map(int, input().split())
A = list(map(int, input().split()))

ans = []
q = deque()

for i, a in enumerate(A):
    while q and A[q[-1]] >= a:
        q.pop()
    q.append(i)
    if i - L + 1 >= 0:
        ans.append(A[q[0]])
        if q[0] == i - L + 1:
            q.popleft()

print(*ans)


Measured memory_bytes: 126252
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    int a,b;
    string ans="Odd";
    cin>>a>>b;
    if((a*b)%2==0)ans="Even";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=998244353;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

struct Dice
{
    //int x, y;
    int l, r, f, b, d, u;

    void RollN()
    {
        //  --y;
        int buff = d;
        d = f;
        f = u;
        u = b;
        b = buff;
    }

    void RollS()
    {
        // ++y;
        int buff = d;
        d = b;
        b = u;
        u = f;
        f = buff;
    }

    void RollL() // ----->
    {
        int buff = f;
        f = l;
        l = b;
        b = r;
        r = buff;
    }

    void RollR() // <------
    {
        int buff = f;
        f = r;
        r = b;
        b = l;
        l = buff;
    }

    void RollE() // .o -> o.
    {
        // --x;
        int buff = d;
        d = l;
        l = u;
        u = r;
        r = buff;
    }


    void RollW() // o. -> .o
    {
        //  ++x;
        int buff = d;
        d = r;
        r = u;
        u = l;
        l = buff;
    }


    vector< Dice > makeDice()
    {
        vector< Dice > ret;
        for(int i = 0; i < 6; i++) {
            Dice d(*this);
            if(i == 1) d.RollN();
            if(i == 2) d.RollS();
            if(i == 3) d.RollS(), d.RollS();
            if(i == 4) d.RollL();
            if(i == 5) d.RollR();
            for(int j = 0; j < 4; j++) {
                ret.emplace_back(d);
                d.RollE();
            }
        }
        return (ret);
    }
};

int h,w;
vector<string> s(100);
bool vis[100][100];

bool dfs(int y,int x,Dice dice){
    if(y == h - 1 && x == w - 1) return true;
    if(vis[y][x]) return false;
    vis[y][x] = true;
    for (int i = 0; i < 4; i++) {
        int ny = y + dy[i], nx = x + dx[i];
        if(0<=ny&&ny<h&&0<=nx&&nx<w){
            Dice ndice = dice;
            if(i == 0) ndice.RollW();
            if(i == 1) ndice.RollN();
            if(i == 2) ndice.RollE();
            if(i == 3) ndice.RollS();
            if(ndice.d == s[ny][nx] - '0' && dfs(ny, nx, ndice)) return true;
        }
    }
    return false;
}

int main(){
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> s[i];
    }
    Dice dice;
    dice.d = 6;
    dice.u = 1;
    dice.r = 3;
    dice.l = 4;
    dice.f = 2;
    dice.b = 5;
    if(dfs(0,0,dice)) puts("YES");
    else puts("NO");
    return 0;
}



Measured memory_bytes: 4044
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}


int main() {
	IOS;
	int n;
	cin >> n;
	cout << n * (n + 1) /2 << endl;
}



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

using namespace std;

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

    int x[N + 1];
    for(int i = 1; i <= N; i++) {
        cin >> x[i];
    }

    int ans[N + 1];
    for(int i = 1; i <= N; i++) {
        ans[i] = 0;
    }

    for(int i = 1; i <= N; i++) {

        int A = 0, B = 0;

        A = x[i] * 2;
        B = abs(K - x[i]) * 2;
        ans[i] = min(A, B);
    }

    int answer = 0;

    for(int i = 1; i <= N; i++) {
        answer += ans[i];
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define mod 1000000007
using namespace std;
inline long long ksm(long long x,long long y)
{
	long long rtn=1;
	while(y)
	{
		if(y&1) rtn*=x,rtn%=mod;
		x*=x,x%=mod,y>>=1;
	}
	return rtn;
}
int main(int argc, char** argv) {
	int n;
	cin >> n;
	int ans=ksm(10,n);
	ans-=ksm(9,n)*2;
	ans%=mod;
	ans+=ksm(8,n);
	cout << (ans%mod+mod)%mod;
	return 0;
}

Measured memory_bytes: 3216
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  string T;
  cin >> T;
  int N = len(T);
  rep(i, N) {
    T[i] = (T[i] == '?' ? 'D' : T[i]);
  }
  cout << T << endl;
}

Measured memory_bytes: 3772
from math import factorial
from collections import Counter

N, M = map(int, input().split())
MOD = 10 ** 9 + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A = prime_factorize(M)
c = Counter(A)
cases = 1

for v in c.values():
    if v > 1:
        x = factorial(v+N-1)*pow(factorial(N-1)*factorial(v) % MOD, MOD-2, MOD)%MOD
        cases *= x
    else:
        cases *= N
    cases %= MOD
print(cases)

Measured memory_bytes: 4684
// Best practice
    
    #include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> // Common file 
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <ext/pb_ds/detail/standard_policies.hpp>
    #include <functional> // for less 
    
    #define int         long long
    #define pb          emplace_back
    #define pf          emplace_front
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define endl        '\n'
    #define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    using namespace std;
    using namespace __gnu_pbds; 
     
    typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
    
    #define fbo find_by_order
    #define ook order_of_key
    
    signed main() {
       tezz
       
       int n;
       cin >> n;
       int p;
       bool poss=true;
       for(int i=0; i<n; i++){
           cin >> p;
           if(p%2==0 && p%3!=0 && p%5!=0){
               cout << "DENIED" << endl;
               return 0;
           }
       }
       cout << "APPROVED" << endl;
      
       return 0;
    }
    


Measured memory_bytes: 256
#include<iostream>
using namespace std;
template<typename T>
class stack
{
  T elements[10000];
  int index=-1;
public:
  void push(T num)
  {
    index++;
    elements[index]=num;
  }
  void pop()
  {
    index--;
  }
  T peep()
  {
    if(index==-1)return 0;
    else
    return elements[index];
  }
  bool empty()
  {
    return index==-1;
  }
  int size()
  {
    return index+1;
  }
};
//  stack definition ...............................................................??
int main()
{ 
   int t=1;
   //cin >> t;
   while(t--)
   {
     // int size;
     // cin >> size;
     // int arr[size];
     // for(int i=0;i<n;i++)
     // {

     // }
    int n;
    cin >> n;
    if(n)
      cout << "0" << endl;
    else
      cout << "1" << endl;
   }
   
return 0;
}



Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int a[10];
bool flag[3][3],check=true;
int main(){
	int n,m;
	cin>>n>>m;
	int c,b;
	for(int i=1;i<=m;i++){
		cin>>c>>b;
		if(a[c]>0&&a[c]!=b) check=false;
		else{
			a[c]=b;
		}
		if(c==1&&b==0&&n>1) check=false;
	}
	if(a[1]==0&&n>1) a[1]=1;
	
	if(!check) cout<<-1;
	else{
		for(int i=1;i<=n;i++) cout<<a[i];
	}
}

Measured memory_bytes: 256
abck = input('')
a = int(abck.split(' ')[0])
b = int(abck.split(' ')[1])
c = int(abck.split(' ')[2])
k = int(abck.split(' ')[3])

cnt=0
left=k

#A
if a > k:
    left=0
    cnt=k
else:
    left=k-a
    cnt=a

if left>0:
    left-=b

if left>0:
    cnt-=left

print(cnt)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using llint = long long;
using vint = vector<int>;

int main () {
    int r; cin >> r;
    r = r * r;
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
li=[int(x) for x in input().split()]
d={}
for i in range(len(li)):
	if li[i] in d:
		d[li[i]]+=1
	else:
		d[li[i]]=1

for i in range(1,n+1):
	if i in d:
		print(d[i])
	else:
		print(0)

Measured memory_bytes: 111660
def input_from_console():
    n = int(input())
    return n


def solve(n):
    last_digit_str = str(n)[-1]
    if last_digit_str == "3":
        return "bon"
    if last_digit_str in ["0", "1", "6", "8"]:
        return "pon"
    return "hon"


def main():
    n = input_from_console()
    print(solve(n))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

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

int main() {

    ll A, B, K;
    cin >> A >> B >> K;

    if (K <= A) cout << A - K << " " << B << endl;
    else if (K <= A+B) cout << 0 << " " << B-K+A << endl;
    else cout << "0 0" << endl;


    return 0;
}

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

//vector <long long> v[1000001];

//stack <long long> s, s2;

//queue <long long> s;

long long int  z[1000000], x, y, m=0, szu, wy;
//char s[10000000];

int main()
{
    long long int d, e, f, i, j, q, t, n, k, a, b, c, w, p, aa, bb, cc, dd, nn, kk;
    t=1;
 //   scanf("%lld", &t);
    for(q=1; q<=t; q++)
    {
        scanf("%lld", &n);

        w=0;
        a=0;

        for(i=0; i<n; i++)
        {
            scanf("%lld%lld", &x, &y);
            x--;
            y--;
            z[i]=x*1000000000+y;
        }

        sort(z, z+n);

        y=z[0]%1000000000;
        x=z[0]/1000000000;
        a=x;
        b=y;
        c=x;
        d=y;
        w=0;

        for(i=1; i<n; i++)
        {
            y=z[i]%1000000000;
            x=z[i]/1000000000;
            w=max(w, max(abs(x-a)+abs(y-b), abs(x-c)+abs(y-d)));
            if(y-x>b-a)
            {
                a=x;
                b=y;
            }
            if(-y-x>-d-c)
            {
                c=x;
                d=y;
            }
  //          printf("%lld %lld %lld %lld %lld %lld\n", x, y, a, b, c, d);
        }

        printf("%lld\n", w);
    }
    return(0);
}



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

int main(){
  int N;
  cin>>N;
  vector<ll> H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
  }
  int s=0;
  int m=0;
  for(int i=0;i<N-1;i++){
    if(H.at(i)>=H.at(i+1)){
      s++;
    }
    else{  
     
      
      s=0;
    }
    m=max(m,s);
  }
  
  cout<<m<<endl;
}



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

int main(){

    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans1 = 0;
    int ans2 = 0;
    double ratio = -1.0;
    for(int i=0; 100*a*i <= f; i++){
        for(int j=0; 100*(a*i + b*j) <= f; j++){
            int water = 100 * (a * i + b * j);
            if(water == 0){
                continue;
            }
            for(int k = 0; water + c*k <= f; k++){
                for(int l=0; water + c*k + d*l <= f; l++){
                    int sugar = c * k + d * l;
                    double temp = (100.0*sugar)/(water + sugar);
                    if(sugar <= e * (a * i + b * j) && ratio < temp){
                        ans1 = water + sugar;
                        ans2 = sugar;
                        ratio = temp;
                    }
                }
            }
        }
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 35005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    int i , j , k , l , m , n , a ;

    int d2=0 , d4=0 , d1=0 ;

    scanf("%d",&n) ;

    for(i=1 ; i<=n ; i++){
        scanf("%d",&a) ;
        if(a%4==0) d4++ ;
        else if(a%2==0) d2++ ;
        else d1++ ;
    }

    if( (d2==0 && d1<=d4+1) || d1<=d4 ) printf("Yes\n") ;
    else printf("No\n") ;

    return 0 ;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll A, B, C, X, Y;

    cin >> A >> B >> C >> X >> Y;

    ll ans_case1;//全部 A, Bのみで買う
    ll ans_case2;// A, B, Cで買う
    ll ans_case3;// Cのみで買う
    ll ans = INF;

    ans_case1 = A * X + B * Y;
    chmin(ans, ans_case1);

    ans_case2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + 2 * C * min(X, Y);
    chmin(ans, ans_case2);
    
    ans_case3 = 2 * C * max(X, Y);
    chmin(ans, ans_case3);
    
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
n = int(input())
t_v = a_v = 1
for _ in range(n):
    t, a = [int(x) for x in input().split()]
    r = max((t_v + t - 1) // t, (a_v + a - 1) // a)
    t_v, a_v = r * t, r * a
print(t_v + a_v)

Measured memory_bytes: 9184
#include<iostream>
#include<complex>
#include<vector>
#include<iomanip>

using namespace std;

typedef complex<double> P;

#define EPS 1e-9
#define shosu(x) fixed<<setprecision(x)

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
struct C{
  P c;double r;
  C(const P &c,double r):c(c),r(r){}
};

namespace std{//演算子の定義
  bool operator < (const P& a,const P& b){
    return real(a)!= real(b) ? real(a) < real(b) : imag(a) < imag(b);
    //return imag(a) != imag(b) ? imag(a) < imag(b) : real(a) < real(b)
  }
  bool operator == (const P& a,const P& b){
    return a.real()==b.real() && a.imag()==b.imag();
  }
}

double dot(P a,P b){
  return real(conj(a)*b);
}

double cross(P a,P b){
  return imag(conj(a)*b);
}

int ccw(P a, P b, P c) {//3点の関係性
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;                               // a--c--b on line
}

P projection(L l, P p){//pの直線l上の射影の点
  double t=dot(p-l[0],l[0]-l[1])/norm(l[0]-l[1]);
  return l[0]+t*(l[0]-l[1]);
}

P reflection(L l, P p){//点pの直線lに関して対称な点
  return p+2.0*(projection(l,p)-p);
}

bool isOrthogonal(L l1, L l2){//2直線の直交判定
  return fabs(dot(l1[1]-l1[0],l2[1]-l2[0])) < EPS;
}

bool isParallel(L l1, L l2){//2直線の平行判定
  return fabs(cross(l1[1]-l1[0],l2[1]-l2[0])) < EPS;
}

P inP(){
  double x,y;
  cin >> x >> y;
  P p(x,y);
  return p;
}

int main(){

  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    P p1,p2,p3,p4;
    p1=inP();
    p2=inP();
    p3=inP();
    p4=inP();
    L l1(p1,p2),l2(p3,p4);
    if(isOrthogonal(l1,l2)){
      cout<<1<<endl;
    }else if(isParallel(l1,l2)){
      cout<<2<<endl;
    }else{
      cout<<0<<endl;
    }
  }

}



Measured memory_bytes: 3216
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
    int a,c=0,j=1;
    scanf("%d",&a);
    for(int i=1;i<4;i++){
        if(a%10==9){
            c+=j;
        }
        if(a%10==1){
            c+=j*9;
        }
        else if(a%10!=1 && a%10!=9){
            c+=j*(a%10);
        }
        j=j*10;
        a=a/10;
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
from collections import deque

h, w = map(int, input().split())
S = []
for _ in range(h):
    s = str(input())
    S.append(s)

dq = deque([])
if S[0][0] == '.':
    dq.append([0,0,'.'])
else:
    dq.append([0,0,'#'])

Visited = [[False for _ in range(w)] for _ in range(h)]
Visited[0][0] = True

All_grid = deque([])
for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            pass
        else:
            All_grid.append([i,j])

ans = 0
black = 0
white = 0
while dq:
    now = dq.popleft()

    y = now[0]
    x = now[1]
    color = now[2]

    if color == '.':
        white += 1
    else:
        black += 1

    Nexts = [[y,x-1], [y,x+1], [y-1,x], [y+1,x]]
    for nex in Nexts:
        if nex[0] >= h or nex[0] < 0 or nex[1] >= w or nex[1] < 0:
            continue
        if Visited[nex[0]][nex[1]] == True:
            continue

        if color == '.' and S[nex[0]][nex[1]] == '.':
            continue
        elif color == '#' and S[nex[0]][nex[1]] == '#':
            continue
        elif color == '.' and S[nex[0]][nex[1]] == '#':
            dq.append([nex[0], nex[1], '#'])
            Visited[nex[0]][nex[1]] = True
        else:
            dq.append([nex[0], nex[1], '.'])
            Visited[nex[0]][nex[1]] = True

    if len(dq) == 0:
        ans += black * white
        black = 0
        white = 0

        while All_grid:
            cand = All_grid.popleft()
            i = cand[0]
            j = cand[1]
            if Visited[i][j] == False:
                c = S[i][j]
                dq.append([i,j,c])
                Visited[i][j] = True
                break

print(ans)

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

//Common
typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
}
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

//Bellman-ford
Graph g;
std::vector<Weight> costs;
std::vector<int> trace;
bool bellmanFord(int start) {
    int n = g.size();
    costs.resize(n, WEIGHT_INF);
    trace.resize(n, -2);
    costs[start] = 0;
    trace[start] = -1;

    bool negativeCycle = false;
    REP(k, n) REP(i, n) if(costs[i] != WEIGHT_INF) EACH(e, g[i]) {
        if(costs[e->dst] > costs[e->src] + e->weight){
            costs[e->dst] = costs[e->src] + e->weight;
            trace[e->dst] = e->src;
            if(k == n-1){
                costs[e->dst] = -WEIGHT_INF;
                negativeCycle = true;
            }
        }
    }
    return !negativeCycle;
}

int main(void){
    int v, e, r;
    std::cin >> v >> e >> r;
    g.resize(v);
    REP(i, e){
        int s, t, d;
        std::cin >> s >> t >> d;
        Edge edge{s, t, d};
        g[s].pb(edge);
    }

    bool res = bellmanFord(r);
    if(res){
        REP(i, v){
            if(costs[i] != WEIGHT_INF){
                std::cout << costs[i] << std::endl;
            } else {
                std::cout << "INF" << std::endl;
            }
        }
    } else {
        std::cout << "NEGATIVE CYCLE" << std::endl;
    }
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
#define pi acos(-1)
using namespace std;

int n, ma, mb, dp[405][405];

struct node
{
    int a, b, c;
}nd[45];

int main()
{
    mem(dp, -1);
    scanf("%d%d%d", &n, &ma, &mb);
    for(int i = 1;i <= n;i++)
        scanf("%d%d%d", &nd[i].a, &nd[i].b, &nd[i].c);
    dp[0][0] = 0;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 400;j >= nd[i].a;j--)
        {
            for(int k = 400;k >= nd[i].b;k--)
            {
                if(dp[j - nd[i].a][k - nd[i].b] != -1)
                {
                    if(dp[j][k] == -1)
                        dp[j][k] = dp[j - nd[i].a][k - nd[i].b] + nd[i].c;
                    else
                        dp[j][k] = min(dp[j][k], dp[j - nd[i].a][k - nd[i].b] + nd[i].c);
                }
            }
        }
    }
    int ans = inf;
    for(int i = 1;;i++)
    {
        if(ma * i <= 400&&mb * i <= 400)
        {
            int x = ma * i;
            int y = mb * i;
            if(dp[x][y] != -1)
                ans = min(ans, dp[x][y]);
        }
        else
            break;
    }
    if(ans == inf)
        puts("-1");
    else
        printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>

int main(void){
    // Your code here!
    int N, D, L = 0, X[10][10] = {}, count = 0;
    scanf("%d %d",&N,&D);
    for(int n = 0; n < N; n++)
    {
        for(int d = 0; d < D; d++)
        {
            scanf("%d",&X[n][d]);
        }
    }
    
    for(int n = 0; n < N; n++)
    {
        for(int m = 0; m < N; m++)
        {
            L = 0;
            if(n != m)
            {
                for(int d = 0; d < D; d++)
                {
                    L += abs(X[n][d]-X[m][d]) * abs(X[n][d]-X[m][d]);
                }
                for(int k = 1; k <= 126; k++)
                {
                    if(k*k == L)
                    {
                        //printf("%d\n",k);
                        count++;
                        break;
                    }
                }
            }
        }
    }
    printf("%d\n",count/2);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;

	vector<bool> ans(60, false);
	ll t = 1, start = 0;
	for (ll i = 59; i >= 0; i--) {
		ll x = n, y = 2 * t;
		while (x + y < 0) y *= 2;
		x += y;
		ans[i] = (x - start) / t % 2;
		t *= 2;
		if (i % 2 == 0) start -= t / 2;
	}

	for (ll i = 0; i < 60; i++) {
		if (ans[i]) {
			while (i < 60) {
				cout << ans[i];
				i++;
			}
			cout << endl;
			break;
		}
		if (i == 59) cout << ans[i] << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <set>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

void print_v(vector<int> v){
    for(int i=0; i<v.size(); i++){
        cout << char(v[i]+97);
    }
    cout << endl;
}

int main()
{
	ll A,B,K;
    cin >> A >> B >> K;
    if(A<K){
        ll tmp=K-A;
        cout << 0 << ' ' << max(B-tmp,(ll)0) << endl;
    }else{
        cout << A-K << ' ' << B << endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
//ll ans[N];
 
ll gao(int l,int r){  //求区间l,r的和
    return sum[r]-sum[l-1];
}
 
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    int n ;
    cin >>n;
    for(int i=1;i<=n;i++)   cin >> a[i];
    for(int i=1;i<=n;i++)   sum[i]=sum[i-1]+a[i]; //求前缀和
    ll l=1,r=3;
    ll ans=1e18+8;
    for(int i=2;i<=n-2;i++){
         while(l+1<i&&abs(gao(1,l)-gao(l+1,i))>=abs(gao(1,l+1)-gao(l+2,i)))//若[1,l+1]和[l+1,i]的距离比[1,l+1]和[l+2,i]的距离小，那么我们就继续加，使得两边尽可能平衡
            l++;
         while(r+1<n&&abs(gao(i+1,r)-gao(r+1,n))>=abs(gao(i+1,r+1)-gao(r+2,n)))
            r++;
         set<ll>st;///利用set的log排序
         st.insert(gao(1,l));
         st.insert(gao(l+1,i));
         st.insert(gao(i+1,r));
         st.insert(gao(r+1,n));
         ans=min(ans,abs(*st.begin()-*prev(st.end())));
    }
    cout << ans << endl;
 
    return 0;
}



Measured memory_bytes: 3328