akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<55;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int n,k;

int main(){
	cin>>n>>k;
	vi dp(n);
	dp[0]++;
	for(int i=0;i<k-1;i++){
		for(int j=1;j<n;j++) (dp[j]+=dp[j-1])%=mod;
		dp[i]=0;
	}
	int t=0;
	for(auto i:dp) (t+=i)%=mod;
	for(int i=1;i<n-k;i++) (t*=2)%=mod;
	cout<<t<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ALDS1_5-B

Recursion / Divide and Conquer - Merge Sort
Merge Sort

=end

class Merge
  def merge(a, left, mid, right)
    sentinel = 1000000001
    n1 = mid - left;
    n2 = right - mid;
    l = Array.new(n1+1);
    r = Array.new(n2+1);

    0.upto(n1-1) {|i|
      l[i] = a[left + i]
    }
    0.upto(n2-1) {|i|
      r[i] = a[mid + i]
    }
    l[n1] = sentinel;
    r[n2] = sentinel;
    i = 0;
    j = 0;
    q = 0;
    left.upto(right-1) {|k|
      q = q + 1;
      if (l[i] <= r[j]) then
        a[k] = l[i];
        i = i + 1;
      else
        a[k] = r[j];
        j = j + 1;
      end
    }
    return q;
  end

  def mergeSort(a, left, right)
    if left + 1 < right then
      mid = (left + right)/2
      n1 = mergeSort(a, left, mid)
      n2 = mergeSort(a, mid, right)
      n3 = merge(a, left, mid, right)
      return n1+n2+n3
    else
      return 0
    end
  end

end

class Main

  def initialize()
    #fh = open("/home/muz/Downloads/ALDS1_5_B_in1.txt")
    fh = STDIN
    n = fh.gets.to_i
    a = fh.gets.chomp.split.map{|x| x.to_i}
    abort("size does not match") if n != a.length 
    ms = Merge.new

    q1 = ms.mergeSort(a, 0, n)

    puts a.map{|x| x.to_s}.join(" ")
    puts q1
  end

end

if $0 == __FILE__ then
  Main.new
end

Measured memory_bytes: 72872
while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  H = range(h)
  C = [0]*(h+1)
  M = C[:]
  a=[0]*w
  for i in H:
    x = raw_input()
    b=[0]*w
    sp=-1
    C = [-1]*(h+1)
    for j in range(w):
      if x[j]=="*": c=0
      else: c=a[j]+1
      b[j]=c
      dw=c-sp
      if dw>0: C[sp+1:c+1]=[j]*dw
      elif dw<0:
        for k in range(c+1,sp+1):
          M[k]=max(M[k],j-C[k])
        C[c+1:sp+1]=[-1]*(-dw)
      sp=c
    for k in range(1,sp+1):
      if C[k]>=0:
        M[k]=max(M[k],w-C[k])
    a=b
  s=max([a*b for a,b in zip(M, H+[h])])
  print s

Measured memory_bytes: 4312
#import<bits/stdc++.h>
#define sorted(vector) sort(vector.begin(),vector.end())
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)
using namespace std;


int a,b,c,x,g;
string s,t,r;

int main(void){
    cin>>s>>t>>r;
    auto a = stoi(s+t+r);
    if (a%4==0) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


int vs[1 << 19];
pair<int,int> dp[1 << 19];

struct K {
  int i;
};
bool operator<(const K& a, const K& b) {
  return vs[a.i] < vs[b.i];
}

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, 1 << n) {
    scanf("%d", &vs[i]);
  }
  dp[0] = make_pair(0, 1 << 18);
  int res = 0;
  for(int i = 1; i < (1 << n); ++i) {
    priority_queue<K, vector<K>, less<K> > q;
    q.push((K){i});
    REP(j, 18) {
      if(i & (1 << j)) {
        int k = i ^ (1 << j);
        q.push((K){dp[k].first});
        q.push((K){dp[k].second});
      }
    }
    K a = q.top(); q.pop();
    K b = q.top(); q.pop();
    while(b.i == a.i) {
      b = q.top(); q.pop();
    }
    dp[i] = make_pair(a.i, b.i);
    res = max(res, vs[a.i]+vs[b.i]);
    printf("%d\n", res);
  }
  return 0;
}


