akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int2(int *a1, int *a2) {
  scanf("%d %d", a1, a2);
  return 0;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}
#define NUM_MAX 100000

int swap(const void *a1, const void *a2) {
    return *(int*)a1 - *(int*)a2;
}

int gcd(int a, int b) {
    if(a==0) return b;
    return gcd(b%a, a);
}

int main(void) {
    int num, pos;
    static int arr[NUM_MAX];
    get_int2(&num, &pos);
    fget_array(arr, num);

    int i;
    int ans = 0;
    for(i = 0; i < num; i++) {
        int diff = abs(arr[i]-pos);
        int cur = ans;
        if(cur > diff) swap(&cur, &diff);
        ans = gcd(cur, diff);
    }
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<char> D;
    rep(i, k)
    {
        char d;
        cin >> d;
        D.push_back(d);
    }

    ll ans = n;
    while (1)
    {
        string s = to_string(ans);
        int ok = 1;
        rep(i, s.length())
        {
            for (auto d : D)
            {
                if (d == s[i])
                    ok = 0;
            }
        }
        if (ok)
        {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
}

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

pair<ll, ll> mo[200010];
ll sum[200010];


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

    ll n, d, a;
    cin >> n >> d >> a;
    for(int i = 0; i < n; i++)
        cin >> mo[i].fi >> mo[i].se;
    sort(mo, mo + n);
    ll pref1 = 0;
    ll pref2 = 0;

    int pok = 0;
    ll cnt = 0;
    for(int i = 0; i < n; i++)
    {
        pref2 += sum[i];
        
        while(pok < n && mo[i].fi + 2*d >= mo[pok].fi) pok++;
        
        ll rem = mo[i].se - pref1 + pref2;
        if(rem <= 0) continue;
        ll damage = ((rem+a-1)/a)*a;
        cnt += (rem+a-1)/a;
        if(pok < n) sum[pok] += damage;
        pref1 += damage;
        
    }

    cout << cnt;


    return 0;
}


Measured memory_bytes: 4992
text = input()
if (len(text) % 2 != 0):
    left = int(len(text)/2) + 1
    right = len(text) - int(len(text)/2)-1
else:
    left = int(len(text)/2)
    right = len(text) - int(len(text)/2)

score = 0

left_part = text[:right]
right_part = text[left:]

for i in range(0, len(left_part)):
    if (left_part[i] != right_part[len(right_part)-i-1]):
        score += 1

print(score)


Measured memory_bytes: 3064
import java.util.Scanner;
class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner (System.in);
        int n = scan.nextInt();
        int [] v = new int[n];
        for(int i =0;i < n;i++){
            v[i] = scan.nextInt();
        }
        for(int i = 0;i < n-1;i++){
            for(int t = 0;t < n-1-i;   t++){
                if(v[t] > v[t+1]){
                    int keep = v[t];
                    v[t] = v[t+1];
                    v[t+1] = keep;
                }
            }
        }
        double ans = (double)v[0];
        for(int i = 1; i < n;i++) {
        	ans = (ans + (double)v[i]) / 2.0;
        }
        System.out.println(ans);
    }
}


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

namespace cswork {
    class Program {
        static void Main (string[] args) {
            List<long> ll = ReadList();

            if(ll[0] == ll[1] && ll[1] == ll[2]){
                Write(1);
            }else if(ll[0] == ll[1] || ll[1] == ll[2] || ll[2] == ll[0]){
                Write(2);
            }else{
                Write(3);
            }
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }

        public static List<int> ReadListInt () {
            return ReadListStr ().ConvertAll (x => int.Parse (x));
        }
    }
}

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

