akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define eb emplace_back
#define precision(n) cout << fixed << setprecision(n);
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }
    return 0;
}




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

int main(){
	int a,b,c,d;
  	cin>>a>>b>>c>>d;
  	int e,f;
  	e=(c-1)/b+1;
  	f=(a-1)/d+1;
  	if(e>f) cout<<"No";
  	else cout<<"Yes";
  	return 0;
}

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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n;
  cin >> n;
  vector<string> s(n);
  for(int i=0;i<n;i++)cin >> s[i];

  for(int i=0;i<n;i++){
    sort(s[i].begin(),s[i].end());
  }
  sort(s.begin(),s.end());

  ll c=0;
  string a=s[0];
  ll b=upper_bound(s.begin(),s.end(),a)-lower_bound(s.begin(),s.end(),a);
  c+=b*(b-1)/2;
  for(int i=0;i<n;i++){
    if(a==s[i])continue;
    else{
      a=s[i];
      b=upper_bound(s.begin(),s.end(),a)-lower_bound(s.begin(),s.end(),a);
      c+=b*(b-1)/2;
    }
  }

  cout << c << endl;



}

Measured memory_bytes: 6404
import scala.io.StdIn
 
case class Expr(l:Int, op: String, r:Int)
 
object Main extends App {
    Iterator.continually(StdIn.readLine()).takeWhile(_ != null).foreach{
      line =>
        if(line.trim.isEmpty == false){
          val Array(left, op, right) = line.split(" ")
            Expr(left.toInt, op, right.toInt) match {
              case Expr(l, "+", r) => println(l + r)
              case Expr(l, "-", r) => println(l - r)
              case Expr(l, "*", r) => println(l * r)
              case Expr(l, "/", r) => println(l / r)
              case _ =>
            }
        }
    }
}

Measured memory_bytes: 43912
N = int(input())
S = input()

list_s = []
count = 0
if len(S) == N:
  for i in range(1,N):
    for a in S:
      if a == "A":
        list_s.append("A")
      elif a == "B":
        list_s.append("B")
      elif a == "C":
        list_s.append("C")
      else:
        break
      
      b = ''.join(list_s)
      if b == "ABC":
        count = count + 1
        break
    list_s = [] 
    S = S[1:]
      
      
      

print(count)

Measured memory_bytes: 3064
use std::io;


