akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	int a, b;
	
	cin >> a >> b;
	
	if( a <= 9 && b <= 9 ){
		cout << a * b << endl;
	}
	else{
		cout << -1 << endl;
	}
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
const ll MOD = 1000000007;
// const ll INF = 1000000000000000000LL;

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

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

int main(){
    int L;  cin >> L;
    int r = log2(L);
    vector<vector<int>> edge(r+1, vector<int>());
    for(int i=1; i<=r; i++){
        edge[i].push_back(0);
        edge[i].push_back(pow(2, i-1));
    }

    int M = 2*r;
    for(int i=r; i>=1; i--){
        int X = L - pow(2, i-1);
        if(X >= pow(2, r)){
            edge[i].push_back(X);
            L -= (L-X);
            M++;
        }
    }
    int N = r+1;
    cout << N << " " << M << endl;
    for(int i=1; i<=r; i++){
        int n = edge[i].size();
        for(int j=0; j<n; j++){
            cout << i << " " << (j<2 ? i+1:N) << " " << edge[i][j] << endl;
        }
    }
}


Measured memory_bytes: 384
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars,
        t: chars,
        a: usize,
        b: usize,
        u: chars
    }
    if s == u {
        println!("{} {}", a - 1, b);
    } else {
        println!("{} {}", a, b - 1);
    }
}


Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = inf;
	for (int ab = 0; ab <= 2 * max(x, y); ab += 2)
	{
		int tans = ab * c + max(x - ab / 2, 0) * a + max(y - ab / 2, 0) * b;
		ans = min(ans, tans);
	}
	cout << ans;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; ++i) {
        cin >> S[i];
    }
    vector<vector<int>> dp(H, vector<int>(W));
    dp[0][0] = 1;
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            if(S[i][j] == '#') continue;
            if(i - 1 >= 0) dp[i][j] += dp[i - 1][j];
            if(j - 1 >= 0) dp[i][j] += dp[i][j - 1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H - 1][W - 1] << '\n';
    return 0;
}


Measured memory_bytes: 5248
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
bool pr(long long n){
    for(long long i=2;i*i<=n;i++){
        if(n%i==0){
            return true;
        }
    }
    return false;
}
/*Main function*/
int main()
{
    long long n;bool k=0;
    cin>>n;
    k=pr(n);
    
    int di=0;
    if(k){
        
        map <long long,int> p;
        for(long long i=2;i<=sqrt(n+9);i++){
            while(n%i==0){
                n/=i;
                p[i]++;
            }
        }
        if(n>1) p[n]++;
        
        for(auto a:p){
            long long pn=a.first;
            long long np=a.second;
            //cout<<pn<<" "<<np;br;
            for(int i=1;i<=np;++i){
                di++;
                np-=i;
            }
        }
        cout<<di;br;
        
    }else if(n==1){
        cout<<0;br;
    }else{
        cout<<1;br;
    }
    
    
    return 0;
}


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

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

    if (S == "Sunny")
    {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy")
    {
        cout << "Rainy" << endl;
    } else
    {
        cout << "Sunny" << endl;
    }
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;
vector<int> v[200005];

vector<int> dj(int source,int n)
{
      vector<bool> check(n+1,false);
      vector<int> dist(n+1,INF);
      vector<int> prev(n+1,-1);
      priority_queue<pii> pq;
      dist[source]=0;
      pq.push({0,source});
      while(!pq.empty())
      {
            pii p=pq.top();
            pq.pop();
            int ind=p.s;
            int dist1=-p.f;
            if(check[ind])continue;
            check[ind]=true;
            for(auto it:v[ind])
            {
                  if(dist[ind]+1<dist[it])
                  {
                        dist[it]=dist[ind]+1;
                        prev[it]=ind;
                        pq.push({-dist[it],it});
                  }
            }
      }
      return prev;
}

int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
            int n,m;
            cin>>n>>m;
            rep(i,1,m+1)
            {
                  int x,y;
                  cin>>x>>y;
                  v[x].push_back(y);
                  v[y].push_back(x);
            }
            vector<int> prev=dj(1,n);
            rep(i,2,n+1)
            {
                  if(prev[i]==-1)
                  {
                        cout<<"No"<<endl;
                        return 0;
                  }
            }
            cout<<"Yes"<<endl;
            rep(i,2,n+1)cout<<prev[i]<<endl;         
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

Measured memory_bytes: 17292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;cin >> N;
	for(ll n=1;n<=3500;++n){
		for(ll w=1;w<=3500;++w){
			ll h=0;
			if(4*n*w-N*w-N*n>0 && n*w*N/(4*n*w-N*w-N*n)<=3500){
				h=n*w*N/(4*n*w-N*w-N*n);
				if(4*h*n*w/(n*w+h*w+h*n)==N){
					cout << h << " " << n << " " << w << endl;
					return 0;
				}
			}
		}
	}
}

