akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    static int n,m;
    static long mod = 1000000000+7;
    // static ArrayList<Integer>[] graph,tree;
    public static void main(String[] args)throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        Scanner sc = new Scanner(System.in);
        //String[] buf = reader.readLine().split(" ");
        n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        int[] cnt = new int[26];
        for(char w:s){
            cnt[w-'a']++;
        }
        long ans = 1;
        for(int i=0;i<26;i++){
            ans = ans*(cnt[i]+1)%mod;
        }
        ans = (ans-1+mod)%mod;
        System.out.println(ans);
    }
    static long pow(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
}

Measured memory_bytes: 27612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<ll> cnt(26, 1e18);
  REP(i, n) {
    string s;
    cin >> s;
    vector<ll> tmp(26, 0);
    for (char c : s) {
      ll x = c - 'a';
      tmp[x]++;
    }
    REP(i, 26) { cnt[i] = min(cnt[i], tmp[i]); }
  }

  REP(i, 26) {
    REP(j, cnt[i]) { cout << (char)('a' + i); }
  }
  cout << endl;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def f(x) :
    ret = 0
    b = 1
    for i in range(44) :
        c = (x // (b * 2)) * b
        rest = x % (b * 2)
        if rest - b > 0 :
            c += rest - b
        if c & 1 :
            ret += 1 << i
        b <<= 1
    return ret
    
print(f(A)^f(B+1))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

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

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m,l;cin>>n>>m>>l;
	if(n+m>=l){
		cout << "Yes" << endl;
	}else{

		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
	int k,s;
	while(~scanf("%d%d",&k,&s))
	{
		int ans = 0;
		if(3*k<s)
		{
			printf("%d\n",ans);
			continue;
		}
		for(int i=0;i<=s&&i<=k;i++)
		{
			int tmp = s-i;
			if(tmp==0)
			ans++;
			else if(2*k>=tmp)
			{
				if(tmp>k)
				{
					ans += (2*k-tmp)+1;
				}
				else 
				ans += tmp+1;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
  double x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;
  double X=pow(x2-x1,2);
  double Y=pow(y2-y1,2);
  cout<<fixed<<setprecision(12);
  cout<<sqrt(X+Y)<<endl;
}


Measured memory_bytes: 3280
N,K = map(int,input().split())
S = input()
L = [0]
ans = 0
res = '1'
i = 0
for s in S:
    if s != res:
        L.append(i)
        i += 1
    else:
        i += 1
    res = s
L.append(i)
L.append(i)
if len(L)<=2*K+1:
    ans = N
for i in range(0,len(L)-K*2-1,2):
    ans = max(ans,L[i+K*2+1]-L[i])
print(ans)

Measured memory_bytes: 7156
def grade(m, f, r)
  if m == -1 || f == -1
    puts "F"
  else
    puts case m + f
      when (0...30) then "F"
      when (30...50)
        if r >= 50
          "C"
        else
          "D"
        end
      when (50...65) then "C"
      when (65...80) then "B"
      when (80..100) then "A"
      end
  end
end

loop do
  m, f, r = gets.chomp.split(" ").map(&:to_i)
  break if [m, f, r] == [-1, -1, -1]
  grade(m, f, r)
end

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

using namespace std;

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int arr[150];
int main(){
	int n;
	int sum=0,sum1=0,Min=1e9,p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		sum+=arr[i];
	}
	for(int i=0;i<n;i++){
		sum1+=arr[i];
		p=abs(sum-sum1-sum1);
		if(arr[i]!=arr[i+1]&&Min>p){
			Min=p;
		}	
	}
	cout<<Min<<endl;
	
	return 0;
} 

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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;

    if (e - a > k)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{/*
ll t;
cin>>t;
while(t--)
{*/
ll k,a,b;
cin>>k>>a>>b;
ll p=(a/k)*k;
if(p<a)
p+=k;

if(p<=b)
cout<<"OK"<<endl;
else
cout<<"NG"<<endl;

return 0;
}




Measured memory_bytes: 3600
package main

import "fmt"

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

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

func gcdMulti(xs []int) int {
	ans := xs[0]
	for i := 1; i < len(xs); i++ {
		ans = gcd(ans, xs[i])
	}
	return ans
}

func main() {
	var N, X int
	fmt.Scan(&N, &X)
	ds := make([]int, N)
	var t int
	for i := range ds {
		fmt.Scan(&t)
		ds[i] = abs(X - t)
	}
	fmt.Println(gcdMulti(ds))
}


Measured memory_bytes: 5504
#include <iostream>
#include<time.h>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
#include<unordered_map>
#include <cassert>
#include <bit>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}//x^n%mod
int main(){
    ll n;
    ll a[MAX*3];
    cin>>n;
    rep(i,n)cin>>a[i];
    ll sum=0;
    ll two_factors=1;
    rep(d,60){
        ll p=0,q=0;
        rep(i,n){
            if(a[i] & (1LL<<d))p++;
            else q++;
        }
        sum=(sum+(p*q)%MOD*two_factors%MOD)%MOD;
        two_factors=two_factors*2%MOD;
    }
    cout<<sum<<endl;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll MOD = 1e9 + 7;

// g = eGCD(a, b, s, t)  --->  sa + tb = g
constexpr ll eGCD(ll a, ll b, ll& s, ll& t) {
  if (a == 0) {
    s = 0;
    t = 1;
    return b;
  }
  ll u = 0;
  ll g = eGCD(b % a, a, t, u);
  s = u - (b / a) * t;
  return g;
}


struct Fp {
  ll val;

  Fp(ll t = 0) :
    val(t < 0 ? MOD + t % MOD : t >= MOD ? t % MOD : t) {}

  Fp& operator +=(const Fp& t) {
    val += t.val;
    if (val > MOD) val -= MOD;
    return *this;
  }

  Fp& operator -=(const Fp& t) {
    val -= t.val;
    if (val < 0) val += MOD;
    return *this;
  }

  Fp& operator *=(const Fp& t) {
    val = (val * t.val) % MOD;
    return *this;
  }

  Fp inv() const {
    if (val == 0) {
      cerr << "inv() is called for zero." << endl;
      exit(1);
    }
    ll u = 0;
    ll v = 0;
    eGCD(val, MOD, u, v);
    return Fp(u);
  }

  Fp& operator /=(const Fp& t) {
    return (*this) *= t.inv();
  }

  Fp operator +(const Fp& t) const { return Fp(val) += t; }
  Fp operator -(const Fp& t) const { return Fp(val) -= t; }
  Fp operator *(const Fp& t) const { return Fp(val) *= t; }
  Fp operator /(const Fp& t) const { return Fp(val) /= t; }
  Fp operator -() const { return Fp(-val); }

  bool operator ==(const Fp& t) const { return val == t.val; }
  bool operator !=(const Fp& t) const { return val != t.val; }
  
  operator ll() const { return val; }

};


constexpr ll maxNM = 2010;
ll N, M;
vector<ll> S(maxNM), T(maxNM);
vector<vector<Fp>> tbl;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> M;
  for (ll i = 1; i <= N; i++) cin >> S.at(i);
  for (ll i = 1; i <= M; i++) cin >> T.at(i);
  tbl.resize(N+1);
  for (ll i = 0; i <= N; i++) tbl.at(i).resize(M+1);
  for (ll j = 1; j <= M; j++) {
    for (ll i = 1; i <= N; i++) {
      Fp x = tbl.at(i-1).at(j-1);
      Fp y = tbl.at(i).at(j-1);
      Fp z = tbl.at(i-1).at(j);
      if (S.at(i) == T.at(j)) {
	tbl.at(i).at(j) = y + z + Fp(1);
      }else {
	tbl.at(i).at(j) = y + z - x;
      }
    }
  }
  cout << (ll)(tbl.at(N).at(M) + Fp(1)) << endl;
  return 0;
}



Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,c,temp;
	cin>>a>>b>>c;
	if(a%c==0)
	cout<<(b/c-a/c)+1<<endl;
	else 
	cout<<(b/c-a/c)<<endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define L "\n"
#define S " "
#define ll long long
#define pb push_back
#define mp make_pair
#define vi std::vector<int>
#define si std::set<int>
#define vl std::vector<long long>
#define qi std::queue<int>
#define de(a) cout << #a << "  ------>  " << a << "\n"
#define SIZE 100002
#define INF INT_MAX
#define FOR(i, n) for (i = 1; i <= n; i++)
#define FASTIO                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;
int dp[SIZE], N, h[SIZE];
bool flag[SIZE];

int findcost(int i)
{
    int cost1, cost2;
    if (i == N)
        return 0;
    else if (i == N - 1)
    {
        dp[i] = abs(h[N] - h[N - 1]);
        flag[i] = 1;
        return dp[i];
    }
    if (flag[i + 1])
        cost1 = abs(h[i] - h[i + 1]) + dp[i + 1];
    else
        cost1 = abs(h[i] - h[i + 1]) + findcost(i + 1);
    if (flag[i + 2])
        cost2 = abs(h[i] - h[i + 2]) + dp[i + 2];
    else
        cost2 = abs(h[i] - h[i + 2]) + findcost(i + 2);
    flag[i] = 1;
    return dp[i] = min(cost1, cost2);
}

void solve()
{
    int i;
    cin >> N;
    FOR(i, N)
        cin >> h[i];
    int cost = findcost(1);
    cout << cost << L;
}
int main()
{
    FASTIO;
// #ifndef ONLINE_JUDGE
//     freopen("in.txt", "r", stdin);
// #endif
    int t;
    // cin >> t;
    // while (t--)
    solve();
    return 0;
}

Measured memory_bytes: 4224
# -*- coding: utf-8 -*-

import sys
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(li): return reduce(lcm, li, 1)

N = INT()
A = LIST()
print(lcm_list(A))



Measured memory_bytes: 6368
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n = read!(usize);
    let mut a: Vec<Vec<usize>> = Vec::new();
    for i in 0..2 {
        a.push(read![[usize]]);
    }
    let mut ans = 0;
    for i in 0..n {
        let s1 = a[0].get(0..(i + 1)).unwrap().iter().sum::<usize>();
        let s2 = a[1].get(i..n).unwrap().iter().sum::<usize>();
        //        let s: usize = a[0].iter().take(i + 1).sum::<usize>()
        //            + a[1].iter().by_ref().skip(i).take(n - i).sum::<usize>();
        let s = s1 + s2;
        if s > ans {
            ans = s;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int k = in.nextInt();
        int result = 0;
        char[] input = in.next().toCharArray();
        for (int i = 0; i < n - 1; i++) {
            if (input[i] == input[i + 1]) {
                result++;
            }
        }

        result += 2 * k;

        System.out.println(Math.min(result, n-1));
    }
}


Measured memory_bytes: 26912
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

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

	long N, K;
	cin >> N >> K;
	vector<long long>H(N);
	for (long i = 0; i < N; i++) cin >> H.at(i);
	sort(H.begin(), H.end(), greater<long long>());

	if (K >= N) {
		cout << 0 << endl; 
		exit(0);
	}
	long long res = 0;
	for (long i = 0 + K; i < N; i++) {
		res += H.at(i);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include <string.h>
int main(){
	char s[100002];
	scanf("%s",s);
	int len = strlen(s);
	if((s[0]==s[len-1] || len%2!=0) && (s[0]!=s[len-1] || len%2==0))
		printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	double p[n+1];
	for(int i=1;i<=n;i++)
		cin >> p[i];
	double dp[n+1][n+1];//dp[i][j] is probability of getting j heads with first i coins
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++)
			dp[i][j] = 0.0;
	}
	dp[0][0] = 1.0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(j == 0){
				dp[i][j] = dp[i-1][j]*(1-p[i]);
				continue;
			}
			dp[i][j] = dp[i-1][j-1]*p[i] + (1-p[i])*(dp[i-1][j]);
		}
	}
	double answer = 0;
	for(int i=(n+1)/2;i<=n;i++)
		answer += dp[n][i];
	printf("%.12lf\n",answer);
}

