akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <memory>
using namespace std;
typedef long long ll;

#define MAX_N (1<<20)

struct SegTree {
  unique_ptr<int[]> D;
  SegTree() {
    D = make_unique<int[]>(2 * MAX_N);
    for (int i=0; i<2*MAX_N; i++) {
      D[i] = 0;
    }
  }
  void update(int k, int a) {
    k += MAX_N;
    D[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      D[k] = D[k*2+1] + D[k*2 + 2];
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return D[k];
    else {
      int vl = query(a, b, k*2+1, l, (l+r)/2);
      int vr = query(a, b, k*2+2, (l+r)/2, r);
      return vl + vr;
    }
  }
};

int main() {
  ios::sync_with_stdio(false);
  int N, Q;
  string S;
  cin >> N >> S >> Q;
  SegTree st[26];
  for (int i=0; i<S.size(); i++) {
    int letter = S[i] - 'a';
    st[letter].update(i, 1);
  }
  for (int q=0; q<Q; q++) {
    int type;
    cin >> type;
    if (type == 1) {
      int idx;
      char c;
      cin >> idx >> c;
      idx--;
      if (S[idx] != c) {
        st[S[idx] - 'a'].update(idx, 0);
        st[c - 'a'].update(idx, 1);
        S[idx] = c;
      }
    } else {
      int l, r;
      cin >> l >> r;
      int ret = 0;
      for (int i=0; i<26; i++) {
        ret += st[i].query(l, r+1, 0, 0, MAX_N) > 0;
      }
      cout << ret << '\n';
    }
  }
}

Measured memory_bytes: 214044
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();

        while (true) {
            if (C - B <= 0) {
                System.out.println("Yes");
                return;
            } else {
                C -= B;
            }
            if (A - D <= 0) {
                System.out.println("No");
                return;
            } else {
                A -= D;
            }
        }
    }
}

Measured memory_bytes: 27004
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var count = 0;
            for (int i = 1; i <= N; i += 2)
            {
                if (GetYakusu(i).Count() == 8)
                    count++;
            }
            return count;
        }
        IEnumerable<int> GetYakusu(int n)
        {
            int amari;
            var sqrt = (int)Math.Sqrt(n);
            for (int i = 1; i <= sqrt; i++)
            {
                var d = Math.DivRem(n, i, out amari);
                if (amari == 0)
                {
                    yield return i;
                    if (i != d)
                        yield return d;
                }
            }
        }

        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader()).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader { public class SplitLine { string[] splited; public SplitLine(string line) { splited = line.Split(); } public string[] String => splited.ToArray(); public int[] Int => splited.Select(int.Parse).ToArray(); public long[] Long => splited.Select(long.Parse).ToArray(); public ulong[] ULong => splited.Select(ulong.Parse).ToArray(); public double[] Double => splited.Select(double.Parse).ToArray(); } public class RepeatLine { ConsoleReader reader; int num; public RepeatLine(ConsoleReader reader, int num) { this.reader = reader; this.num = num; } public IEnumerable<string> String { get { for (int i = 0; i < num; i++) yield return reader.String; } } public IEnumerable<int> Int { get { for (int i = 0; i < num; i++) yield return reader.Int; } } public IEnumerable<long> Long { get { for (int i = 0; i < num; i++) yield return reader.Long; } } public IEnumerable<string[]> Split { get { for (int i = 0; i < num; i++) yield return reader.Split.String; } } public IEnumerable<int[]> SplitInt { get { for (int i = 0; i < num; i++) yield return reader.Split.Int; } } } public virtual string String => Console.ReadLine(); public int Int => int.Parse(String); public long Long => long.Parse(String); public ulong ULong => ulong.Parse(String); public double Double => double.Parse(String); public SplitLine Split => new SplitLine(String); public RepeatLine Repeat(int count) => new RepeatLine(this, count); }
}

Measured memory_bytes: 11220
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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

	int N;
	cin >> N;
	//vector<pair<int,int> > P;
//	REP(i, N) {
	//	int p;
	//	cin >> p;
	//	P.push_back(make_pair(i,p));
	//}
	VI P(N);
	REP(i, N)
		cin >> P[i];
	VI A(N);
	VI B(N);

	REP(i, N)A[i] = (i + 1)*N;

	int j = 1;
	for (int i = N - 1; i >= 0; i--){
		B[i] = j*N;
		j++;
	}
	REP(i, N) {
		A[P[i]-1]+=i;
	}
	
	cout << A[0];
	FOR(i, 1, N)
		cout << " " << A[i];
	cout << endl;

	cout << B[0];
	FOR(i, 1, N)
		cout << " " << B[i];
	cout << endl;

	return 0;
}