Measured memory_bytes: 256
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()
}

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let line = read_as_vec::<i64>();

    let (a, b, k) = (line[0], line[1], line[2]);

    if a >= k{
        println!("{} {}", a-k, b);
        return;
    }

    println!("{} {}", 0, cmp::max(b-(k-a), 0));
}


Measured memory_bytes: 4352
#include<stdio.h>
#define SENTINEL 1000000000
#define N 500000
int c = 0;
void Merge(int A[],int left, int mid, int right){
  int n1, n2;
  n1 = mid - left;
  n2 = right - mid;
  int L[n1 + 1], R[n2 + 1];
  int i, j, k;
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    c++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void MergeSort(int A[], int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A, left, mid, right);
  }
}

int main(){
  int A[N], n, i;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }
  MergeSort(A, 0, n);
  for(i = 0; i < n; i++){
    printf("%d", A[i]);
    if(i < n - 1)printf(" ");
  }
  printf("\n%d\n", c);
  return 0;
}

Measured memory_bytes: 4508
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 10000000;
typedef double D;
const D EPS = 1e-9;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

typedef struct {
	double x, y;
} Point;

double rad(double deg)
{
	return deg*2*PI/360;
}

int sig(D a, D b) {
	if(a < b - EPS) return -1;
	if(a > b + EPS) return +1;
	return 0;
}

/** Problem0166 : Area of Polygon **/
double area(vector<Point> points)
{
	points.push_back(points[0]);
	
	double S=0;
	for (int i=0; i<points.size(); i++) {
		S += fabs(points[i].x*points[i+1].y - points[i+1].x*points[i].y);
	}
	
	return S/2;
}

int main()
{
	int M, N;
	while (cin>>M, M) {
		int angle=0;
		double S1=0;
		rep(k, M-1) {
			int t; cin>>t;
			angle+=t;
			S1 += sin(rad(t));
		}
		S1 += sin(rad(360-angle));
		
		angle=0;
		cin>>N;
		double S2=0;
		rep(k, N-1) {
			int t; cin>>t;
			angle+=t;
			S2 += sin(rad(t));
		}
		S2 += sin(rad(360-angle));
		
		if (sig(S1, S2)>0)
			cout << 1 << endl;
		else if (sig(S1, S2)==0)
			cout << 0 << endl;
		else
			cout << 2 << endl;
	}
}