Measured memory_bytes: 9216
# B問題
N = int(input())
T = list(map(int, input().split()))
M = int(input())
px = []
for i in range(M):
    px.append(list(map(int, input().split())))
for i in range(M):
    ans = 0
    ans += sum(T) - T[px[i][0]-1] + px[i][1]
    print(ans)

Measured memory_bytes: 3060
import java.util.*;
import java.util.Map.Entry;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		Hashtable<Integer,Integer> vals = new Hashtable<Integer, Integer>();
		while (sc.hasNext()) {
			int m = sc.nextInt();
			if(vals.containsKey(m)){
				vals.put(m,vals.get(m)+1);
			}else{
				vals.put(m,0);
			}
		}
		
		ArrayList<Entry<Integer,Integer>> valList=new ArrayList<Entry<Integer,Integer>>(vals.entrySet());
			
		Collections.sort(valList,new Comparator<Entry<Integer,Integer>>() {
@Override
		public int compare(Entry<Integer, Integer> o1,
				Entry<Integer, Integer> o2) {
	if(o2.getValue()!=o1.getValue())return o2.getValue()-o1.getValue();
	else	return o1.getKey()-o2.getKey();
		}
		});
		
		int max=0;
		for(Entry<Integer,Integer> val:valList) {
			if(val.getValue()>=max){
				max=val.getValue();
				ln(val.getKey());
			}else{
				break;
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<iostream>
#define MOD 1000000007
using namespace std;

int number_count[100005];

int main() {
    int N, A, count = 1;
    cin >> N;
    for (int i = 0; i <= N; i++) number_count[i] = 0;
    for (int i = 0; i < N; i++) {
        cin >> A;
        number_count[A]++;
    }
    bool flag = false;
    if (N % 2 == 0) {
        for (int i = 0; i < N; i++) {
            if ((i % 2 == 0 && number_count[i] != 0) || (i % 2 == 1 && number_count[i] != 2)) {
                flag = true;
                break;
            }
        }
    }
    else {
        for (int i = 0; i < N; i++) {
            if (i == 0 && number_count[i] == 1) continue;
            else if (i == 0 && number_count[i] != 1) {
                flag = true;
                break;
            }
            if ((i % 2 == 1 && number_count[i] != 0) || (i % 2 == 0 && number_count[i] != 2)) {
                flag = true;
                break;
            }
        }
    }
    if (flag) count = 0;
    else {
        for (int i = 0; i < N / 2; i++) count = ((count % MOD) * (2 % MOD)) % MOD;
    }
    cout << count << endl;
    return 0;
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

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

    int A, B, T; cin >> A >> B >> T;

    cout << T / A * B << endl;

}


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

def insert(root, z):
    y = None
    x = None
    if root != None:
        x = root
        
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
            
    z.parent = y
    if y == None:
        root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def printInOrder(z):
    if z == None:
        return
    if z.left != None:
        printInOrder(z.left)
    inorder.append(str(z.key))
    #print(z.key, end = " ")
    if z.right != None:
        printInOrder(z.right)
        
def printPreOrder(z):
    if z == None:
        return
    #print(z.key, end = " ")
    preorder.append(str(z.key))
    if z.left != None:
        printPreOrder(z.left)
    if z.right != None:
        printPreOrder(z.right)

root = None


n = int(input())
for i in range(n):
    command = input()
    if command[0] == "i":
        com,num = command.split()
        z = Node(int(num))
        insert(root, z)
        if root == None:
            root = z
    else:
        inorder = []
        printInOrder(root)
        print(" ", end = "")
        print(' '.join(inorder))
        preorder = []
        printPreOrder(root)
        print(" ", end = "")
        print(' '.join(preorder))







Measured memory_bytes: 178536
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;
const int MAX_M = 200000;
struct edge{int to, cost;};

vector<edge> G[MAX_N];
int V[MAX_N];

int n, m;
int l[MAX_M], r[MAX_M], d[MAX_M];

bool used[MAX_N];

bool dfs(int v) {
  if(used[v]) return true;
  used[v] = true;
  bool res = true;
  REP(i, G[v].size()){
    if(used[G[v][i].to]) res = res & (G[v][i].cost == V[v] - V[G[v][i].to]);
    else {
      V[G[v][i].to] = V[v] - G[v][i].cost;
      res = res & dfs(G[v][i].to);
    }
  }
  return res;
}

int main(){
  cin >> n >> m;
  REP(i, m) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--; r[i]--;
    G[l[i]].push_back(edge{r[i], d[i]});
    G[r[i]].push_back(edge{l[i], -d[i]});
  }

  REP(i, n) used[i] = false;

  bool ans = true;
  REP(i, n) {
    if(!used[i]) V[i] = 0;
    ans = ans & dfs(i);
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

int N, M;
long long a[100010], dp[100010];
const long long INF = 1LL << 60;
const long long mod = 1e9 + 7;

long long rec(int i) {
  if (dp[i] < INF) return dp[i];
  if (i == 0 || i == 1) return 1;
  
  return dp[i] = (rec(i - 1) % mod) + (rec(i - 2) % mod);
}

int main() {
  cin >> N >> M;
  for (int i = 0; i <= N; i++) dp[i] = INF;
  for (int i = 0; i < M; i++) { cin >> a[i]; dp[a[i]] = 0; }
  cout << rec(N) % mod << endl;
  
  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <set>
const int N = 100005;
using namespace std;
typedef long long ll;
int a[N];
int main()
{
 
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    ll imax=2,imin=2;
 
    for(int i=n;i>=1&&imax>=imin;i--){
        if(imin%a[i]!=0)
            imin=imin/a[i]*a[i]+a[i]; //最小 计算机乘除法处理求出a[i]的整数倍
        imax=(imax/a[i]+1)*a[i]-1;    //最大 
    }
    if(imax>imin)
        printf("%lld %lld\n",imin,imax);
    else
        printf("-1\n");
    return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
*A, = map(int, stdin.readline().split())
cnt = 0

def merge(A, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    L = [A[left + i] for i in range(n1)]
    R = [A[mid + i] for i in range(n2)]
    L.append(10 ** 9)
    R.append(10 ** 9)
    i = 0
    j = 0
    for k in range(left, right):
        # print(" ".join(map(str,A)))#TODO
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
    global cnt
    cnt += right - left  # !

def merge_sort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)

merge_sort(A, 0,n)
print(" ".join(map(str, A)))
print(cnt)


Measured memory_bytes: 66592
//AOJ ALDS1_1_A
#include <stdio.h>

int main() {
	int c,d,e,n,o;
	scanf("%d", &n);

	int r[n];
	for (c = 0; c < n; c++) {
		scanf("%d", &r[c]);
	}

	for (c = 0; c < (n - 1); c++) {
		for (e = 0; e < n; e++) {
			if (e != n - 1) {
				printf("%d ", r[e]);
			}else {
				printf("%d\n", r[e]);
			}
		}

		d = c;
		while (r[d] > r[d + 1]) {
			o = r[d + 1];
			r[d + 1] = r[d];
			r[d] = o;
			d--;

		}
	}

	for (e = 0; e < n; e++) {
		if (e != n - 1) {
			printf("%d ", r[e]);
		}else {
			printf("%d\n", r[e]);
		}
	}

	return 0;
}


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

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

	long sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}

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

Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
    int x,y,z,a;
    scanf("%d %d %d",&x,&y,&z);
    if(x>y){
        a=x;
        x=y;
        y=a;
    }
    if(y>z){
        a=y;
        y=z;
        z=a;
    }
    if(x>y){
        a=x;
        x=y;
        y=a;
    }
printf("%d %d %d\n",x,y,z);


    return 0;

}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

void open(){
	freopen("D:/Code/in.txt","r",stdin);
	freopen("D:/Code/out.txt", "w", stdout);
}

int main(void){
	int n;
	sc(n);
	int ganjil, genap;
	ganjil = genap = 0;
	FOR(i,n){
		int x;sc(x);
		if(x % 2 == 0)genap++;
		else ganjil++;
	}
	
	printf("%s", (ganjil % 2 == 0) ? "YES" : "NO");

    return 0;
}




Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
int main() {
    int d[9] = {1, 3, 6, 10, 15, 21, 28, 36, 45};
    ll N;
    cin >> N;
    vector<ll>e;
    map<ll, ll>res;
    for (ll i = 2; i*i <= N; i++) {
        if (N%i==0) {
            e.push_back(i);
        }
        while (N%i==0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) {
        e.push_back(N);
        res[N] = 1;
    }
 
    ll cnt;
    ll ans = 0;
    for (int i = 0; i < e.size(); i++) {
        cnt = 1;
        while (res[e[i]] >= cnt) {
            ans++;
            res[e[i]] -= cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());

    let n: i64 = rd.get();
    let mut ans = 0;
    for a in 1..=n {
        for b in 1..=n {
            if a * b >= n {
                break;
            }
            ans += 1;
        }
    }
    println!("{}", ans);
}

pub struct ProconReader<R: std::io::Read> {
    reader: R,
}

impl<R: std::io::Read> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self { reader }
    }
    pub fn get<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&byte| byte == b' ' || byte == b'\n' || byte == b'\r')
            .take_while(|&byte| byte != b' ' && byte != b'\n' && byte != b'\r')
            .collect::<Vec<_>>();
        std::str::from_utf8(&buf)
            .unwrap()
            .parse()
            .ok()
            .expect("Parse Error.")
    }
}

Measured memory_bytes: 2164
#include <stdio.h>

#define MYSCAN scanf

int main(void){
	int w = 0, ans = 0;
	int last = 4280;
	int base = 1150;

	while (true){

		MYSCAN("%d", &w);
		if (w == -1){ break; }
		if (w > 30){
			ans = (w - 30) * 160;
			ans += 140 * 10 + 125 * 10 + base;
		}else if (w > 20){
			ans = (w - 20) * 140;
			ans += 125 * 10 + base;
		}else if (w > 10){
			ans = (w - 10) * 125;
			ans += base;
		}
		else{
			ans = base;
		}
		printf("%d\n", last - ans);

	}	
	return 0;
}

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

using namespace std;

int main() {
  int ans = 0;
  int n, t;
  cin >> n >> t;
  int prev = 1000000000;
  int m = 1000000000;
  int maxd = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a <= prev) {
      m = min(m, a);
    } else {
      int d = a - m;
      if (maxd == d) {
        ans++;
      } else if (maxd < a - m) {
        maxd = a - m;
        ans = 1;
      }
    }
    prev = a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    aa = MII()
    aa.sort(reverse=True)
    print(sum(aa[1:2*n:2]))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 37468
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, m;
	while (cin >> n >> m) {
		if (n == 0 && m == 0) {
			break;
		}
		int h[1510];
		int w[1510];
		for (int i = 0; i < n; i++) {
			cin >> h[i];
		}
		for (int j = 0; j < m; j++) {
			cin >> w[j];
		}
		int sq = 0;
		vector< vector<int> > dp(n, vector<int>(n, 0));
		vector< vector<int> > dp2(m, vector<int>(m, 0));
		vector<int> retu(1500010, 0);
		dp[0][0] = h[0];
		dp2[0][0] = w[0];
		retu[h[0]]++;
		for (int i = 1; i < n; i++) {
			dp[0][i] = dp[0][i-1] + h[i];
			retu[dp[0][i]]++;
		}
		for (int i = 1; i < n; i++) {
			for (int j = i; j < n; j++) {
				dp[i][j] = dp[i][j-1] + h[j];
				retu[dp[i][j]]++;
			}
		}
		if (retu[w[0]] > 0) {
			sq += retu[w[0]];
		}
		for (int i = 1; i < m; i++) {
			dp2[0][i] = dp2[0][i-1] + w[i];
			if (retu[dp2[0][i]] > 0) {
				sq += retu[dp2[0][i]];
			}
		}
		for (int i = 1; i < m; i++) {
			for (int j = i; j < m; j++) {
				dp2[i][j] = dp2[i][j-1] + w[j];
				if (retu[dp2[i][j]] > 0) {
					sq += retu[dp2[i][j]];
				}
			}
		}
		cout << sq << endl;
	}
	return 0;
}