Measured memory_bytes: 74028
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];
  int m; cin >> m;
  vi b(m); rep(i, m) cin >> b[i];
  vi res;

  set_symmetric_difference(begin(a), end(a), begin(b), end(b), inserter(res, end(res)));

  for_each(begin(res), end(res), [](int x){cout << x << '\n';});

  return 0;
}


Measured memory_bytes: 6580
s = input()
n = len(s)
s = [s[i] for i in range(n)]

l = (n - 1) // 2
r = (n + 3) // 2

left = s[:l]
right = s[r - 1:]

if s == list(reversed(s)) and left == list(reversed(left)) and right == list(reversed(right)):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <functional>
    #include <map>
    #include <cstdlib>
    #include <math.h>
     
    using namespace std;
     
    typedef long long ll;
    #define rep(i, n) for(long (i) = 0; (i) < (long) (n); (i)++)
    #define rep1(i,n) for(int i=1;i<=(n);i++)
    #define rrep(i,a,b) for(long i=(a);i<(b);i++)
    #define rrep1(i,a,b) for(long i=(a);i<=(b);i++)
    #define rrrep(i,a,b) for(long i=(a);i>=(b);i--)
    #define define pb push_back
    #define ALL(obj) (obj).begin(), (obj).end()
    #define X first
    #define Y second
    #define vi vector<int>
    #define vl vector<ll>
    #define vvi vector<vector<int> >
    #define vpl vector<pair<long, long> >
    #define vppl vector<pair<long, pair<long, long> > >
    #define vall(i) vector<ll[i]>
     
    const int INF = 100100100;
    const long LONG_INF = 2147483647;
    const int MOD = (int)1e9 + 7;
    const double EPS = 1e-9;
    const ll LINF = 1e18;
     
     
    int pow(int x) {
    	if (x == 0) {
    		return 1;
    	}
    	else {
    		return pow(x - 1) * 2;
    	}
    }

    

    int main(int argc, char const *argv[])
    {
    	cin.tie(0);
    	ios::sync_with_stdio(false);

        string s;
        cin >> s;
        if (s == "Sunny")
        {
            cout << "Cloudy";
        } else if (s == "Cloudy")
        {
            cout << "Rainy";
        } else
        {
            cout << "Sunny";
        }
        return 0;
    }

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

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


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, K;
	cin >> N >> K;
	ll A[N];
	REP(i, N) {
		cin >> A[i];
	}
	ll G = A[0];
	REP(i, N) {
		G = gcd(G, A[i]);
	}
	sort(A, A + N);
	if (K%G == 0&&K<=A[N-1]) {
		cout << "POSSIBLE" << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+45;
const int mod = 1000000007;

ll n,a[N],b[N];
map <pair<ll,pair<ll,ll>>,ll> mapa,uradijo;

ll fp(ll x,ll y){
    if(y == 0){
        return 1;
    }
    ll p = fp(x,y/2);
    p = (p*p)%mod;
    if(y&1){
        p = (p*x)%mod;
    }
    return p;
}

ll minv(ll x){
    return fp(x,mod-2);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    ll nule = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i];
        if(a[i] == 0 && b[i] == 0){
            nule++;
        }
        else{
            ll znak = (a[i] > 0 ? 1 : -1)*(b[i] > 0 ? 1 : -1);
            a[i] = abs(a[i]),b[i] = abs(b[i]);
            ll g = __gcd(a[i],b[i]);
            a[i] /= g;
            b[i] /= g;
            if(a[i] == 0 || b[i] == 0){
                mapa[{1,{a[i],b[i]}}]++;
            }
            else{
                mapa[{znak,{a[i],b[i]}}]++;
            }

        }
    }
    //cout << "staa" << endl;
    ll sol = 1;
    for(auto f : mapa){
        if(uradijo[f.first]){
            continue;
        }
        auto ob = make_pair(-f.first.first,make_pair(f.first.second.second,f.first.second.first));
        if(f.first.second.second*f.first.second.first == 0){
            ob.first=1;
        }
        uradijo[f.first] = uradijo[ob] = 1;
        ll ima = mapa[ob];
        //cout << f.first.first << " " << f.first.second.first << " " << f.first.second.second << " ima " << f.second << " a ob " << ima << endl;
        ll dod = (fp(2,f.second)+fp(2,ima)-1)%mod;
        if(dod < 0){
            dod += mod;
        }
        //cout << "Staa" << dod << endl;
        sol = (sol*dod)%mod;
    }
    sol = (sol-1)%mod;
    if(sol < 0){
        sol += mod;
    }
    sol = (sol+nule)%mod;
    cout << sol << endl;
}