int main(){
    ll N;
    string S;
    cin >> N >> S;
    vector<ll> b(N, 0), w(N, 0);
    rep(i, 1, N){
        b[i] = b[i-1];
        if(S[i-1] == '#') b[i]++;
    }
    for(ll i = N-2; i >= 0; i--){
        w[i] = w[i+1];
        if(S[i+1] == '.') w[i]++;
    }
    ll ans = 1e18;
    rep(i, 0, N) ans = min(ans, b[i] + w[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3844
/*
  dp[i][j] = iばんめまでで
  greedy?
*/
     
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
using ll = long long;
     
     
int n,k;
int cnt[30];
     
int main(){
    while(cin >> n >> k){
        memset(cnt, 0, sizeof cnt);
        rep(i,n){
            string s;
            cin >> s;
            ++cnt[s[0]-'A'];
        }
     
        int ans = 0;
     
        vector<int> a(cnt, cnt+26);
        while(1){
            sort(all(a));
            reverse(all(a));
            int x = 0;
            rep(i,26){
                if(a[i] > 0){
                    ++x;
                    --a[i];
                }
                if(x == k) break;
            }
            if(x != k) break;
            ++ans;
        }

        cout << ans << endl;
    }
}


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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc064/tasks/abc064_a
    public class Q064A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');

            string result = "NO";
            if (long.Parse(inputStrArray[0] + inputStrArray[1] + inputStrArray[2]) % 4 == 0)
            {
                result = "YES";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main(){

  int n,a[100];
  int min,tmp,sum=0;

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


  for(int i=0; i<n; i++){
    min = i;
    for(int j=i; j<n; j++){
      if(a[j] < a[min])
	min = j;
    }

    if(min!=i){
      tmp = a[i];
      a[i] = a[min];
      a[min] = tmp;
      sum++;
    }

  }
   
  cout << a[0];
  for(int i=1; i<n; i++)
    cout << ' ' <<a[i];

  cout << endl << sum << endl;


  return 0;
}

Measured memory_bytes: 1164
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll a,b,x;
int main(){
	cin>>a>>b>>x;

    a += (x - a % x) % x;
    b -= b % x;
    if (a <= b){
        cout << (b - a) / x + 1 << endl;
    }else{
        cout << "0" << endl;
    }
	return 0;
}


Measured memory_bytes: 256
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

NUM = 100000

N = int(input())

table = [0] * (NUM+1)

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

for i in range(N):
    table[input_array[i]] += 1


maximum = 1

#連続する3つの数
for i in range(0,100001,1):
    tmp = 0
    if i-1 >= 0:
        tmp += table[i-1]
    tmp += table[i]
    if i+1 <= 100000:
        tmp += table[i+1]
    maximum = max(maximum,tmp)

print("%d"%(maximum))

Measured memory_bytes: 15244
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: char,
        b: char,
    }

    if a=='H' {
        if b=='H' {
            println!("H");
        } else {
            println!("D");
        }
    } else {
        if b=='H' {
            println!("D");
        } else {
            println!("H");
        }
    }

}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	int W, H, N;
	cin >> W >> H >> N;
	vector< vector<int> > S(W);
	vector<int> X(N), Y(N), a(N);

	rep(i, W) {
		S[i] = vector<int>(H, 0);
	}

	rep (i, N) {
		cin >> X[i] >> Y[i] >> a[i];
	}

	rep (i, N) {
		if (a[i] == 1) {
			rep(j, X[i]) rep(k, H) S[j][k] = 1;
		} else if (a[i] == 2) {
			rep(j, X[i], W) rep(k, H) S[j][k] = 1;
		} else if (a[i] == 3) {
			rep(j, W) rep(k, Y[i]) S[j][k] = 1;
		} else if (a[i] == 4) {
			rep(j, W) rep(k, Y[i], H) S[j][k] = 1;
		}
	}

	int ans = 0;
	rep(i, W) rep(j, H) if (!S[i][j]) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,i = 0;
    string s,t;
    cin >> n >> s >> t;
    s += '1';
    t += '2';
    ll c = 1;
    while(i < n){
        if (s[i] == s[i+1]){
            if (i == 0) c *= 6;
            else{
                if (s[i-1] == t[i-1]) (c *= 2)%=MOD;
                else (c *= 3)%=MOD;
            }
            i += 2;
        }
        else{
            if (i == 0) c *= 3;
            else{
                if (s[i-1] == t[i-1]) (c *= 2)%=MOD;
            }
            i += 1;
        }
    }
    PRINT(c);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

const int B = 80 * 160 + 10;
const int B2 = B * 2;
using bs = bitset<B2>;

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

    int h, w;
    cin>>h>>w;
    vector<vector<int>> grid(h, vector<int>(w));
    rep(i, h) rep(j, w) cin>>grid[i][j];
    rep(i, h) rep(j, w) {
        int a;
        cin>>a;
        grid[i][j] = abs(grid[i][j] - a);
    }

    vector<vector<bs>> dp(h, vector<bs>(w));
    dp[0][0][B + grid[0][0]] = 1;
    dp[0][0][B - grid[0][0]] = 1;
    rep(i, h) rep(j, w) {
        if (i) {
            dp[i][j] |= dp[i - 1][j]<<grid[i][j];
            dp[i][j] |= dp[i - 1][j]>>grid[i][j];
        }
        if (j) {
            dp[i][j] |= dp[i][j - 1]<<grid[i][j];
            dp[i][j] |= dp[i][j - 1]>>grid[i][j];            
        }
    }

    int ans = B2;
    rep(i, B2) if (dp[h - 1][w - 1][i]) ans = min(ans, abs(i - B));
    cout<<ans<<endl;
}

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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

using namespace std;


int main()
{
    int a, b, c = 0;
    cin >> a >> b >> c;

    int arr[] = { a, b, c };
    int num = 0;

    for (int i = 0; i < COUNTOF(arr); i++)
    {
        for(int j = i + 1; j < COUNTOF(arr); j++)
        {
            if (arr[i] != arr[j])
            {
                num++;
            }
        }
    }  

    cout << ((num == 0) ? 1 : num) << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
fn main() {
    let mut ab = String::new();
    stdin().read_line(&mut ab).unwrap();

	let a: usize = ab.trim().split_whitespace().collect::<Vec<&str>>()[0].parse::<usize>().unwrap();
	let b: usize = ab.trim().split_whitespace().collect::<Vec<&str>>()[1].parse::<usize>().unwrap();

    
    if a >= 13 {
        println!("{}",b);
    } else if a >= 6 {
        println!("{}", b / 2);
    } else {
        println!("0");
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int a[200010], b[200010];
int main() {
	int n, m;
	cin >> n;
	rep(i, n)cin >> a[i];
	cin >> m;
	rep(i, m)cin >> b[i];
	rep(i, n)if (binary_search(b, b + m, a[i]))cout << a[i] << endl;
	return 0;
}


Measured memory_bytes: 4640
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    mat c(110,vec(110));
    int H,W,N;cin>>H>>W>>N;
    int a[10010];
    for(int i=1;i<=N;i++)cin>>a[i];
    int i=0,j,color=1,count=0;
    while(i<H){
        if(i%2==0){
            j=0;
            while(j<W){
                c[i][j]=color;
                j++;count++;
                if(count==a[color]){
                    color++;
                    count=0;
                }
            }
        }
        else{
            j=W-1;
            while(j>=0){
                c[i][j]=color;
                j--;count++;
                if(count==a[color]){
                    color++;
                    count=0;
                }                
            }
        }
        i++;
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W-1;j++)
            cout<<c[i][j]<<" ";
        cout<<c[i][W-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long count = 0;
        if(x >= 11) {
            count += (x / 11) * 2;
            x %= 11;
        }
        if(x >= 7) count += 2;
        else if(x != 0) count++;
        System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>
long long int hcf(long long int a,long long int b)
{
	if(b==0)
	{
		return a;
	}
	return hcf(b,a%b);
}
int main()
{
	long long int a,b,c,d,f,f1,s,s1,t1,t,k;
	scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
	t=(b-a)+1;
	//printf("%lld\n",t);
	f=((b/c)-((a-1)/c));s=((b/d)-((a-1)/d));
	t1=(c*d)/hcf(c,d);
	k=(b/t1)-((a-1)/t1);
	//printf("%lld\n",f+s);
	/*if(c!=d)
	{
		printf("%lld\n",t);
	}
	else
		printf("%lld\n",t-(f+s)+k+1);*/
	t=t-(f+s)+k;
	printf("%lld\n",t);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int,input().split()))
Q = int(input())

dp = [0 for _ in range(10**5+10)]

for a in range(len(A)):
    dp[A[a]] += 1
s = sum(A)

for q in range(Q):
    B, C = map(int,input().split())
    dp[C] += dp[B]
    s +=(C-B)*dp[B] 
    dp[B] = 0
    print(s) 

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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  for(int i = 1;i <= N;i++){
    if(i % 3 == 0||i % 5 == 0){
      continue;
    }
    ans += i;
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<cstdio>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N;
	cin >> N;
	ll cnt[111] = {};
	for (ll i = 2; i <= N; ++i) {
		ll t = i;
		for (ll j = 2; t != 1; ++j) {
			while (t%j == 0) {
				t /= j;
				cnt[j]++;//全部素因数分解して因数の数を格納する
			}
		}
	}
	ll sum = 0;
	for (ll i = 0; i < 111; ++i) {
		if (cnt[i] >= 74)sum++;
		for (ll j = 0; j < 111; ++j) {
			for (ll k = j + 1; k < 111; ++k) {
				if (i == j || i == k)continue;
				if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4)sum++;
			}
		}
	}
	for (ll i = 0; i < 111; ++i) {
		for (ll j = 0; j < 111; ++j) {
			if (i == j)continue;
			if (cnt[i] >= 14 && cnt[j] >= 4)sum++;
			if (cnt[i] >= 24 && cnt[j] >= 2)sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n;
  cin >> n;
  vector<int> pos(n, -1);
  int l, m, r;
  rep(i, n+1){
    int in;
    cin >> in;
    in--;
    if(pos.at(in) == -1) pos.at(in) = i;
    else{
      l = pos.at(in);
      m = i - l - 1;
      r = n+1 - l - m - 2;
    }
  }
  combination cb(n+1);

  rep(i, n+1){
    if(i == 0){
      cout << n << endl;
      continue;
    }
    mint ans = cb(n+1, i+1);
    mint mi = cb(l+r, i);
    ans -= mi;
    cout << ans.x << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	T := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&T[i])
	}

	var M int
	fmt.Scan(&M)

	P := make([]int, M)
	X := make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Scanf("%d %d", &P[i], &X[i])
	}

	for i := 0; i < M; i++ {
		pi := P[i] - 1
		xi := X[i]

		time := 0
		for ii := 0; ii < N; ii++ {
			if ii == pi {
				time += xi
			} else {
				time += T[ii]
			}
		}

		fmt.Println(time)
	}
}

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

using namespace std;
const int N=2005;
const int mod=1000000007;

int n,m;
int tree[4*N][4*N];

void update(int x,int y,int val)
{
    for(;x<N;x+=x&-x)
    {
        for(int j=y;j<N;j+=j&-j)
        {
            tree[x][j]=(tree[x][j]+val)%mod;
        }
    }
}

int query(int x,int y)
{
    int res=0;
    for(;x>0;x-=x&-x)
    {
        for(int j=y;j>0;j-=j&-j)
        {
            res=(res+tree[x][j])%mod;
        }
    }
    return res;
}

int main()
{
    scanf("%d%d",&n,&m);
    int s[n+1],t[m+1];
    for(int i=1;i<=n;i++) scanf("%d",&s[i]);
    for(int i=1;i<=m;i++) scanf("%d",&t[i]);
    for(int o=1;o<=n;o++)
    {
        for(int i=1;i<=m;i++)
        {
            if(s[o]!=t[i]) continue;
            if(o==1||i==1) update(o,i,1);
            else update(o,i,query(o-1,i-1)+1);
        }
    }
    printf("%d\n",(query(n,m)+1)%mod);
    return 0;
}


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

 
int main(){
  string A,B,C;
  cin>>A>>B>>C;
  char a,b,c;
  
  a= toupper(A.at(0));
  b=toupper(B.at(0));
  c=toupper(C.at(0));
  
  cout<<a<<b<<c<<endl;
  
}
  


Measured memory_bytes: 256
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
int main()
{
	string S;
	int N, K;
	cin >> N >> K >> S;
	 if (S.at(K - 1) =='A' ) { S.at(K - 1) = 'a'; }
	else if (S.at(K - 1) =='B' ) { S.at(K - 1) ='b' ; }
	else  { S.at(K - 1) ='c' ; }
	 cout << S << endl;
	 return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a == b) {
        printf("a == b\n", a, b);
    } else if (a > b) {
        printf("a > b\n", a, b);
    } else {
        printf("a < b\n", a, b);
    }

    return 0;
}



Measured memory_bytes: 3140
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var input2 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        
        var N = input[0];
        var K = input[1];
        
        var X = (double)(N - 1) / (K - 1);
        Console.WriteLine(Math.Ceiling(X));
    }
}