Measured memory_bytes: 1152
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const n = Number(inputs.shift());
const adj = inputs.map((s) => s.split(' ').map(Number));

class Node {
  constructor(id) {
    this.id = id;
    this.children = [];
  }
  getDepth() {
    if (this.depth === undefined) {
      this.depth = this.parent ? this.parent.getDepth() + 1 : 0;
    }
    return this.depth;
  }
  add(node) {
    node.parent = this;
    this.children.push(node);
  }
  getType() {
    if (this.getDepth() === 0) {
      return 'root';
    }
    return this.children.length ? 'internal node' : 'leaf';
  }
  toString() {
    return 'node ' + this.id + ': ' + [
      'parent = ' + (this.parent ? this.parent.id : -1),
      'depth = ' + this.getDepth(),
      this.getType(),
      '[' + this.children.map(node => node.id).join(', ') + ']',
    ].join(', ');
  }
}

class Tree {
  constructor() {
    this.map = new Map();
  }
  getNode(id) {
    if (!this.map.has(id)) {
      this.map.set(id, new Node(id));
    }
    return this.map.get(id);
  }
  print() {
    for (let i = 0; i < this.map.size; i++) {
      const node = this.map.get(i);
      console.log(node.toString());
    }
  }
}

const tree = new Tree();
adj.forEach(([id, k, ...ck]) => {
  const parent = tree.getNode(id);
  ck.forEach(c => {
    const node = tree.getNode(c);
    parent.add(node);
  });
});

tree.print();



Measured memory_bytes: 110284
#include<iostream>
#include<vector>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
#define ll long long
using namespace std;

int main(){
    ll X,N,ans;
    int b;
    double B;
    cin >> X >> N;
    vector<ll>p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    if(N==0){
        cout << X <<endl;
        return 0;
    }
    sort(p.begin(),p.end());
    for(int i=0;i<105;i++){
        int a,b;
        a = X-i;
        b = X+i;
        if(find(p.begin(), p.end(), a) == p.end()){
            cout << a << endl;
            return 0;
        } 
        if(find(p.begin(), p.end(), b) == p.end()){
            cout << b << endl;
            return 0;
        } 
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl "\n"
#define mod 1000000007

ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
// Function to find modulo inverse of b. It returns 
// -1 when inverse doesn't 
ll modInverse(ll b, ll m) 
{ 
    ll x, y; // used in extended GCD algorithm 
    ll g = gcdExtended(b, m, &x, &y); 
  
    // Return -1 if b and m are not co-prime 
    if (g != 1) 
        return -1; 
  
    // m is added to handle negative x 
    return (x%m + m) % m; 
} 
  
// Function to compute a/b under modlo m 
ll modDivide(ll a, ll b, ll m) 
{ 
    a = a % m; 
    ll inv = modInverse(b, m); 
     return (inv * a) % m; 
} 
  
// C function for extended Euclidean Algorithm (used to 
// find modular inverse. 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; // To store results of recursive call 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 



ll fi(ll A[], ll n) 
{ 
    // calculating array sum (a1 + a2  ... + an) 
    ll array_sum = 0; 
    for (ll i = 0; i < n; i++) 
        array_sum = (array_sum%mod + A[i]%mod)%mod; 
  
    // calcualting square of array sum 
    // (a1 + a2 + ... + an)^2 
    ll array_sum_square = (array_sum%mod * array_sum%mod)%mod; 
  
    // calcualting a1^2 + a2^2 + ... + an^2 
    ll individual_square_sum = 0; 
    for (ll i = 0; i < n; i++) 
        individual_square_sum = (individual_square_sum%mod+(A[i]%mod*A[i]%mod)%mod)%mod; 
  
    // required sum is (array_sum_square - 
    // individual_square_sum) / 2 
    array_sum_square=array_sum_square%mod;
    individual_square_sum=individual_square_sum%mod;
     ll v= (array_sum_square%mod - individual_square_sum%mod)%mod;
     if(v<0)
     v=v+mod;
     return modDivide(v, (ll)2, mod);
} 

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    cout<<fi(arr,n);
	return 0;
}


Measured memory_bytes: 5192
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		boolean[] prime = new boolean[300000];
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for (int i = 0; i < prime.length; i++)
			if (prime[i])
				for (int j = i * 2; j < prime.length; j += i)
					prime[j] = false;
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int result = 0;
			for (int i = n + 1; i <= 2 * n; i++)
				if (prime[i])
					result++;
			System.out.println(result);
		}
		scanner.close();
	}
}

