akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

int n;
vector<ll> a;
vector<vector<ll>> memo;

ll rec(int l, int r){
    if(memo[l][r] != -1) return memo[l][r];
    if(l == r) return a[l];

    ll res = -1e15;
    chmax(res, a[l] - rec(l+1, r));
    chmax(res, a[r] - rec(l, r-1));
    return memo[l][r] = res;
}

void input(){
    cin >> n;
    a.resize(n+1, 0);
    repr(i, 1, n+1) cin >> a[i];
    memo.resize(n+5, vector<ll>(n+5, -1));
}

void solve(){
    cout << rec(1, n) << endl;
}

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

    input();
    solve();
    

    return 0;
}

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


int main(){
    int n, t[110000], x[110000], y[110000];
    cin >> n;

    t[0] = x [0] = y[0] = 0;
    for (int i = 0; i < n; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;
    for (int i = 0; i < n; ++i){
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;
    }

    if (can == true) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 1408
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[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()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        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)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        s: chars,
        t: chars
    }
    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    for si in 0..s.len() {
        for ti in 0..t.len() {
            dp[si + 1][ti + 1] = cmp::max(cmp::max(dp[si][ti] + (s[si] == t[ti]) as i64, dp[si + 1][ti]), dp[si][ti + 1]);
        }
    }
    let mut ans: Vec<char> = vec![];
    let (mut s_len, mut t_len) = (s.len(), t.len());
    while s_len > 0 && t_len > 0 {
        if dp[s_len][t_len - 1] == dp[s_len][t_len] {
            t_len -= 1;
        } else if dp[s_len - 1][t_len] == dp[s_len][t_len] {
            s_len -= 1;
        } else {
            t_len -= 1;
            s_len -= 1;
            ans.push(s[s_len]);
        }
    }
    println!("{}", ans.into_iter().rev().collect::<String>());
}


Measured memory_bytes: 90364
n=int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ans=0
for i in range(n):
    #print(ab[-i-1][0]+ans,ab[-i-1][1])
    if (ab[-i-1][0]+ans)%ab[-i-1][1]!=0:
        ans+=ab[-i-1][1]-(ab[-i-1][0]+ans)%ab[-i-1][1]
    #print(ans)
print(ans)

Measured memory_bytes: 27380
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	nums := make([]int, 5)
	for i := range nums {
		nums[i] = scanInt()
	}

	for i, e := range nums {
		if e == 0 {
			fmt.Println(i + 1)
			break
		}
	}
}


Measured memory_bytes: 1768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long n = scanner.nextLong(),m = scanner.nextLong();
		if(n * 2 > m){
			System.out.println(m / 2);
		}else{
			long piece = n;
			m -= n * 2;
			System.out.println(n + (m / 4));
		}
	}

}


Measured memory_bytes: 22740
#include<stdio.h>
int main(void)
{
	int a,b;
	char op;
	while(1) {
		scanf("%d %c %d",&a,&op,&b);
//		printf("%d %c %d\n",a,op,b);
		if(op=='?') break;
		if(op=='+'){
			printf("%d\n",a+b);
		}
		else if(op=='-'){
			printf("%d\n",a-b);
		}
		else if(op=='*'){
			printf("%d\n",a*b);
		}
		else if(op=='/'){
			printf("%d\n",a/b);
		}
	}	
	return 0;
}

Measured memory_bytes: 2732
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n+1];
    for(int i=1;i<=n;i++){
      a[i]=sc.nextInt();
    }
    int ans=0;
    int[] b=new int[n+1];
    for(int i=n;i>0;i--){
      int cnt=0;
      for(int j=i+i;j<=n;j+=i){
        cnt+=b[j];
      }
      if((cnt&1)==a[i]){
        
      }else{
        b[i]=1;
        ans++;
      }
    }
    System.out.println(ans);
    for(int i=1;i<=n;i++){
      if(b[i]>0){
        System.out.print(i+" ");
      }
    }
    System.out.println();
  }
}


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