Measured memory_bytes: 69148
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=2e5+5;
ll n,ans,a[N],lft[N],rgt[N];
stack<ll>stk;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n;
    for(ll i=1;i<=n;i++)cin>>a[i];
    stk.push(0);
    for(ll i=1;i<=n;i++){
        while(a[stk.top()]>a[i])stk.pop();
        lft[i]=stk.top();
        stk.push(i);
    }
    while(!stk.empty())stk.pop();
    stk.push(n+1);
    for(ll i=n;i>=1;i--){
        while(a[stk.top()]>a[i])stk.pop();
        rgt[i]=stk.top();
        stk.push(i);
    }
    for(ll i=1;i<=n;i++)ans+=a[i]*(i-lft[i])*(rgt[i]-i);
    cout<<ans;
}



Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    
    if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R'){
        cout << 3 << endl;
    }else if(S[0] == 'R' && S[1] == 'R'){
        cout << 2 << endl;
    }else if(S[1] == 'R' && S[2] == 'R'){
        cout << 2 << endl;
    }else if(S[0] == 'R' || S[1] == 'R' || S[2] == 'R'){
        cout << 1 << endl;
    }else cout << 0 << endl;
}

Measured memory_bytes: 3624
din = str(input())
length = len(din)
first_A = -1
last_Z = -1
for i in range(length):
    if (din[i] == 'A' and first_A == -1):
        first_A = i
    elif din[i] == 'Z':
        last_Z = i