Measured memory_bytes: 1200
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  ans = float('inf')
  N, A, B = map(int, input().split())
  mae = [list(map(int, input().split())) for _ in range((N+1)//2)]
  usiro = [list(map(int, input().split())) for _ in range(N-(N+1)//2)]
  if N==1:
    a,b,c = mae[0]
    if a*B==b*A:
      return c
    return -1
  mae_lis = [[float('inf')]*201 for _ in range(201)]
  mae_lis[0][0] = 0
  for p in product([0,1],repeat=(N+1)//2):
    a,b,c = 0,0,0
    for i in range((N+1)//2):
      if p[i]==1:
        a += mae[i][0];b += mae[i][1];c += mae[i][2]
    mae_lis[a][b] = min(mae_lis[a][b],c)
  usiro_lis = [[float('inf')]*201 for _ in range(201)]
  usiro_lis[0][0] = 0
  for p in product([0,1],repeat=N-(N+1)//2):
    a,b,c = 0,0,0
    for i in range(N-(N+1)//2):
      if p[i]==1:
        a += usiro[i][0];b += usiro[i][1];c += usiro[i][2]
    usiro_lis[a][b] = min(usiro_lis[a][b],c)
  for i in range(1,201):
    for j in range(1,201):
      c = mae_lis[i][j]
      if c==float('inf'):
        continue
      for k in range(201):
        if (i+k)*B%A!=0:
          continue
        l = (i+k)*B//A - j
        if l<0 or l>200 or usiro_lis[k][l]==float('inf'):
          continue
        ans = min(ans,c+usiro_lis[k][l])
  for k in range(1,201):
    if k*B%A!=0:
      continue
    l = k*B//A
    if l>200 or usiro_lis[k][l]==float('inf'):
      continue
    ans = min(ans,usiro_lis[k][l])
  return ans if ans<float('inf') else -1
print(solve())

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    set<int> ss;
    string s;
    cin >> s;

    bool f = true;

    if (s[0] != 'A')
        f = false;

    ss.insert(0);

    int cnt = 0;
    for (int i = 2; i < s.size() - 1; i++)
        if (s[i] == 'C')
        {
            cnt++;
            ss.insert(i);
        }
    if (cnt != 1)
        f = false;

    if (f)
    {
        for (int i = 0; i < s.size(); i++)
        {
            // cout << "a" << endl;
            if (ss.find(i) != ss.end())
            {
                continue;
            }
            if (s[i] > 'z' || s[i] < 'a')
                f = false;
        }
    }

    if (f)
        cout << "AC" << endl;
    else
    {
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<vector<ll>>c(3, vector<ll>(3));
	rep(i, 3) {
		rep(k, 3) {
			cin >> c[i][k];
		}
	}
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 101) {
				if ((c[0][0] - i == c[0][1] - j) &&(c[0][0] - i == c[0][2] - k)) {
					if ((c[1][0] - i == c[1][1] - j) && (c[1][0] - i == c[1][2] - k)) {
						if ((c[2][0] - i == c[2][1] - j) && (c[2][0] - i == c[2][2] - k)) {
							return cout << "Yes" << endl,0;
						}
					}
				}
			}
		}
	}
	return cout << "No" << endl, 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = (1..N).map { readLine()!!.toLong() }.sortedDescending()
    var result = 0L; var result2 = 0L
    if (N % 2 == 0) {
        for (i in 0 until (N / 2 - 1)) result += A[i] * 2
        result += A[N / 2 - 1]
        result -= A[N / 2]
        for (j in (N / 2 + 1) until N) result -= A[j] * 2
    } else {
        for (i in 0 until (N / 2 - 1)) result += A[i] * 2
        result += A[N / 2 - 1] + A[N / 2]
        for (j in (N / 2 + 1) until N) result -= A[j] * 2

        for (i in 0 until (N / 2)) result2 += A[i] * 2
        result2 -= A[N / 2] + A[N / 2 + 1]
        for (j in (N / 2 + 2) until N) result2 -= A[j] * 2
    }
    println(Math.max(result, result2))
}

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

using namespace std;

int main() {
  int N;
  string s, t;
  cin >> N >> s >> t;
  for (int i = N; i >= 0; --i)
    if (s.substr(N - i, i) == t.substr(0, i)) {
      cout << N * 2 - i << endl;
      break;
    }
  return 0;
}

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

using namespace std;
int main(void){
    int a,n,k,sum=0;
    vector<int> array;

    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a;
        array.push_back(a);
    }

    sort(array.begin(),array.end());
    reverse(array.begin(), array.end());

    for(int i=0; i<k;i++){
        sum+=array.at(i);
    }

    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	string s;
	cin>>s;
	int r = 0, g = 0, b = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'R')r++;
		if(s[i] == 'G')g++;
		if(s[i] == 'B')b++;
	}
	ll ans = r*1LL*g*b;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < i; j++){
			int k = 2*i - j;
			if(k >= n || s[i] == s[j] || s[j] == s[k] || s[i] == s[k])continue;
			ans--;
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3656
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi A(n);
  VIN(A)
  SORT(A);
  bool flg = true;
  REP(i,n-1){
    if(A[i]==A[i+1]) flg = false;
  }
  YES(flg);
}

Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n, W; cin>>n>>W;
    vector<int> v(n), w(n);
    for(int i=0; i<n; i++) cin>>v[i]>>w[i];

    vector<vector<ll>> dp(n+1, vector<ll>(10010, INF));
    dp[0][0] = 0;

    for(int i=0; i<n; i++){
        for(int j=0; j<=10000; j++){
            chmin(dp[i+1][j], dp[i][j]);

            if(j + v[i] <= 10000){
                dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
            }
        }
    }

    int ans = 0;
    for(int i=0; i<=10000; i++){
        if(dp[n][i] <= W) chmax(ans, i);
    }

    cout << ans << endl;
}


Measured memory_bytes: 10788
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	string s; cin >> s;
	if(s == "A")		puts("T");
	else if(s == "T")	puts("A");
	else if(s == "G")	puts("C");
	else if(s == "C")	puts("G");
}