Measured memory_bytes: 19936
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int N, p[15];
    scanf("%d", &N);
    rep1(i, N) scanf("%d", &p[i]);
    /* ====================================== */
    int max = 0;
    int maxI;
    rep1(i, N) {
        if (max < p[i]) {
            max = p[i];
            maxI = i;
        }
    }
    int ans = 0;
    rep1(i, N) {
        if (i == maxI) {
            ans += p[i] / 2;
        } else {
            ans += p[i];
        }
    }

    cout << ans;
    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int P[10000];
void init(int N) {
  for (int i = 0; i < N; i++) {
    P[i] = i;
  }
}

int root(int a) {
  if(P[a] == a)
    return a;
  return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b) {
  return root(a) == root(b);
}

void unite(int a, int b) {
  P[root(a)] = root(b);
}

int main()
{
  int N;
  cin >> N;
  int A[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      int x;
      cin >> x;
      A[j][i] = x;
      // cout << "cost: " << x << " = " <<  j << "->"  << i << endl;
    }
  }
  // cout << "-----エッジ-------" << endl;
  int cost[10000], src[10000], dst[10000];
  int M = 0;
  for (int r = 0; r < N; r++)
  {
    for (int c = r + 1; c < N; c++)
    {
      if (A[r][c] > -1)
      {
        cost[M] = A[r][c];
        src[M] = r;
        dst[M] = c;
        // cout << "cost: " << cost[M] << " = " <<  src[M] << "->"  << dst[M] << endl;
        M += 1;
      }
    }
  }
  // cout << "M = " << M << " N = " << N << endl;
  init(N);
  pair<int, pair<int, int> > edges[M + 1];
  for (int m = 0; m < M; m++)
  {
    edges[m] = make_pair(cost[m], make_pair(src[m], dst[m]));
  }
  // cout << "-----sort前-------" << endl;
  // for (int i = 0; i < M; i++)
  //     cout << "cost: " << edges[i].first << " = " << edges[i].second.first << "->"  << edges[i].second.second << endl;
  sort(edges, edges+M);
  // cout << "-----sort後-------" << endl;
  // for (int i = 0; i < M; i++)
  //     cout << "cost: " << edges[i].first << " = " << edges[i].second.first << "->"  << edges[i].second.second << endl;
  int sum = 0;
  for (int i=0; i<M; i++) {
    if (is_same_set(edges[i].second.first, edges[i].second.second))
      continue;
    unite(edges[i].second.first, edges[i].second.second);
    sum += edges[i].first;
  }
  cout << sum << endl;
}


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