print(last_Z-first_A+1)


Measured memory_bytes: 65384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	uint64_t v = 1;
	bool is_valid = true;
	FOR_LT(i, 0, n) {
		uint64_t c; cin >> c;
		uint64_t nv = v * c;
		if ((uint64_t)1000000000000000000ULL / v < c) {
			is_valid = false;
			continue;
		}
		if ((uint64_t)1000000000000000000ULL < nv) {
			is_valid = false;
			continue;
		}
		if (c == 0) {
			cout << 0 << endl;
			return 0;
		}
		v = nv;
	}
	if (is_valid) {
		cout << v << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define mper make_pair
#define all(x) x.begin(), x.end()
#define fe first
#define se second
#define erba continue
using namespace std;

string s;
ll k, ans;
vector < pair <char, int> > g;

void kek() {

    for(int i = 0; i < g.sz(); ++i) {

        ans += g[i].se / 2ll;

    }

    ll key = ans * k;

    cout << key;

}

void LOL() {

    ll key = g[0].se * k;

    cout << key / 2ll;


}

int main() {

    cin >> s;
    cin >> k;

    ll cnt = 0;
    bool check = 0;

    for(int i = 0; i < s.sz(); ++i) {


        cnt++;
        if(!i) {erba;}

        if(s[i] != s[i - 1]) {

            if(!check) {

                check = 1;
                g.pb(mper(s[i - 1], cnt - 1));
                cnt = 1;
            }

            else {

                g.pb(mper(s[i - 1], cnt - 1));
                cnt = 1;

            }

        }

    }

    if(cnt) {

        g.pb(mper(s[s.sz() - 1], cnt));

    }

    if(g.sz() == 1) {LOL();}

    else if(s[0] != s[s.sz() - 1]){kek();}

    else {

        for(int i = 1; i < g.sz() - 1; ++i) {

            ans += g[i].se / 2ll;

        }

        ll all =  ans * k + (g[g.sz() - 1].se / 2ll) + (g[0].se / 2ll) + ( (g[g.sz() - 1].se + g[0].se) / 2ll ) * (k - 1);
        cout << all;
    }


return 0;
}




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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else 
      x=x->right;
  }
  z->parent=y;

  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right =z;
  }
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