Measured memory_bytes: 24732
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll A, B, K; cin >> A >> B >> K;
	
	for (int i = A; i <= min(A + K - 1, B); i++) {
		cout << i << endl;
	}
	for (int i = max(B - K + 1, A + K); i <= B; i++) {
		cout << i << endl;
	}
}

Measured memory_bytes: 256
operator fun Pair<Int, Int>.minus(pair: Pair<Int, Int>) = Pair(first - pair.first, second - pair.second)
fun Pair<Int, Int>.manhattanTo(pair: Pair<Int, Int>) = (this - pair).manhattanLength()
fun Pair<Int, Int>.manhattanLength() = Math.abs(first) + Math.abs(second)

data class Destination(private val t: Int, private val coordinate: Pair<Int, Int>) {
    private fun timeTo(destination: Destination) = destination.t - t

    fun canThenReachTo(destination: Destination) = coordinate.manhattanTo(destination.coordinate).let { distance ->
        distance <= timeTo(destination) && timeTo(destination) % 2 == distance % 2
    }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val destinations = listOf(Destination(0, Pair(0, 0))) + (0 until n).map {
        val (t, x, y) = readLine()!!.split(" ").map { it.toInt() }
        Destination(t, Pair(x, y))
    }

    val travellable = destinations.mapIndexedNotNull { index, destination ->
        when(index) {
            n -> null
            else -> Pair(destination, destinations[index + 1])
        }
    }.all { it.first.canThenReachTo(it.second) }