const int mod = 1000000007;
int main() {
  int n;
  cin >> n;

  //変数格納
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int ans = 0;
  int x = 0;
  rep(i,n) {
    ans = (ans+(ll)a[i]*x)%mod;
    x = (x + a[i])%mod;
  }

  cout << ans << endl;
}


Measured memory_bytes: 4056
def insertion_sort(A,N):
	prin(A)
	for i in range(1,N):
		v = A[i]
		j = i-1
		while j >= 0 and A[j] > v:
			A[j+1] = A[j]
			j -= 1
		A[j+1] = v
		prin(A)
def prin(A):
	print(' '.join(list(map(str, A))))
N = int(input())
A = [int(i) for i in input().split(' ')]
insertion_sort(A,N)


Measured memory_bytes: 7712
n, m, x = map(int, input().split())
C = []
A = []
for i in range(n):
    ls = input().split()
    C.append(int(ls[0]))
    A.append(list(map(int, ls[1:])))

flag = False
min_c = float('inf')
for i in range(2 ** n):
    min_ls = [0] * n
    tmp_c = 0
    for j in range(n):
        if i >> j & 1:
            min_ls = [a+b for a, b in zip(min_ls, A[j])]
            tmp_c += C[j]       
    if min(min_ls) >= x:        
        flag = True
        min_c = min(min_c, tmp_c)        