Measured memory_bytes: 256
<?php

    fscanf(STDIN, "%d %d %d", $K, $a, $b);
    $add = $b - $a;
    if ($add < 3) {
    	echo $K + 1;
    	exit;
    }
    $count = $K - $a + 1;
    if ($count % 2 == 1) {
    	echo ($count - 1) / 2 * $add + $a + 1;
    }else{
    	echo $count / 2 * $add + $a;
    }

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

using namespace std;

#define int long long
#define sz(a) (int) (a).size()

int n;

vector<int> a;

void rec(int i = 0, int r = 0) {
    if (i == n) {
        for (int j = 0; j < n; j++) {
            cout << (char) (a[j] + 'a');
        }
        cout << "\n";
        return;
    }
    for (int j = 0; j < r; j++) {
        a.push_back(j);
        rec(i + 1, r);
        a.pop_back();
    }
    a.push_back(r);
    rec(i + 1,  r + 1);
    a.pop_back();
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n;
    rec();

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int64_t> Lucas(N + 1);
  
  Lucas.at(0) = 2;
  Lucas.at(1) = 1;
  
  if ( N > 1 ) {
    for ( int i = 2; i < N + 1; i++ ) {
        Lucas.at(i) = Lucas.at(i-1) + Lucas.at(i-2);
      }
    }
    
    cout << Lucas.at(N);
    
}

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

int main(){
    int N;
    cin >> N;
    int W[N];
    for(int n=0; n<N; n++){
        cin >> W[n];
    }
    int sum = 0;
    for(int n=0; n<N; n++){
        sum += W[n];
    }
    int res = 10000;
    int S1=0;
    for(int n=0; n<N; n++){
        S1 += W[n];
        int kouho = abs(sum - 2*S1);
        if(res > kouho) res = kouho;
    }
    cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#define inf 1000000000000000

using namespace std;
typedef pair<long long, long long> P;

long long N, M;
long long HP[105];
vector<P> sing, all;
long long dp_sing[100005], dp_all[100005];

void calc(long long dp[100005], vector<P> &vec)
{
	for(long long i = 0; i < 100005; i++) dp[i] = inf;
	dp[0] = 0;
	
	for(long long i = 0; i <= 100000; i++){
		for(long long j = 0; j < vec.size(); j++){
			if(i <= vec[j].second) dp[i] = min(dp[i], vec[j].first);
			else dp[i] = min(dp[i], dp[i-vec[j].second] + vec[j].first);
		}
	}
}

int main(void)
{
	while(1){
		cin >> N;
		if(N == 0) break;
		for(long long i = 0; i < N; i++) cin >> HP[i];
		
		cin >> M;
		
		string s, t;
		long long mp, dmg;
		
		sing.clear();
		all.clear();
		for(long long i = 0; i < M; i++){
			cin >> s >> mp >> t >> dmg;
			if(t == "Single") sing.push_back( make_pair(mp, dmg) );
			else all.push_back( make_pair(mp, dmg) );
		}
		
		calc(dp_sing, sing);
		calc(dp_all, all);
		
		long long sum, ans = inf;
		for(long long i = 0; i <= 100000; i++){
			sum = dp_all[i];
			for(long long j = 0; j < N; j++){
				if(HP[j] - i > 0) sum += dp_sing[ HP[j] - i ];
			}
			ans = min(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4724
#include <stdio.h>
int main(void)
{
  char s[20]={};
  int i,a,b,flag=1;
  scanf("%d%d%s",&a,&b,s);
  for(i=0;i<a+b+1;i++)
  {
    if(i!=a)
    {
      if(s[i]<'0' || s[i]>'9')
      {
        flag=0;
        break;
      }
    }
    else
    {
      if(s[i]!='-')
      {
        flag=0;
        break;
      }
    }
  }
  if(flag)
  {
    puts("Yes");
  }
  else
  {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String args[] ) {
		Scanner sc = new Scanner(System.in);
		
		String abcd = sc.next();
		int[] a = new int[4];
		
		a[0] = abcd.charAt(0)-'0';
		a[1] = abcd.charAt(1)-'0';
		a[2] = abcd.charAt(2)-'0';
		a[3] = abcd.charAt(3)-'0';

		char[] op = new char[3];
		for( int i = 0; i < (1<<3); i++ ) {
			int sum = a[0];
			for( int j = 0; j < 3; j++ ) {
				if( (1&(i>>j)) == 1 ) {
					sum += a[j+1];
					op[j] = '+';
				}
				else {
					sum -= a[j+1];
					op[j] = '-';
				}
			}
			
			if( sum == 7 ) {
				for( int j = 0; j < 4; j++ ) {
					if( j != 3 )
						System.out.print( a[j] + "" + op[j] );
					else
						System.out.println( a[j] + "=7" );
				}
				break;
			}
		}
		
		sc.close();
	}
}

Measured memory_bytes: 39112
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
typedef struct node * NodePointer;
NodePointer nil;
NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(1){
    if( cur == nil ) return NULL;
    if( cur->key == key ) return cur;
    cur = cur->next;
  }
}
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
void deleteNode(NodePointer t){
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
} 
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer t = nil->prev;
  if( t == nil ) return;
  deleteNode(t);
}
void delete(int key){
  NodePointer t;
  t=listSearch(key);
  if(t==NULL) return;
  deleteNode(t);
}
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->prev = nil;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
}
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
  printList();
  return 0;
}

Measured memory_bytes: 31784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
ll n;
cin >> n;
map<char, ll> mp;
for (ll i = 0; i < n;i++){
    string s;
    cin >> s;
    mp[s[0]]++;
}
ll ans = 0;
ans += mp['M'] * mp['A'] * mp['R'];
ans += mp['M'] * mp['A'] * mp['C'];
ans += mp['M'] * mp['A'] * mp['H'];
ans += mp['M'] * mp['R'] * mp['C'];
ans += mp['M'] * mp['R'] * mp['H'];
ans += mp['M'] * mp['C'] * mp['H'];
ans += mp['A'] * mp['R'] * mp['C'];
ans += mp['A'] * mp['R'] * mp['H'];
ans += mp['A'] * mp['C'] * mp['H'];
ans += mp['R'] * mp['C'] * mp['H'];
cout << ans << endl;
}