Measured memory_bytes: 22604
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m,k = LI()
a = LI()
b = LI()
a = [0] + list(accumulate(a))
b = [0] + list(accumulate(b))
ans = 0
for i in range(n+1):
    r = br(b, k-a[i])
    if r == 0 and a[i] <= k:
        ans = max(ans, i + r - 1)
    elif r != 0:
        ans = max(ans, i + r - 1)
print(ans)


Measured memory_bytes: 138936
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

struct UnionFind {
	vector<int> data;
	void init(int n) { data.assign(n, -1); }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if(x != y) {
			if(data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) { return root(x) == root(y); }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	int size(int x) { return -data[root(x)]; }
};

typedef int Weight;
struct Edge {
	int x, y;
	Weight w;
	Edge() { }
	Edge(int x_, int y_, Weight w_): x(x_), y(y_), w(w_) { }
};
bool operator<(const Edge &a, const Edge &b) { return a.w < b.w; }


int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	vector<Edge> edges(M);
	rep(i, M) {
		int S, D, C;
		scanf("%d%d%d", &S, &D, &C), -- S, -- D;
		edges[i] = Edge(S, D, C);
	}
	sort(all(edges));
	vector<int> mst;
	{	UnionFind uf; uf.init(N);
		rep(i, edges.size()) {
			Edge e = edges[i];
			if(uf.unionSet(e.x, e.y))
				mst.push_back(i);
		}
	}
	int cnt = 0, sum = 0;
	rep(ix, mst.size()) {
		UnionFind uf; uf.init(N);
		int i = mst[ix];
		rep(jx, mst.size()) if(ix != jx)
			uf.unionSet(edges[mst[jx]].x, edges[mst[jx]].y);
		bool important = true;
		int w = edges[i].w;
		rep(j, edges.size()) if(j != i) {
			if(w == edges[j].w && !uf.findSet(edges[j].x, edges[j].y)) {
				important = false;
			}
		}
		if(important) {
			++ cnt;
			sum += w;
		}
	}
	printf("%d %d\n", cnt, sum);
	return 0;
}

Measured memory_bytes: 1532
#include<stdio.h>
int main()
{
    int A,B,x,y,z;
    scanf("%d%d",&A,&B);
    x=A+B;
    y=A-B;
    z=A*B;
    if(x>=y && x>=z)
    {
       printf("%d\n",x);
    }
    else if(y>=x && y>=z)
    {
       printf("%d\n",y);
    }
    else
    {
       printf("%d\n",z);
    }
    return 0;
}


Measured memory_bytes: 128
N, M = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(M)]

B = []
for i in range(M):
    if A[i][0] == 1:
        B.append(A[i][1])
    if A[i][1] == N:
        B.append(A[i][0])
        
if len(set(B)) != len(B):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 50052
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        Point currentPoint = new Point(0, 0);

        for (int i = 0; i < n; i++) {
            final int time = scanner.nextInt();
            final int x = scanner.nextInt();
            final int y = scanner.nextInt();

            final int distance = Math.abs(x - currentPoint.x) + Math.abs(y - currentPoint.y);
            if (distance > time || (time - distance) % 2 == 1) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }

    static class Point {
        int x;
        int y;

        Point(final int x, final int y) {
            this.x = x;
            this.y = y;
        }
    }
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n, m;
    cin >> n >> m;
    vector<Int> a(m);
    for (Int i = 0; i < m; i++) {
        cin >> a[i];
    }
    sort(all(a), greater<Int>());
    vector<Int> b(m - 1);
    for (Int i = 0; i < m - 1; i++) {
        b[i] = a[i] - a[i + 1];
    }
    Int sum = accumulate(all(b), (Int)0);
    sort(all(b), greater<Int>());
    for (Int i = 0; i < min(n - 1, m - 1); i++) {
        sum -= b[i];
    }
    print(sum);
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 4740
# encoding: utf-8
N = int(input())
S = input()

tmp = 0
acm = [0] * (N + 1)

for i, Si in enumerate(S):
    if Si == "W": tmp += 1
    else: tmp -= 1
    acm[i + 1] = tmp

minscore = N
for i in range(N):
    L = acm[i]
    R = acm[N] - acm[i + 1]
    if (L - R) < minscore:
        minscore = (L - R)

