akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
using namespace std;

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

  if (abs(a-c) <= d) cout << "Yes" << endl;
  else if (abs(a-b) <= d && abs(b-c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
} 


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

int main () {
	int n, k, m;
	while (cin >> n >> k >> m, n || k || m) {
		vector<int> stones(n);
		for (int i = 1; i <= n; i++) stones[i - 1] = i;
		k--, m--;
		while (stones.size() != 1) {
			stones.erase(stones.begin() + m);
			m = (m + k) % stones.size();
		}
		cout <<(*stones.begin()) << endl;
	}
	return 0;
}

Measured memory_bytes: 1252
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[]){
	int a,b;
	int k;
	cin >> a >> b;
	k = (a + b) / 2;
	if(abs(a - k) == abs(b - k))	OUT(k) BR;
	else OUT("IMPOSSIBLE") BR;
	RET;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endll '\n'
#define sz(a) (int)(a).size()
#define RWFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e9 + 7, N = 2e6 + 5, oo = 1e9;
const double pi = acos(-1);
using namespace std;

int n, arr[50][50], dp[50][1 << 20];
ll solve(int i, int msk)
{
    if(i == n) return 1;
    if(~dp[i][msk]) return dp[i][msk];
    ll ans = 0;
    for(int j = 0; j < n; j++)
    {
        int cur = (1 << j);
        if(arr[i][j] and !(msk & cur)) ans += solve(i + 1, msk + cur), ans %= MOD;
    }
    return dp[i][msk] = ans;
}

int main()
{
    assem99
    memset(dp, -1, sizeof dp);
    cin>>n;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin>>arr[i][j];
    cout<<solve(0, 0);

    return 0;
}

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

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N, A[MAX_N];

void solve() {
  sort(A, A + N, std::greater<int>());
  ll v = 0, h = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A[i] == A[i + 1]) {
      if (v == 0) {
        v = A[i];
      } else if (h == 0) {
        h = A[i];
        break;
      }
      i++;
    }
  }

  cout << v * h << endl;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
int main()
{
    ll n,m,i,j,s=0;
    cin>>n>>m;
    ll a[m];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
        s=s+a[i];
    }
    if(n>s)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int dp[100];
int N;