Measured memory_bytes: 3620
($H,$W,$h,$w)=glob<>;
if($H%$h|$W%$w){
	print'Yes';
	for$y(1..$H){
		for$x(1..$W){
			print$",~-$x%$w|~-$y%$h?$x%$w|$y%$h?0:-1e9:9x9
		}
	}
}else{
	print'No'
}


Measured memory_bytes: 3456
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	A, B := nextInt()-1, nextInt()-1
	fmt.Println((A + B - 1) / A)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


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

ll n, k;
ll cnt[45];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;
    
    multiset<ll> val;
    for (int i = 0; i < n; ++i) {
        ll sum = 0;
        for (int j = i; j < n; ++j) {
            sum += a[j];
            for (int l = 0; l < 45; ++l) {
                if (sum & (1ll << l)) ++cnt[l];
            }
            val.insert(sum);
        }
    }
    
    ll taken = 0, tot = 0;
    for (int i = 44; i >= 0; --i) {
        // cout << i << ' ' << cnt[i] << '\n';
        // if (taken == k) break;
        if (cnt[i] >= k) {
            ++taken;
            tot += (1ll << i);

            auto it = val.begin();
            while (it != val.end()) {
                if (!(*it & (1ll << i))) {
                    for (int j = 0; j < 45; ++j) {
                        if (*it & (1ll << j)) 
                            --cnt[j];
                    }
                    it = val.erase(it);
                } else ++it;
            }
        }
    }
    cout << tot;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

  int K;
  cin >> K;
  bool ok = false;
  int A, B;
  cin >> A >> B;
  rep(i, A, B+1) {
    if (i % K == 0) {
      ok = true;
      break;
    }
  }

  if (ok) {
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }

  return 0;
};


Measured memory_bytes: 3648
#include<stdio.h>

int main(void)
{
  int d;
  scanf("%d",&d);

  switch (d)
  {
    case 22:
    printf("Christmas Eve Eve Eve");
    break;
    case 23:
    printf("Christmas Eve Eve");
    break;
    case 24:
    printf("Christmas Eve");
    break;
    case 25:
    printf("Christmas");

    
  }

  return 0;
}

Measured memory_bytes: 128
from collections import Counter
*W, = map(ord, input())
N = len(W)

C = Counter(W)
if len(C) == 1:
    print(N)
    print(1)
    exit(0)