int main(){
	ll n, w;
	cin>>n>>w;
	ll wt[n], val[n];
	for(int i=0;i<n;i++)
		cin>>wt[i]>>val[i];

	ll dp[n+1][w+1];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=w;j++){
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(wt[i-1]<=j)
				dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]], dp[i-1][j]);
			else
				dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 82452
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  cin >> n;
  
  ll ans = 1;
  REP(i,n){
    ans *= (i+1);
    ans %= MOD;
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int main()
{
	int x,y;cin>>x>>y;
	int sum = 0;
	sum += max(4-x,0);
	sum += max(4-y,0);
	if(sum==6)sum += 4;
	if(sum==0)cout<<0<<endl;
	else cout << sum << "00000" << endl;
}


Measured memory_bytes: 256
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    c = Counter(A)
    max_num = c.most_common()[0][1]
    ANS = [i[0] for i in c.items() if i[1] == max_num]
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  vector<vector<vector<int>>> dp(N,vector<vector<int>>(401,vector<int>(401,5000)));
  int a,b,c;
  cin>>a>>b>>c;
  dp.at(0).at(0).at(0)=0,dp.at(0).at(a).at(b)=c;
  for(int i=1;i<N;i++){
    cin>>a>>b>>c;
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        if(j>=a&&k>=b){
          dp.at(i).at(j).at(k)=min(dp.at(i-1).at(j).at(k),dp.at(i-1).at(j-a).at(k-b)+c);
        }
        else{
          dp.at(i).at(j).at(k)=dp.at(i-1).at(j).at(k);
        }
      }
    }
  }
  int X=A,Y=B,Z=5000;
  while(X<=400&&Y<=400){
    Z=min(Z,dp.at(N-1).at(X).at(Y));
    X+=A,Y+=B;
  }
  if(Z==5000){
    cout<<"-1"<<endl;
  }
  else{
    cout<<Z<<endl;
  }
                        
}

Measured memory_bytes: 26624
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>

using namespace std;

int N;
vector<long long> A;

int main()
{
    cin >> N;
    long long mv = 1e9 + 7;
    long long mi = -1;
    for (int i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        A.push_back(a);
        if(mv > a)
        {
            mv = a;
            mi = i;
        }
    }

    long long nmv = mv;
    long long nmi = mi;

    while(1)
    {
        for (int i = 0; i < N; i++)
        {
            if(i == mi)
            {
                continue;
            }
            long long t = A[i] % mv;
            if(t != 0)
            {
                if(nmv > t)
                {
                    nmv = t;
                    nmi = i;
                }
            }
            A[i] = t;
        }
        if(nmv != mv)
        {
            //cout << "mv:" << mv << " nmv:" << nmv << endl;
            mv = nmv;
            mi = nmi;
        }
        else
        {
            break;
        }
    }

    cout << mv << endl;

    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    char s[110][110];
    for (int i = 0; i <= h + 1; i++) {
        for (int j = 0; j <= w + 1; j++) {
                s[i][j] = 0;
        }
    }

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> s[i][j];
        }
    }

    for (int i = 0; i <= h + 1; i++) {
        for (int j = 0; j <= w + 1; j++) {
            if (i == 0 || i == h + 1 || j == 0 || j == w + 1) cout << "#";
            else cout << s[i][j];
        }
        cout << endl;
    }

}

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

const int m=2019;



int main(){
  string s;
  cin >>s;
  int n=s.size();
  reverse(s.begin(),s.end());
  int x=1,tot=0;
  vector<int> cnt(m);
  ll ans =0;
  rep(i,n){
    cnt[tot]++;
    tot+=(s[i]-'0')*x;
    tot %=m;
    ans +=cnt[tot];
    x=x*10%m;
  }
  cout <<ans<<endl;
}


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

using namespace std;