print((minscore + N - 1) // 2)

Measured memory_bytes: 15244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i, n) for(int i=((int)(n));i>0;i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	int cnt = 0;
	rep(i, S.size()){
		if(S[i] == '1')cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int H, W, D; cin >> H >> W >> D;
    vvi A(H, vi(W));
    REP(i, H)
        REP(j, W) cin >> A[i][j];

    int Q; cin >> Q;
    vi L(Q), R(Q); REP(i, Q) cin >> L[i] >> R[i];

    map<int, pii> mp;
    REP(i, H)
        REP(j, W) mp[A[i][j]] = pii(i+1, j+1);

    map<pii,int> cost;
    for(int i=1; i+D <= H*W; i++) {
        pii p = mp[i];
        pii np = mp[i + D];
        cost[pii(i, i + D)] = abs(np.first - p.first) + abs(np.second - p.second);
    }
    
    vi sum(H*W + 1, 0);
    sum[H*W] = 0;
    for (int i=H*W; i>=1; i--) {
        if (i + D > H*W) sum[i] = 0;
        else sum[i] = sum[i + D] + cost[pii(i, i + D)];
    }

    REP(i,Q) {
        int ans = sum[L[i]] - sum[R[i]];
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 13952
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    int targetNumber = Integer.parseInt(str);
    int count = 0;
    for(int i=1;i<=targetNumber;i++){
      if(targetNumber > 1){
        for(int j=1;j<=targetNumber;j++){
          for(int k=1;k<=targetNumber;k++){
            count++;      
          }
        }
      }else{
        count++;
      }
    }
    System.out.print(""+count+" ");
  }
}

Measured memory_bytes: 38312
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

string s,t;
int n,m;
int dp[3001][3001];
string ans;
int find()
{
	for (int i = 0; i <= n; i++)  
    {  
        for (int j = 0; j <= m; j++)  
        {  
        if (i == 0 || j == 0)  
            dp[i][j] = 0;  
      
        else if (s[i - 1] == t[j - 1])  
            dp[i][j] = dp[i - 1][j - 1] + 1;  
      
        else
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);  
        }  
    }  
    return dp[n][m];
}
void prints(int i,int j)
{
	if(i==0||j==0)return;

	if(s[i-1]==t[j-1]){ans.pb(s[i-1]);prints(i-1,j-1);}
	else if(dp[i-1][j]>dp[i][j-1])prints(i-1,j);
	else prints(i,j-1);
}
void solve()
  {
	cin>>s>>t;
	n=sz(s);m=sz(t);
	ans.clear();
	rep(i,n)rep(j,m)dp[i][j]=-1;
	find();
	prints(n,m);
	REVERSE(ans);
	cout<<ans;
	// cout<<endl<<endl<<dp[2][4]<<endl<<dp[3][3];

  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


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

typedef long long ll;
const int MAX=1e4+10;
const int mod=1e9+7;

void fun(int *cnt,int n){
    for(int i=2;i<=n;i++){
        while(n%i==0){
            cnt[i]++;
            n/=i;
        }
    }
}

ll solve(int n){
    int cnt[1001]={0};
    ll ans=1;
    for(int i=2;i<=n;i++){
        fun(cnt,i);
    }
    for(int i=2;i<=1000;i++){
        ans=ans*(cnt[i]+1)%mod;
    }
    return ans;
}

int main(){
    int n;
    while(cin>>n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> zyun(N);
  vector<int> p(N);
  for( int i = 0; i < N; i++ ){
    cin >> p.at(i);
    zyun.at(i) = p.at(i);
  }
  
  sort(zyun.begin(),zyun.end());
  
  int count = 0;
  for( int i = 0; i < N; i++ ){
    if( zyun.at(i) != p.at(i) ){
      count++;
    }
  }
  
  if( count > 2 ){
    cout << "NO" << endl;
  }else{
    cout << "YES" << endl;
  }
 
  
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#define MAX 500001
#define NIL -2000000001

void maxHeapify(int*,int);
void buildMaxHeap(int*);

int H;

int main(){
    int key[MAX];
    int i;

    for(i = 0;i < MAX;i++){
        key[i] = NIL;
    }

    scanf("%d",&H);

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

    buildMaxHeap(key);

    for(i = 1;i <= H;i++){
        printf(" %d",key[i]);
    }
    printf("\n");

    return 0;
}

void maxHeapify(int *A,int i){
    int largest,l,r;
    int tmp;

    l = i * 2;
    r = i * 2 + 1;

    if(l <= H && A[l] > A[i]){
        largest = l;
    }
    else{
        largest = i;
    }
    if(r <= H && A[r] > A[largest]){
        largest = r;
    }
    
    if(largest != i){
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        maxHeapify(A,largest);
    }
}

void buildMaxHeap(int *A){
    int i;
    for(i = H / 2 ;i > 0;i--){
        maxHeapify(A,i);
    }
}


Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<map>
#include<set>

using namespace std;

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

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

	vector<int>p(n), q(n);

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

	sort(p.begin(),p.end());

	
	int z = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != q[i]) {
			z++;
		}
	}



	if (z == 2 || z == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

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

 

int main()
{
    int t=1;

    while(t--)
    {

        int n;

    ll ans = 0;cin >> n;

         for(int i = 1; i<=n; i++){

            for(int j = i; j<=n; j+=i){
                ans+=j;
            }
         }


         cout << ans << endl;
    }


    return 0;
}


Measured memory_bytes: 3528
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<cmath>
#include<string>

#define ls (t<<1)
#define rs ((t<<1)+1)
#define mid ((l+r)>>1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back

#define N 100005
#define M 200005
#define seed 23333

using namespace std;
int i,j,m,n,p,k;
char C[2];
char s1[4]={'.','.','#','#'};
char s2[4]={'#','.','#','.'};
int main()
{
		scanf("%d",&n);
		string a,b;
		for (;;)
		{
				string c,d;
				for (i=0;i<4;++i) 
				{
					c=a+s1[i];
					d=b+s2[i];
					cout<<c<<'\n'<<d<<endl;
					scanf("%s",&C);
					if (C[0]=='T') break;
				}
				if (i==4)	break;
				a=c; b=d;
		}
		for (;;)
		{
				string c,d;
				for (i=0;i<4;++i)
				{
						c=s1[i]+a;
						d=s2[i]+b;
						cout<<c<<'\n'<<d<<endl;
						scanf("%s",&C);
						if (C[0]=='T') break;
				}
				if (i==4) break;
				a=c; b=d; 
		}
		cout<<a<<'\n'<<b<<endl;
}


Measured memory_bytes: 724
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	string S;
	cin >> S;
	int N = S.size();
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'A') {
			cout << "T";
		}
		else if (S[i] == 'T') {
			cout << "A";
		}
		else if (S[i] == 'C')cout << "G";
		else cout << "C";
	}
	cout << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())