if flag:
    print(min_c)
else:
    print('-1')


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code
int main(int argc, char const* argv[])
{
    string s;
    cin >> s;
    VL alf(26,0);
    for (int i = 0; i < s.size(); i++) {
        alf[s[i] - 'a']++;
    }
    for (int i = 0; i < 26; i++) {
        if (alf[i] == 0) {
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 512
from math import gcd
n=int(input())
arr=list(map(int,input().split()))
p=[i for i in range(10**6+1)]
for i in range(2,10**3+1):
    if p[i]==i:
        for j in range(i*i,10**6+1,i):
            if p[j]==j:
                p[j]=i
se=set()
k=0
for i in arr:
    c=i
    f=p[c]
    l=set()
    while(c!=1):
        if f in se:
            k=1
            break
        l.add(f)
        c//=f
        f=p[c]
    se|=l
    if k:
        break
if k==0:
    print("pairwise coprime")
else:
    gc=arr[0]
    for i in arr[1:]:
        gc=gcd(gc,i)
    if gc==1:
        print("setwise coprime")
    else:
        print("not coprime")







Measured memory_bytes: 223728
#include<stdio.h>
#include<algorithm>
#include<string.h>

typedef long long ll;

int N;
ll ans = 1;

ll GCD(ll a,ll b)
{
    if(b == 0)return a;
    return GCD(b,a%b);
}

ll LCM(ll a,ll b)
{
    return a / GCD(a,b) * b;
}

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        ll a;
        scanf("%lld",&a);
        ans = LCM(ans,a);
    }
    printf("%lld\n",ans);
    return 0;
}

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

#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}

//end of template

int n;
int A,B;
ll arr[105];

ll C(ll a,ll b){
	if(b>a-b)return C(a,a-b);
	ll ret = 1;
	
	for(ll bb = 1;bb<=b;bb++,a--)ret = ret*a/bb;
	return ret;
}
int main(){
	cin>>n>>A>>B;
	
	rep(k,0,n)cin>>arr[k];
	
	sort(arr,arr+n);
	reverse(arr,arr+n);
	
	ll x = 0;
	rep(k,0,A)x+= arr[k];
	
	printf("%.7lf\n",(double)x/A);
	
	ll ret = 0;
	
	map<int,int> cur,bil;
	rep(k,0,n)bil[arr[k]]++;
	
	
	ll sum = 0;
	rep(k,0,A-1)sum+=arr[k],cur[arr[k]]++;
	rep(k,A-1,B){
		sum += arr[k];
		
		cur[arr[k]]++;
		if(x*(k+1)==sum*A){
			ret += C(bil[arr[k]],cur[arr[k]]);
			ll a = cur[arr[k]],b = bil[arr[k]];
			//printf("%d %d %lld\n",cur[arr[k]],bil[arr[k]],C(b,a));
		}
	}
	
	cout<<ret<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;

const int N = (int)3e3+5;

ll dp[N][N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int x,a;
    cin>>x>>a;
    if(x<a) cout<<0;
    else cout<<10;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math

big = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
num = A[0]
for i in range(1, N):
    num = num * A[i] // math.gcd(num, A[i])

res = 0
for a in A:
    res += num * pow(a, big-2, big)

print(res % big)


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

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

   int cnt = 0;
   for (int i=0; i<N-2; i++)
      if (S.substr(i, 3) == "ABC")
         cnt++;

   cout << cnt << endl;
}



Measured memory_bytes: 256
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())
def inp():
    return input()

N=10**9 +7
n=int(inp())
s=inp()
dp=[[0]*(n+1) for _ in range(n+1)]#base 1 indexing
dp[1][1]=1
for i in range(2,n+1):
    pref=[0]
    for t in range(1,i):
        pref.append((pref[-1]+dp[i-1][t])%N)
    for j in range(1,i+1):


        if s[i-2]==">":
            l=j
            r=i-1
        else:

            l=1
            r=j-1

        if l>r:
            continue
        dp[i][j]=((pref[r]-pref[l-1])%N + N)%N
ans=0
for i in range(1,n+1):
    ans=(ans+dp[n][i])%N

print(ans)




Measured memory_bytes: 144872
taro = 0
hanako = 0
n = int(input())
for _ in range(n):
    t_c, h_c = input().strip().split()
    if t_c < h_c:
        hanako += 3
    elif t_c == h_c:
        taro += 1
        hanako += 1
    else:
        taro += 3
print ('{} {}'.format(taro, hanako))


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    while(cin>>x){
        bool first=true;
        for(int w=1; w<1024; w<<=1){
            if(w&x){
                if(!first) cout<<' ';
                else first=false;
                cout<<w;
            }
        }
        cout<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define pb push_back
typedef pair<int,int> pi;
#define MAX 1000000
int isprime[1145141];
int table[2000][2000];
pi S[1145141];
int D[2000][2000];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
void eratos(int n)
{
  rep(i,n+1)isprime[i]=true;
  isprime[0]=isprime[1]=false;
  for(int i=2;i*i<=n;i++)
    {
      if(isprime[i])
	{
	  int j = i + i;
	  while(j <= n)
	    {
	      isprime[j] = false;
	      j = j + i;
	    }
	}
      
    }
  
}
int main(){
  eratos(MAX);
  //table turkuru
  memset(table,0,sizeof(table));
  int now = 2;
  int dist = 1;
  int cnt = 0;
  int dir = 0;
  int y = 1000;
  int x = 1000;
  table[y][x]=1;
  S[1] = pi(y,x);
  while(now <= MAX)
    {
      if(cnt < dist)
	{
	  y += dy[dir];
	  x += dx[dir];
	  table[y][x] = now;
	  S[now] = pi(y,x);
	  cnt++;
	  now++;
	}
      else
	{
	  dir = (dir+1)%4;
	  if(dir == 2 || dir == 0)dist++;
	  y += dy[dir];
	  x += dx[dir];
	  table[y][x] = now;
	  S[now] = pi(y,x);
	  cnt = 1;
	  now++;
	}
    }
  /*rep(i,2000)
    {
      rep(j,2000)
	{
	  printf("%d ", table[i][j]);
	}
	    printf("\n");    
	    }*/
  //cout << table[1000][1000]<< endl;
  //cout << table[1001][1001] << endl;
  int M, N;
  int ans;
  int pp;
  int ey[3] = {1,1,1};
  int ex[3] = {-1,0,1};
  //printf("%d", isprime[table[S[947].first][S[947].second]]);
  while(true){
    cin >> M >> N;
    if(M==0&&N==0)break;
    memset(D,-1,sizeof(D));
    queue<pi> Q;
    queue<int> R;
    ans = 0;
    pp = 0;
    Q.push(pi(S[N].first,S[N].second));
    //printf("%d %d\n", S[N].first,S[N].second);
    R.push(0);
    while(!R.empty())
      {
	int ty = Q.front().first;
	int tx = Q.front().second;
       
	
	int point = R.front();
	Q.pop();R.pop();


	
	if(isprime[table[ty][tx]])
	  {
	    point++;
	  }
	if(ans <= point)
	  {
	    if(ans < point && isprime[table[ty][tx]])pp = table[ty][tx];
	    else if(ans == point && isprime[table[ty][tx]])pp = max(table[ty][tx],pp);
	    ans = point;
	    
	  }

	//printf("ty=%d, tx=%d, point=%d\n",ty,tx,point);
	
	if(point <= D[ty][tx])continue;
	D[ty][tx] = point;
	//ans = max(ans,point);
	rep(r,3)
	  {
	    int y = ty + ey[r];
	    int x = tx + ex[r];
	    
	    if(table[y][x]==0)continue;
	    if(table[y][x]>M)continue;
	    Q.push(pi(y,x));
	    R.push(point);
	  }
	
      }
    printf("%d %d\n", ans, pp);
  }
  return 0;
}

Measured memory_bytes: 66380
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)
typedef long long ll;

using namespace std;

ll gcd(ll a, ll b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

int main(){
	
	ll a,b;
	cin >> a >> b;

	ll ans = lcm(a,b);
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
<?php
while (true) {
    list($height, $width) = getSpacesByExplodeTrimInput();
    $lines = array(); 
 
    if ($height == 0 && $width == 0) {
        break;
    }
  
    for ($i = 0; $i < $height; $i++) {
        if ($i % 2) {
                $lines[] = setEvenNumLine($width);
        } else {
                $lines[] = setOddNumLine($width);
        }
    }
 
    echo implode($lines), PHP_EOL;
}
  
function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}
  
function setEvenNumLine($width)
{
    $line = "";
    for ($i = 0; $i < $width; $i++) {
        $line .= $i % 2 ? "#" : ".";
    }
    return $line.PHP_EOL;
}
  
function setOddNumLine($width)
{
    $line = "";
    for ($i = 0; $i < $width; $i++) {
        $line .= $i % 2 ? "." : "#";
    }
    return $line.PHP_EOL;
}

Measured memory_bytes: 15524
#include<bits/stdc++.h>
#include<algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
    long long n,k,max=0,x; cin>>k>>n;
    long long a[n];
    cin>>a[0];
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        if(abs(a[i]-a[i-1])>max)
        {
            max = abs(a[i]-a[i-1]);
            x = i;
        }
    }
    if(max<abs(k-a[n-1])+a[0])
        max = abs(k-a[n-1]) + a[0];
    long long ans = k - max;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    int n,i,j;
    int a[200010]={0};
    long long int ans=0;

    scanf("%d",&n);
    int cand=0;

    for(i=0;i<n;i++)
    {
        scanf("%d",&(a[i]));
        if(cand<=a[i])cand=a[i];
        else ans+=(long long int)(cand-a[i]);
    }
	printf("%lld",ans);
}