Node treeSearch(Node u,int k){
  while(u!=NIL && k!=u->key){
    if(k<u->key){
      u=u->left;
    }
    else{
      u=u->right;
    }
  }
  return u;
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } 
    else if(com[0]=='f'){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;

}

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

#define ll          long long
#define pb          push_back
#define all(a)      (a).begin(),(a).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)    
#define cls(a) a.clear()
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rs(a,n) a.resize(n)  
#define time        cerr << "Time elapsed: " << (double)1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define sf(a) scanf("%d",&a)
#define vi vector<int>
#define pf(b) printf("%d\n",b)

using namespace std;

void test_case()
{  
   //h1:m1 wake
   //h2:m2 sleep
   int h1,m1,h2,m2,k;
   cin>>h1>>m1>>h2>>m2>>k;
   int ti=(h2*60+m2)-(h1*60+m1);
   if(k<=ti)
   {
	   cout<<ti-k<<"\n";
	   }
	   else
	   cout<<"0"<<"\n";
   }
	
	     
	
signed main()
{
	fast;
	time;
	
	   test_case();
		
	return 0;
	}


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

int main()
{
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; i++)
    {
        cout << S[i] << T[i];
    }
    cout << endl;

    return 0;
}

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

ll solve(ll i,vector <ll> adj[],ll dp[]){
    if(dp[i]!=-1)
        return dp[i];
    ll longest_path=0;
    for(ll j : adj[i])
        longest_path=max(longest_path,solve(j,adj,dp)+1);
    dp[i]=longest_path;
    return longest_path;
}