a = math.radians((H/12+M/720) * 360)
b = math.radians(M/60 * 360)

ax = math.sin(a)*A
ay = math.cos(a)*A
bx = math.sin(b)*B
by = math.cos(b)*B

ans = math.sqrt(abs(ax-bx)**2 + abs(ay-by)**2)
print(ans)


Measured memory_bytes: 9548
import java.io.*;
import java.util.*;
import java.util.function.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer in = new StringTokenizer("");
		int n=Integer.parseInt(br.readLine());
		in=new StringTokenizer(br.readLine());
		Map<Integer,Integer> mp=new HashMap<>();
		Consumer<Integer> add_mp=(it)->mp.put(it, mp.getOrDefault(it, 0)+1);
		Consumer<Integer> subtract_mp=(it)->mp.put(it, mp.getOrDefault(it, 0)-1);
		for(int i=0;i<n;i++)add_mp.accept(Integer.parseInt(in.nextToken()));
		int m=Integer.parseInt(br.readLine());
		in=new StringTokenizer(br.readLine());
		for(int i=0;i<m;i++)subtract_mp.accept(Integer.parseInt(in.nextToken()));
		mp.values().stream().forEach(it->{
			if(it<0){
				System.out.println("NO");
				System.exit(0);
			}
		});
		System.out.println("YES");
	}
}

class Pair<T extends Comparable<T>, U extends Comparable<U>> implements Comparable<Pair<T, U>> {
	public T first;
	public U second;

	public Pair(T first, U second) {
		this.first = first;
		this.second = second;
	}

	@Override
	public int compareTo(Pair<T, U> ob) {
		if (first.compareTo(ob.first) != 0) return first.compareTo(ob.first);
		else return second.compareTo(ob.second);
	}
}

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

public class Main {
	FastScanner in;
	PrintWriter out;

	class O implements Comparable<O> {
		int type;
		int x;

		public O(int type, int x) {
			super();
			this.type = type;
			this.x = x;
		}

		public int compareTo(O arg0) {
			return Integer.compare(x, arg0.x);
		}

	}