int main() {
	cin >> N;
	rep(i, N+1){
		if(i == 0 || i == 1) dp[i] = 1;
		else dp[i] = dp[i-2] + dp[i-1];
	}
	cout << dp[N] << endl;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll dp[3030][3030][4];
int masu[3030][3030];
int main() {
  int r, c, m;
  cin >> r >> c >> m;
  vi x(m), y(m), w(m);
  rep(i, m) {
    cin >> x[i] >> y[i] >> w[i];
    x[i]--;
    y[i]--;
    masu[x[i]][y[i]] = w[i];
  }
  rep(i, r) {
    rep(j, c) {
      for (int k = 2; k >= 0; k--) {
        maxs(dp[i][j][k + 1], dp[i][j][k] + masu[i][j]);
      }
      rep(k, 4) {
        maxs(dp[i + 1][j][0], dp[i][j][k]);
        maxs(dp[i][j + 1][k], dp[i][j][k]);
      }
    }
  }
  ll ans = 0;
  rep(k, 4) maxs(ans, dp[r - 1][c - 1][k]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 325072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>

using namespace std;
using llong = long long;

int main(){
  llong n,m;
  cin >> n >> m;
  if(n==1){
    if(m==1){
      std::cout << 1 << std::endl;
    }else{
      std::cout << m-2 << std::endl;
    }
  }else{
    if(m==1){
      std::cout << n-2 << std::endl;
    }else{
      std::cout << (n-2)*(m-2) << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	int n;
	cin>>n;
	vector<string> words(n);
	set<string> dict;
	bool ans = true;
	for(int i = 0 ; i < n; i++){
		cin>>words[i];
		if( dict.count(words[i]) == 0){
			dict.insert(words[i]);
		}else{
			ans = false;
		}
	}
	for(int i = 1; i < n; i++){
		if( words[i-1][words[i-1].size()-1] != words[i][0]) ans = false;
	}
	if( ans == false){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

long long mod = 1000000000+7;

long powpow(long x, long n) {
  long y = 1;
  for(int i = 0; i < n; i++) {
    y *= x;
    y %= mod;
  }
  return y;
}

int main() {
  long n;
  cin >> n;  
  
  long ans = powpow(10,n)-powpow(9,n)*2+powpow(8,n);
  ans %= mod;
  cout << (ans+mod)%mod << endl;

  return 0;
}

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

ll f(ll a)
{
    if(a%4==0)
        return a;
    if(a%4==1)
        return 1;
    if(a%4==2)
        return a+1;
    if(a%4==3)
        return 0;
}
int main()
{
    long long a,b,ans;
    scanf("%lld%lld",&a,&b);
    if(a==0)
        ans=f(b);
    else
        ans=f(a-1)^f(b);
    printf("%lld\n",ans);
}



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

using namespace std;
const int maxn = 1e5+10;

int a[maxn],n;

int main()
{
	int ans = 0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		int t;
		scanf("%d",&t);
		if(t > 100000)	ans++;
		else a[t]++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(a[i]<i)	ans+=a[i];
		else ans += a[i]-i;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FIN ios::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
ll k,n;
const ll MOD = 1e9+7;

void solve(){
   string s;
   cin >> s;
   map<char,ll> mp;
   mp['R'] = mp['G'] = mp['B'] = 0;
   ll noCumple = 0;
   for(ll i=0 ; i<n ; ++i){
      for(ll j=1 ; i+2*j<n ; ++j ){
         if( s[i]!=s[i+j] && s[i]!=s[i+2*j] && s[i+j]!=s[i+2*j]) noCumple++;
      }
      mp[s[i]]++;
   }
   cout << mp['R'] * mp['G'] * mp['B'] - noCumple;
}

int main(){
   FIN;
   cin >> n;
   
   solve();
   
   return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
#define Mod 1000000007

using namespace std;

void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int main(){
	fastio();
	ll n,odd=0,even=0;
	cin>>n;
	for(ll i=1;i<=n;i++){
		if(i%2==1)
		odd++;
	}
	double ans=(double)odd/n;
	cout<<fixed<<setprecision(7)<<ans;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();

            List<Integer> list = new ArrayList<>();
            while (N != 0) {
                list.add(N & 1);
                N >>= 1;
                N *= -1;
            }
            if (list.isEmpty()) {
                out.println(0);
                return;
            }
            for (int i = list.size() - 1; i >= 0; i--) {
                out.print(list.get(i));
            }
            out.println();
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
package com.example.itp1.one

import java.util.*

fun main(args: Array<String>) {
    val sc: Scanner = Scanner(System.`in`)
    val S: Int = Integer.parseInt(sc.nextLine())
    val h = S / (60 * 60)
    var remainingS = S % (60 * 60)
    val m = remainingS / 60
    remainingS %= 60
    val s = remainingS
    println(String.format("%d:%d:%d", h, m, s))
}



Measured memory_bytes: 25572
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	fResultCountMap := map[int]int{}

	for x := 1; x < n; x++ {
		for y := 1; y < n; y++ {
			if x*x+y*y+x*y+3 > n {
				break
			}
			for z := 1; z < n; z++ {
				fResult := x*x + y*y + z*z + x*y + y*z + z*x
				if fResult > n {
					break
				}
				fResultCountMap[fResult]++
			}
		}
	}
	for i := 1; i <= n; i++ {
		fmt.Println(fResultCountMap[i])
	}
}


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

int binarySearch(long n[], int range, int num) {
	int low = 0, high = range;
	while (low <= high) {
		int mid = (low + high) / 2;
		if (n[mid] < num) {
			low = mid + 1;
		} else if(n[mid] > num) {
			high = mid - 1;
		} else if(n[mid] == num){
			return 1;
		}
	}
	return 0;
}

int main(void) {
	int num,q,count = 0;
	long n[100000];

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

	cin >> q;
	for (int i = 0; i < q; i++) {
		int value;
		cin >> value;
		count += binarySearch(n, num, value);
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, n, m);
  print(--n * --m);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
    size_t n;
    scanf("%zu", &n);

    int fib[2]={1, 1};
    for (size_t i=0; i<n; ++i)
        swap(fib[0]+=fib[1], fib[1]);

    printf("%d\n", fib[0]);
    return 0;
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,v,w,t;
  cin >> a >> v >> b >> w >> t;
  if(t*abs(v-w) >= abs(a-b) && v >= w){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
using System;
using System.Linq;
using System.Collections.Generic;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var md1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var md2 = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Console.WriteLine(md1[0]==md2[0]?"0":"1");

        }
    }
}


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

const ll maxS = 1e5+10;

int main()
{
  ll n,k;
  cin >> n >> k;
  if(k==1)
  {
    cout << 0 << "\n";
  }
  else
  {
    ll tmp =n/k;
    ll num1 = tmp*k;
    ll num2 = (tmp+1)*k;
    ll ans = labs(n-num1)<=labs(n-num2)?labs(n-num1):labs(n-num2);
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
vector<pair<int, int>> conn[101010];
int ans[101010];
void dfs(int a, int pa, int c) {
  ans[a] = c;
  for (auto x : conn[a])
    if (x.first != pa)
      dfs(x.first, a, c ^ x.second);
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N - 1; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    conn[u].emplace_back(v, w % 2);
    conn[v].emplace_back(u, w % 2);
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= N; ++i)
    printf("%d\n", ans[i]);
}


Measured memory_bytes: 8448
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> 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().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{x:i64};
    let ans = x/11;
    //debug!(ans, ans*2, ans*11, x-ans*11);
    if x-ans*11 == 0 {
        println!("{}", ans*2);
    }
    else if x-ans*11 <= 6 {
        println!("{}", ans*2+1);
    } else {
        println!("{}", ans*2+2);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define COUT(x) cout << (x) << endl
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int gcd( int m, int n )
{
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd

int main() {
    int k;
    cin >> k;
    int ans = 0;
    rrep(i, k) {
        rrep(j, k) {
            rrep(h, k) {
                int a = gcd(i, j);
                ans += gcd(a, h);
            }
        }
    }
    
    COUT(ans);

    return 0;
}

Measured memory_bytes: 3632
#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()
{
    int K, S;
    cin >> K >> S;

    int ans = 0;

    rep(x, K) {
        rep(y, K) {
            int z = S - x - y;
            if (0 <= z and z <= K) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
def count_divisor(n):
    c = 0
    i = n
    while i % 2 == 0:
        c += 1
        i = i // 2
    return c


_ = int(input())
A = [int(x) for x in input().split()]

res = [count_divisor(i) for i in A]
print(sum(res))


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

// Template for atcoder
public class Main {

    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};

    void solve() throws IOException {
        int LIMIT = 1000 * 1000 + 10;
//        int LIMIT = 100;
        int n = nextInt();
        int[] arr = nextIntArr(n);
        boolean[] good = new boolean[LIMIT];
        shuffle(arr);
        Arrays.sort(arr);
        Set<Integer> has = new HashSet<>();
        for (int v : arr) {
            has.add(v);
        }
        List<Integer> ls = new ArrayList<>(has);
        Collections.sort(ls);
        for (int v : ls) {
            if (!good[v]) {
                for (int j = 2 * v; j < LIMIT; j += v) {
                    good[j] = true;
                }
            }
        }
        for (int i = 0; i < n - 1; i++) {
            if (arr[i] == arr[i + 1]) {
                good[arr[i]] = true;
            }
        }

        int res = 0;
        for (int v : arr) {
            if (!good[v]) {
                res++;
            }
        }
        outln(res);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public Main() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new Main();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}


Measured memory_bytes: 68936
#include <iostream>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int ret = 0;
  for(int i = 0; K >= i; i++){
    for(int j = 0; K >= j; j++){
      if(i + j <= S && i + j + K >= S){
        ret++;
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

i64 gcd(i64 m, i64 n) {
	if (n == 0) {
		return m;
	}
	while (m%n != 0) {
		m %= n;
		swap(m, n);
	}
	return n;
}

i64 lcm(i64 m, i64 n) {
	i64 a = gcd(m, n);
	return m / a * n;
}

int main() {
	int n;
	cin >> n;
	vector<i64> t(n);
	rep(i, 0, n) {
		cin >> t[i];
	}
	i64 ans = t[0];
	rep(i, 1, n) {
		ans = lcm(ans, t[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
int n,k;
double v[200001];
double s[200001];
int main()
{
	cin >> n >> k;
	cout << setprecision(9);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
		v[i] = (((v[i] + 1) * v[i]) / 2) / v[i];
		s[i] = s[i - 1] + v[i];
	}
	double ans=0;
	
	for (int i = k; i <= n; i++)
	{
		if (s[i] - s[i - k] > ans) ans = s[i] - s[i - k];
	}
	
	cout << ans;
	return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

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

double hour(double h, double m) {
  return h * 30 + m * 0.5;
}

double minute(double m) {
  return 360 * m / 60;
}

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

  ll a, b, h, m;
  cin >> a >> b >> h >> m;
  double hRad = hour(h, m);
  double mRad = minute(m);
  ll hoge = 0;
  if (hRad > mRad) hoge = h;
  else hoge = m;
  double tmp = abs(hRad-mRad);
  if (tmp == 180) {
    // 桁数と変数名を指定
    //cout << fixed << setprecision(6) << ans << endl;
    cout << fixed << setprecision(10) << a+b << endl;
    return 0;
  }
  if (tmp > 180) {
    tmp = 360 - tmp;
  }
  double pi = 2.0 * asin(1.0);
  // 桁数と変数名を指定
  //cout << fixed << setprecision(6) << ans << endl;
  double ans = pow(a, 2) + pow(b, 2) - 2*a*b*cos(tmp * M_PI / 180.0);
  // 桁数と変数名を指定
  //cout << fixed << setprecision(6) << ans << endl;
  cout << fixed << setprecision(10) << sqrt(ans) << endl;
  return 0;
}


Measured memory_bytes: 4132
X,Y = map(int,input().split())

if X == Y == 1:
    print((3+3+4)*10**5)
else:
    if (1 <= X <= 3) and (1 <= Y <= 3):
        print(((4-X)+(4-Y))*10**5)
    elif X >= 4 and Y >= 4:
        print(0)
    else:
        print((4-min(X,Y))*10**5)

Measured memory_bytes: 9188
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)){
        cout << "No" << endl;;
    }else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);	
int main()
{
	ll x;
	cin>>x;
	if(x>=30)
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  vector<string> c(3);
  rep(i, 3) cin >> c[i];
  rep(i, 3) cout << c[i][i];
  cout << endl;
}

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

int main()
{
	int iStampSize;		// スタンプ列(入力として受け取るスタンプ)の長さ
	char* achStamps;	// 入力されるスタンプ列
	char* pchStampIni;	// 未判定のスタンプ列の先頭ポインタ
	int iOXStamp = 0;	// oxスタンプの数
	char chStamp1, chStamp2;	// 連続する2スタンプ
	int iCount;			// ループカウンタ


	// 入力：スタンプ列の長さ
	scanf("%d", &iStampSize);

	// スタンプ列の長さ分+1、入力を受け取る領域を確保する
	achStamps = (char*)malloc(sizeof(char) * iStampSize + 1);
	pchStampIni = achStamps;

	// 入力：スタンプ列
	for (iCount = 0; iCount < iStampSize; iCount++)
	{
		scanf(" %c", &achStamps[iCount]);
	}

	// スタンプ列の終端を表す記号(e)を末尾に追加
	achStamps[iStampSize] = 'e';

	// 未判定のスタンプ列から2個ずつ取り出してoxまたはxo判定
	while (*pchStampIni != 'e')
	{
		// 先頭ポインタの指し先から、連続する2スタンプを取り出す
		chStamp1 = *pchStampIni;
		chStamp2 = *(pchStampIni + 1);

		// 連続2スタンプがoeまたはxe
		if (chStamp2 == 'e')
		{
			// oxスタンプではないので先頭ポインタを1つ進める
			pchStampIni++;
		}
		// 連続2スタンプがoxまたはxo
		else if (chStamp1 != chStamp2)
		{
			// oxスタンプなのでスタンプ数をインクリメントし、先頭ポインタを2つ進める
			iOXStamp++;
			pchStampIni += 2;
		}
		// 連続2スタンプがoxまたはxoでない
		else
		{
			// oxスタンプではないので先頭ポインタを1つ進める
			pchStampIni++;
		}
	}

	// oxスタンプの個数を表示
	printf("%d\n", iOXStamp);

	// ヒープ領域の解放
	free(achStamps);

	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int a,b;
	cin >> a >> b;
	string c[100];
	for(int i=0;i<a;i++){
		cin >> c[i];
		
	}
	sort(c,c+a);
	
	for(int j=0;j<a;j++){
		cout << c[j];
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
class Node():
    def __init__(self, key = None ,left =None ,right = None):
        self.key_value = key
        self.left = left
        self.right = right

class BST():
    def __init__(self):
        self.root = None

    def insert(self, data):
        n = self.root
        if n == None:
            self.root = Node(data)
            return
        else:
            while True:
                entry = n.key_value
                if data < entry:
                    if n.left is None:
                        n.left = Node(data)
                        return
                    n = n.left
                elif data > entry:
                    if n.right is None:
                        n.right = Node(data)
                        return
                    n = n.right
                else:
                    n.data = data
                    return

    def inorder(self,node):
        if node is None:
            return
        else:
            self.inorder(node.left)
            print(' {}'.format(node.key_value),end='')
            self.inorder(node.right)

    def preorder(self,node):
        if node is None:
            return
        else:
            print(' {}'.format(node.key_value),end='')
            self.preorder(node.left)
            self.preorder(node.right)

if __name__ == "__main__":
    n = int(input())

    bst = BST()
    for i in range(n):
        o = input().split()

        if o[0] == 'insert':
            bst.insert(int(o[1]))
        elif o[0] == 'print':
            bst.inorder(bst.root)
            print()
            bst.preorder(bst.root)
            print()



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

using namespace std;
//using namespace std::chrono;

#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<long long>

typedef long long ll;

void print(vi v){
    cout<<"Contents of vector:\n";
    for(auto x : v) cout<<x<<" ";
    cout<<endl<<endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); //cout.tie(nullptr);
    //ifstream cin("lmio_1991_3e1_seka_01.in"); ofstream cout("lmio_1991_3e1_seka_01.out");///cia failai

    //int T; cin>>T;
    int T = 1;

    for(int it = 1; it<=T; it++){
        int k; cin>>k;
        int c = 7;
        for(int i = 1; i<100000000; i++){
            if(c%k == 0) {
                cout<<i<<endl;
                return 0;
            }
            c = (c%k) * 10 + 7;
        }
        cout<<"-1\n";


    }
}


Measured memory_bytes: 3664
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

a_set=set()

for index in range(m):
    a_set.add(int(input()))

ans_list=[0] * (n + 1)

for index in range(n + 1):
    if index == 0:
        ans_list[index] += 1
        continue
    if index == 1 and (index not in a_set):
        ans_list[index] += ans_list[index - 1]
        continue
    
    if index not in a_set:
        if (index - 1) not in a_set:
            ans_list[index] += ans_list[index - 1]
            ans_list[index] %= 1000000007
        if (index - 2) not in a_set:
            ans_list[index] += ans_list[index - 2]
            ans_list[index] %= 1000000007

print(ans_list[n])


Measured memory_bytes: 11884
func readInt() -> Int {
    Int(readLine()!)!
}

func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func tuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func tuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }
    
    func safe(at index: Index) -> Element? {
        self.indices.contains(index) ? self[index] : nil
    }
}

struct DP<Argument: Hashable, Element> {
    var dictionary = [Argument: Element]()
    
    var expression: (Argument, (Argument) -> Element) -> Element
    
    init(expression: @escaping (_ argument: Argument, _ note: (Argument) -> Element) -> Element) {
        self.expression = expression
    }
    
    subscript(_ argument: Argument) -> Element {
        mutating _read {
            if let note = dictionary[argument] {
                yield note
            } else {
                let result = expression(argument) { self[$0] }
                dictionary[argument] = result
                yield result
            }
        }
    }
}

extension Dictionary {
    init(_ initialize: (inout Self) -> ()) {
        var dictionary = Self()
        initialize(&dictionary)
        self = dictionary
    }
}

extension Int {
    var abs: Int {
        self < .zero ? -self : self
    }
}

// MARK: ---------------------------------------------------------------------

// import Foundation
let (d, t, s) = readInts().map(Double.init).tuple()

print(d / s <= t ? "Yes" : "No")


Measured memory_bytes: 8200
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int,int>> x(n);
    vector<int> a(n);
    for (int i=0; i<n; i++)
        cin >> x[i].first, x[i].second = i;
    sort(x.begin(), x.end());
    int k = n/2;
    for (int i=0; i<n; i++) {
        int p;
        if (i < k) p = x[k].first;
        else p = x[k-1].first;
        a[x[i].second] = p;
    }
    for (int i=0; i<n; i++)
        cout << a[i] << endl;
}

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

using namespace std;

typedef long long int ll;

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

typedef pair<int,int> pair;


int main(){
    ll n; cin >> n;

    bool odd;

    if(n%2==1) odd=true;
    else odd=false;

    ll ans=0;

    if(!odd){
        ll base=10;
        while(base<=n){
            ans+=n/base;
            base*=5;
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++) 
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    ll sum = a + b;
    if(sum % 2 == 0) {
        sum /= 2;
        cout << sum - a << endl;
    }
    else {
        cout << min(a-1,n-b) + 1 + (b - a - 1) / 2 << endl;
    }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
to=[[]for _ in range(n)]
ot=[[]for _ in range(n)]
dic={}
for i in range(m):
    a,b,c=map(int,input().split())
    to[a-1].append([b-1,-c])
    ot[b-1].append([a-1,-c])
#print(to)
vi_to=[0]*n
vi_to[0]=1
from collections import deque
que=deque()
que.append(0)
while que:
    v=que.pop()
    for u,c in to[v]:
        if vi_to[u]:
            continue
        vi_to[u]=1
        que.appendleft(u)

vi_ot=[0]*n
vi_ot[n-1]=1
que=deque()
que.append(n-1)
while que:
    v=que.pop()
    for u,c in ot[v]:
        if vi_ot[u]:
            continue
        vi_ot[u]=1
        que.appendleft(u)

av=[0]*n
for i in range(n):
    if vi_to[i] and vi_ot[i]:
        av[i]=1
#print(av)

dist=[float("inf")]*n
dist[0]=0
for i in range(n):
    for a,toa in enumerate(to):
        for b,c in toa:
            if av[a] and av[b]:
                if dist[b]>dist[a]+c:
                    dist[b]=dist[a]+c
                    if i==n-1:
                        print("inf")
                        exit()
#print(dist)
print(-dist[n-1])


Measured memory_bytes: 46444
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;

int main(){

	int w;
	string s;
	cin >> s >> w;
	int i=0, n=s.size();
	while(i<n){
		cout << s[i];
		i+=w;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gint(){
		return Integer.parseInt(s.next());
	};
	public static void main(String[] $){
		boolean o=false;
		int n=gint();
		for(int i=0;i<n;++i)
			if(gint()%2==1)
				o=true;
		
		System.out.println(o?"first":"second");
	}
}


Measured memory_bytes: 45868
#include <bits/stdc++.h>
using namespace std;
long long N,A,counter=0,sum=0,mini=1000000000+10;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    if(A<0) counter++;
    sum+=abs(A);
    if(mini>abs(A)) mini=abs(A);
  }
  if(counter%2==0) cout << sum << endl;
  else cout << sum-2*mini << endl;
  return 0;
}


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

int main()
{
    int w, q, a, b;
    char query;

    while( cin >> w >> q )
    {
        if( w + q == 0 )
            break;

        int* c = new int[w];
        for( int i = 0; i < w; i++ )
            c[i] = 0;
        
        for( int i = 0; i < q; i++ )
        {
            cin >> query;
            if( query == 's' )
            {
                cin >> a >> b;
                bool judge = false;
                for( int j = 0; j <= w - b; j++ )
                {
                    judge = true;
                    for( int k = j; k < j + b; k++ )
                        if( c[k] != 0 )
                            judge = false;
                    if( judge == 1 )
                    {
                        for( int k = j; k < j + b; k++ )
                            c[k] = a + 1;
                        cout << j << endl;
                        break;
                    }
                }
                if( !judge )
                    cout << "impossible" << endl;
            }
            else
            {
                cin >> a;
                for( int j = 0; j < w; j++ )
                    if( c[j] == a + 1 )
                        c[j] = 0;
            }
        }
        cout << "END" << endl;
        delete c;
    }
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long N = 1e5+20,OO=1e18;
int n,arr[N];
int dp[N];
ll solve(int i){
    if(i==n-1)return 0;
    if(i>=n) return OO;
    if(~dp[i])return dp[i];
    ll choice1=abs(arr[i]-arr[i+1])+solve(i+1);
    ll choice2=abs(arr[i]-arr[i+2])+solve(i+2);
    return dp[i]=min(choice1,choice2);
}
int main()
{
    memset(dp,-1,sizeof dp);
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",arr+i);
    cout<<solve(0)<<endl;
}


Measured memory_bytes: 4096
<?php
//終端まで繰り返す
while ( ! feof(STDIN) ) {
  $line[] = trim(fgets(STDIN));
}

$abc = explode(" ", $line[0]);
rsort($abc);

if ($abc[0] == ($abc[1] + $abc[2])) {
    echo "Yes";
} else {
    echo "No";
}


Measured memory_bytes: 3704
N = int(input())
songs_list = []
time_list = []
for i in range(N):
  song, time = input().split()
  time = int(time)
  songs_list.append(song)
  time_list.append(time)
  
last_song = input()
for i in range(N):
  if last_song == songs_list[i]:
    num = i
    break
#print(songs_list[(num+1):])
print(sum(time_list[(num+1):]))

Measured memory_bytes: 3064
using System;

class Iroha
{
    static void Main()
    {
        var input = Console.ReadLine().Split(' ');
        var answer = "";
        if(int.Parse(input[0])+ int.Parse(input[1]) + int.Parse(input[2]) == 17){
            answer = "YES";
        }else{
            answer = "NO";
        }
        
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11348
while True:
    h1 = int(input())
    if h1 == 0:
        break
    h = [h1, *map(int, (input() for _ in [0]*4))]
    s = set(h)
    if len(s) % 2 == 1:
        print(*([3]*5), sep="\n")
    else:
        result = [0, 0, 0, 0]
        if 1 in s and 2 in s:
            result[1], result[2] = 1, 2
        elif 2 in s and 3 in s:
            result[2], result[3] = 1, 2
        else:
            result[1], result[3] = 2, 1
        print(*(result[n] for n in h), sep="\n")


Measured memory_bytes: 5612
#include<cstdio>
using ull = unsigned long long;

int main(){
    ull a, b, x;
    scanf("%llu %llu %llu", &a, &b, &x);
    printf("%llu\n", a ? b/x - (a - 1)/x : (b/x + 1));
    return 0;
}

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

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

    int cnt = 0;
    for(int i=0; i+2<N; i++){
        if("ABC" == S.substr(i, 3)){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

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

  string S, T; cin >> S >> T;
  for (int i = 0; i < T.size(); i++) {
    if (S == T.substr(i) + T.substr(0, i)) {
      cout << "Yes" << "\n";
      return 0;
    }
  }
  cout << "No" << "\n";
}

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int M=1e9 + 7;

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int a,b,c,d,k;
		cin >> a >> b >> c >> d >> k;
		int tot = (c-a)*60 + (d-b);
		//cout << tot << endl;
		cout << tot - k << endl;
	}
}


Measured memory_bytes: 3648
def main():
    N = int( input())
    A = list( map( int, input().split()))
    root = 1
    if A[0] == 1:
        if N == 0:
            print(1)
        else:
            print(-1)
        return
    B = A[::-1]
    low = high = B[0]
    # Low = []
    Hight = [high]
    Low = [low]
    for b in B[1:]:
        low = max(1, (low+1)//2) + b
        high = high + b
        Hight.append(high)
        Low.append(low)
    if low > 1:
        print(-1)
        return
    ans = 1
    now = 1
    BHight = Hight[::-1]
    BLow = Low[::-1]
    for i in range(1,N+1):
        high = BHight[i]
        low = BLow[i]
        if high < now or now*2 < low:
            print(-1)
            return
        leaf = A[i]
        now = min(high, now*2)
        ans += now
        now -= leaf
    print(ans)
if __name__ == '__main__':
    main()

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

int main(){
	int i, j, k;
	char s[202], p[100], s2[101];
	gets(s);
	gets(p);
	strcpy(s2,s);
	strcat(s,s2);
	if(strstr(s,p) == NULL){
		printf("No\n");
	} else {
		printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  map<int,int> mp;
  mp[0]++;
  int N = S.size();
  long long ans = 0,fac = 1,num = 0;
  for(int i = 0;i < N;i++) {
    num = (num+fac*(S.at(N-i-1)-'0'))%2019;
    fac = fac*10%2019;
    mp[num]++;
  }

   for(auto itr = mp.begin();itr != mp.end();itr++) {
      long long v = itr->second;
      ans += v*(v-1)/2;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3760