def z_algo(S):
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        A[i] = j
        if not j:
            i += 1
            continue
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

def calc(W):
    Z = z_algo(W)
    G = [0]*N
    for i in range(N):
        G[i] = 1
    for p in range(1, N):
        if not G[p-1]:
            continue
        for k in range(2, Z[p]//p+2):
            G[k*p-1] = 0
    return G
G0 = calc(W)
W.reverse()
G1 = calc(W)

if G0[N-1]:
    print(1)
    print(1)
    exit(0)

print(2)
print(sum(p and q for p, q in zip(G0[:-1], reversed(G1[:-1]))))

Measured memory_bytes: 35248
n = int(input())
D = [[*map(int, input().split())] for _ in range(n)]
# print(n)
# print(D)

# ans = True
c = 0
for x, y in D:
    # print(x,y)
    if x==y:c+=1
    else: c = 0
    if c == 3: break

print('Yes' if c>=3 else 'No')


Measured memory_bytes: 9164
n, m = map(int, input().split())
l = [0 for _ in range(n+1)]
ans = 0
penalty = 0
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if l[p] >= 0:
        if s == 'WA':
            l[p] += 1
        else:
            ans += 1
            penalty += l[p]
            l[p] = -1
print(ans, penalty)

Measured memory_bytes: 3888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//

void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec (N,0);
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
     SUM += abs(vec[i]);
  }
  sort(ALL(vec));
  if(vec.front() > 0)SUM -= vec.front()*2;
  if(vec.back() < 0)SUM += vec.back()*2;
  cout<<SUM<<endl;
  int ACC = vec.front();
  for (int i = 1; i < N-1; i++)
  {
    if(vec[i] >= 0)
    {
      cout<<ACC<<" "<<vec[i]<<endl;
      ACC -=vec[i];
    }
  }
  cout<<vec.back()<<" "<<ACC<<endl;
  ACC = vec.back() - ACC;
  for (int i = 1; i < N - 1; i++)
  {
    if(vec[i] < 0)
    {
      cout<<ACC<<" "<<vec[i]<<endl;
      ACC -=vec[i];
    }
  }
  
  
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 2688
import fractions
N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, pow(b,mod-2,mod))
if N == 1:
    ans = 1
else:
    lcm = A[0] * A[1] // fractions.gcd(A[0],A[1])
    for i in range(2,N):
        #lcm = div((lcm * A[i]),fractions.gcd(lcm,A[i]))
        lcm = lcm * A[i] // fractions.gcd(lcm,A[i])
    ans = 0
    for i in range(N):
        b = div(lcm,A[i])
        ans += b 
        ans %= mod 
    #print(ans)
    #print(lcm)
print(ans)


Measured memory_bytes: 6112
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (H, W) = input_tuple();
    let (h, w) = input_tuple();
    println!("{}", (H-h)*(W-w));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e6+5,MAX=3e7,MOD=1e9+7;

using namespace std;

int n,a[N];
int dp[N];
int main(){
   // #ifndef ONLINE_JUDGE
     //   freopen("test.txt","r",stdin);
    //#endif
   
     scanf("%d",&n);


     for(int i=0;i<N;i++)dp[i]=1e9;

     for(int i=0;i<n;i++)scanf("%d",&a[i]);
     dp[0]=0;
     for(int i=0;i<n-1;i++){

     	 dp[i+2] = min(dp[i+2],dp[i]+abs(a[i+2]-a[i]));
     	 dp[i+1] = min(dp[i+1],dp[i]+abs(a[i+1]-a[i]));
     }

     printf("%d\n",dp[n-1] );
}

Measured memory_bytes: 6400
n, k = io.read("*n", "*n")
t = {}
for i = 1, n do
    a = io.read("*n")
    if(t[a] == nil) then t[a] = 1 else t[a] = t[a] + 1 end
end
tall = {}
for k, v in pairs(t) do
    table.insert(tall, v)
end
table.sort(tall)
tot = 0
remcount = #tall - k
for i = 1, remcount do
    tot = tot + tall[i]
end
print(tot)

Measured memory_bytes: 4524
import java.util.Scanner;

public class Main {

    private final static Scanner sc = new Scanner(System.in);

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        String s = nextString();

        for (int i = 0; i < s.length(); i += 2) {
            System.out.print(s.charAt(i));
        }

        System.out.println();
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt() {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString() {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }
}

Measured memory_bytes: 30704