	void solve() {
		int n = in.nextInt();
		O[] o = new O[n * 2];
		for (int i = 0; i < n; i++) {
			o[i] = new O(+1, in.nextInt());
		}
		for (int i = 0; i < n; i++) {
			o[i + n] = new O(-1, in.nextInt());
		}
		Arrays.sort(o);
		int cur = 0;
		long res = 1;
		long mod = (long) 1e9 + 7;
		for (O oo : o) {
			if (cur != 0 && oo.type == cur / Math.abs(cur)) {
				res = (res * (Math.abs(cur) + 1) % mod);
			}
			cur += oo.type;
		}
		out.println(res);
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 31212
# from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_2
from itertools import accumulate

n=int(input())
a=[0]+list(accumulate(map(int,input().split())))
dp=[[0]*(n+1) for i in range(n)]
for w in range(2,n+1):
    for l in range(n-w+1):
        r=l+w
        dp[l][r]=min(dp[l][m]+dp[m][r] for m in range(l+1,r)) + a[r]-a[l]
print(dp[0][n])


Measured memory_bytes: 43612
import fractions


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

gcd_l = [0]
gcd_r = [0]
for i in range(N):
    gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
    gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))
gcd_r = gcd_r[::-1]

ans = []
for i in range(N):
    ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))


Measured memory_bytes: 100064
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

bool check(int turn, string str, int player)
{
  if(turn%3 == 0 && turn%5 == 0){
    return str == "FizzBuzz";
  } else if(turn%3 == 0){
    return str == "Fizz";
  } else if(turn%5 == 0){
    return str == "Buzz";
  }

  return atoi(str.c_str()) == turn;
}

int main()
{
  int n, m;
  string str;

  while(cin>>m>>n && n+m){
    queue<int> players;

    for(int i = 1; i <= m; ++i)
      players.push(i);

    for(int i = 1; i <= n; ++i){
      cin >> str;
      if(players.size() == 1) continue;

      int player = players.front();
      players.pop();

      if(check(i, str, player)){
	players.push(player);
      }
    }

    vector<int> vec;
    while(!players.empty()){
      vec.push_back(players.front());
      players.pop();
    }
    sort(vec.begin(), vec.end());

    for(int i = 0; i < vec.size()-1; ++i)
      cout << vec[i] << " ";
    cout << vec.back() << endl;
  }

  return 0;
}

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

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

int A[N];
  for (int i=0; i<N; i++){
   cin >> A[i];
  }
  
int num[N]={0};
  for (int i=0;i<N; i++){
   num[A[i]-1] ++;
  }
  sort(num,num+N); 
  int sum =0;
   for (int i=0; i<N-K; i++){
    sum += num[i];
   }
  cout << sum << endl;  
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  stack<int> st;
  stack<pair<int, int>> st2;

  int sum = 0;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == '\\') {
      st.push(i);
    }
    if (s[i] == '/' && !st.empty()) {
      int left = st.top();
      st.pop();
      int area = i - left;
      sum += area;
      while (st2.size() > 0 && st2.top().first > left) {
        area += st2.top().second;
        st2.pop();
      }
      st2.push(make_pair(left, area));
    }
  }
  vector<int> ans;
  while (!st2.empty()) {
    ans.push_back(st2.top().second);
    st2.pop();
  }
  reverse(ans.begin(), ans.end());

  cout << sum << endl;
  cout << ans.size();
  for (int i = 0; i < ans.size(); i++) {
    cout << " " << ans[i];
  } cout << endl;
  return 0;
}


Measured memory_bytes: 3276
from math import gcd
import time

#pri_arr[i]におけるiの素因数のうち最大の数を持つ配列をつくる
#pri_arrはこんな感じになる↓
#[0, 0, 2, 3, 2, 5, 3, 7, 2, 3,...]
def make_prime_arr(max_a):
    pri_arr = [0] * max_a
    #start_time = time.time()
    for i in range(2, max_a):
        if(pri_arr[i] != 0):
            continue
        for j in range (i, max_a, i):
            pri_arr[j] = i
    #end_time = time.time()
    #print(end_time - start_time)
    return pri_arr


#pairwiseかどうかを判定する関数
def is_pairwise(a_arr, pri_arr, max_a):
    flg_arr = [0] * (max_a)
    for a_ele in a_arr:
        x = a_ele
        y = 0
        while x != 1:
            if(pri_arr[y] != pri_arr[x]):
                flg_arr[pri_arr[x]] += 1
            if flg_arr[pri_arr[x]] > 1:
                return False
            y = x
            x = x // pri_arr[x]
            
    return True