int main(){

    ll n,m;
    cin>>n>>m;
    vector <ll> adj[n+1];
    ll x,y;
    for(ll i=0;i<m;i++){
        cin>>x>>y;
        adj[x].push_back(y);
    }
    ll longest_path=0;
    ll dp[n+1];
    for(ll i=0;i<n+1;i++)
        dp[i]=-1;
    for(ll i=1;i<=n;i++)
        longest_path=max(longest_path,solve(i,adj,dp));
    cout<<longest_path<<"\n";
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> table(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b, --a, --b;
        table[a].emplace_back(b);
        table[b].emplace_back(a);
    }

    vector<int> ans(n, -1);
    queue<int> que;
    ans[0] = 0;
    que.push(0);
    while (!que.empty())
    {
        int v = que.front();
        que.pop();

        for (int nv : table[v])
        {
            if (ans[nv] == -1)
            {
                ans[nv] = v + 1;
                que.push(nv);
            }
        }
    }
    bool yes = true;
    rep(i, n) if (ans[i] == -1) yes = false;

    if (yes)
    {
        cout << "Yes" << endl;
        for (int i = 1; i < n; ++i)
            cout << ans[i] << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 10336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

class UnionFind {
public:
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    rep(i, 0, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    int ans = 0;
    rep(i, 0, m) {
        UnionFind tree(n);
        rep(j, 0, m) {
            if (i != j) {
                tree.unite(a[j], b[j]);
            }
        }
        rep(i, 0, n) {
            if (!tree.same(0, i)) {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
  int S1,S2,S3,X,N;
  cin >> N;
  
  S1 = N/100;
  S2 = (N-(S1*100))/10;
  S3 = (N-(S1*100)-(S2*10))/1;
  X  = S1+S2+S3;
    
  cout  << X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool vis[15];
bool judge(int x)
{
    while(x)
    {
        if(vis[x%10]) return false;
        x/=10;
    }
    return true;
}
int main()
{
    int n,k,x;
    memset(vis,false,sizeof(vis));
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++) scanf("%d",&x),vis[x]=true;
    for(int i=n;;i++)
    {
        if(judge(i)) {cout<<i<<endl;return 0;}
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

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

ans = 0
for i in range(1, n+1):
    tmp = 0
    for j in str(i):
        tmp += int(j)

    if tmp >= a and tmp <= b:
        ans += i
print(ans)


Measured memory_bytes: 9008
#include<bits/stdc++.h>
using namespace std;
struct q{
    int sum, add;
}a[15];
int main()
{
    string s;
    cin >> s;
    bool judge = false;
    if (s[0] != 'A') return 0 & puts("WA");
    for (int i = 2; i <= s.size() - 2 ; ++i){
        if (!('a' <= s[i] && s[i] <= 'z') && s[i] != 'C') return 0 & puts("WA");
        if (s[i] == 'C'){
            if (!judge) judge = true;
            else return 0 & puts("WA");
        }
    }
    for (int i = 1; i < s.size(); ++i) if (!('a' <= s[i] && s[i] <= 'z') && s[i] != 'C') return 0 & puts("WA");
    if (!judge) puts("WA");
    else puts("AC");
    return 0;
}


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

int main(){
    int n;
    cin>>n;
    string s[n];
    set<string> t;
    for(int i=0;i<n;i++){
    	cin>>s[i];
    	t.insert(s[i]);
	}
	cout<<t.size()<<endl;
	return 0;
}


Measured memory_bytes: 25300
#include<bits/stdc++.h>
using namespace std;
int val[101];
string name;
bool cmp(int a, int b){
	return val[a] > val[b];
}
int main(){
	int n;
	cin >> n;
	map < string, vector < int > > res;
	for(int i = 1;i <= n;++i){
		cin >> name >> val[i];
		res[name].push_back(i);
	}
	for(auto &i : res){
		sort(i.second.begin(), i.second.end(), cmp);
		for(int &j : i.second)cout << j << '\n';
	}
}


Measured memory_bytes: 256
n, m, c = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0
sum = 0
n.times do
  a = gets.split.map(&:to_i)
  sum = 0
  a.each_with_index do |k, i|
    sum += (k * b[i])
  end
  if (sum + c) > 0
    count += 1
  end
end
puts count

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

using namespace std;

#define int64 long long 
const int mod = (int) 1e9 + 7;


int main(){
	string s, t;
	cin>>s>>t;
	int n = s.size(), m = t.size(), ans = 1e9;
	for(int i=0; i+m<=n; i++){
		int ch = 0;
		for(int j=0; j<m; j++){
			if(s[i+j] != t[j])ch++;
		}
		//cout<<s[i]<<"\n";
		ans = min(ans, ch);
	}
	cout<<ans<<"\n";
}


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

int main() {
    int A, B, C, D;
    std::cin >> A >> B >> C >> D;
    
    if ((A+B)==(C+D)) {
        std::cout << "Balanced" << std::endl;
    } else {
        std::cout << ((A+B)>(C+D) ? "Left" : "Right") << std::endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

const int MAX_N = 300000;
typedef unsigned long long ull;
typedef long long ll;
const ull mod = 1000000000 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N){
        cin >> A[i];
    }
    ll resA = 0;
    ll resB = 0;
    ll S = 0;
    REP(i, N){
        S += A[i];
        if ((2*(i%2)-1)*S <= 0){
            resA += abs(S - (2*(i%2)-1));
            S = 2*(i%2)-1;
        }
    }
    S = 0;
    REP(i, N){
        S += A[i];
        if ((2*(i%2)-1)*S >= 0){
            resB += abs(S + (2*(i%2)-1));
            S = -(2*(i%2)-1);
        }
    }
    cout << min(resA, resB) <<endl;
    return 0;
}

Measured memory_bytes: 1024
N = gets.chomp
A = gets.chomp.split(' ').map(&:to_i)
flag = 0
for a in A do
  if a % 2 == 0
    unless a % 3 == 0 || a % 5 == 0
      flag = 1
    end
  end
end
puts flag == 0 ? "APPROVED": "DENIED"

Measured memory_bytes: 14336
//#include    <bits/stdc++.h>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <cassert>
#include <iterator>
#include <complex>
#define N  310*310
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
template<typename T> inline T max(T a,T b,T c){
    return max(a,max(b,c));
}
template<typename T> inline T min(T a,T b,T c){
    return min(a,min(b,c));
}
template<typename T> inline T max(T a,T b,T c,T d){
    return max(a,max(b,c,d));
}
template<typename T> inline T min(T a,T b,T c,T d){
    return min(a,min(b,c,d));
}
const int  dx[]={0,1,0,-1,0,1,-1,1,-1};
const int  dy[]={0,0,1,0,-1,1,-1,-1,1};
typedef long long ll;
using namespace std;
//ll a[N][N];
int magic[N];
struct point{
  int x;
  int y;
}a[N];
int main(){
    IOS;
    int h,w,d;
    cin>>h>>w>>d;
    int k;
    for (int i=1;i<=h;i++)
       for (int j=1;j<=w;j++){
         cin>>k;
         a[k].x=i;
         a[k].y=j;
       }
       for (int i=1+d;i<=h*w;i++)
         magic[i]=magic[i-d]+abs(a[i].x-a[i-d].x)+abs(a[i].y-a[i-d].y);
    int q,m,n;
    ll sum;
    cin>>q;
    while (q--){
           cin>>n>>m;
           cout << magic[m]-magic[n] << endl;
        }
  return 0;
}


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

using namespace std;

int main()
{ 
	int x,a,b;
	cin>>x>>a>>b;
	a=abs(a-x);
	b=abs(b-x);
	if(a<b){
		cout<<"A"<<endl;
	}
	else{
		cout<<"B"<<endl;
	}
		
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
static int button[100001];
void solve(void)
{
	int n, i, i_next;
	int count=0;
	scanf("%d", &n);
	for(i=0;i<n;++i){
		int a;
		scanf("%d", &a);
		button[i]=a-1;
	}
	for(i=0; button[i]!=-1; i=i_next){
		i_next=button[i];
		button[i]=-1;
		if(i==1){
			break;
		}
		++count;
	}
	if(button[1]==-1){
		printf("%d\n", count);
	} else {
		printf("-1\n");
	}
}
int main(int argc, char **argv)
{
	solve();
	return 0;
}


Measured memory_bytes: 512
/**
 *    author:  FromDihPout
 *    created: 2020-07-14
**/

#include <bits/stdc++.h>
using namespace std;


int f(vector<int> &nums) {
    int x = nums[0], y = nums[1], z = nums[2];
    return x * x + y * y + z * z
        + x * y + y * z + x * z;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> nums(3, 1), ways(n + 1);
    int mx = 1;
    while (f(nums) <= n) {
        mx++;
        nums[0] = mx;
    }
    
    for (int i = 1; i < mx; i++) {
        nums[0] = i;
        for (int j = i; j < mx; j++) {
            nums[1] = j;
            for (int k = j; k < mx; k++) {
                nums[2] = k;
                int val = f(nums);
                if (val <= n) {
                    set<int> unique;
                    for (int i : nums) {
                        unique.insert(i);
                    }
                    if (unique.size() == 1) {
                        ways[val] += 1;
                    }
                    else if (unique.size() == 2) {
                        ways[val] += 3;
                    }
                    else {
                        ways[val] += 6;
                    }
                }
            }
        }
    }
    
    for (int i = 1; i <= n; i++) {
        cout << ways[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3664
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    int N = 0;
    int M = 0;
    var zen = Console.ReadLine().Split();
    N = int.Parse(zen[0]);
    M = int.Parse(zen[1]);
    var ok = new List<int>();
    for(var i = 0;i<M;i++){
      var d = int.Parse(Console.ReadLine());
      var yaho = Console.ReadLine().Split();
      for(var h = 0;h<d;h++){
        ok.Add(int.Parse(yaho[h]));
      }
    }
    var n = ok.Distinct().ToList();
    int a = n.Count;
    Console.WriteLine(N-a);
    
  }
}

Measured memory_bytes: 28560
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string s; cin >> s;
 
  	string t = "";
  	if (s == "Sunny")  t = "Cloudy";
  	if (s == "Cloudy") t = "Rainy";
  	if (s == "Rainy")  t = "Sunny";
 
  	cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;

	For(i,1,10) For(j,1,10){
		if(i*j==n){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;































	
}

Measured memory_bytes: 256