int main() {
  long long n,d;
  cin>>n>>d;
  long long ans=0;
  for(long long i=0;i<n;i++){
    long long x,y;
    cin>>x>>y;
    if(x*x+y*y<=d*d){
      ans++;
    }
  }
  cout<<ans<<endl;
  
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;

signed main()
{
	//FILEIO
 	//start_routine
	
	int tests = 1;
	//cin>>tests;
	int n,h,w;
	cin>>n>>h>>w;
	int ans= 0;
	int i;
	fr(i,1,n + 1)
	{
		int a,b;
		cin>>a>>b;
		if(a>=h && b>=w)ans++;
	}
	cout<<ans<<'\n';

 	//end_routine
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MAXN = 301;


int main() {
    int N; cin >> N;
    vector<pair<int, int>> P(N);
    for(int i = 0; i < N; i++){
        int a, b; cin >> a >> b;
        P[i] = make_pair(b, a);
    }
    sort(P.begin(), P.end());
    for(int i = 1; i < N; i++) P[i].second += P[i-1].second;
    for(int i = 0; i < N; i++){
        if(P[i].first < P[i].second){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}  

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

typedef long long ll;
typedef long double ld;

int main(){
  ll a,b;
  cin >> a >> b;
  string str;
  cin >> str;
  vector <ll> arr(a);
  for (int z=0;z<a;z++){
    arr[z] = str[z]-'0';
  }
  ll temp=0;
  if((b==2)||(b==5)){
    for (int z=0;z<a;z++){
      if((arr[z]%b==0)||(arr[z]==0)){
        temp+=z+1;
      }
    }
    cout << temp << endl;
  }
  else{
    vector <ll> power(a+1);
    power[0] = 1;
    for (int z=1;z<=a;z++){
        power[z] = power[z-1]*10;
        power[z] %= b;
    }

    vector <ll> suf(a);
    suf[a-1] = arr[a-1]%b; 
    map<ll,ll> mapp;
    mapp[arr[a-1]%b]++;
    ll ans = 0;
    ll i = 1;

    for (int z=a-2;z>=0;z--){
      suf[z] = (suf[z+1]+arr[z]*power[i])%b;
      ans += mapp[suf[z]];
      mapp[suf[z]]++;
      i++;
    }
    cout << ans+mapp[0] << endl; 
  }

   
}
  

Measured memory_bytes: 5756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main(){
    string s;
    cin >> s;
    for(int i=0;i<3;i++){
        if(s.at(i) =='7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>

int parent(int);

int left(int);

int right(int);


int main(){
  int h,i,j,a[251];

  scanf("%d",&h);

  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }

  for(i=1;i<=h;i++){
    printf("node %d: key = %d, ",i,a[i]);

    if(parent(i)>=1) printf("parent key = %d, ",a[parent(i)]);

    if(left(i)<=h) printf("left key = %d, ",a[left(i)]);

    if(right(i)<=h) printf("right key = %d, ",a[right(i)]);

    printf("\n");
  }

  return 0;
}


int parent(int i){
  return i/2;
}


int left(int i){
  return 2*i;
}


int right(int i){
  return 2*i+1;
}



Measured memory_bytes: 2056
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn gcd(a: u64, b: u64) -> u64{
    if b == 0{
        return a;
    }else{
        gcd(b, a%b)
    }
}

fn lcm(a: u64, b: u64) -> u64{
    (a*b)/gcd(a, b)
}

fn num_of_anti(n: u64, c: u64, d: u64) -> u64{
    n - (n/c + n/d - n/lcm(c, d))
}

fn main(){
    let line: Vec<u64> = read_as_vec();
    let (a, b, c, d) = (line[0], line[1], line[2], line[3]);

    let ans = num_of_anti(b, c, d) - num_of_anti(a-1, c, d);
    
    println!("{}", ans);
}
    


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int dp[100010],prefix[100010],n,x,k,mod=1e9+7;
void solve()
{
    cin>>n>>k;
    for(int i=0;i<=k;i++)prefix[i]=1;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        dp[0]=prefix[0];
        for(int j=1;j<=k;j++)
        {
            if(j-x>=1)dp[j]=prefix[j]-prefix[j-x-1];
            else dp[j]=prefix[j];
            if(dp[j]<0)dp[j]+=mod;
        }
        for(int j=1;j<=k;j++)prefix[j]=(prefix[j-1]+dp[j])%mod;
    }
    cout<<dp[k];
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;
using Graph = vector<vector<ll> >;

vector<bool> seen;
vector<ll> first_order;
vector<ll> last_order;

void dfs(const Graph &G, ll v, ll& ptr) {
    // 行きがけ順をインクリメントしながらメモ
    first_order[v] = ptr++;

    seen[v] = true;
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue;
        dfs(G, next_v, ptr);
    }

    // 帰りがけ順をインクリメントしながらメモ
    last_order[v] = ptr++;
}

int main(){
  ll N; cin >> N;
  Graph G(N);

  rep(i,N){
    ll a; cin >> a;
    ll k; cin >> k;
    rep(j,k){
      ll to; cin >> to; to--;
      G[i].pb(to);
    }
  }

  seen.assign(N, false);
  first_order.resize(N);
  last_order.resize(N);

  ll ptr = 1;

  rep(i, N){
    if(!seen[i]) dfs(G, i, ptr);
  }

  rep(i , N){
    cout << i + 1 << " " << first_order[i] << " " << last_order[i] << endl;
  }
}




Measured memory_bytes: 3168
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    long double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed << setprecision(11)<<w*h/2<<" ";
    if(w/2==x && h/2==y) cout<<1<<endl;
    else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

const ll mod = 1e9 + 7;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
   // cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++)
    {
        int H,W;
        int h,w;
        cin >> H >> W >> h >> w;
        cout << (H - h)* (W - w)<<endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  bool exist = false;
  int val = 0;
  for(int i=0; i<25; i++){
    for(int j=0; j<15; j++){
      val = (i*4 + j*7);
      if( val == n ){
        exist = true;
      }
      if(val > n) break;
    }
  }

  if(exist){
    cout << "Yes";
  }else{
    cout << "No";
  }

  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  string ans = "";
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
    if (a.at(i) % 2 == 0 && (a.at(i) % 3 != 0 && a.at(i) % 5 != 0))
    {
      ans = "DENIED";
    }
  }
  if (ans == "")
  {
    ans = "APPROVED";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    string s;
    cin>>s;
    if(s.size()%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i+=2)
    {
        if(s[i]=='h' && s[i+1]=='i'){

        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    
    return 0;
}

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

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int L;
    cin >> L;
    auto l =  (double) L / 3;
    cout << fixed << setprecision(15) <<  l * l * l << endl;
    return 0;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String a[] = new String[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.next();
        }

        Set<String> set = new HashSet<>();
        
        for (int i = 0; i < n; i++) {
            set.add(a[i]);
        }
        
        if(set.size() == 4){
            System.out.println("Four");
        }else{
            System.out.println("Three");
        }

        sc.close();
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;

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

int main()
{
  ll N, M;
  cin >> N >> M;

  map<ll, vector<ll>> g;
  ll *d = new ll[N];
  REP(x, N)
  {
    d[x] = 0;
  }
  REP(m, M)
  {
    ll x, y;
    cin >> x >> y;
    x--, y--;

    g[x].push_back(y);
    d[y]++;
  }

  ll *dp = new ll[N];
  ll max = 0;

  queue<ll> q;
  REP(x, N)
  {
    dp[x] = 0;
    if (d[x] == 0)
    {
      q.push(x);
    }
  }

  while (!q.empty())
  {
    ll x = q.front();
    q.pop();

    for (auto y : g[x])
    {
      d[y]--;
      if (d[y] == 0)
      {
        chMax(dp[y], dp[x] + 1);
        chMax(max, dp[y]);
        q.push(y);
      }
    }
  }

  cout << max << endl;

  return 0;
}

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

int main() {
  vector<int64_t> a(87);
  a.at(0)=2;
  a.at(1)=1;
  for(int i=2;i<87;i++){
    a.at(i)=a.at(i-1)+a.at(i-2);
  }
  int n;
  cin>>n;
  cout<<a.at(n);
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

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

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
// r#"3"# => "2",
r#"6"# => "9",
 // r#"11"# => "30",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        k: usize,
    }
    (k/2 * ((k+1)/2)).to_string()
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1000000000
typedef long long ll;


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

	char c[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ch char
#define st string
using namespace std;
ll a,b,c,d,e,f,g,h;
void Urvatullo_Atoev()
{
    cin>>a>>b;
    c=pow(b-1,a-1);
    if(a!=1)
    {
    	cout<<c*b<<endl;
    }
    else
    {
    	cout<<b<<endl;
    }
}
int main()
{
    Urvatullo_Atoev();
}


Measured memory_bytes: 3992
while 1:
    H,W = map(int, input().split())
    if [H, W] == [0, 0]:
        break
    for i in range(H):
        ans = ""
        for j in range(W):
            if (i + j) % 2 == 0:
                ans += "#"
            else:
                ans += "."
        print(ans)
    print("")


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

int main(){
int N;
  cin >> N;
  vector<int> A(N);
  for(int i= 0;i < N;++i)
    cin >> A[i];
  int ans = 1e10;
  
  for(int i =1;i < N;++i){
    int l =0,r =0;
  for(int j =0;j<i;++j) l += A[j];
  for(int k =i;k < N;++k) r += A[k];
    ans =min(ans,abs(l-r));  
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
#define inputtxt() std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf())
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define foreach(e, v) for (auto e : v)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

using ll = long long;
int main(){
    ll N, v_min; cin >> N >> v_min;
    ll t = 0;
    rep(i,4){
        ll temp; cin >> temp;
        v_min = min(v_min,temp);
    }
    t = ceil((double)N/v_min)+4;
    cout << t << endl;
}

Measured memory_bytes: 256
d, n = [int(i) for i in input().split()]

if d == 0 and n == 100:
    print(101)
elif d == 0:
    print(n)
elif d == 1 and n == 100:
    print((100**d)*n+100)
elif d == 2 and n == 100:
    print((100**d)*n+10000)
else:
    print((100**d)*n)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i],b[i] = scanInt(), scanInt()
	}
	sort.Ints(a)
	sort.Ints(b)

	debug(a,b)

	if n&1 == 1 {
		fmt.Fprintln(wr, b[n/2]-a[n/2]+1)
	} else {
		fmt.Fprintln(wr, (b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1)
	}

}


Measured memory_bytes: 25560
n = int(input())
a = [int(input()) for _ in range(n)]
f, s = sorted(a, reverse=True)[:2]
idx = a.index(f)
if f == s:
    for _ in range(n):
        print(f)
else:
    for i in range(n):
        if i == idx:
            print(s)
        else:
            print(f)

Measured memory_bytes: 68540
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

bool comp_p(const pll& l, const pll& r) {
	return l.second < r.second;
}

int main() {
	ll N, K;
	cin >> N >> K;
	ll i, j;
	if (N == 2) {
		if (K == 0) {
			cout << 1 << endl;
			cout << 1 << " " << 2 << endl;
		}
		else {
			cout << -1 << endl;
		}
		return 0;
	}
	if (K > (N - 1) * (N - 2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	vector<pll> P;
	for (i = 2; i <= N; i++) {
		P.push_back(pll(1, i));
	}
	ll f = 2;
	ll t = 3;
	ll now = (N - 1) * (N - 2) / 2;
	while (now > K) {
		P.push_back(pll(f, t));
		now--;
		t++;
		if (t > N) {
			f++;
			t = f + 1;
		}
		if (f == N) {
			break;
		}
	}
	cout << P.size() << endl;
	for (auto& e : P) {
		cout << e.first << " " << e.second << endl;
	}

	return 0;
}


Measured memory_bytes: 512
lines=readlines(open("/dev/fd/0"))
input()=shift!(lines)
int(s::String)=parse(Int,s)
intSub(s::SubString{String})=parse(Int,s)
intLine(s::Array{SubString{String},1})=map(intSub,s)
function main()
  w,h,x,y=intLine(split(input()))
  println(.5w*h,' ',+(.5(w+h)==x+y))
end
main()

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

int main(){
  int A,B;
  cin >> A >> B;
  
  if(A-B>=1){
    cout << 2*A-1;
  }else if(A==B){
    cout << 2*A;
  }else{
    cout << 2*B-1;
  }
  
}

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

int main(){
    string n,a,b;
    cin >> n;
    for(int i=0;i<n.size()-1;i++){
        if(n[i]=='A'&&n[i+1]=='C'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

int arr[605][605];

char s[605][605];

bool u[26];

int n, ans;

int rectSum(int x, int y) {	
	return arr[x + n][y + n] + arr[x][y] - arr[x][y + n] - arr[x + n][y];
}

void solve() {                   
	scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
    	scanf("%s", s[i]);
    }

    for (int i = 0; i < n; ++i) {
    	for (int j = 0; j < n; ++j) {
    		s[i + n][j] = s[i][j];
    		s[i][j + n] = s[i][j];
    		s[i + n][j + n] = s[i][j];
    	}
    }

    int m = n * 2;

    for (int diff = -n + 1; diff < n; ++diff) {
    	for (int i = 1; i < m; ++i) {
    		for (int j = 1; j < m; ++j) {
    			arr[i][j] = 0;

    			if (j + diff < 1 || j + diff >= m) {
    				continue;
    			}

    			if (i - diff < 1 || i - diff >= m) {
    				continue;
    			}

				if (s[i][j] == s[j + diff][i - diff]) {
					arr[i][j] = 1;
				}    				                 		
    		}
    	}

    	for (int i = 1; i < m; ++i) {
    		for (int j = 1; j < m; ++j) {
				arr[i][j] += arr[i - 1][j];
				arr[i][j] += arr[i][j - 1];
				arr[i][j] -= arr[i - 1][j - 1];    			
    		}
    	}

    	int l = 1 + max(0, diff);
    	int r = n + min(0, diff);

    	for (int sti = l; sti <= r; ++sti) {
    		ans += (rectSum(sti - 1, sti - diff - 1) == n * n);
    	}                                   
    }                      

    printf("%d\n", ans);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include<vector>
#include <list>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#include <tuple>
#include <string>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
#define FORk(N) for(int k=0;k<N;++k)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
void swap(ll &a,ll &b){
  ll tmp=a;
  a=b;
  b=tmp;
}
int main(){
  ll W,H,x,y;
  cin>>W>>H>>x>>y;
  cout<<W*H/2.0<<" ";
  if((W%2==0&&W/2==x)&&(H%2==0&&H/2==y)){
    cout<<1<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<stdio.h>
#include<stack>
#include<math.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,n) for(int i=1;i<=(n);i++)
#define LL long long int
#define MOD 1000000007
 
 
using namespace std;
 
LL lcm(LL n, LL m)
{
	LL u;
	LL ansl = 0;
	for(u=m; u>=m; u++){
		if(u%n == 0){
			if(u%m == 0){
				ansl = u;
				break;
			}
		}
	}
	return ansl;
}
 

int main(){
    int n,m,q;

    cin>>n>>m>>q;
        int a[52],b[52],c[52],d[q+1];
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    vector<int> i(11,1);
    int ans=0,D=0;
    for( i[0]=1;i[0]<=m ;i[0]++){
        for(i[1]=i[0];i[1]<=m ;i[1]++){
            for( i[2]=i[1];i[2]<=m ;i[2]++){
                for( i[3]=i[2];i[3]<=m ;i[3]++){
                    for( i[4]=i[3];i[4]<=m ;i[4]++){
                        for( i[5]=i[4];i[5]<=m ;i[5]++){
                            for( i[6]=i[5];i[6]<=m ;i[6]++){
                                for( i[7]=i[6];i[7]<=m;i[7]++){
                                    for( i[8]=i[7];i[8]<=m;i[8]++){
                                        for( i[9]=i[8];i[9]<=m;i[9]++){

                                            for(int h=0;h<q;h++){
                                                if(i[b[h]-1]-i[a[h]-1] == c[h]){
                                                    D+=d[h];
                                                }
                                                //cout<<i[b[h]-1]-i[a[h]-1] <<","<<c[h]<<"  ";
  
                                            }
                                            ans=max(ans,D);
                                            D=0;
                                            /*
                                            rep(f,10){
                                                cout<<i[f]<<" ";
                                            }
                                            cout<<ans<<endl;
                                            */

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

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

namespace AtCorder1
{
	class Program
	{
		static void Main(string[] args)
		{
			Console.WriteLine(Test(Console.ReadLine().ToList()));
		}

		private static String Test(IEnumerable<char> s)
		{
			var ls = new List<int>();
			var p = 0;
			do
			{
				var r = s.Skip(p).TakeWhile(t => t == 'R').Count();
				var l = s.Skip(p + r).TakeWhile(t => t == 'L').Count();
				int h = (r + l) / 2;
				if ((r + l) % 2 == 0)
				{
					ls.AddRange(Enumerable.Repeat(0, r - 1)
						.Append(h)
						.Append(h)
						.Concat(Enumerable.Repeat(0, l - 1)));
				}
				else
				{
					ls.AddRange(Enumerable.Repeat(0, r - 1)
						.Append(h + (r % 2))
						.Append(h + (l % 2))
						.Concat(Enumerable.Repeat(0, l - 1)));
				}
				p += r + l;
			} while (s.Count() != p);

			return String.Join(" ", ls);
		}
	}
}

Measured memory_bytes: 47196
#pragma region template
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a) \
    REP(i, (a).size()) { cout << (a[i]) << (i == (a).size() - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    vi A(N);
    REP(i, N) { cin >> A[i]; }
    vi acc(N + 1);
    REP(i, N) { acc[i + 1] = acc[i] + A[i]; }
    ll ans = INF;
    REP1(i, N)
    {
        ans = min(ans, abs(acc[i] - (acc[N] - acc[i])));
    }
    OUT(ans);
}
#pragma endregion template

Measured memory_bytes: 3328
import java.io.*;// 从这行开始复制，这是第一行
import java.util.*;

public class Main {

    /**
     * TODO 提交的时候一定要设置为 true
     */
    private boolean submitFlag = true;

    private void solve() {
        int ans = 0;


        System.out.println(ans);
    }


    private void run() throws IOException {
        setReader();

        //TODO 从这里开始读入题目输入


        int x = nextInt();
        int n = nextInt();
        boolean[] flag = new boolean[102];
//        int[] p = new int[n];

        for (int t = 0; t < n; t++) {
            int a = nextInt();
            flag[a] = true;
        }
        int ans = 0;
        for (int i = x; i > 0; i--) {
            if (flag[i] == false) {
                ans = i;
                break;
            }
        }

        for (int i = x; i < 102; i++) {
            if (flag[i] == false) {
                if (x - ans > i - x) {
                    ans = i;
                }
                break;
            }
        }
        System.out.println(ans);

    }


//    main以及输入输出========================================================================

    public static void main(String[] args) throws IOException {
        Main solution = new Main();
        solution.run();
        solution.reader.close();
    }

    /**
     * TODO 存档时，改一下moduleName
     */
    String moduleName = "atcoder-race";

    /**
     * 注意不同题目这里路径要设一下
     *
     * @throws IOException
     */
    private void setReader() throws IOException {
        if (submitFlag) {
            reader = new BufferedReader(new InputStreamReader(System.in));
        } else {
            String projectPath = System.getProperty("user.dir");
            String modulePath = projectPath + "/" + moduleName + "/src/main/java/";
            String className = this.getClass().getPackage().getName().replace(".", "\\");
            reader = new BufferedReader(new FileReader(modulePath + className + "\\input.txt"));
        }
    }

    private BufferedReader reader;
    private StringTokenizer tokenizer;

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String next() throws IOException {
        return nextToken();
    }

    private String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


Measured memory_bytes: 32752
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        int n;
        while(~getI(n)){
                int ans=0;
                FE(i,1,n){
                        if(i>=1&&i<=9) ans++;
                        if(i>=100&&i<=999) ans++;
                        if(i>=10000&&i<=99999) ans++;
                }
                printf("%d\n",ans);
        }
}

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

int main(){

    vector<int> a(5);
    int ans;
    
    for(int i=0;i<5;i++){
      cin>>a.at(i);
    }

    for(int i=0;i<5;i++){
        if(a.at(i)==0){
         ans=i+1;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>


using namespace std;


int f[12][12];

void dfs(int y, int x) {
  if (y < 0 || y > 11) {
    return;
  }
  if (x < 0 || x > 11) {
    return;
  }
  if (!f[y][x]) {
    return;
  }
  if (f[y][x]) {
    f[y][x] = 0;
  }

  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1 };

  for (int i = 0; i < 4; i++) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    dfs(ny, nx);
  }
}

int main() {
  while (true) {
    for (int i = 0; i < 12; i++) {
      string str;
      if (!(cin >> str)) {
        exit(EXIT_SUCCESS);        
      }
      for (int j = 0; j < 12; j++) {
        f[i][j] = str[j] - '0';
      }
    }
    int ans = 0;
    for (int i = 0; i < 12; i++) {
      for (int j = 0; j < 12; j++) {
        if (f[i][j]) {
          ans++;
          dfs(i, j);
        } 
      }
    }

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

Measured memory_bytes: 3072
/*
AizuOnline A0118
Property Distribution
*/
#include <stdio.h>
#include <stdlib.h>

int width = 10;
int height = 10;

char kajuen[100][101];

//char *owner[100];

char search_next(int * x,int * y)
{
  int i,j;
/* printf("SEARCH =%d %d\n",*x,*y); */
  i = *x;j = *y;goto START;
  for(i=*x+1;i<height;i++)
    for(j=0;j<width;j++)
      {
      START:
	if(kajuen[i][j] != '.')
	  { *x=i;*y=j;
	    return(kajuen[i][j]);
	  }
      }
  return(0);
}

void paint(int p,char f,int x,int y)
{
  //printf("P =%d %d %c\n",x,y,f); 
  kajuen[x][y]='.';
  if(x > 0)
    if(kajuen[x-1][y] == f)
      paint(p,f,x-1,y);
  if(y > 0)
    if(kajuen[x][y-1] == f)
      paint(p,f,x,y-1);
  if(x < height )
    if(kajuen[x+1][y] == f)
      paint(p,f,x+1,y);
  if(y < width)
    if(kajuen[x][y+1] == f )
      paint(p,f,x,y+1);
      
}
void display_input()
{
  int i,j;

  for(i=0;i<height;i++)
    {
      for(j=0;j<width;j++)
        printf("%c",kajuen[i][j]);
      printf("\n");
    }
}
 
int devide_kajuen()
{
  int x,y;
  int person;
  char f;
  
  x=0;y=0;
  person = 0;
  while(f=search_next(&x,&y) != 0)
    {   
      f = kajuen[x][y];
      //printf("SEARCH =%d %d %c\n",x,y,f); 
      
      paint(person,f,x,y);
      person ++;
    }
  return(person);
}

void clear_table()
{
  int i,j;
  for(i=0;i<100;i++)
      for(j=0;j<101;j++)
        kajuen[i][j]='\0';
}


main()
{
  int n;
  int i;
 
  while(EOF != scanf("%d %d",&height,&width) && (width || height))
    {
      clear_table();
      for(i=0;i<height;i++)
        {  scanf(" %s",&(kajuen[i][0]));
	}
      //display_input();
      n = devide_kajuen();
      printf("%d\n",n);
    }
return(0);
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

int main()
{
    int n, k;
    long long int x[100010];
    long long int ans = 1000000010;

    cin >> n >> k;

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

    for (int i = 0; i < n-k+1; i++) {
        long long int a = abs(x[i]) + abs(x[i+k-1]-x[i]);
        long long int b = abs(x[i+k-1]) + abs(x[i]-x[i+k-1]);
        ans = min(ans, min(a, b));
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 1024