#setwiseかどうかを判定する関数
def is_setwise(a_arr, N):
    entire_gcd = a_arr[0]
    for i in range(1, N):
        entire_gcd = gcd(entire_gcd, a_arr[i])
    if entire_gcd != 1:
        return False        
    return True


def main():
    N = int(input())
    a_arr = list(map(int, input().split(" ")))
    max_a = 10**6 + 1
    pri_arr = make_prime_arr(max_a)
    if is_pairwise(a_arr, pri_arr, max_a):
        print("pairwise coprime")
    elif is_setwise(a_arr, N):
        print("setwise coprime")
    else:
        print("not coprime")

if __name__ == "__main__":
    main()

Measured memory_bytes: 132536
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        Long[] a = new Long[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextLong();
            if(i != 0) {
                a[i] += a[i - 1];
            }
        }
        Map<Long, Long> map = new HashMap<>();
        map.put(0L, 1L);
        for(long num: a) {
            Long val = num % m;
            map.put(val, map.getOrDefault(val, 0L) + 1L);
        }
        long ans = 0;
        for(Long val : map.values()) {
            ans += val * (val - 1) / 2;
        }
        System.out.println(ans);
    }
}


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

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

    string s[input.length()];

    for ( int i = 0; i < input.length(); i++) {
        s[i] = input.substr(i, 1);
    }

    if ( ( s[0] == s[1] && s[1] == s[2] ) || (  s[1] == s[2] && s[2] == s[3] ) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

const int MAX_N = 102, MAX_K = 1e5+2, MOD = 1e9+7;
int N, K;
int a[MAX_N];
ll dp[MAX_N][MAX_K];

void solve()
{
	dp[0][0]=1;
	for(int i=0;i<N;++i){
	    ll psum = 0;
		for(int j=0;j<=K;++j){
		    (psum += dp[i][j])%=MOD;
            (dp[i+1][j] += psum)%=MOD;
            if(j>=a[i]) psum = (psum-dp[i][j-a[i]]+MOD)%MOD;
		}
	}
	ll ans = dp[N][K];
	cout << ans << '\n';
}

int main()
{
	cin >> N >> K;
	for(int i=0;i<N;++i) cin >> a[i];
	solve();
	return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll n,k;
  cin >> n >> k;
  cout << min(n%k,1LL) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  ll X;
  cin >> X;

  ll now = 100;
  for (int i = 1; ; i++){
    now += now / 100;
    if (now >= X){
      cout << i << endl;
      return 0;
    }
  }
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> ostream& operator <<(ostream& r, const vector<T> t){vrep(v,t)r<<*v<<(v+1==t.end()?"":" ");return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<vector<T>, int> p){int n=p.second;minup(n,p.first.size());rep(i,n-1)r<<p.first[i]<<' ';r<<p.first[n-1];return r;}
template<typename T> ostream& operator <<(ostream& r, const pair<T*, int> p){int n=p.second-1;rep(i,n)r<<p.first[i]<<' ';return r<<p.first[n];}
template<typename T, size_t S> ostream& operator <<(ostream& r, const T (&a)[S]){rep(i,S-1)r<<a[i]<<' ';return r<<a[S-1];}

const int n = 10;
string str;

int main()
{
  while(cin >> str){
    int res[n][n];
    rep(i, n) res[0][i] = str[i] - '0';
    rrep(i, 1, n) rep(j, n-i+1) res[i][j] = (res[i-1][j] + res[i-1][j+1]) % 10;
    cout << res[n-1][0] << endl;
  }

  return 0;
}

Measured memory_bytes: 1180
import Control.Applicative

main :: IO ()
main = do  
 num <- read <$> getLine :: IO Int
 putStrLn $ toDispTime num



toDispTime :: Int -> String
toDispTime a = show hour ++ ":" ++ show minute ++ ":" ++ show second
 where  
    hour = a `div` 3600
    minute = (a `mod` 3600) `div` 60 
    second = a `mod` 60


Measured memory_bytes: 3608
import sys
input=sys.stdin.readline
N=int(input())
data=[]
ans=1
mod=10**9+7
for i in range(N):
    data.append(('a',int(input())))
for i in range(N):
    data.append(('b',int(input())))
cnt=0
bef=data[0][0]
data.sort(key=lambda x:x[1])
for d in data:
    if cnt==0:
        bef=d[0]
        cnt+=1
    elif bef==d[0]:
        cnt+=1
    elif bef!=d[0]:
        ans=(ans*cnt)%mod
        cnt-=1
print(ans)

Measured memory_bytes: 27136
<?php
  $N = fgets(STDIN);
  $line = fgets(STDIN);
  $X = explode(" ", $line);
  $syu = round(array_sum($X)/$N);
  $tai = 0;
  for ($i=0; $i<$N; $i++) {
    $tai += ($X[$i]-$syu)*($X[$i]-$syu);
  }
  echo $tai."\n";
    
?>


Measured memory_bytes: 4604
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long a = read.to!long;
	long p = read.to!long;
	
	p += a * 3;
	
	(p / 2).writeln;
	
	
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
using ll = long long;
using pi = pair <ll, ll>;
int s[N];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	unordered_map <int, deque <int>> a;
	a[0].emplace_back(0);
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		int x;
		cin >> x;
		x %= k;
		s[i] = (s[i - 1] + x) % k;
		int t = (s[i] - i + k * 200000ll) % k;
		int pos = 0, sz = a[t].size(), sh;
		for (; pos < sz; ++pos)
			if (i - (sh = a[t][pos]) < k)
				break;
		ans += a[t].size() - pos;
		while (pos--)
			a[t].pop_front();
		a[t].emplace_back(i);
	}
	cout << ans;
}