fn main() {
    let (x, y) = {
        let i = read::<isize>();
        (i[0], i[1])
    };
    if x % y == 0 { println!("-1"); }
    else { println!("{}", x); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstring>

using namespace std;

int main(){
  char c[26];
  int count[26] = {};
  for (int i=0;i<26;i++){
    c[i] = '\0';
  }
  cin >> c;
  int l = strlen(c);
  for (int i = 0;i < l;i++) {
    if (count[(int)c[i]-97]++ > 0) {
      cout << "no" << endl;
      return(0);
    }
  }
  cout << "yes" << endl;
}


Measured memory_bytes: 256
# abc084_b.py
A, B = map(int,input().split())
S = input()
ans ='Yes'
for i,c in enumerate(S):
    if i<A and c.isdecimal():
        continue
    elif i== A and c =="-":
        continue
    elif  i>A and c.isdecimal():
        continue
    else:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c=a+b,d=a-b,e=a*b;
		int f;
		f=Math.max(c,d);
		System.out.println(Math.max(f,e));

    }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;
string S;

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

    for (int i = 0; i < S.length(); i++) {
        S[i] += N;
        if (S[i] > 'Z') S[i] -= 26;
    }

    cout << S << endl;
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  double l, r;
  int left[4] = {0};
  int right[4] = {0};
  while (cin >> l >> r) {
    if (l >= 1.1)
      left[0]++;
    else if (l >= 0.6)
      left[1]++;
    else if (l >= 0.2)
      left[2]++;
    else
      left[3]++;

    if (r >= 1.1)
      right[0]++;
    else if (r >= 0.6)
      right[1]++;
    else if (r >= 0.2)
      right[2]++;
    else
      right[3]++;
  }

  for (int i = 0; i < 4; i++)
    cout << left[i] << ' ' << right[i] << endl;
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b){ a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero() { return 0; }
signed main() {
	int n,k;
	cin >> n >> k;
	vel co(n);
	vel re(n);
	for (int i = 0; i < n; i++) {
		cin >> co[i] >> re[i];
	}
	vel qfr(k);
	vel qto(k);
	vel kos(n);
	for (int i = 0; i < k; i++) {
		cin >> qfr[i] >>qto[i];
		qfr[i]--; qto[i]--;
		kos[qfr[i]]++; kos[qto[i]]++;
	}
	vvel wa(n);
	for (int i = 0; i < n; i++) {
		vel xx(kos[i]);
		wa[i] = xx;
	}
	vel coun(n,0);
	for (int i = 0; i < k; i++) {
		int fr1 = qfr[i];
		int to1 = qto[i];
		wa[fr1][coun[fr1]] = to1;
		wa[to1][coun[to1]] = fr1;
		coun[fr1]++; coun[to1]++;
	}
	vvel con(n, vel(n, 0));
	for (int i = 0; i < n; i++) {
		vel que(n);
		con[i][i] = 1;
		que[0] = i;
		int up = 1;
		int lo = 0;
		for (int j = 1; j <= re[i]; j++) {
			int qup = up;
			for (int in = lo; in < up; in++) {
				int pos = que[in];
				for (int ind = 0; ind < kos[pos]; ind++) {
					int pot = wa[pos][ind];
					if (con[i][pot] == 0) {
						con[i][pot] = 1;
						que[qup] = pot;
						qup++;
					}
				}
			}
			lo = up;
			up = qup;
		}
	}
	int max1 = 10000 * 10000 + 1;
	vel di(n, max1);
	di[0] = 0;
	vel alch(n, 0);
	for (int i = 0; i < n; i++) {
		int x = -1;
		int miv =max1;
		for (int j = 0; j < n; j++) {
			if (alch[j] == 0) {
				if (miv > di[j]) {
					miv = di[j];
					x = j;
				}
			}
		}
		alch[x] = 1;
		for (int j = 0; j < n; j++) {
			if (con[x][j] == 1) {
				if (di[j] > di[x] + co[x]) {
					di[j] = di[x] + co[x];
				}
			}
		}
	}
	cout << di[n-1] << endl;
	return 0;
}



Measured memory_bytes: 199188
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

i = Array.new(n, 1)

m.times do
  a, b = gets.split.map(&:to_i)
  next if i[a-1] == 0 && i[b-1] == 0

  if h[a-1] < h[b-1]
    i[a-1] = 0
  elsif h[a-1] > h[b-1]
    i[b-1] = 0
  else
    i[a-1] = i[b-1] = 0
  end
end

p i.count { |ii| ii == 1 }


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

#define el '\n'
#define MOD 1000000007

ll num(ll l, ll r, ll x){
    ll a,b;
    if(l%x==0){
        a=l/x-1;
    } else {
        a=l/x;
    }
    b=r/x;
    return b-a;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll k=c*d;
    k /= __gcd(c, d);
    ll res = num(a,b,c)+num(a,b,d)-num(a,b,k);
    cout << b-a+1-res << el;
    return 0;
}

Measured memory_bytes: 384
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        l:i64,r:i64,
    }
    if r - l > 2019 {
        println!("{}", 0);
    } else {
        let mut ans = 2018;
        for i in l..=r {
            for j in i + 1..=r {
                ans = min(i * j % 2019, ans);
            }
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 2132
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,maxi=0,f=0,mini=INF;
    ll sum=0;
    string str,sub;
    ll h,w;
    ll m;
    cin>>n>>m;
    if(m==0){
        if(n==1){
            cout<<0<<endl;
        }else if(n==2){
            cout<<10<<endl;
        }else{
            cout<<100<<endl;
        }
        return 0;
    }
    vector<pair<ll,ll>> s(m);

    rep(i,m){
        cin>>a>>b;
        s[i]=make_pair(a,b);
    }
    f=0;
    sort(s.begin(),s.end());
    sum=0;
            if(s[0].first==1) {
                //sum-=100;
                if(s[0].second==0&&n!=1) f=1;

                sum+=100*s[0].second;
            }
            if(s[0].first==2){
                //if(s[0].second==0&&n==2) f=1;

                sum+=10*s[0].second;
               // sum-=10;
            } 
            if(s[0].first==3){
                //sum-=1;
                sum+=1*s[0].second;
            } 
    for(ll i=1;i<m;i++){
        if(s[i-1].first==s[i].first&&s[i-1].second!=s[i].second) f=1;
        else if(s[i-1].first==s[i].first&&s[i-1].second==s[i].second) continue;
        else{
            if(s[i].first==1) {
               // sum-=100;
               if(s[i].second==0&&n!=1) f=1;
                sum+=100*s[i].second;
            }
            if(s[i].first==2) {
               // sum-=10;
                sum+=10*s[i].second;
            }
            if(s[i].first==3) {
              //  sum--;
                sum+=1*s[i].second;
            }
        }
    }
    if(n==1&&sum!=0) sum/=100;
    if(n==2&&sum!=0) sum/=10;
    if(n==3&&sum!=0&&sum<100) sum+=100;
    if(n==2&&sum<10) sum+=10;
    if(f!=1&&sum==0&&n==1){
        cout<<0<<endl;
        return 0;
    }
    
    if(f==1){
        cout<<"-1"<<endl;
    }else{
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    cout << (1000 - (n%1000))%1000 << endl;

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  
  for(int i = 0; i < N; i++){
    cin >> p[i];
  }

  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(p[i] == i + 1){
      cnt++;
      i++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    p = [0 for i in range(m)]
    x = [0 for i in range(m)]

    for i in range(m):
        p[i], x[i] = map(int, input().split())

    for i in range(m):
        print(sum(t) - t[p[i] - 1] + x[i])


if __name__ == "__main__":

    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string> 
using namespace std;
#define LL long long
#define MOD 1000000007
int main()
{
	
	int n;
	string s;
	cin>>n>>s;
	LL ans=1;
	LL al[26]={0};
	for(int i=0;i<s.size();i++)
		al[s[i]-'a']++;
	for(int i=0;i<26;i++)
		ans=ans*(al[i]+1)%MOD;
	cout<<ans-1<<'\n';
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
int main()
{
    int n,m;
    cin>>n>>m;
    int left,right;
    int a,b;
    left = 1;
    right = n;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        left = max(left,a);
        right = min(right,b);
    }
    cout<<max(right-left+1,0)<<endl;
}


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

int main() {
  int N;
  cin >> N;
  vector<int>a(N);
  for(int i=0; i<N; i++)cin >> a.at(i);
  
  int count =0;
  
  for(int i=0; i<N; i++){
    while(a.at(i)%2==0){
      a.at(i)/=2;
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3624
(defun main ()
  (let* ((n (read))
         (a (make-array n :element-type 'fixnum))
         (dp (make-array n :element-type 'fixnum :initial-element (floor most-positive-fixnum 2))))
    (dotimes (i n)
      (setf (aref a i) (read)))
    (flet ((relax (from to)
             (let* ((from-val (aref dp from))
                    (to-val (aref dp to))
                    (diff (abs (- (aref a to) (aref a from)))))
               (setf (aref dp to) (min to-val (+ from-val diff))))))
      (setf (aref dp 0) 0)
      (dotimes (i n)
        (when (< (+ i 1) n) (relax i (+ i 1)))
        (when (< (+ i 2) n) (relax i (+ i 2)))))
    (format t "~a~%" (aref dp (- n 1)))))

(main)


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

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

  int time = 1;
  bool rev = false;
  string front;
  while(time<=q) {
    int t;
    cin>>t;
    if(t==1) rev = !rev;
    else {
      int f;
      char c;
      cin>>f>>c;
      if((!rev && f==1) || (rev && f==2)) front.push_back(c);
      else s.push_back(c);
    }
    time++;
  }

  string ans;
  if(rev) {
    reverse(s.begin(), s.end());
    ans = s+front;
  }

  else {
    reverse(front.begin(), front.end());
    ans = front+s;
  }

  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1248
package main

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

func main() {
        fp := os.Stdin
        scanner := bufio.NewScanner(fp)
        var lst [3]int

        for scanner.Scan() {
                num, _ := strconv.Atoi(scanner.Text())
                if lst[0] < num {
                        lst[2] = lst[1]
                        lst[1] = lst[0]
                        lst[0] = num
                } else if lst[1] < num {
                        lst[2] = lst[1]
                        lst[1] = num
                } else if lst[2] < num {
                        lst[2] = num
                }
        }

        for _, i := range lst {
                fmt.Printf("%d\n", i)
        }
}



Measured memory_bytes: 1108
#include<iostream>
#include<string>
#include<algorithm>
#include<stdbool.h>
using namespace std;

int main(void) {
	int ans = 0, num = 0, n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0;i < n;i++) {
		if (s[i] == 'I') {
			num++;
			ans = max(ans, num);
		}
		else {
			num--;
			ans = max(ans, num);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

c = [LIST() for _ in range(3)]

if c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] == c[0][2] + c[1][0] + c[2][1]:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 5200
#include<stdio.h>
int main(void)
{
	int K,c,x;
	int sum=0;

	while(1){
		scanf("%d",&K);
		if( K==0 )
			break;
		else{
			c=K*(K-1)/2;

		while(c--){
			scanf("%d",&x);
			sum+=x;
		}
printf("%d\n",sum/(K-1));
sum=0;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (auto &e:a)cin >> e;
    for (auto &e:b)cin >> e;
    for (auto &e:c)cin >> e;
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll r = 0;
    for (auto &e:b) {
        auto u = lower_bound(a.begin(), a.end(), e) - a.begin();
        auto v = c.end() - upper_bound(c.begin(), c.end(), e);
        r += u * v;
    }
    cout << r << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b == c || a+c == b || b+c == a)  dump("Yes");
  else dump("No");
  return 0;
}


Measured memory_bytes: 256
//PDF解説に倣ってワーシャル・フロイド法
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n,m,l,a,b,c,q;
  cin>> n >> m >> l;
  vector<vector<int>> M(n,vector<int> (n));
  for (int i=0; i<m; i++){
    cin>> a >> b >> c;
    M[a-1][b-1]=c;
    M[b-1][a-1]=c;
  }
  cin>> q;
  vector<pair<int,int>> quiz(q);
  for (int i=0; i<q; i++){
    cin>> a >> b;
    quiz[i]=make_pair(a-1,b-1);
  }
  
  vector<vector<int>> D(n,vector<int> (n,1e9+1));
  for (int i=0; i<n; i++)
    for (int j=0; j<n; j++)
      if (M[i][j]!=0) D[i][j]=M[i][j];
  for (int k=0; k<n; k++)
    for (int i=0; i<n; i++)
      for (int j=0; j<n; j++)
        if (D[i][j]>D[i][k]+D[k][j]) D[i][j]=D[i][k]+D[k][j];
  
  for (int i=0; i<n; i++){
    for (int j=0; j<n; j++){
      if (D[i][j]<=l) D[i][j]=1;
      else D[i][j]=n;
    }
  }
  for (int k=0; k<n; k++)
    for (int i=0; i<n; i++)
      for (int j=0; j<n; j++)
        if (D[i][j]>D[i][k]+D[k][j]) D[i][j]=D[i][k]+D[k][j];
  
  for (auto i: quiz){
    if (D[i.first][i.second]==n) cout<<-1<<endl;
    else cout<<D[i.first][i.second]-1<<endl;
  }
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M;
  cin >> N >> M;
  int C[40]={0};
  for(int i=1;i<=N;i++){
    int K;
    cin >> K;
    for(int j=0;j<K;j++){
      int A;
      cin >> A;
      C[A]++;
    }
  }
  int ans=0;
  for(int i=0;i<40;i++){
    if(C[i]==N){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1<<30;
const long long LINF = 1LL << 60;
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//combi : https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n , ll M){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b , ll M){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return -1;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

//ミョ(-ω- ?)
int main() {
    cin.tie(nullptr) ;
    ios::sync_with_stdio(false) ;

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, MOD-2,MOD) % MOD; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll s;
    cin >> s;
    ll res = 0;
    for (ll n = 1;; n++) {
        if(s - n*3 < 0)break;
        ll c = comb(s - n*3 + n -1, s - n*3 , MOD);
        if (c < 0 || c == -1) continue;
        res = (res + c) % MOD;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 7772
import sys
from math import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def lcm(a, b):
    return a // gcd(a, b) * b


def main():
    N, *A = map(int, read().split())

    ans = 0
    l = 1
    for a in A:
        l, l_prev = lcm(l, a), l
        ans = (ans * (l // l_prev) % MOD + l // a) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 76292
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1100
#include <iostream>
#include <cstdio>
#include <iomanip> // setprecision
#include <complex>
#include <cmath>
using namespace std;

typedef complex<double> point;

double inner_product(point x, point y) {
  return (conj(x) * y).real();
}

double outer_product(point x, point y) {
  return (conj(x) * y).imag();
}

point normalize(point a) {
  return a * (1/abs(a)); // normはabsの2乗、absは本来のノルム。
}

point projection(point a, point b) {
  point e = normalize(b);
  return e * inner_product(a, e);
}

int main() {
  point P[110];
  double x, y;
  int n;
  int t = 1;
  while (cin >> n && n) {
    for (int i=0; i<n; i++) {
      cin >> x >> y;
      P[i] = point(x, y);
    }
    double S = 0;
    for (int i=1; i<n-1; i++) {
      S += outer_product(P[i]-P[0], P[i+1]-P[0])/2;
    }
    cout << t++ << " " << fixed << setprecision(1) << abs(S) << endl;
  }
}

Measured memory_bytes: 1308
#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime> 
#include <stack>
#include <iostream>

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 400010;



int a[MAXN];

int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	for (int i = 0; i < 3 * n; i++) cin >> a[i];
	sort(a, a + 3 * n);
	reverse(a, a + 3 * n);
	ll sum = 0;
	for (int i = 1; i < 2 * n; i += 2) {
		sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int n;
    char buf[30];

    //標準入力から1行bufに格納
    fgets(buf, sizeof(buf), stdin);

    n = atoi(buf);

    //標準出力に書き出す
    if (1<=n && n<=10)
    printf("%d\n", n+n*n+n*n*n);
    return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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; }

int main() {
	ll l,r;
	cin >> l >> r;
	ll p = 2019;
	ll mini = 1e9;
	int loopt = min((ll)2019,r-l);
	//cout << loopt << endl;
	for(ll i=0; i<loopt; i++) {
		for(ll j=i+1; j<=loopt; j++) {
			ll t = 0;
			t = (l + i) * (l + j);
			t %= p;
			chmin(mini, t); 
			//if (t < mini) cout << i << " " << j << " " << t << endl;
		}
	}
	cout << mini << endl;

  return 0;
}


Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())
if x==a*a*b:
  ans=0
elif x<=a*a*b/2:
  ans=90-math.degrees(math.atan(2*x/a/b/b))
else:
  ans=90-math.degrees(math.atan(a*a*a/2/(a*a*b-x)))
print(ans)

Measured memory_bytes: 3060
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

#[allow(unused_macros)]
macro_rules! debug {
    ($var:expr) => {
        match &$var { v => eprintln!(concat!(stringify!($var), "={:?}"), v) }
    };
    ($var:expr, $($vars:expr),*) => {
        match &$var { v => eprint!(concat!(stringify!($var), "={:?} "), v) }
        debug!($($vars),*);
    };
}

fn main() {
    let h: usize = input();
    let w: usize = input();
    let mut a: Vec<Vec<i32>> = (0..h).map(|_| (0..w).map(|_| input()).collect()).collect();

    let mut ans = vec![];
    for i in 0..h {
        for j in 0..w {
            if a[i][j] & 1 == 1 {
                if j < w - 1 {
                    a[i][j] -= 1;
                    a[i][j + 1] += 1;
                    ans.push((i, j, i, j + 1));
                } else if i < h - 1 {
                    a[i][j] -= 1;
                    a[i + 1][j] += 1;
                    ans.push((i, j, i + 1, j));
                }
            }
        }
    }

    with_stdout_lock(|mut w| {
        writeln!(w, "{}", ans.len()).unwrap();
        for (a, b, c, d) in ans {
            writeln!(w, "{} {} {} {}", a + 1, b + 1, c + 1, d + 1).unwrap();
        }
    });
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, x, diff = INF, a, ans;
  cin >> x >> n;
  set<ll> p;
  rep(i, n) cin >> a, p.insert(a);

  for (int i = 101; i >= 0; --i)
     if(!p.count(i)) if (abs(x - i) <= diff) ans = i, diff = abs(x - i);

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


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[2000007],finv[2000007],inv[2000007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<2000007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    
    cominit();
    ll ans = 0;
    c++;d++;
    ans += com(c + d, c);
    ans -= com(c + b, c);
    ans -= com(a + d, a);
    ans += com(a + b, a);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 47104
var
	N,i,j:Longint;
	ans:int64;
begin
	read(N);
	j:=round(sqrt(N));
	if j*j>N then dec(j);
	for i:=1 to j do inc(ans,(N div i)*(N div i+1)*i-i*i*i);
	writeln(ans);
end.

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

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        String[] arr = reader.readLine().split (" ");
        int N;
        N = Integer.parseInt (arr[0]);
        Integer[] arrHon = {2, 4, 5, 7, 9};
        Integer[] arrPon = {0, 1, 6, 8};
        if (Arrays.asList (arrHon).contains (N % 10)) {
            System.out.println ("hon");
            return;
        }
        if (Arrays.asList (arrPon).contains (N % 10)) {
            System.out.println ("pon");
            return;
        }
        System.out.println ("bon");
        return;
    }
}


Measured memory_bytes: 32284
#include <iostream>
#include <cstdio>

using namespace std;

int n, cnt;
int a[200005];
int b[200005];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i = n; i >= 1; i--)
    {
        bool v = a[i];
        for(int j = i * 2; j <= n; j+=i)
        {
            v ^= b[j];
        }
        b[i] = v;
        if(b[i]) cnt++;
    }
    printf("%d\n", cnt);
    for(int i = 1; i <= n; i++)
    {
        if(b[i]) printf("%d ", i);
    }
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    string S;
    cin >> S;
    string str1, str2;

    for (int i = 0; S.size() > 1; i++)
    {
        S.pop_back();
        if (S.size() % 2 != 0) continue;
        str1 = S.substr(0, S.size() / 2);
        str2 = S.substr(S.size() / 2, S.size() / 2);
        if (str1 == str2) break;
    }
    
    cout << str1.size() * 2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
fn solve(n: &str) -> i64 {
    let n: i32 = n.parse().unwrap();
    let mut ab = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let v: Vec<i64> = s.split_whitespace().map(|x|x.parse().unwrap()).collect();
        ab.push((v[0],v[1]));
    }
    ab.iter().rev().fold(0,|c,&(a,b)| {
        c+(b-(a+c)%b)%b
    })
}
fn main() {
    loop {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let s = s.trim_right();
        if s=="" { break; }
        println!("{}",solve(&s));
    }
}

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

int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  
  if ( S.size() <= K) {
      cout << S << endl;
  }
  else{
    for (int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main()
{
	int t=0,i=0;
	char a[4];
	char u[4];
	gets(u);
	gets(a);
	while(i<3)
	{
		if(a[i]==u[i])
		{
		
		t=t+1;
	}

		i=i+1;
		
	}
		printf("%d",t);
	
	return 0;
	
}

Measured memory_bytes: 128
s=str(input())
l=len(s)
cnt1=0
cnt2=0
for i in range(l):
  if i%2==0:
    if s[i]=='0':
      cnt1+=1
    else:
      cnt2+=1
  else:
    if s[i]=='0':
      cnt2+=1
    else:
      cnt1+=1
print(min(cnt1,cnt2))

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

int main(){
  int a,b; cin>>a>>b;
  if(a+b==15){
    cout<< '+' <<endl;
  }
  else if(a*b==15){
    cout << '*' << endl;
  }
  else cout << 'x' << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    ll N;
    cin >> N;
    vecl f(N+1);
    for(ll i = 1; i <= N; i++) {
        for(ll j = i; j <= N; j += i) f[j]++;
    }
    ll ans = 0;
    for(int i = 1; i <= N; i++) ans += i*f[i];
    cout << ans << endl;
}

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

const int INF = 1e9 + 7;

struct MinCost {
    struct Edge {
        int u, f, mf, cost; // f -- flow, mf -- max flow
    };
    vector<Edge> edges;
    vector<vector<int>> e;
    int ALL;
    MinCost(int ALL): ALL(ALL) {
        e.resize(ALL);
    }

    void add_edge(int v, int u, int mf, int cost) {
        assert(v != u);
        e[v].push_back(edges.size());
        edges.push_back({u, 0, mf, cost});
        e[u].push_back(edges.size());
        edges.push_back({v, 0, 0, -cost});
    }

    pair<int,int> get_flow(int S, int T) {
        int f_size = 0;
        int sum_cost = 0;
        queue<int> q;
        vector<int> dist;
        vector<int> par;

        int last_min_dist = -INF;
        while (true) {
            dist.assign(ALL, INF);
            par.assign(ALL, -1);
            dist[S] = 0;
            q.push(S);
            while (!q.empty()) {
                int v = q.front();
                q.pop();
                for (auto eid: e[v]) {
                    auto E = edges[eid];
                    if (E.f < E.mf && dist[E.u] > dist[v] + E.cost) {
                        dist[E.u] = dist[v] + E.cost;
                        q.push(E.u);
                        par[E.u] = eid;
                    }
                }
            }
            if (dist[T] == INF) {
                break;
            }

            sum_cost += dist[T];
            f_size++;
            int v = T;
            while (v != S) {
                int eid = par[v];
                assert(eid != -1);
                edges[eid].f += 1;
                edges[eid ^ 1].f -= 1;
                v = edges[eid ^ 1].u;
            }
        }
        return {f_size, sum_cost};
    }
};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    MinCost mf(n * m + 2);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] != '#') {
                if (i + 1 < n && a[i + 1][j] != '#') mf.add_edge(i * m + j + 1, (i + 1) * m + j + 1, INF, -1);
                if (j + 1 < m && a[i][j + 1] != '#') mf.add_edge(i * m + j + 1, i * m + j + 2, INF, -1);
                mf.add_edge(i * m + j + 1, n * m + 1, 1, 0);
            }
            if (a[i][j] == 'o') mf.add_edge(0, i * m + j + 1, 1, 0);
        }
    }
    cout << -mf.get_flow(0, n * m + 1).second;
    return 0;
}


Measured memory_bytes: 3860
#include<bits/stdc++.h>
using namespace std;
const int maxn=100000+10;

int n;
int a[maxn];
int d[maxn]={0};
int l[maxn],r[maxn];
int dd[maxn]={0};
int kq;

int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i=i+2) d[a[i]]++;
    for(int i=2;i<=n;i=i+2) dd[a[i]]++;
    l[1]=d[1];for(int i=2;i<=100000;i++) l[i]=max(l[i-1],d[i]);
    r[100000]=d[100000];for(int i=99999;i>=1;i--) r[i]=max(r[i+1],d[i]);
    kq=n;
    for(int i=1;i<=100000;i++){
        int tmp=0;
        if (i-1>=1) tmp=max(tmp,l[i-1]);
        if (i+1<=100000) tmp=max(tmp,r[i+1]);
        kq=min(kq,n-dd[i]-tmp);
    }
    cout<<kq;
}


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

using namespace std;
typedef long long ll;

vector<ll> res;

void dfs(ll cur, int pre, int si, int h) {
  if ((h > 3 && si >= 9) || si >= 10) {
    return;
  }

  for (int i = max(0, pre - 1); i <= min(pre + 1, 9); ++i) {
    ll next = cur * 10;
    next += i;
    res.push_back(next);
    dfs(next, i, si + 1, h);
  }
}

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

  for (ll i = 1; i <= 9; ++i) res.push_back(i);
  for (ll i = 1; i <= 9; ++i) {
    dfs(i, i, 1, i);
  }

  sort(res.begin(), res.end());
  cout << res[k - 1] << '\n';
  return 0;
}



Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cmath>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  while (true) {
    ll N;
    cin >> N;
    if (N == 0) return;
    vector<ll> foo(N);
    rep (i, N) cin >> foo[i];
    double sum = 0;
    rep (i, N) sum += foo[i];
    double avg = sum / N;
    double ans = 0;
    rep (i, N) {
      double a = foo[i];
      a -= avg;
      a = a * a;
      ans += a;
    }
    ans /= N;
    ans = pow(ans, 0.5);
    cout << ans << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3456
n = int(input())
s = input()

dp = [[0 if max(i,j) == n else -1 for i in range(n+1)] for j in range(n+1)]

ans = 0
for i in range(n-1, -1, -1):
    for j in range(n-1, i, -1):
        if s[i] == s[j]:dp[i][j] = dp[i+1][j+1] + 1
        else: dp[i][j] = 0
        ans = max(ans, min(dp[i][j], j-i))

print(ans)

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

const long long DX[4] = {-1, 0, 1, 0}, DY[4] = {0, 1, 0, -1};

long long k, x, y;
vector<pair<long long, long long>> ve;

pair<long long, long long> forward(long long ox, long long oy, long long dx, long long dy, long long dst) {
    long long tmp = dst, dir;
    if (dx < ox) {
        long long mov = min(ox - dx, tmp);
        ox -= mov;
        tmp -= mov;
        dir = -1;
    } else {
        long long mov = min(dx - ox, tmp);
        ox += mov;
        tmp -= mov;
        dir = 1;
    }
    if (dy < oy) {
        long long mov = min(oy - dy, tmp);
        oy -= mov;
        tmp -= mov;
    } else {
        long long mov = min(dy - oy, tmp);
        oy += mov;
        tmp -= mov;
    }
    return {ox + dir * tmp, oy};
}

vector<pair<long long, long long>> solve(long long ox, long long oy, long long dx, long long dy) {
    vector<pair<long long, long long>> ret;
    while (abs(ox - dx) + abs(oy - dy) > 2 * k) {
        pair<long long, long long> fi = forward(ox, oy, dx, dy, k);
        ret.push_back(fi);
        ox = fi.first; oy = fi.second;
    }
    if ((abs(dx - ox) + abs(dy - oy)) % 2 == 1) {
        pair<long long, long long> fi = forward(ox, oy, dx, dy, k);
        ret.push_back(fi);
        ox = fi.first; oy = fi.second;
    }
    if (ox == dx && oy == dy) {
        return ret;
    }
    long long dst = abs(ox - dx) + abs(oy - dy);
    pair<long long, long long> mid = forward(ox, oy, dx, dy, dst / 2);
    for (int i = 0; i < 4; i++) {
        long long tx = mid.first + DX[i] * (k - dst / 2), ty = mid.second + DY[i] * (k - dst / 2);
        if (abs(tx - ox) + abs(ty - oy) == k && abs(tx - dx) + abs(ty - dy) == k) {
            ret.push_back({tx, ty});
            ret.push_back({dx, dy});
            return ret;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> k >> x >> y;
    if (abs(x + y) % 2 == 1 && k % 2 == 0) {
        return cout << -1, 0;
    }
    if (abs(x + y) % 2 == 1) {
        pair<long long, long long> st = forward(0, 0, x, y, k);
        long long tx = st.first, ty = st.second;
        ve = solve(tx, ty, x, y);
        cout << ve.size() + 1 << '\n' << tx << " " << ty << '\n';
        for (pair<long long, long long> &v : ve) {
            cout << v.first << " " << v.second << '\n';
        }
        return 0;
    } else {
        ve = solve(0, 0, x, y);
        cout << ve.size() << '\n';
        for (pair<long long, long long> &v : ve) {
            cout << v.first << " " << v.second << '\n';
        }
        return 0;
    }
}


Measured memory_bytes: 5484
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    if(n & 1) {
        for(int i = 0; i < m; i++) {
            printf("%d %d\n", i + 1, n - i - 1);
        }
    }else {
        for(int i = 0; i < m; i++) {
            if(i < n / 4) printf("%d %d\n", i + 1, n - i);
            else printf("%d %d\n", i + 1, n - i - 1);
        }
    }
    return 0;
}

Measured memory_bytes: 3784
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> G[100000];
bool vis[100000];
int qtype[100000], vertex[100000], marked[100000];

int par[100000], pp[100000];

void init()
{
	for (int i = 0; i < 100000; i++) par[i] = i;
}

int find(int x)
{
	if (par[x] == x) return (x);
	return (par[x] = find(par[x]));
}

void merge(int x, int y)
{
	x = find(x); y = find(y);
	if (x != y){
		par[y] = x;
	}
}

void dfs(int v, int p, int m)
{
	int nm = m;
	if (marked[v]) nm = v;
	pp[v] = p;
	
	merge(nm, v);
	
	for (int i = 0; i < G[v].size(); i++){
		dfs(G[v][i], v, nm);
	}
}

int main()
{
	int N, Q;
	
	while (scanf("%d %d", &N, &Q) && N){
		for (int i = 0; i < N; i++) G[i].clear();
		
		for (int i = 1; i < N; i++){
			int v;
			scanf("%d", &v);
			G[--v].push_back(i);
		}
		
		init();
		
		memset(marked, 0, sizeof(marked));
		marked[0]++;
		for (int i = 0; i < Q; i++){
			char t[10];
			scanf("%s %d", t, vertex + i);
			qtype[i] = (t[0] == 'Q');
			--vertex[i];
			if (!qtype[i]) ++marked[vertex[i]];
		}
		
		dfs(0, -1, -1);
		
		long long int ans = 0;
		for (int i = Q - 1; i >= 0; i--){
			if (qtype[i]){
				ans += find(vertex[i]) + 1;
			}
			else {
				--marked[vertex[i]];
				if (!marked[vertex[i]]) merge(pp[vertex[i]], vertex[i]);
			}
		}
		
		printf("%lld\n", ans);
	}
	
	return (0);
}


Measured memory_bytes: 15264
N = int(input())
S = input()
l, r = 0, 0
lp, rp = 0, 0

for i in range(N):
    if S[i] == '(':
        l += 1
    else:
        r += 1
    lp = max(lp, r-l)
rp = lp + l - r

ans = '(' * lp + S + ')' * rp
print(ans)


Measured memory_bytes: 3060
import math
n = int(input())
if n < 10:
    print(1)
else:
    a = 0
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            a = i
    b = n//a
    j = 1
    while True:
        m = b / (10**j)
        if m>=1 and m<10:
            ans = j+1
            break
        j+=1

    print(ans)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    double md = m;
    double sum_a = accumulate(a.begin(), a.end(), 0);
    if (a[m-1] < sum_a/(4*md)) {
        cout << "No" << endl;
    }
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
/* func */
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
 
//#define int ll
//#define int long long
 
signed main()
{
  int options; cin >> options;
  
  int t; cin >> t;
  int a; cin >> a; a *= 1000;
  int h;
  int ave;
  
  vi H(0);
  REP(i, options){
    cin >> h;
    H.PB(h);
  }
  
  vi Ave(0);
  REP(i, options){
    ave = t*1000-H[i]*6;
    Ave.PB(ave);
  }
  
   REP(i, options)
    if(Ave[i] == a){
      cout << i+1;
       return 0;
    }
  
  REP(i, options){
     Ave[i] = Ave[i] - a;
  }
  
  REP(i, options)
    if(Ave[i] < 0)
      Ave[i] *= -1;
  
  int min = *min_element(ALL(Ave));
  
  REP(i, options)
   if(min == Ave[i]){
    cout << i+1;
     return 0;
  }
 
  return 0;
}

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

int main() {
	int n, m;
	cin >> n >> m;
	if (n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  int a,b,c;
  cin>>a>>b>>c;

  int ans=a;
  for(int i=a+a;i<=b*a;i+=a){
    if(ans%b==c){
      cout<<"YES"<<endl;
      return 0;
    }
    ans+=a;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 256
<?php

$a = [];
$b = [];
$c = [];
fscanf(STDIN, "%d", $n);
for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, "%d %d", $a[$i], $b[$i]);
    $c[$i] = $a[$i] + $b[$i];
}


array_multisort($c, SORT_DESC, $a, $b, SORT_ASC);
$max_diff = 0;
foreach ($c as $k => $val) {
    if ($k % 2) {
        $max_diff -= $b[$k];
    } else {
        $max_diff += $a[$k];
    }
}


echo $max_diff;

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _f64 a, b, C; cin >> a >> b >> C;
        _f64 S = a * b * sin(C * M_PI / 180) / 2;
        _f64 L = a + b + sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C * M_PI / 180));
        _f64 h = S / a * 2;
        cout << fixed << setprecision(8) << S << endl << L << endl << h << endl;
    }
    return 0;
}


Measured memory_bytes: 3480