    println(if (travellable) "Yes" else "No")
}

Measured memory_bytes: 78976
S = int(input())
MOD = 1_000_000_007

t = [0, 0, 1]
f = 0 if S <= 2 else 1
for i in range(S - 3):
    f = t[0] + 1
    f %= MOD
    t = t[1:3] + [(t[2] + f) % MOD]
print(f)


Measured memory_bytes: 9192
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let s = read::<String>();
    println!("{}", s.replace(","," "));
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
VL a, b;

signed main() {
    cin >> N;
    REP(i, N) a.emplace_back(IN());
    REP(i, N) b.emplace_back(IN());
    VL cnt(29, 0);
    REP(k, 29) {
        VL ak(N), bk(N);
        ll T = 1 << k;
        REP(i, N) ak[i] = a[i] % (2 * T);
        REP(i, N) bk[i] = b[i] % (2 * T);
        sort(All(bk));
        REP(i, N) {
            cnt[k] += lower_bound(All(bk), 2 * T - ak[i]) - lower_bound(All(bk), T - ak[i]);
            cnt[k] += lower_bound(All(bk), 4 * T - ak[i]) - lower_bound(All(bk), 3 * T - ak[i]);
        }
    }
    ll ans = 0;
    REP(k, 29) {
        if(cnt[k] % 2) ans |= 1 << k;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 8568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>

signed main()
{
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
repone(i,x)y+=i;
std::cout << y << '\n';
}


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

int main(){
    
    int n,x;
    cin>>n>>x;
    
    while(n!=0 || x!=0){
        int cnt=0;
        for(int i=1; i<=n; i++){
            for(int j=i+1; j<=n; j++){
                for(int k=j+1; k<=n; k++){
                    if(i+j+k == x){
                        cnt++;
                    }
                }
            }
        }
    cout<< cnt << endl;
    cin >>n >>x;
    }
    return 0;
}


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

long n, m;

long comb(long x) {
  if (x < 2) return 0;
  return (x * (x - 1)) / 2;
}

int main(void) {
  cin >> n >> m;
  cout << comb(n) + comb(m) << endl;
  return 0;
}


Measured memory_bytes: 3640
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        long N   = reader.nextLong();
        long ans = N*(N-1)/2;
        System.out.println(ans);
    }
    
    public static void solver() {
        // write logic
    }
    
    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main() {
  string n, ans;
  std::cin >> n;
  switch (n[n.length() - 1]) {
    case '0':
    case '1':
    case '6':
    case '8':
      ans = "pon";
      break;
    case '2':
    case '4':
    case '5':
    case '7':
    case '9':
      ans = "hon";
      break;
    case '3':
      ans = "bon";
      break;
  }
  std::cout << ans;
}


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

using namespace std;
using ll = long long;

int main() {
    int w=0,k=0;
    vector<int> a(10),b(10);
    for(int i = 0;i < 10;++i) {
        cin>>a[i];
    }
    for(int i = 0;i < 10;++i) {
        cin>>b[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    w+=a[9]+a[8]+a[7];
    k+=b[9]+b[8]+b[7];
    cout<<w<<" "<<k<<endl;
    return 0;
}



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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(a>=b){
    cout << "delicious" << endl;
  }else if(a+x>=b){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,m,a,b,f[1111][1111],sx[1111],sy[1111];

int ord[1111];
bool cmp(int x,int y){return sy[x]>sy[y];}
int main()
{
	get2(n,m);get2(a,b);
	
	bool ok=0;
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)if(i*a+(n-i)*(m-a)==j*b+(m-j)*(n-b))
	{
		for(int p=1;p<=n;p++)if(p<=i)sx[p]=a;else sx[p]=m-a;
		for(int p=1;p<=m;p++)if(p<=j)sy[p]=b;else sy[p]=n-b;
		ok=1;
		break;
	}
	if(!ok)
	{
		puts("-1");
		return 0;
	}
	for(int j=1;j<=m;j++)ord[j]=j;
	for(int i=n;i>=1;i--)
	{
		sort(ord+1,ord+m+1,cmp);
		for(int j=1;j<=sx[i];j++)
		{
			int v=ord[j];
			if(!sy[v])
			{
				puts("-1");
				return 0;
			}
			f[i][v]=1;
			sy[v]--;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)printf("%d",f[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin>>n;
  cout << "ABC" <<  n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  string t;
  cin >> s >> t;
  if(s.size()>t.size()){cout << "GREATER" << endl;return 0;}
  else if(s.size()<t.size()){cout << "LESS" << endl;return 0;}
  

  for(int i=0; i<s.size(); i++){
    if(s[i]>t[i]){cout << "GREATER" << endl;return 0;}
    else if(s[i]<t[i]){cout << "LESS" << endl;return 0;}
    else {cout << "EQUAL" << endl;return 0;}
  }
}


Measured memory_bytes: 256
n,k,q=map(int,input().split())
a=[]
for _ in range(q):
  a.append(int(input()))
p=[k-q]*n
for num in a:
  p[num-1] += 1
for num in p:
  if num > 0:
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 10472
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
	using namespace std;

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

		if (S == "SUN") {
			cout << 7 << endl;
		}

		else if (S == "SAT") {
			cout << 1 << endl;
		}

		else if (S == "FRI") {
			cout << 2 << endl;
		}

		else if (S == "THU") {
			cout << 3 << endl;
		}

		else if (S == "WED") {
			cout << 4 << endl;
		}

		else if (S == "TUE") {
			cout << 5 << endl;
		}

		else if (S == "MON") {
			cout << 6 << endl;
		}

		
	}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
 
/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */
 
int main() {//これで本当に通る？
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll M;
  while (cin >> N >> M) {
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    sort(A.begin(), A.end());
    ll pass = 0, fail = 2 * 1e5 + 10;
    while (fail - pass > 1) {
      ll X = (pass + fail) / 2;
      ll cnt = 0;
      for (int i = 0, j = N - 1; i < N; i++) {
        while (j >= 0 && A[i] + A[j] >= X) --j;
        cnt += N - j - 1;
      }
      if (cnt >= M) {
        pass = X;
      } else {
        fail = X;
      }
    }
    ll res = 0;
    ll sum = 0, rem = M;
    for (int i = 0, j = N - 1; i < N; i++) {
      while (j >= 0 && A[i] + A[j] > pass) {
        sum += A[j];
        --j;
      }
      ll c = N - j - 1;
      rem -= c;
      res += sum + c * A[i];
    }
    res += pass * rem;
    cout << res << endl;
  }
  return 0;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    ll X;
    cin >> X;
    ll x = 100;
    int ans = 0;
    while (x < X) {
        x *= 1.01;
        ans += 1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

ull comb_mod(int n, int r, int mod) {
  ull ans = 1;

  for (int i = n; i > n - r; i--) {
    ans *= (ull)i;
    ans %= (ull)mod;
  }

  return ans;
}

int main(int argc, char *argv[]) {
  int N, M;
  ull MOD = 1e9 + 7;
  ull ans;

  cin >> N >> M;

  if (abs(N - M) >= 2) {
    ans = 0ULL;
  } else if (abs(N - M) == 1) {
    ull tmp = comb_mod(MIN(N, M), MIN(N, M), MOD);
    ans = ((tmp * tmp) % MOD * MAX(N, M)) % MOD;
  } else {
    ull tmp = comb_mod(N, N, MOD);
    ans = ((tmp * tmp) % MOD * 2ULL) % MOD;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int P = V[0], Q = V[1], R = V[2];
            Console.WriteLine(new[] { P + Q, Q + R, R + P }.Min());
        }
    }
}


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

int main(){
  long long a,b,c;
  cin >> a >> b >> c;
  long long M,m,n;
  M=max({a,b,c});
  m=min({a,b,c});
  n=a+b+c-M-m;
  long long ans;
  if(a*b*c%2==0){ans=0;}
  else{ans=n*m;}
  cout << ans << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

// 01234567
// 12345678
// redcoder

int ans;
char S[105];

int main(void) {
    scanf("%s", S);
    int n = strlen(S);

    rep(i, 0, n/2) {
      if (S[i] != S[n-1-i]) ans++;
    }
   

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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> arr(n, 0);
    for(ll& val: arr)
        cin >> val;
    ll ans = 0;
    if (arr[0] > x) {
        ans += arr[0] - x;
        arr[0] = x;
    }
    for(int i = 1; i < n; i++) {
        if (arr[i]+arr[i-1] > x) {
            ll diff = (arr[i]+arr[i-1] - x);
            ans += diff;
            arr[i] -= diff;
        }
    }
    cout << ans << endl;

    return 0;
}




Measured memory_bytes: 1024
#!/usr/bin/env python
from collections import deque

def comb(a, b):
    result = 1
    for i in range(b):
        result *= (a - i) / (i + 1)
    return result


def main():
    A, B, C = map(int, input().split())

    if len(set([A, B, C])) == 2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <map>

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

    std::map<std::string, int64_t> num;
    for (int i = 0; i < n; i++) {
        std::string s;
        std::cin >> s;
        std::sort(s.begin(), s.end());
        num[s]++;
    }

    int64_t ans = 0;
    for (auto p: num) {
        ans += p.second * (p.second - 1) / 2;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
#include <cmath>
#include <map>
#include <string>

using namespace std;

int a[100000];
pair<int,int> cb[100000];

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

    int n, m;
    cin >> n >> m;

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

    sort(a, a + n);

    for (size_t i = 0; i < m; i++)
    {
        cin >> cb[i].second >> cb[i].first;
    }

    sort(cb, cb + m);

    int idx = 0;
    for (int i = m - 1; i >= 0; i--)
    {
        for (size_t j = 0; j < cb[i].second; j++)
        {
            if (idx >= n) break;
            if (a[idx] >= cb[i].first) break;

            a[idx] = cb[i].first;
            idx++;
        }
    }
    
    long long int ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        ans += a[i];
    }
    
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1408
N,X = map(int,input().split())
x = [int(i) for i in input().split()]
x = [i-X for i in x]
Min = min([abs(i) for i in x])
flag = False
for i in range(1,Min+1):
    if flag == True:
        break
    flag = True
    if Min%i==0:
        ans = Min//i
        for j in x:
            if j%ans!=0:
                flag = False
    else:
        flag = False
print(ans)

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

int main() {
  string S, T, U;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;
  
  if (S == U) A--;
  else if(T == U) B--;
  cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func number2string(n int) string {
	var res string
	for i, c := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
		if n == i {
			res = string(c)
			break
		}
	}
	return res
}
func string2number(s string) int {
	var res int
	for i, c := range "ABCDEFGHIJKLMNOPQRSTUVWXYZ" {
		if s == string(c) {
			res = i
			break
		}
	}
	return res
}
func main() {
	var N int
	var S string
	var output = ""

	fmt.Scan(&N)
	fmt.Scan(&S)

	for _, c := range S {
		i := string2number(string(c))
		//fmt.Printf("%d \n", i)
		j := number2string((i + N) % 26)
		//fmt.Printf("%s \n", j)
		output += j
	}
	fmt.Printf("%s ", output)
}


Measured memory_bytes: 8704
fn main() {
    let (n, m): (usize, usize) = readln();
    let k = 1 << m;
    let unit = 1900 * m + 100 * (n - m);
    println!("{}", unit * k);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352