akhauriyash/Code-Regression huggingface dataset:
// https: //onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/4/ITP2_4_A
#include <iostream>
#include <vector>
#include <algorithm>

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

    std::vector<int> A(n);
    for (auto &x : A)
    {
        std::cin >> x;
    }

    int q;
    std::cin >> q;

    for (int i = 0; i < q; i++)
    {
        int b, m, e;
        std::cin >> b >> m >> e;

        std::rotate(A.begin() + b, A.begin() + m, A.begin() + e);
    }

    for (auto itr = A.begin(); itr != A.end(); itr++)
    {
        std::cout << *itr;
        if (itr + 1 != A.end())
        {
            std::cout << " ";
        }
    }
    std::cout << std::endl;

    return 0;
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int num=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())num=(num<<3)+(num<<1)+c-48;
	return num*f;
}
int a[100];
inline void init()
{
	for(int i=1;i<=3;++i)
	{
		a[i]=read();
	}
	sort(a+1,a+1+3);
	if((a[2]-a[1])%2)cout<<a[3]-a[2]+1+(a[2]+1-a[1])/2;
	else               cout<<a[3]-a[2]+(a[2]-a[1])/2;
}
int main()
{
	init();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll fac(ll a) { return a > 1 ? fac(a - 1) * a : 1; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int>v(n);
  rep(i,n)cin >> v[i];
  vector<int>ans(n,0);
  for(int i = n; i > 0; i--){
    int count = n / i;
    int j = i - 1;
    int tmp = 0;
    REP(k,1,count + 1){
      tmp += ans[i * k - 1];
    }
    if(tmp % 2 != v[j])ans[j] = 1;
  }
  int t = 0;
  rep(i,n){
    if(ans[i] == 1)t++;
  }
  cout << t << endl;
  rep(i,n){
    if(ans[i] == 1)cout << i + 1 << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 1000

int main(void) {
  string a[3];

  FOR(i, 0, 3) {
	cin >> a[i];
  }

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

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)
#define mp(a, b) make_pair((a),(b))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;
constexpr double eps = 0.000000001;

int main() {
    ull n, a[200000];
    cin >> n;
    rep(i, n)cin >> a[i];
    ull c = 0, x = 0, s = 0, r = 0;
    for (ull l = 0; l < n; l++) {
        while (r < n && (x ^ a[r]) == (s + a[r])) {
            x ^= a[r];
            s += a[r];
            r++;
        }
        c += r - l;
        x ^= a[l];
        s -= a[l];
    }
    cout << c << endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> date(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> date.at(i).at(j);
    }
  }

  double ans = 0.0;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      ans += sqrt((date.at(i).at(0) - date.at(j).at(0)) * (date.at(i).at(0) - date.at(j).at(0)) + (date.at(i).at(1) - date.at(j).at(1)) * (date.at(i).at(1) - date.at(j).at(1)));
    }
  }

  cout << setprecision(20) << ans / N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
	//std::cout << "Hello World!\n"; 

	int N, M;
	cin >> N >> M;

	vector<int> vec_i(M);
	for (int ic = 0; ic < M; ic++) {
		int buf;
		cin >> buf;
		vec_i[ic] = buf;
	}

	if (N >= M) {
		cout << 0;
		return 0;
	}

	sort(vec_i.begin(), vec_i.end(), std::greater<int>());//降順ソート

	//点間の距離を測る
	vector<int> vec_len(M-1);
	for (int ic = 0; ic < M - 1; ic++) {
		int dlen = abs(vec_i[ic] - vec_i[ic + 1]);
		vec_len[ic] = dlen;
	}

	////昇順ならべて、最後を消す、というのをN-1回繰り返す
	//for (int ic = 0; ic < N - 1; ic++) {
	//	sort(vec_len.begin(), vec_len.end());
	//	//vec_len[M - 1] = 0;
	//	vec_len.pop_back();
	//}

	//昇順ならべて、最後を消す、というのをN-1回繰り返す
	sort(vec_len.begin(), vec_len.end());
	for (int ic = 0; ic < N - 1; ic++) {
		vec_len[M - 2 -ic] = 0;
	}

	//全部足す
	int sum = 0.0;
	//for (int ic = 0; ic < M - 1 - N - 1; ic++) {
	int nn = (int)vec_len.size();
	for (int ic = 0; ic < nn; ic++) {
			sum += vec_len.at(ic);
	}

	cout << sum;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define inf 2000000000000000000
#define NMAX 100
#define VMAX 1000

using namespace std;

long long n, k, dp[NMAX*VMAX+10], sum;

int main()
{
    cin >> n >> k;
    for(int i=1; i<=NMAX*VMAX; i++) dp[i] = inf;
    for(int i=1; i<=n; i++)
        {   long long v, w;
            cin >> w >> v;
            sum += v;
            for(int j=sum; j>=v; j--) dp[j] = min(dp[j], dp[j-v]+w);
        }
    for(int i=sum; i>=0; i--)
        if(dp[i] <= k)
            {   cout << i << '\n';
                return 0;
            }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<vector>
    #include<algorithm>
    #include<stack>
    using namespace std;
    const int maxn = 1000000 + 10;
    #define INF 0x7fffffff
    #define clr(x,y) memset(x,y,sizeof(x))
    typedef long long ll;
    #define eps 10e-10
    const ll Mod = 1000000007;
    char s[100];
    int main()
    {
        int n;
        while(cin >> s)
        {
            stack<int>q;
            int len = strlen(s);
            for(int i = 0; i < len; i ++)
            {
                if(s[i] != 'B')
                    q.push(s[i] - '0');
                else if(s[i] == 'B' && !q.empty())q.pop();
            }
            string ans;
            while(!q.empty())
            {
                ans += (char)q.top() +'0';
                q.pop();
            }
            reverse(ans.begin(),ans.end());
            cout << ans << endl;
        }

        return 0;
    }


Measured memory_bytes: 256
"""
明らかに無理→最小が2つ無い or 最小同士がペアになってない
(最小から接続する頂点に最小がない)

満たしてる→最小の辺を置いちゃおう
小さい奴からGreedyに置いてく？

自分の周りにendしてるやつ or 大きさが同じやつがあったら繋げちゃう
そのとき白黒はどうでも良さそう？

"""
import sys

N,M = map(int,input().split())

D = list(map(int,input().split()))

dic2 = [[] for i in range(N)]

for i in range(M):

    U,V = map(int,input().split())
    U -= 1
    V -= 1

    if len(dic2[U]) == 0 or dic2[U][0][0] > D[V]:
        dic2[U] = []
        dic2[U].append([D[V],V,i])
    if len(dic2[V]) == 0 or dic2[V][0][0] > D[U]:
        dic2[V] = []
        dic2[V].append([D[U],U,i])


dic = [[] for i in range(N)]
for i in range(N):
    for j in dic2[i]:
        dic[i].append([j[1],j[2]])

#print (dic)

end = [False] * N
color = [0] * N
q = []
ans = [10**9] * M

for i in range(N):
    q.append([D[i],i])
q.sort()
#print (q)

for i in range(N):
    if end[q[i][1]]:
        continue
    flag = False
    for vi in dic[q[i][1]]:
        nexv = vi[0]
        mind = vi[1]
        nowd = q[i][0]
        nowp = q[i][1]
        #print (vi,q[i])

        if end[nexv]:
            flag = True
            color[nowp] = color[nexv] ^ 1
            end[nowp] = True
            ans[mind] = nowd
            break
        elif D[nexv] == nowd:
            
            flag = True
            color[nowp] = color[nexv] ^ 1
            end[nowp] = True
            end[nexv] = True
            ans[mind] = nowd
            break
        break
    #print (ans)

    if not flag:
        print (-1)
        sys.exit()


S = []
for i in color:
    if i == 0:
        S.append("B")
    else:
        S.append("W")

print ("".join(S))

print (" ".join(map(str,ans)))
        

Measured memory_bytes: 148060
def sum_of_digits(n):
    answer = 0
    while True:
        if n == 0:
            break
        else:
            answer += n%10
            n = n // 10
    return answer
    
answer = 0
N, A, B = map(int, (input().split()))

for i in range(N+1):
    count = sum_of_digits(i)
    if(A<=count & count <= B):
        answer += i
        
    
print(answer)

Measured memory_bytes: 3060
import scala.collection.mutable
import scala.io.StdIn.readLine

object Main extends App {
  val n = readLine.toInt
  val a = readLine.split(" ").map(_.toLong)

  val sum1 = a.take(n).sum
  val sum2 = a.take(2 * n).sum - sum1
  val sum3 = a.sum - sum2 - sum1

  val formerQueue = mutable.PriorityQueue(a.take(n): _*)(implicitly[Ordering[Long]].reverse)

  val formerMap: mutable.Map[Int, Long] = mutable.HashMap.empty[Int, Long]
  formerMap.put(n - 1, sum1)

  for(i <- 0 until n) {
    val j = n + i
    formerQueue.enqueue(a(j))
    val min = formerQueue.dequeue()
    formerMap.put(j, formerMap(j - 1) + a(j) - min)
  }

  val latterQueue = mutable.PriorityQueue(a.takeRight(n): _*)

  val latterMap = mutable.HashMap.empty[Int, Long]
  latterMap.put(2 * n, sum3)

  for(i <- 0 until n) {
    val j = 2 * n - 1 - i
    latterQueue.enqueue(a(j))
    val max = latterQueue.dequeue()
    latterMap.put(j, latterMap(j + 1) + a(j) - max)
  }

  val ans = (for(i <- 0 to n) yield {
    val j = n - 1 + i
    formerMap(j) - latterMap(j + 1)
  }).max

  println(ans)

}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    map<int, int> mp;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }

    ll ans = 0;
    for (auto &e: mp) {
        ans += (ll)e.second * (e.second - 1) / 2;
    }

    for (int i = 0; i < n; i++) {
        cout << ans - (mp[a[i]] - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 8320
while True:
    x,y=map(int, input().split())
    if x==y==0:
        break
    
    i=0
    if x<y:
        x,y=y,x
    
    while y!=0:
        x=x%y
        x,y=y,x
        i+=1
    
    print(x, i)


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int C = 0;
  for(int i = 0; i < N; i++){
    int F, L;
    cin >> F >> L;
    C += (L - F) + 1;
  }
 
  cout << C << endl;
  
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
D=[0]
d=0
for i in A:
  d+=i
  D.append(d)
D=sorted(D)
ans=0
d=-10**9+1
D.append(10**9+1)
cnt=0
for i in range(N+2):
  if D[i]==d:
    cnt+=1
  else:
    if cnt>1:
      ans+=cnt*(cnt-1)//2
      cnt=1
    else:
      cnt=1
    d=D[i]
print(ans)

Measured memory_bytes: 31600
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC";
    else if (r < 2800) cout << "ARC";
    else cout << "AGC";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>

#define div1 1000000007

using namespace std;

int main(void)
{
    int N, start, end, count[10][10], i, j, digit, num, num1, num2, ans=0;

    cin >> N;

    for(i=1; i<=9; i++){
        for(j=1; j<=9; j++){
            count[i][j] = 0;
        }
    }

    for(i=1; i<=N; i++){
        num = i;

        digit = 0;
        
        while(num != 0){
            num /= 10;
            digit++;
        }

        start = i / (pow(10, digit-1));

        end = i % 10;

        count[start][end]++;
    }

    for(i=1; i<=9; i++){
        for(j=i; j<=9; j++){
            num1 = count[i][j];
            num2 = count[j][i];

            if(i == j){
                ans += pow(num1, 2);
            }

            else{
                ans += (num1*num2*2);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

H = 0
W = 0
i = 0
b = []

while H <= h-1:
    if H % 2 == 0:
        b.append(i+1)
        a[i] -= 1
        if a[i] == 0:
            i += 1
        if W == w-1:
            H += 1
        if W < w-1:
            W += 1
    else:
        b.append(i+1)
        a[i] -= 1
        if a[i] == 0:
            i += 1
        if W == 0:
            H += 1
        if W > 0:
            W -= 1

if h % 2 == 0:
    for ih in range(h//2):
        print(*b[w*ih*2:w*ih*2+w])
        print(*b[w*ih*2+2*w-1:w*ih*2+w-1:-1])
else:
    for ih in range(h//2):
        print(*b[w * ih * 2:w * ih * 2 + w])
        print(*b[w * ih * 2 + 2 * w - 1:w * ih * 2 + w - 1:-1])
    print(*b[w*(h-1):w*h])

Measured memory_bytes: 3920
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pll;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  return is;
}


int main(){

  int N;

  cin >>N;

  cout << ((N+1)*N/2) <<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    #xの根を求める
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    #xとyの属する集合の併合
    def unite(x,y):
        x = find(x)
        y = find(y)

        if x == y:
            return False
        else:
            #sizeの大きいほうがx
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True

    #xとyが同じ集合に属するかの判定
    def same(x,y):
        return find(x) == find(y)

    #xが属する集合の個数
    def size(x):
        return -par[find(x)]

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

    #初期化
    #根なら-size,子なら親の頂点
    par = [-1]*n
    #print(par)
    for i in range(m):
        A,B = map(int, input().split())
        unite(A-1,B-1)
    print(max([size(i) for i in range(n)]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 98604
import sys
import math

ALPHABET = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
result = []

def alphabet_decimal(v):
    quotient = math.floor(v / len(ALPHABET))
    surplus = v % len(ALPHABET)
    quotient -= 1 if surplus == 0 else 0
    surplus = len(ALPHABET) if surplus == 0 else surplus
    result.append(surplus)
    if len(ALPHABET) < quotient:
        alphabet_decimal(quotient)
    elif len(ALPHABET) < v:
        result.append(quotient)
    return "".join([ALPHABET[i - 1] for i in reversed(result)])

n = int(input())
print(str.lower(alphabet_decimal(n)))

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

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    if ((A == B && A != C) || (B == C && A != C) || (A == C && B != A)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int ans=0;
int n;
void dfs(int64_t k,bool t,bool f,bool s){
    if(k>n){
    }
    else{
        dfs(10*k+3,true,f,s);
        dfs(10*k+5,t,true,s);
        dfs(10*k+7,t,f,true);
        if(t&&f&&s){
            ans++;
        }
    }
}
int main(){
    //int n;
    cin >> n;
    dfs(0,false,false,false);
    cout <<ans <<endl;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())

    if n == 0 and x == 0:
        break

    count = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            if i == j:
                break
            else:
                for k in range(1, n + 1):
                    if k == i or k == j:
                        break
                    elif (i + j + k) == x:
                        count += 1
    print(count)



Measured memory_bytes: 5592
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

const double pi = 3.14159265;

int main(){
  int n;
  while(cin>>n, n){
    int sum = 0;
    int ang;
    double s1 = 0.0, s2 = 0.0;
    REP(i,n-1){
      cin>>ang;
      sum += ang;
      s1 += sin(pi * ang/180.0);
    }
    s1 += sin(pi * (360-sum)/180.0);

    int m;
    cin >> m;
    sum = 0;
    REP(i,m-1){
      cin>>ang;
      sum += ang;
      s2 += sin(pi * ang/180.0);
    }
    s2 += sin(pi * (360-sum)/180.0);

    if(abs(s1-s2) < 1e-15) puts("0");
    else if(s1 > s2) puts("1");
    else puts("2");
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;
int main(void){
    int N;
    cin >> N;
    int sum = 0;
    int max_S = 0;
    for(int i=0;i<N;i++){
        int l;
        cin >> l;
        sum += l;
        max_S = max(max_S,l);
    }
    string ans = "Yes";
    if(max_S >= sum - max_S){
        ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
n = int(input())
A = list(map(int, input().split()))
cnt4 = 0
cnt2 = 0
other = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
        continue
    if a % 2 == 0:
        cnt2 += 1
    else:
        other += 1
if cnt4+1 >= cnt2 + other or cnt4 >= other:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 20000
using System;
using System.Collections.Generic;

namespace abc123_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var NumberOfLine = 5;
            var inputs = new List<string>();
            for(int lineIndex=0;lineIndex<NumberOfLine;lineIndex++)
            {
                inputs.Add(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine());
            int a = int.Parse(inputs[0]);
            int b = int.Parse(inputs[1]);
            int c = int.Parse(inputs[2]);
            int d = int.Parse(inputs[3]);
            int e = int.Parse(inputs[4]);
            

            if (e - a <= k)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }
    }
}


Measured memory_bytes: 13140
n,k=map(int,input().split())
a=list(map(int,input().split()))

x=0
y=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if a[i]>a[j]:
            x+=1
for i in range(len(a)):
    for j in range(0,i):
        if a[i]>a[j]:
            y+=1
ans=x*k*(k+1)//2+y*k*(k-1)//2
print(ans%(10**9+7))


Measured memory_bytes: 3188
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll n;
  std::cin>>n;

  ll sum=0;
  ll ans=0;
  rep(i,0,n){
    ll a;
    std::cin>>a;

    if(a==0){
      ans+=sum/2;
      sum=0;
    }else{
      sum+=a;
    }
  }

  std::cout<<ans+sum/2<<"\n";

  return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int n;
    cin >> n >> s;

    LL ans = 1;
    map<char, LL> mp;
    REP(i, n) mp[s[i]]++;

    for (int j = 0; j < 26; j++)
    {
        ans = ans * (mp[(char)('a' + j)] + 1) % MOD;
    }

    cout << (ans + MOD - 1) % MOD << endl;
}

Measured memory_bytes: 512
/*
AOJ_0002_DigitNumber

EOFはWindowsはCtrl+Z,UNIXはCtrl+D

*/

#include <iostream>
#include <string>
#include <cstdio>
#include <math.h>

using namespace std;

int main() {
	int a, b;

	//while (scanf("%d %d", &a, &b) != EOF){
	while (cin >> a >> b){
		cout << (int)log10(a + b) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#include <iostream>

using namespace std;


//配列の要素を順番に出力
void trace(int a[], int n){
    for(int i = 0; i<n; i++){
        if(i>0) cout << ' ';
        cout << a[i];
    }
    cout << '\n';
}

//挿入ソート（０オリジン配列）
void insertionSort(int a[], int n){
    int i, j, v;
    for(i = 1; i<n; i++){
        v = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j + 1] = a[j];
            j--;
        }
        a[j+1] =v;
        trace(a, n);
    }
}

int main(){
  int n, i, j;
  int a[100];

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

  trace(a, n);
  insertionSort(a, n);

  return 0;
}


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

int main() {
  int N,sum;
  cin >> N;
  sum=1;
  vector<int> point(N);
  for(int i=0;i<N;i++){
  	cin >> point.at(i);
  }
  sort(point.begin(),point.end());
  for(int i=0;i<N-1;i++){
  	if(point.at(i+1)>point.at(i)){
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct mint{
	ull v;
	mint(ll vv=0){s(vv%mod+mod);}
	mint& s(ull vv){
		v=vv<mod?vv:vv-mod;
		return *this;
	}
	mint operator-()const{return mint()-*this;}
	mint& operator+=(const mint&rhs){return s(v+rhs.v);}
	mint&operator-=(const mint&rhs){return s(v+mod-rhs.v);}
	mint&operator*=(const mint&rhs){
		v=ull(v)*rhs.v%mod;
		return *this;
	}
	mint&operator/=(const mint&rhs){return *this*=rhs.inv();}
	mint operator+(const mint&rhs)const{return mint(*this)+=rhs;}
	mint operator-(const mint&rhs)const{return mint(*this)-=rhs;}
	mint operator*(const mint&rhs)const{return mint(*this)*=rhs;}
	mint operator/(const mint&rhs)const{return mint(*this)/=rhs;}
	mint pow(int n)const{
		mint res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	mint inv()const{return pow(mod-2);}
	/* mint inv()const{
		int x,y;
		int g=extgcd(v,mod,x,y);
		assert(g==1);
		if(x<0)x+=mod;
		return mint(x);
    }*/
	friend ostream& operator<<(ostream&os,const mint&m){
		return os<<m.v;
	}
	bool operator<(const mint&r)const{return v<r.v;}
	bool operator==(const mint&r)const{return v==r.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
int main(){
    int n,k;
    cin>>n>>k;
    init();
    for(int i=1;i<=k;i++){
        mint ans=COM(n-k+1,i)*COM(k-1,i-1);
       cout<<ans<<endl;
    }
}

Measured memory_bytes: 47104
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

int n;

struct node{
	int l,r;
	int key;
	void init(int a){
		l=r=-1;
		key=a;
	}
};
struct bst{
	int size;
	node t[600001];
	void init(){
		size=0;
	}
	void insert(int v){
		int i=0;
		while(i<size){
			int& child=(v<t[i].key?t[i].l:t[i].r);
			if(child==-1)child=size;
			i=child;
		}
		t[size++].init(v);
	}
	bool find(int v){
		int i=0;
		while(i<size){
			if(t[i].key==v)return true;
			int child=(v<t[i].key?t[i].l:t[i].r);
			if(child==-1)child=size;
			i=child;
		}
		return false;
	}

	void preorder(int pos){
		if(pos==-1|| pos==size)return;
		printf(" %d",t[pos].key);
		preorder(t[pos].l);
		preorder(t[pos].r);
	}

	void inorder(int pos){
		if(pos==-1|| pos==size)return;
		inorder(t[pos].l);
		printf(" %d",t[pos].key);
		inorder(t[pos].r);
	}

	void postorder(int pos){
		if(pos==-1|| pos==size)return;
		postorder(t[pos].l);
		postorder(t[pos].r);
		printf(" %d",t[pos].key);
	}
};

bst T;

int main(void){
	scanf("%d",&n);
	char str[100];
	for(int i=0;i<n;i++){
		scanf("%s",str);
		if(str[0]=='i'){
			int a;
			scanf("%d",&a);
			T.insert(a);
		}else if(str[0]=='f'){
			int a;
			scanf("%d",&a);
			printf("%s\n",T.find(a)?"yes":"no");
		}else{
			T.inorder(0);
			printf("\n");
			T.preorder(0);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 7392
#include <iostream>

using namespace std;
typedef long long ll;
const int MAX = 6010;
ll inv[MAX],fact[MAX],fi[MAX],mod = 998244353;
void inverse(){
	int i;
	inv[1] = 1;
	for(i=2;i<MAX;i++){
		inv[i] = mod - (mod/i)*inv[mod%i]%mod;
	}
	fact[0] = fi[0] = 1;
	for(i=1;i<MAX;i++){
		fact[i] = fact[i-1]*i%mod;
		fi[i] = (fi[i-1]*inv[i])%mod;
	}
}

ll comb(int n,int k){
	if(n<0 || k<0 || n<k){
		return 0;
	}else{
		return fact[n]%mod*fi[k]%mod*fi[n-k]%mod;
	}
}

ll solve(int x,int s,int t){
	int k = s + 2*t;
	if(k<x) return comb(s + t,t);
	if((k - (x - 1))&1) return 0;
	if(s==0) return (x&1);
	if(k>=2*(x - 1)) return 0;
	int l = k - (x - 1);
	return comb(s + t - l,s);
}

int main(){
	int i,j,n,x;
	cin >> n >> x;
	inverse();
	ll ans = 0;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			if(i + j>n) continue;
			(ans += solve(x,i,j)*comb(n,(i + j))%mod) %= mod;
		}
	}
	cout << ans << endl;
}

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

int solve(int n){
    int ret = 0;
    int m = floor(sqrt(n/6 + 6)) + 1;
    for (int x = 1; x < m; x++)
    {
        for (int y = x; y*y < n; y++)
        {
            int rhs = n - x*x - y*y - x*y;
            for (int z = y; z*z < n; z++)
            {
                if(z*z + (x+y)*z == rhs){
                    if(x == y && z == y)ret++;
                    else if(x == y || y == z)ret += 3;
                    else ret += 6;
                }
            }  
        }
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cout << solve(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 3680
import copy

A = []
for x in range(3):
 A.append(list(map(int,input().split())))

A_rep = copy.deepcopy(A)

N = int(input())

B = []
for x in range(N):
    B.append(int(input()))
    #B = int(input())

for x in range(3):   
    for y in range(3):
        for z in B:
            if A_rep[x][y] == z:
                A_rep[x][y] = -1

#print(A)
#print(A_rep)
#print(B)

for x in range(3):
    if max(A_rep[x]) == -1:
        print("Yes")
        exit()

if A_rep[0][0] == -1 and A_rep[1][0] == -1 and A_rep[2][0] == -1:
    print("Yes")
    exit()

if A_rep[0][1] == -1 and A_rep[1][1] == -1 and A_rep[2][1] == -1:
    print("Yes")
    exit()

if A_rep[0][2] == -1 and A_rep[1][2] == -1 and A_rep[2][2] == -1:
    print("Yes")
    exit()


if A_rep[0][0] == -1 and A_rep[1][1] == -1 and A_rep[2][2] == -1:
    print("Yes")
    exit()

if A_rep[0][2] == -1 and A_rep[1][1] == -1 and A_rep[2][0] == -1:
    print("Yes")
    exit()

print("No")







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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int R = a+b;
  int L = c+d;

  if (R > L){
    cout << "Left" << endl;
  } else if (R == L){
    cout << "Balanced" << endl;
  } else if (R < L){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 3584
n = gets.to_i
c = n.times.map {gets.to_i}
M = 10 ** 9 + 7
m = Array.new(2 * 10 ** 5 + 1)
m[c[-1]] = 1

(n-2).downto(0) do |i|
    x, y = c[i], c[i+1]
    next if x == y
    m[x] = m[x] ? (m[x] + m[y]) % M : m[y]
end
#p m[0..5]
p m[c[0]]

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

int main(){

	int N;
	cin >> N;
	int H[N];
	for(int k = 0; k < N; k++){
		cin >> H[k];
	}

	int ans = 0;
	for(int i = 0; i < N; i++){
		int count = 0;
		for(int j = 0; j < i; j++){
			if(H[i] >= H[j]){
				count++;
			}
		}
		if(count == i){
			ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	long long int mi[100000] = {};
	long long int ma[100000] = {};
	long long  int t = 0;
	for (int i = 0; i < N; i++) {
		long long int a;
		cin >> a;
		if (a > t) {
			t = a;
			mi[i] = a;
			ma[i] = a;
		}
		else {
			mi[i] = 1;
			ma[i] = t;
		}
	}
	t = 0;
	int num[100001] = {};
	for (int i = 0; i < N; i++)cin >> num[i];
	for (int i = N-1; i >=0; i--) {
		long long int a = num[i];
		if (a > t) {
			t = a;
			mi[i] = max(mi[i], a);
			ma[i] = min(ma[i], a);
		}
		else {
			mi[i] = max(mi[i], 1ll);
			ma[i] = min(ma[i], t);
		}
	}
	ans = 1;
	for (int i = 0; i < N; i++) {
	//	cout << ma[i] << " " << mi[i] << endl;
		ans *= max(0ll,(ma[i] - mi[i] + 1));
		ans %= MOD;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2176
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s []byte
	fmt.Scan(&s)
	n := len(s)
	as := make([]int, n)
	for i := range as {
		a, _ := strconv.Atoi(string([]byte{s[i]}))
		as[i] = a
	}
	ms := make([]int, n+1)
	const mod = 2019
	ms[0] = 0
	k := 1
	for i := n - 1; i >= 0; i-- {
		ms[n-i] = as[i]*k + ms[n-i-1]
		ms[n-i] %= mod
		k *= 10
		k %= mod
	}
	m := make(map[int]int)
	for i := range ms {
		m[ms[i]]++
	}
	var ans int
	for _, v := range m {
		if v > 1 {
			ans += v * (v - 1) / 2
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		sc.close();
		if(H%A==0) {
			System.out.println(H/A);
		}else {
			System.out.println(H/A+1);
		}
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ull unsigned long long
#define mp make_pair
#define F first
#define S second
#define mod 1000000007

ll g[51][51];
int n;
ll g_fake[51][51];
ll g_cur[51][51];
ll k;

void mul()
{
    ll ans[51][51];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            ll cur = 0;
            for(int k=0;k<n;k++)
                cur += (g_fake[i][k]*g_fake[k][j])%mod;
            ans[i][j] = cur%mod;
        }

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            g_fake[i][j] = ans[i][j];
    
}

void mul_cur()
{
    ll ans[51][51];
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            ll cur = 0;
            for(int k=0;k<n;k++)
                cur += (g_cur[i][k]*g_fake[k][j])%mod;
            ans[i][j] = cur%mod;
        }

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            g_cur[i][j] = ans[i][j];
    
}


int main()
{
    cin >> n >> k;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin >> g[i][j];
    
    for(int i=0;i<n;i++)
        g_cur[i][i] = 1;

    ll base = 2;
    while(k)
    {   
        //cout << "k: " << k << endl;
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                g_fake[i][j] = g[i][j];
        
        base = 2;
        while(base <= k)
        {
            mul();
            base *= 2;
        }

        if(base>k)
            base/=2;
        k -= base;

        mul_cur();
    }

    ll ans = 0;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            ans = (ans+g_cur[i][j])%mod;
    
    cout << ans << endl;


    



    



}


Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];
    auto as = readln.split.to!(int[]).map!"a - 1"().array();
    int[] bs = [0];
    auto memo = new int[](N);
    int n = as[0];
    foreach (i; 1..N) {
        if (n == 0 || memo[n]) break;
        memo[n] = i.to!int;
        bs ~= n;
        n = as[n];
    }
    if (K < bs.length) {
        writeln(bs[K]+1);
    } else {
        auto f = memo[n];
        K -= f;
        bs = bs[f..$];
        writeln(bs[K%bs.length]+1);
    }
}

Measured memory_bytes: 13208
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = 0;
		int max = 0;
		int ans = 0;
		for (int i = 0; i < n; i++) {
			p = sc.nextInt();
			max = Math.max(max, p);
			ans += p;
		}
		sc.close();

		ans -= max / 2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
std::vector<std::vector<int>> vec;
int x[2];
int main(){
	do{
		std::cin>>x[0]>>x[1];
		if(x[0]!=0 && x[1]!=0)vec.push_back(std::vector<int>{x[0],x[1]});
	}while(x[0]!=0 && x[1]!=0);
	for(auto v:vec){
		for(int i=0;i<v[0];++i){
			if(i==0 || i+1==v[0]){
				std::cout<<std::string(v[1],'#')<<std::endl;
			}else std::cout<<"#"<<std::string(v[1]-2,'.')<<"#"<<std::endl;
		}
		std::cout<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    string s; cin>>s;
    if(s=="hi" || s=="hihi" || s=="hihihi" || s=="hihihihi" || s=="hihihihihi"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
	return 0;
}


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

#include <iostream>
#include <vector>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

void print(string& str, int begin, int end) {
	for (int i = begin; i <= end; i++) {
		cout << str[i];
	}
	cout << endl;
}

void reverse(string& str, int begin, int end) {
	for (int i = begin, count = 0; i <= (begin + end) / 2; i++, count++) {
		char tmp = str[i];
		str[i] = str[end - count];
		str[end - count] = tmp;
	}
}

void replace(string& str, int begin, int end, string p) {
	for (int i = begin, count = 0; i <= end; i++, count++) {
		str[i] = p[count];
	}
}

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

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		string op;
		int b, e;
		cin >> op >> b >> e;
		if (op == "print") {
			print(str, b, e);
		}
		if (op == "reverse") {
			reverse(str, b, e);
		}
		if (op == "replace") {
			string p;
			cin >> p;
			replace(str, b, e, p);
		}
	}
	// std::cout << "\e[38;5;0m\e[48;5;40m --- end ---  \e[m" << std::endl; // debug
	return 0;
}



Measured memory_bytes: 3176
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
#define ALL(v)  (v).begin(),(v).end()
std::set<int> st;
using ll = long long;

ll gcd(ll a,ll b){
	if(b == 0) return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g = gcd(a,b);
	return a / g * b; // Be careful not to overflow
}
int main(void) {
	int N;
	cin >> N;

	ll ans = 1LL;

	for (int i = 0; i < N; ++i) {
		ll T;
		cin >> T;
		ans = lcm(ans, T);
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

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

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

bool place(vector<vector<bool>>& bo, const pii& p) {
	int a = p.first, b = p.second;
	bo[a][b] = true;
	rep(i, 8) if(i != b && bo[a][i]) return false;
	rep(i, 8) if(i != a && bo[i][b]) return false;

	int di[] = {1, 1, -1, -1};
	int dj[] = {1, -1, 1, -1};
	rep(k, 4) {
		int i = a + di[k], j = b + dj[k];
		while(i >= 0 && i < 8 && j >= 0 && j < 8) {
			if(bo[i][j]) return false;
			i += di[k];
			j += dj[k];
		}
	}
	return true;
}

int main() {
//	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<pii> p(n);
	rep(i, n) cin >> p[i].first >> p[i].second;

	vector<vector<bool>> board(8, vector<bool>(8, false));
	vi per(8);
	rep(i, 8) per[i] = i;
 	do {
		bool valid = true;
		rep(i, n) if(per[p[i].first] != p[i].second) valid = false;
		if(!valid) continue;

		valid = true;
		rep(i, 8) rep(j, 8) board[i][j] = false;
		rep(i, 8) if(!place(board, pii(i, per[i]))) valid = false;
		if(valid) break;
	} while(next_permutation(per.begin(), per.end()));

	rep(i, 8) {
		rep(j, 8) {
			if(per[i] == j) cout << 'Q';
			else cout << '.';
		}
		cout << endl;
	}
}



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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

void solve() {
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; ++i) cin >> a.at(i);

  sort(a.begin(),a.end());
  int ans=n;
  int dupes=0;
  for(int i=0; i<n; ++i) {
    int x=a.at(i);
    int count=1;
    for(int j=i+1; j<n; ++j,++i) {
      if(x!=a.at(j)) break;
      ++count;
    }
    if(count>=3) {
      if(count%2==0) {
        ans-=count-2; ++dupes;
      } else {
        ans-=count-1;
      }
    } else if(count==2) {
      ++dupes;
    }
  }
  if(dupes%2!=0) ++dupes;
  
  cout << ans-dupes << endl;

  return;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;
long long ll_MAX = 1000000000000000000;
int int_MAX = 1000000;

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
  return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
  cout << setprecision(10);
  int N, Ma, Mb; 
  cin >> N >> Ma >> Mb;
  vector<int> a(N), b(N), c(N);
  for(int i = 0; i < N; i++){
    cin >> a[i] >> b[i] >> c[i];
  }

  auto dp = make_vec<int>(N, 401, 401);

  for(int i = 0; i < N; i++){
    for(int j = 0; j <= 400; j++){
      for(int k = 0; k <= 400; k++){
        dp[i][j][k] = int_MAX;
        if(j == 0 && k == 0){
          dp[i][j][k] = 0;
        }
      }
    }
  }
  dp[0][0][0] = 0;
  dp[0][a[0]][b[0]] = c[0];

  for(int i = 1; i < N; i++){
    for(int j = 0; j <= 400; j++){
      for(int k = 0; k <= 400; k++){
        if(j - a[i] >= 0 && k - b[i] >= 0){
          dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a[i]][k-b[i]] + c[i]);
        }
        dp[i][j][k] = min(dp[i-1][j][k], dp[i][j][k]);

      }
    }
  }

  int ans = int_MAX;
  for(int i = 1; (Ma * i <= 400) && (Mb * i <= 400); i++){
    ans = min(dp[N-1][Ma*i][Mb*i], ans);
  }
  cout << (ans == int_MAX ? -1 : ans ) << endl;


}


Measured memory_bytes: 26624
#include <iostream>
#include <algorithm>
#include <vector>

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

    std::vector<std::vector<int>> a(n, std::vector<int>(m));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> a[i][j];
            a[i][j]--;
        }
    }

    int ok = n;
    int ng = 0;
    while (ok - ng > 1) {
        int mid = (ok + ng) / 2;

        std::vector<int> cnt(m);
        std::vector<bool> used(m, true);

        auto setval = [&]() {
            for (int i = 0; i < m; i++) {
                cnt[i] = 0;
            }
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (used[a[i][j]]) {
                        cnt[a[i][j]]++;
                        break;
                    }
                }
            }
        };

        setval();

        while (true) {
            int pos = -1;
            for (int i = 0; i < m; i++) {
                if (cnt[i] > mid) {
                    pos = i;
                    break;
                }
            }
            if (pos == -1) break;
            used[pos] = false;
            setval();
        }

        if (std::count(used.begin(), used.end(), true) != 0) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    std::cout << ok << std::endl;
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static int binarySearchRightMost(int arr[],int key){
        int l=0,r=arr.length-1;
        while (l<r){
            int mid=Math.floorDiv(l+r,2);
            if(arr[mid]>key){
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        return r-1;

    }

    public static void main(String[] args) {
//        int arr[]={1,2,3,4,4,4,6,7};
//        System.out.println(binarySearchRightMost(arr,4));
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int k=scanner.nextInt();
        long arr[]=new long[n];
        for(int j=0;j<n;j++){
            arr[j]=scanner.nextLong();
        }
        Arrays.sort(arr);
        int c=0;
        if(k>0) {
            for (int j = arr.length - 1; j >= 0; j--) {
                arr[j] = 0;
                c++;
                if (c == k) {
                    break;
                }
            }
        }
        long ans=0;
        for(int j=0;j<arr.length;j++){
            ans=(long)((long)ans+(long)arr[j]);
        }
        System.out.println(ans);
//        int arr[]=new int[b];
//        for(int j=0;j<b;j++){
//            a-=scanner.nextInt();
//            if(a<=0){
//                System.out.println("Yes");
//                break;
//            }
//        }
//        if(a>0){
//            System.out.println("No");
//        }
//        System.out.println(a%b==0?Math.floorDiv(a,b):Math.floorDiv(a,b)+1);
    }
}


Measured memory_bytes: 92212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

int main(){
    
    int N, D;
    cin >> N >> D;
    
    ld temp = 0.0;
    int cnt = 0;
    for(int i=0; i<N; i++){
        double x, y;
        cin >> x >> y;
//        if(x>D) continue;
//        if(y>D) continue;
        temp = sqrt(x*x + y*y);
        cerr << "> debug: " << temp << endl;

        if(temp<=D) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<string>

using namespace std;

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

    int ans = 0;

    for(int i=0;i<s.length();i++){
        if(s[i]=='?')s[i]='D';
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3732