akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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, 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!{
        n: usize,
        mut xy: [(i64, i64); n],
    }
    if n == 1 {
        println!("1");
        return;
    }
    let mut cst = 0;
    xy.sort();
    let mut diffs = HashMap::new();

    for i in 0..n {
        for j in i+1..n {
            *diffs.entry((xy[i].0 - xy[j].0, xy[i].1 - xy[j].1)).or_insert(0) += 1;
        }
    }
    let mut cnts = vec![];
    for ((_, _), v) in diffs {
        cnts.push(v);
    }
    cnts.sort();
    cnts.reverse();

    println!("{}", cst + n - cnts[0]);
}

Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;

#define ll long long
#define rep(i,n) for(int i = 0;i < (n); i++)

int main() {
	int x;
	cin >> x;
	if (x == 1)cout << 0 << endl;
	else cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char s[2010][2010];

int n, m;
int a[2010][2010];

int sp[2010];
int hi[2010];
int top;

void Init(){
	top=0;
}

int ans;

void Feed(int i, int x){
	if(top == 0){
		sp[top]=i;
		hi[top]=x;
		++top;
		return;
	}
	int lp=i;
	while(top && hi[top-1] >= x){
		lp=sp[top-1];
		if(hi[top-1]) ans = max(ans, (hi[top-1]+1)*(i-sp[top-1]+1));
		--top;
	}
	sp[top]=lp;
	hi[top]=x;
	++top;
}

int main()
{
	read(n, m);
	for(int i=1; i<=n; ++i){
		scanf("%s", s[i]+1);
		for(int j=1; j<=m; ++j){
			s[i][j]=(s[i][j]=='#');
		}
	}
	for(int i=1; i<n; ++i){
		for(int j=1; j<m; ++j){
			a[i][j]=1-(s[i][j]+s[i+1][j]+s[i][j+1]+s[i+1][j+1])%2;
			if(a[i][j]) a[i][j]+=a[i][j-1];
		}
	}
	for(int j=1; j<m; ++j){
		Init();
		Feed(0, 0);
		for(int i=1; i<n; ++i) Feed(i, a[i][j]);
		Feed(n, 0);
	}
	ans = max({ans, n, m});
	printf("%d\n", ans);
	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int s_size = s.size();
  if(s_size%2 != 0){
  	cout << "No" << endl;
    return 0;
  }else{
    for(int i=0;i<s_size/2;i++){
      if( s.at(i) != s.at(s_size/2+i) ){
        cout << "No" <<endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
     
    public class Main {
        public static void main(String[] args){
            // Your code here!
            Scanner sc = new Scanner(System.in);
            
            int N = sc.nextInt();
            
            int result = 0;
            int maxCount = 0;
            
            for(int i = 1; i <= N; i++){
                
                int count = 0;
                int num = i;
                
                while((num % 2) == 0){
                    count++;
                    num = num/2;
                }
                if(count >= maxCount){
                    maxCount = count;
                    result = i;
                }
            }
            
            System.out.println(result);
            
        }
        
    }

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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;

  cout << W * H / 2.0 << " ";
  if (!(W & 1) && !(H & 1) && x == W / 2 && y == H / 2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const LL maxn = 35;

int n, m, k, a, vis[maxn];
int main()
{
    int ans = 0;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> k;
        for(int j = 1; j <= k; j++)
            cin >> a, vis[a]++;
    }
    for(int i = 1; i <= m; i++)
        if(vis[i]==n)
            ans++;
    cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
function Main(arg) {
 
    var N = arg.split("\n")[0].split(" ")[0]-0;
    var K = arg.split("\n")[0].split(" ")[1]-0;
    var Q = arg.split("\n")[0].split(" ")[2]-0;

    var A = arg.split("\n").slice(1);

    var score = new Array(N);
    score.fill(0);

    for (var i = 0; i < Q; i++){
        score[A[i] - 1]++;
    }

    for (var i = 0; i < N; i++){
        var tmp = K - (Q - score[i]);
        
        console.log(tmp > 0? "Yes" : "No");
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 50996
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 300500; //       e5
//const int SZ = 2100;
//const int delta = 1 << 19;

long long dp1[MX];
long long dp2[MX];
int a[MX];

void go(int n, int dx, int *a, long long *dp){
    priority_queue<int> q;
    long long sum = 0;
    for(int i = 0; i < n; i++){
        q.push(a[i] * dx);
        sum += a[i];
    }
    dp[n - 1] = sum;
    for(int i = n; i < 3 * n; i++){
        sum += a[i];
        q.push(a[i] * dx);

        sum -= dx * q.top();
        q.pop();

        dp[i] = sum;
    }
}

void dump(int n){
    for(int i = 0; i < 3 * n; i++){
        cout << dp1[i] << ' ';
    }
    cout << endl;
    for(int i = 0; i < 3 * n; i++){
        cout << dp2[i] << ' ';
    }
    cout << endl;

}

int main()
{
    ios_base::sync_with_stdio(false);
    //if(debug)
//freopen("/Users/ozzy/Documents/in.txt","r", stdin);
//    freopen("/Users/ozzy/Documents/C-small-attempt1.in.txt","r", stdin);
//freopen("/Users/ozzy/Documents/out.txt","w", stdout);
    int n;
    cin >> n;
    for(int i = 0; i < 3 * n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < 3 * n; i++){
        dp2[i] = infLL;
    }

    go(n, -1, a, dp1);
    reverse(a, a + 3 * n);
    go(n, 1, a, dp2);
    reverse(a, a + 3 * n);
    reverse(dp2, dp2 + 3 * n);

    //dump(n);

    long long ans = -infLL;
    for(int i = n - 1; i < 2 * n; i++){
        long long s = dp1[i] - dp2[i + 1];
        if(s > ans) ans = s;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6776
def main():
    N, K = map(int, input().split())
    S = input()

    counts = [0]
    last = "1"
    for s in S:
        if s == last:
            counts[-1] += 1
        else:
            counts += [1]
            last = s
    if S[-1] == "0":
        counts += [0]
    l, r = 0, K * 2 + 1
    max_c = sum(counts[l:r])
    current_c = max_c
    while r < len(counts):
        current_c -= (counts[l] + counts[l + 1])
        l += 2
        current_c += (counts[r] + counts[r + 1])
        r += 2
        max_c = max(max_c, current_c)
    print(max_c)

main()


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

class PriorityQueue {
  vll heap;

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

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

  int right(int i1) {
    return i1 * 2 + 1;
  }
  
  void increase_key(int i, ll key) {
    if (key < heap[i]) return;

    heap[i] = key;
    int p = parent(i);
    while (i > 1 && heap[p] < heap[i]) {
      swap(heap[i], heap[p]);
      i = p;
      p = parent(i);
    }
  }

  void max_heapify(int i) {
    int l = left(i), r = right(i), largest = i;

    if (l < (int)heap.size() && heap[l] > heap[i]) largest = l;
    if (r < (int)heap.size() && heap[r] > heap[largest]) largest = r;

    if (largest != i) {
      swap(heap[i], heap[largest]);
      max_heapify(largest);
    }
  }
  
public:
  PriorityQueue() {
    heap.push_back(-1);
  }

  void insert(ll key) {
    heap.push_back(-LLONG_MAX);
    increase_key(heap.size() - 1, key);
  }

  ll extract_max() {
    if (heap.size() < 1) return -1;

    ll max = heap[1];
    heap[1] = heap[heap.size() - 1];
    heap.pop_back();
    max_heapify(1);

    return max;
  }
};

int main() {
  char cmd[100];

  auto q = PriorityQueue();
  do {
    scanf("%s", cmd);
    
    if (cmd[0] == 'i') {
      ll key;
      scanf("%lld", &key);
      q.insert(key);
    } else if (cmd[1] == 'x') {
      printf("%lld\n", q.extract_max());
    }
  } while (cmd[2] != 'd');
}



Measured memory_bytes: 11236
"""
https://atcoder.jp/contests/abc136/tasks/abc136_a
"""

import numpy as np


def calc(A: int, B: int, C: int) -> int:
    irerareru = clamp(A - B, 0, C)
    return C - irerareru


def clamp(value: int, min_: int, max_: int) -> int:
    return min(max_, max(min_, value))


def load_input_as_int_array() -> np.ndarray:
    return np.array([int(v) for v in input().split(" ")])


def main() -> None:
    A, B, C = load_input_as_int_array()
    result = calc(A, B, C)
    print(result)


main()


Measured memory_bytes: 21436
S = input() # S_i = B(lack) or W(hite)
N = len(S)

"""
    最終的には W..W...B...B のような並びになる。
    元の状態から B がどれだけ右に進んだかの総和が答え。
"""

""" White version """
cnt_initial = 0
cnt_w = 0
for i in range(N):
    if S[i] == 'W':
        cnt_initial += i
        cnt_w += 1
ans = cnt_initial - sum([i for i in range(cnt_w)])


""" Black version """

# def sum_contin_int(l, r):
#     return (r * (r + 1) - l * (l - 1)) // 2

# cnt_initial = 0
# cnt_b = 0
# for i in range(N):
#     if S[i] == 'B':
#         cnt_initial += i
#         cnt_b += 1

# # cnt_final = sum_contin_int(N - cnt_b, N - 1)
# cnt_final = sum([i for i in range(N - cnt_b, N)])

# ans = cnt_final - cnt_initial
print(ans)

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

ll mp[555][555];
void dfs(int l, int r, int num){
	//cout << "dfs " << l << " " << r << " " << num << endl;
	if(r - l <= 1){
		mp[l][r] = num;
		mp[r][l] = num;
		return;
	}
	int mid = (l + r) / 2;
	for(int i = l;i <= mid;i++){
		for(int j = mid+1;j <= r;j++){
			mp[i][j] = num;
			mp[j][i] = num;
		}
	}
	dfs(l, mid, num + 1);
	dfs(mid + 1, r, num + 1);
}

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll n;cin >> n;
	dfs(0, n-1, 1);
	REP(i, n-1){
		REP(j, n){
			if(i < j)cout << mp[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}


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

int main () {
  int N, K;
  cin >> N >> K;
  int L = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (K - x > x) {
      L += 2*x;
    }
    else {
      L += 2*(K - x);
    }
  }
  cout << L << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class CompareFirst{ public:
        bool operator()(P n1, P n2) {
            return n1.first > n2.first; // 昇順
        }
};

void Main() {
    ll N;
    cin >> N;
    priority_queue<P, vector<P>, CompareFirst> q;
    rep(i, N){
        ll a, b;
        cin >> a >> b;
        // q.push(make_pair(b - a, a)); // (最悪開始時間, 所要時間)
        q.push(make_pair(b, a)); // (最悪開始時間, 所要時間)
    }
    bool flag = true;
    ll time = 0;
    while (q.size() > 0){
        auto p = q.top();
        q.pop();
        if (time + p.second > p.first){
            flag = false;
            break;
        } else {
            time += p.second;
        }
        // cout << p.first << " " << p.second << endl;
    }
    if (flag) {cout << "Yes" << endl;} else {cout << "No" << endl;}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];
  int M;
  cin >> M;
  vector<string > t(M);
  for (int i = 0; i < M; i++) cin >> t[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int money = 0;
    for (int j = 0; j < N; j++) {
      if (s[i] == s[j]) money++;
    }
    for (int j = 0; j < M; j++) {
      if (s[i] == t[j]) money--;
    }
    ans = max(ans, money);
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
using vi = vector<int>;
using vll = vector<ll>;
const ll INF = 1LL<<60;

int main(){
  string s; cin >> s;
  bool flg = true;
  if(s[0] != 'A') flg = false;
  int c = 0;
  for(int i = 2; i < s.size()-1; i++){
    if(s[i] == 'C') c++;
  }
  if(c != 1) flg = false;
  c = 0;
  for(int i = 0; i < s.size(); i++){
    if('A' <= s[i] && s[i] <= 'Z') c++;
  }
  if(c != 2) flg = false;
  if(flg) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

//++時計回り --反時計回り
// int dx[4] = {1, 0, -1, 0};
// int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  cout << N * N * N << '\n';
}


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

signed main() {
    int n,m;
    cin >> n >> m;
    vector<P> v;
    rep(i,n){
        int a;
        cin >> a;
        v.push_back({a,1});
    }
    rep(i,m){
        int b,c;
        cin >> b >> c;
        v.push_back({c,b});
    }

    sort(v.begin(),v.end(),greater<P>());
    int count=0;
    int sum=0;
    for(auto x:v){
        if(x.second+count<=n){
            count+=x.second;
            sum+=x.first*x.second;
        }
        else{
            sum+=x.first*(n-count);
            break;
        }
    }
    cout << sum << endl;
}

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

ans = 0
if X == 1:
    ans += 300000
elif X == 2:
    ans += 200000
elif X == 3:
    ans += 100000

if Y == 1:
    ans += 300000
elif Y == 2:
    ans += 200000
elif Y == 3:
    ans += 100000

if X == 1 and Y == 1:
    ans += 400000
    
print(ans)

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

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

  vector<vector<int>> G(N,vector<int>(0));
  for(int i = 0;i < M;i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  queue<int> Q;
  vector<int> ans(N,0),seen(N,0);
  Q.push(0);
  seen[0] = 1;

  while(!Q.empty()) {
    int q = Q.front();
    Q.pop();
    for(int nv: G[q]) {
      if(seen[nv]) continue;
      seen[nv] = 1;
      ans[nv] = q;
      Q.push(nv);
    }
  }

  cout << "Yes" << endl;
  for(int i = 1;i < N;i++) {
    cout << ans[i]+1 << endl;
  }
  

}


Measured memory_bytes: 10652
def foo(infile, outfile, n):
    mapping = {}
    for i in range(n):
        a, b = infile.readline().split()
        mapping[a]=b
    m = int(infile.readline())

    for j in xrange(m):
        x = infile.readline().split()[0]
        outfile.write(mapping.get(x, x))
    print >> outfile


def run(infile, outfile):
    while True:
        n = int(infile.readline())
        if n == 0:
            break
        foo(infile, outfile, n)


if __name__ == "__main__":
    import sys
    run(sys.stdin, sys.stdout)

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

int main() {
    int n;
    cin >> n;
    n = n % 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon" << endl;
    } else if (n == 0 || n == 1 || n == 6 || n == 8) {
        cout << "pon" << endl;
    } else {
        cout << "bon" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N];
		A[0] = stdIn.nextInt();
		int min = A[0];
		int max = A[0];
		for(int i = 1; i < N; i++) {
			A[i] = stdIn.nextInt();
			if(A[i] < min) {
				min = A[i];
			}
			else if(A[i] > max) {
				max = A[i];
			}
		}
		System.out.println(max-min);

	}

}

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

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

	if (n % 2)
	{
		cout << "No" << '\n';
		return 0;
	}

	for (int i = 0; i < n / 2; i++)
		if (s[i] != s[i + n / 2])
		{
			cout << "No" << '\n';
			return 0;
		}

	cout << "Yes" << '\n';

	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    queue<int> q;
    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        q.push(a);
    }
    int b = 1,c = 0;
    for(int i = 0;i < n;i++){
        //cout << q.front() << " ";
        if(q.front() == b){
            //cout << i << " ";
            b++;
        } else if(q.front() != b){
            //cout << q.front() << " ";
            c++;
        }
        q.pop();
    }
    if(c == n)cout << -1;
    else cout << c;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n;
    cin>>n;
    double a,sum=0;

    for(int i=0;i<n;i++)
    {
        cin>>a;
        sum+=1.0/a;
    }
    cout<<1.0/sum<<endl;
    exit(0);
}


Measured memory_bytes: 3796
# import numpy as np
import math

# S = list(input())
n = int(input())
# a, b, c, d = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(n)]

S = sorted(S, key=lambda x: x[1])

jobs = 0

for i in range(n):
    jobs += S[i][0]
    if jobs <= S[i][1]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 55240
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
	int H,W;
	cin >> H >> W;
	string S[110];
	int dist[110][110];
	int wsum = 0;
	for(int i=0;i<H;i++){
		cin >> S[i];
		for(int j=0;j<W;j++){
			if(S[i][j]=='.') wsum++;
		}
	}
	memset(dist, -1, sizeof(dist));
	dist[0][0] = 1;
	queue<pii> que;
	que.push(make_pair(0, 0));
	while(!que.empty()){
		pii cur = que.front();que.pop();
		int x = cur.first, y = cur.second;
		for(int dir=0;dir<4;dir++){
			int nx = x + dx[dir], ny = y + dy[dir];
			if(nx<0 || nx >= H || ny < 0 || ny >= W) continue;
			if(S[nx][ny]=='#') continue;
			if(dist[nx][ny] == -1){
				dist[nx][ny] = dist[x][y] + 1;
				que.push(pii(nx, ny));
			}
		}
	}

	if(dist[H-1][W-1] == -1) cout << -1 << endl;
	else cout << wsum - dist[H-1][W-1] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd

string s;

int main(){
    cin >> s;
    s[3]='8';
    cout << s;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      string a;
      cin >> a;
      if (a == "snuke") {
        cout << (char)(j + 'A') << 1 + i;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
//abc070_a.cpp
//

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (n/100 == n%10){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
# A,B = map(int, input().split())
# C,D = map(int, input().split())
N = int(input())
S = str(N)

if len(S)>=3:
    shimo2 = int(S[-2:])
    hoka = int(S[:-2])

    count = 0
    while shimo2>0:
        if shimo2 >= 5:
            shimo2 -= 5
            count += 1
        elif shimo2 >= 4:
            shimo2 -= 4
            count += 1
        elif shimo2 >= 3:
            shimo2 -= 3
            count += 1
        elif shimo2 >= 2:
            shimo2 -= 2
            count += 1
        elif shimo2 >= 1:
            shimo2 -= 1
            count += 1
            
    if hoka >= count:
        ans = 1
    else:
        ans = 0
else:
    ans = 0

print(ans)


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

int main(){
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>

using namespace std;

long long int maxmin(long long int a, long long int l) {
	int b[10] = { 0 };
	int c = 0;
	while (a != 0) {
		b[a % 10]++;
		a /= 10;
		c++;
	}
	b[0] += (l - c);
	long long int MAX = 0;
	long long int MIN = 0;
	for (int i = 9; i >= 0; i--) {
		for (int j = 0; j < b[i]; j++) {
			MAX *= 10;
			MAX += i;
		}
	}
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < b[i]; j++) {
			MIN *= 10;
			MIN += i;
		}
	}
	return MAX - MIN;
}

int main() {

	long long int a, l;
	while (cin >> a >> l) {
		if (a == 0 && l == 0) {
			break;
		}
		set<long long int> st;
		map<long long int, long long int> mp;
		st.insert(a);
		mp[a] = 0;
		long long int ans = 0;
		while (true) {
			ans++;
			long long int a2 = maxmin(a, l);
			a = a2;
			if (st.find(a) != st.end()) {
				break;
			}
			st.insert(a);
			mp[a] = ans;
		}
		cout << mp[a] << ' ' << a << ' ' << ans-mp[a] << endl;
	}

	return 0;
}


Measured memory_bytes: 3100
import copy
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
all_city = list()
for i in range(m):
    py = list(map(int, input().split()))
    py.append(i)
    all_city.append(py)
ac_list = copy.deepcopy(all_city)
ac_list.sort()
ac_dict = {}
a = 0
b = 0
for i in range(m):
    if ac_list[i][0] == a:
        b += 1
    else:
        a = ac_list[i][0]
        b = 1
    ac_dict[ac_list[i][2]] = str(str(a).zfill(6) + str(b).zfill(6))
for i in range(m):
    print(ac_dict.get(all_city[i][2]))


Measured memory_bytes: 58856
X = int(input())
L = [1]
for i in range(2, 32):
	j = 2
	while True:
		if i ** j > 1000:
			break
		else:
			if L.count(i ** j) == 0:
				L.append(i ** j)
			j += 1
L = sorted(L)

ans = 1
for i in L:
	if X >= i:
		ans = i
	else:
		break

print(ans)

Measured memory_bytes: 3064
<?php
fscanf(STDIN,'%d%d%d%d',$A,$B,$C,$D);
if($B<=$C||$D<=$A){
  echo 0;
}else{
  if($C<=$A&&$B<=$D){
    echo $B-$A;
  }elseif($A<=$C&&$D<=$B){
     echo $D-$C;
  }else{
    if($A<=$C){
    echo $B-$C;
  }else{
    echo $D-$A;
  }
  }
}
 ?>


Measured memory_bytes: 3576
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            //縦 a cm,横 b cmの長方形の面積と周の長さを求める

            string[] str = Console.ReadLine().Split(' ');           //String.Splitメソッド
                                                                    //文字列を指定した区切り文字で分割し、配列に格納する
            int a = int.Parse(str[0]);
            int b = int.Parse(str[1]);

            Console.WriteLine(a * b + " " + (a + b) * 2);

            Console.ReadKey();
        }
    }
}



Measured memory_bytes: 17896
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    ll X;
    cin>>X;
    double a=100;
    for(int i=0;;i++){
        a*=1.01;
        a=floor(a);
        //cout<<a<<endl;
        
        if(a>=X){
            cout<<i+1<<endl;
            break;
        }
        
    }
    return 0;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	ps := scanIntSlice(n)

	count := 1
	min := ps[0]
	for _, p := range ps[1:] {
		if p <= min {
			min = p
			count++
		}
	}

	fmt.Printf("%d\n", count)
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 7424
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
  while(true) {
    int N; cin >> N;
    if(N == 0) break;
    int W, H; cin >> W >> H;
    int F[W][H];
    memset(F, 0, sizeof(F));
    for(int i = 0; i < N; ++i) {
      int x, y; cin >> x >> y;
      x--, y--;
      F[x][y] = 1;
    }
    int S, T; cin >> S >> T;
    int G[W+1][H+1];
    memset(G, 0, sizeof(G));
    for(int y = 1; y <= H; ++y) {
      for(int x = 1; x <= W; ++x) {
        G[x][y] = G[x-1][y] + G[x][y-1] - G[x-1][y-1] + F[x-1][y-1];
        // cerr << "G(" << y << "," << x << ") = " << G[x][y] << endl;
      }
    }
    int ans = 0;
    for(int y = T; y <= H; ++y) {
      for(int x = S; x <= W; ++x) {
        ans = max(ans, G[x][y] - G[x-S][y] - G[x][y-T] + G[x-S][y-T]);
      }
    }
    cout << ans << endl;
  }
}

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

#define ll long long
#define ld long long
#define M 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

struct st {
	vector<ll> mv, arr;
};

int main() {
    fast;
	ll n;
	cin >> n;
	vector<ll> b(n), ans;
	for (auto &i: b)
		cin >> i;
    int p = 1;
	for (ll i = 1; i <= n; i++) {
        ll m = 0;
        for (ll j = 0; j < b.size(); j++) {
            if (b[j] == j+1 && b[j] > m) 
                m = b[j];
        }
        if (!m) {
            p = 0;
            break;
        }
        else {
            ans.push_back(m);
            b.erase(b.begin() + m - 1);
        }
    }
    if (p) {
        for (ll i = ans.size() - 1; i >= 0; i--)
            cout << ans[i] << endl;
    }
    else 
        cout << -1 << endl;
	return 0;
}


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

int main() {
	int N,x;
	cin >> N;
	x = N;
	for (;N > 0;N--) {
		int l, r;
		cin >> l >> r;
		x = x - l + r;
	}
	cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}

int n, c[600][600];
void color(int alp, int id) {
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			c[i][j]+=((i+(~alp&1)*j)>>(alp/2)&1)<<id;
}
int main() {
	int d1, d2, cnt[4]={};
	assert(scanf("%d%d%d", &n, &d1, &d2)==3);
	n*=2;
	color(__builtin_ctz(d1), 0);
	color(__builtin_ctz(d2), 1);
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j) ++cnt[c[i][j]];
	int maj=std::max_element(cnt, cnt+4)-cnt, cur=0;
	for(int i=0; i<n; ++i)
		for(int j=0; j<n; ++j)
			if(c[i][j]==maj) {
				printf("%d %d\n", i, j);
				if(++cur==n*n/4) return 0;
			}
	return 0;
}


Measured memory_bytes: 2304
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
A = Counter(A)

p = []
l = []
for k, v in A.items():
    if v >= 4:
        p.append(k)
    if v >= 2:
        l.append(k)

ans = 0
if len(p) >= 1:
    p.sort()
    ans = p[-1]**2
if len(l) >= 2:
    l.sort()
    ans = max(l[-1] * l[-2], ans)
print(ans)

Measured memory_bytes: 18600
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var KS = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (K, S) = (KS[0], KS[1]);
            var answer = 0;
            for (var x = 0; x <= K; x++)
            {
                for (var y = 0; y <= K; y++)
                {
                    var z = S - x - y;
                    if (z >= 0 && z <= K) answer++;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n,a,b,c,d; cin >> n >> a >> b >> c>>d;
    string s;
    cin >> s;
    bool can1 = 1, can2 = 1;
    if(d < c) {  //aが超えないといけない
        can1 = 0;
        if(a+1==b) {

        }
        else for(int i = b-1-1; i < d-1; ++i) {
            if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') can1 = 1;
        }
    }
    for(int i = a-1; i < d-1-1; ++i)  {
        if(s[i] == '#' && s[i+1] == '#') can2 = 0;
    }

    cout << (can1&&can2 ? "Yes" : "No") << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}

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

void main_()
{
    ll N;
    vector<ll> Xs;
    cin >> N;
    copy_n(istream_iterator<ll>(cin), N, back_inserter(Xs));

    vector<ll> v(N / 2 + 1);
    partial_sort_copy(begin(Xs), end(Xs), begin(v), end(v));
    auto a1 = v[N / 2 - 1];
    auto a2 = v[N / 2];

    for (auto x : Xs) {
        cout << ((x <= a1) ? a2 : a1) << endl;
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main()
{
  string s; cin >> s;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (i % 2) {
    	cnt1 += s[i] == '0';
    	cnt2 += s[i] == '1';
    } else {
      	cnt1 += s[i] == '1';
    	cnt2 += s[i] == '0';
    }
  }
  cout << (cnt1 < cnt2 ? cnt1 : cnt2) << endl;
}

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

int main () {
    string s,ans;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        if (i == 0 || i % 2 == 0) {
            ans += s.at(i);
        }
    }
    cout << ans << endl;
}

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

//#pragma GCC optimize("Ofast", "no-stack-protector")
//#pragma GCC target("sse4", "avx", "popcnt", "lzcnt", "sse3", "sse4.1", "sse4.2", "sse2", "tune=native")
//#pragma GCC optimize ("unroll-loops")

using namespace std;

typedef long double old;
typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int ans = 0;
    old kek = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        kek += a[i];
    }
    kek /= n;
    for (int i = 0; i < n; ++i) {
        if (abs(a[i] - kek) + 1e-9 < abs(a[ans] - kek)) {
            ans = i;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
xs, ys, hs = [], [], []
N.times do |i|
    xs[i], ys[i], hs[i] = gets.split.map(&:to_i)
end

(0..100).each do |x|
    (0..100).each do |y|
        h = nil
        hmax = 10**10
        success = true
        N.times do |i|
            dist = (xs[i]-x).abs + (ys[i]-y).abs
            if hs[i] == 0
                hmax = dist if hmax > dist
            else
                hc = hs[i] + dist
                if h && h != hc
                    success = false
                    break
                else
                    h = hc
                end
            end
        end
        if success && h <= hmax
            puts [x, y, h].join(' ')
            exit
        end
    end
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}

			var N = inputArray[0];
			var M = inputArray[1];

			var dictionary = new Dictionary<long, SubmitResult>();

			for (int i = 0; i < M; i++) {//提出結果をDictonaryに格納
				var submitArray = Console.ReadLine().Split(' ');

				var p = long.Parse(submitArray[0]);
				var result = submitArray[1];

				if (dictionary.ContainsKey(p)) {
					if (result == "AC") {
						dictionary[p].AC = true;
					}
					else {
						//それまで正解でない場合のみWCを増やす
						if(dictionary[p].AC == false) {
							dictionary[p].WCount++;

						}
					}
				}
				else {
					dictionary.Add(p,new SubmitResult(result));
				}
			}

			var acCount = dictionary.Where(x => x.Value.AC == true).Count();
			//答えの出力
			var penalty = dictionary.Where(x => x.Value.AC == true).Select(x =>x.Value.WCount).Sum();
			Console.WriteLine($"{acCount} {penalty}");

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
	public class SubmitResult {

		public bool AC;
		public long WCount;

		/// <summary>
		/// コンストラクタ
		/// </summary>
		public SubmitResult(string result) {

			if (result == "AC") {
				AC = true;
				WCount = 0;
			}
			else {
				AC = false;
				WCount = 1;
			}

		}


	}
}

Measured memory_bytes: 26184
def ok(s):
    for i in range(len(s)):
        s_list = list(s)
        if i < len(s)-1:
            s_list[i], s_list[i+1] = s_list[i+1], s_list[i]
        if ''.join(s_list).find("AGC") != -1:
            return False
    return True


n = int(input())
table = [{} for i in range(n+1)]
table[0][''] = 1

for i in range(n):
    for s in table[i]:
        for c in 'ATGC':
            if ok(s[-3:] + c):
                if s[-2:]+c in table[i+1]:
                    table[i+1][s[-2:]+c] += table[i][s]
                else:
                    table[i+1][s[-2:]+c] = table[i][s]

print(sum(table[n].values()) % (10 ** 9 + 7))

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=200001 ;
int main()
{
   fast ;
   ll x,y,z ;
   cin>>x>>y>>z ;
   cout<<z<<" "<<x<<" "<<y ;

}



Measured memory_bytes: 256
n=int(input())
al=list(map(int,input().split()))
ans=[]
tl=[0]*n
for i in range(n,0,-1):
    if tl[i-1]%2^al[i-1]:
        ans.append(i)
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                tl[j-1]^=1
                if j**2==i:
                    continue
                tl[i//j-1]^=1
print(len(ans))
print(*ans)

Measured memory_bytes: 70876
#include <iostream>
#include <map>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

ll a[100001] = {};
ll s[100001] = {};

int main() {
	ll n, m; cin >> n >> m;
	map<ll, ll> mp;
	repe(i, 1, n) {
		cin >> a[i];
		s[i] += s[i - 1] + a[i];
		mp[s[i] % m]++;
	}
	ll ans = 0;

	for (map<ll, ll>::iterator it = mp.begin(); it != mp.end(); it++) {
		if (it->second >= 2) {
			ll t = it->second;
			ans += t * (t - 1) / 2;
		}
	}
	cout << mp[0] + ans << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

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

    int size(int x) { return -d[find(x)]; }
};

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

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


int main() {
    ll n, q;
    cin >> n;
    vector<ll> B(1010101, 0);
    ll sum = 0;

    for (ll i = 0; i < n; ++i) {
        ll a;
        cin >> a;
        B[a]++;
        sum += a;
    }

    cin >> q;
    for (ll i = 0; i < q; ++i) {
        ll b, c;
        cin >> b >> c;
        sum -= B[b] * b;
        sum -= B[c] * c;
        B[c] += B[b];
        sum += B[c] * c;
        B[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;
#define lint long long

lint battle(lint a, lint b){
    if(a== b){
        return a;
    } else {
        return abs(a - b);
    }
}

int main() {
    int N;
    cin >> N;
    
    lint num = pow(2, N);
    
    
    queue<lint> que;
    
    for(int i = 0; i < num; ++i){
        lint a;
        cin >> a;
        que.push(a);
    }
    
    while(que.size() > 1){
        lint a, b;
        a = que.front(); que.pop();
        b = que.front(); que.pop();
        lint c;
        c = battle(a,b);
        que.push(c);
    }
    
    cout << que.front() << endl;
}


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

int n;
int arr[4][4];
bool chk[4][4];
int main()
{
    for(int i=1; i<=3; ++i){
        for(int j=1; j<=3; ++j){
            scanf("%d", &arr[i][j]);
        }
    }
    scanf("%d", &n);
    for(int i=1; i<=n; ++i){
        int x;
        scanf("%d", &x);
        for(int j=1; j<=3; ++j){
            for(int k=1; k<=3; ++k){
                if(arr[j][k]==x){
                    chk[j][k] = true;
                }
            }
        }
    }
    for(int i=1; i<=3; ++i){
        if(chk[i][1]&&chk[i][2]&&chk[i][3]){
            printf("Yes"); return 0;
        }
        if(chk[1][i]&&chk[2][i]&&chk[3][i]){
            printf("Yes"); return 0;
        }
    }
    if(chk[1][1]&&chk[2][2]&&chk[3][3]){
        printf("Yes"); return 0;
    }
    if(chk[1][3]&&chk[2][2]&&chk[3][1]){
        printf("Yes"); return 0;
    }
    printf("No");
}

Measured memory_bytes: 256
package main

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

func main() {
	a, b, c, d := readInt(), readInt(), readInt(), readInt()
	for {
		c -= b
		if c <= 0 {
			fmt.Println("Yes")
			return
		}
		a -= d
		if a <= 0 {
			fmt.Println("No")
			return
		}
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

#define int long long

using namespace std;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    char a, b, c;
    cin >> a >> b >> c;

    int res = 0;

    if(a == 'R' || b == 'R' || c == 'R')res = 1;
    if((a == 'R' && b == 'R') || (b == 'R' && c == 'R'))res = 2;
    if(a == 'R' && b == 'R' && c == 'R')res = 3;

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 3624