Measured memory_bytes: 143688
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s;
}


Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>

using namespace std;

long long n, a, b;

long long SolveToZero()
{
    if (a > b) {
        swap(a, b);
    }
    long long c = a;
    long long d = b;
    long long result = c - 1;
    d -= (c - 1);
    c = 1;
    assert(d > 1);
    --d;
    ++result;
    assert(abs(c - d) % 2 == 0);
    result += abs(c - d) / 2;
    return result;
}

void Solve()
{
    if (abs(a - b) % 2 == 0) {
        cout << abs(a - b) / 2 << endl;
        return;
    }
    auto result = SolveToZero();
    a = n - a + 1;
    b = n - b + 1;
    result = min(result, SolveToZero());
    cout << result << endl;
}

bool Read()
{
    if (!(cin >> n >> a >> b)) {
        return false;
    }
    return true;
}

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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    while (Read()) {
        Solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	int p,q,r;
	cin >> p >> q >> r;
	
	cout << p + q + r - max({ p,q,r }) << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    ans = 0
    
    for a in range(1, n):
        for b in range(1, n):
            if 1 <= a * b <= n - 1:
                ans += 1
            else:
                break
           
    print(ans)

        
if __name__ == '__main__':
    main()

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

#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for (int64_t i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  int res = 0;
  for (int i = 1; i <= N; i += 2) {
    vector<int64_t> div = divisor(i);
    if (div.size() == 8) res++;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var x,c500,c5 int
  	fmt.Scan(&x)
  
    if x >= 500 {
      c500 = x / 500
      x -= 500 * c500
    }
  
    if x >= 5 {
      c5 = x / 5
    }
  
    fmt.Println(c500 * 1000 + c5 * 5)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N)
    {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    cout << d[N / 2] - d[N / 2 - 1] << endl;
}

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

const int MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  
  vector<int> vec1(n);
  vector<int> vec2(n);
  for(int i = 0; i < n; i++) {
    cin >> vec1.at(i) >> vec2.at(i);
    //cout << vec1.at(i) << vec2.at(i) << endl;
  }

  int match_flg = 0;
  
  for(int i = 0; i < n; i++) {
    //1回目2回目をパス
    if(i > 1) {
      if(vec1.at(i-2) == vec2.at(i-2) && vec1.at(i-1) == vec2.at(i-1) && vec1.at(i) == vec2.at(i)) {
        match_flg = 1;
      }
    }
  } // for
  if(match_flg == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = getIntList >>= \x -> putStrLn $ if (== [[5, 5], [7]]) (group (sort x)) then "YES" else "NO"

Measured memory_bytes: 380
#include <iostream>
using ll = long long;
using namespace std;

int main(){
        int n,i;
        bool ans = true;
        ll h,h_max;
        cin >> n;
        h_max = 0;
        for(i=0;i<n;++i){
                cin >> h;
                if(h-h_max<-1) ans = false;
                h_max = max(h_max, h);
        }
        if(ans) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}

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

int main()
{
	int a[3];
	int i = 0,temp = 0;
	cin >> a[0] >> a[1] >> a[2];

	for( i = 0; i < 3; i++ )
	{
		for( int j = 1; i < 3; i++ ){
		if( a[i-1] > a[i] )
		{
			temp = a[i-1];
			a[i-1] = a[i];
			a[i] = temp;
		}
	}
	}
	cout << a[0] + a[1] << endl;
	return 0;
}


Measured memory_bytes: 384