Measured memory_bytes: 2508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}



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

int x,y,z;
cin >> x >> y >> z;
printf("%d %d %d",z,x,y);


//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
vector <int> x ;
int n , dp[100003] ;
int SAAD ( int idx ) {
	if ( idx == n-1 ) return 0 ;
	if ( dp[idx] != -1 ) return dp[idx] ;
	if ( idx == n-2 ) return dp[idx] = SAAD(idx+1)+abs(x[idx]-x[idx+1]) ;
	return dp[idx] = min(SAAD(idx+1)+abs(x[idx]-x[idx+1]),SAAD(idx+2)+abs(x[idx]-x[idx+2])) ;
}
int main() {
	memset(dp,-1,sizeof(dp));
	int p ;
	cin >> n ;
	for (int i = 0 ; i < n ; i++ ) {
		cin >> p; 
		x.push_back(p);
	}
	x.push_back(0);
	cout << SAAD(0) ;
	return 0;
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c = 0;
  cin >> a >> b;
  for(int i = 1; i <= a; i++){
    //if(b == 0)break;
    if(i%2 != 0){
        c++;
    }

  }
  if(c >= b){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  return 0;
}


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

int main() {
    ll a,b;
    cin>>a>>b;
    if(a==1 || b==1)
        cout<<1;
    else if(a%2 && b%2)
        cout<<((a*b)/2)+1;
    else
        cout<<(a*b)/2;
    return 0;
}

Measured memory_bytes: 256
//Problem D
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200005;
ll n,x[N],s[N],e[N],a;

int main(){
    scanf("%lld%lld",&n,&a);
    for(ll i=1;i<=n;i++)scanf("%lld",&x[i]),s[i]=x[i]+s[i-1];
    e[1]=e[2]=5;
    for(ll i=3;i<=n;i++)e[i]=e[i-1]+2;
    ll ans=8e18;
    for(ll d=1;d<=n;d++){
        ll x=d*a;
        for(ll i=n,j,c=1;i&&x<ans;i=j,++c){
            j=max(0ll,i-d);
            x+=e[c]*(s[i]-s[j]);
        }
        if(x<ans)ans=x;
    }
    cout<<ans+n*a;
    return 0;
}

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

using namespace std;

#define int long long

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

    int h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1;
    } else {
        cout << ((h + 1) / 2) * ((w + 1) / 2) + (h - (h + 1) / 2) * (w / 2);
    }

    return 0;
}

Measured memory_bytes: 256
p = {
    'm': 1000,
    'c': 100,
    'x': 10,
    'i': 1,
}

def parseNum(s):
    if s[0].isdigit():
        return int(s[0]), s[1:]
    return 1, s

def parseChar(s):
    if s[0] in p:
        return p[s[0]], s[1:]
    print(s)

def parseMCXI(s):
    res = 0
    while s:
        x, s = parseNum(s)
        w, s = parseChar(s)
        res += x * w
    return res

def to(x):
    if x == 0: return None
    if x == 1: return ""
    return str(x)

def toMCXI(x):
    res = ""
    for w, c in sorted(zip(p.values(), p.keys()), reverse=True):
        s = to(x // w)
        if s is not None:
            res += s + c
            x = x % w
    return res
for _ in range(int(input())):
    print(toMCXI(sum(parseMCXI(x) for x in input().split())))

Measured memory_bytes: 6748