akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int h, w, K; cin >> h >> w >> K;
	vector<string> s(h);
	REP(i, h) cin >> s[i];
	vector<int> row, column;
	REP(i, h) {
		REP(j, w) {
			if (s[i][j] == '#') {
				row.push_back(i);
				break ;
			}
		}
	}
	if (row.back() != h - 1)
		row[(int)row.size() - 1] = h - 1;

	vector<vector<int> > res(h, vector<int>(w, 0));
	int k = 1;
	REP(i, h) REP(j, w) {
		if (s[i][j] == '#')
			res[i][j] = k++;
	}

	REP(i, h) {
		REP(j, w - 1) {
			if (res[i][j] != 0) {
				if (res[i][j+1] == 0)
					res[i][j+1] = res[i][j];
			}
		}
		for (int j = w - 1; j > 0; j--) {
			if (res[i][j] != 0) {
				if (res[i][j-1] == 0)
					res[i][j-1] = res[i][j];
			}
		}
	}

	while (true) {
		REP(i, h) REP(j, w) {
			if (res[i][j] == 0) {
				if (i + 1 < h) {
					if (res[i + 1][j] != 0)
						res[i][j] = res[i + 1][j];
				}
			}
		}
		REP(i, h) REP(j, w) {
			if (res[i][j] == 0) {
				if (i - 1 >= 0)
					if (res[i - 1][j] != 0)
						res[i][j] = res[i - 1][j];
			}
		}
		bool ok = true;
		REP(i, h) {
			int sum = 0;
			REP(j ,w) {
				sum += res[i][j];
			}
			if (sum == 0) {
				ok = false;
				break ;
			}
		}
		if (ok) break ;
	}
	int sum = 0;
	REP(i, w) sum += res[h - 1][i];
	if (sum == 0) {
		REP(i, w) res[h - 1][i] = res[h - 2][i];
	}
	REP(i, h) {
		REP(j, w)
			cout << res[i][j] << " ";
		cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 3892
import * as fs from 'fs';

function main(input) {
  input = input.split("\n");
  const tmp = input[0];
  const sum = tmp.split('').map(s => parseInt(s)).reduce((prev, current) => prev + current);
  console.log('%s', sum % 9 === 0 ? 'Yes' : 'No');
  return 0;
}

main(fs.readFileSync("/dev/stdin", "utf8"));


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

void solve(){
    int N;
    cin >> N;
    bool ans = false;
    for(int i = 1; i <= 9; ++i){
        if(N % i != 0) continue;
        int tmp = N / i;
        if(1 <= tmp && tmp <= 9 ){
            ans = true;
            break;
        }
    }
    if(ans){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int N=3005;
const int mod=1e9+7;
int dp[N],fact[200005],ans;
pair<int,int> coor[N];
int binpow(int x,int y){
	int tich=1,mul=x;
	while(y>0){
		if(y%2==1){
			tich=(tich*mul)%mod;
		}
		mul=(mul*mul)%mod;
		y/=2;
	}
	return tich;
}
int C(int x,int y){
	return (((fact[y]*binpow(fact[x],mod-2))%mod)*binpow(fact[y-x],mod-2))%mod;
}
signed main(){
	int h,w,i,j,n,max1;
	cin>>h>>w>>n;
	for(i=1;i<=n;i++){
		cin>>coor[i].first>>coor[i].second;
	}
	fact[0]=1;
	for(i=1;i<=w+h;i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
	sort(coor+1,coor+1+n);
	ans=C(h-1,h+w-2);
//	cout<<C(0,n)<<endl;
	for(i=1;i<=n;i++){
		dp[i]=C(coor[i].first-1,coor[i].first+coor[i].second-2);
		for(j=i-1;j>=1;j--){
			if(coor[j].second<=coor[i].second){
dp[i]=((dp[i]-(dp[j]*C(coor[i].second-coor[j].second,coor[i].second+coor[i].first-coor[j].second-coor[j].first))%mod)+mod)%mod;
			}
		}
		ans=((ans-dp[i]*C(h-coor[i].first,h+w-coor[i].first-coor[i].second))%mod+mod)%mod;
	}
	cout<<ans;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int sts,end;

    sts = X - K;
    end = X + K;
    for(int i = sts + 1; i <= end -1; i++){
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) a.begin(),a.end()
#define INF 2e9
#define updmin(dp,x) (dp = min(dp,x))

int main(void){
    int n,m;
    while(cin>>n>>m, n|m){
        vector<int> c(m);
        rep(i,m) cin>>c[i];
        vector<int> x(n);
        rep(i,n) cin>>x[i];
        vector<vector<int>> dp(n+1,vector<int>(256,INF));
        dp[0][128] = 0;
        rep(i,n)rep(y,256)rep(k,m){
            int ny = max(0,min(255,y+c[k]));
            updmin(dp[i+1][ny], dp[i][y]+(int)pow(x[i]-ny,2));
        }
        cout<<*min_element(all(dp[n]))<<endl;
    }
    return 0;
}



Measured memory_bytes: 23760
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#define ll long long
using namespace std;
int n,a[100086];
ll ans;
bool bo[100086];
ll get()
{
    ll sum=0,tmp=0;
    for(int i=1;i<=n;i++)
    {
        if(bo[i])
        {
            sum+=a[i];if(sum<=0){tmp+=abs(sum)+1;sum=1;}
        }else{
            sum+=a[i];if(sum>=0){tmp+=sum+1;sum=-1;}
        }
    }
    return tmp;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)bo[i]=i%2;
    ans=get();
    for(int i=1;i<=n;i++)bo[i]=1-i%2;
    ans=min(ans,get());
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 768
p=1
num=[]
while p==1:
    x=int(input())
    if x==0:
        break
    else:
        y=x
        while y>0:
            a=int(input())
            num.append(a)
            y-=1
        num.sort()
        del num[0]
        del num[-1]
        poo=sum(num)
        pooh=poo//(x-2)
        print(pooh)
        num.clear()


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

using namespace std;

typedef long long int Int;

int main(void)
{
    Int n,cnt = 0,two = 0;

    cin>>n;
    for(int i = 0;i < n;i++)
    {
	Int temp;
	cin>>temp;
	if(temp % 4 == 0)
	    cnt++;
	else if(temp % 2 == 0)
	    two++;
    }

    if(cnt + two/2 >= n/2)
	cout<<"Yes"<<endl;
    else
	cout<<"No"<<endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import math,sys

n = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split()))
#n = int(input())
#a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
acc = a[0]
for i in range(n):
    acc = math.gcd(acc,a[i])
if acc != 1:
    print("not coprime")
    exit()

LIMIT=max(a)
minPrime = [0]*(LIMIT+1)
minPrime[1] = 1
def make():
    for i in range(2,LIMIT+1):
        if minPrime[i] == 0:
            minPrime[i] = i
            #print(i)
            for j in range(i+i,LIMIT+1,i):
                #print(i,j)
                if minPrime[j] == 0:
                    minPrime[j] = i
make()
def factrial(N):
     ret = []
     while minPrime[N] != N:
         ret.append(minPrime[N])
         N = N//minPrime[N]
     if N != 1:
         ret.append(N)
     return ret

judge = set([])

for e in a:
    asf = set(factrial(e))
    if judge & asf != set():
        print("setwise coprime")
        exit()
    judge |= asf
    #judge = judge | asf #too slow
print("pairwise coprime")

Measured memory_bytes: 126988
#include<stdio.h>
#include<string.h>
  
#define MAX 1010
#define max(a,b) ((a<b)?b:a)
  
char s[MAX], t[MAX];
int dp[MAX][MAX];
  
int LCS() {
  int n = strlen(s);
  int m = strlen(t);
  memset(dp,0,sizeof dp);
  int i,j,maxi=0;
  for(i=0;i<n;i++) {
    for(j=0;j<m;j++) {
      if( i ) dp[i][j] = max(dp[i][j],dp[i-1][j]);
      if( j ) dp[i][j] = max(dp[i][j],dp[i][j-1]);
      if( s[i] == t[j] ) {
    dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
    maxi = max(maxi,dp[i+1][j+1]);
      }
    }
  }
  return maxi;
}
  
int main() {
  int n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++) {
  scanf(" %s",&s[0]);
  scanf(" %s",&t[0]);
  printf("%d\n",LCS());
  }
  return 0;
}


Measured memory_bytes: 5708
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
	string str,str2;
	int matsu=-1;
	cin >> str;
	cin >> str2;
	for (int i=0; i<str.size(); i++) {
		bool ok = true;
		for (int j=0; j<str2.size();j++) {
			if (str[i+j] != '?' && str[i+j] != str2[j]){
				 ok = false;
				 break;
			}
		}
		if (ok) matsu = i;
	}

	if(matsu>=0){
		for(int i=0;i<matsu;i++){
			if(str[i]=='?')	cout << 'a';
			else	cout << str[i];
		}
		cout << str2;
		for(int i=matsu+int(str2.size());i<str.size();i++){
			if(str[i]=='?')	cout << 'a';
			else	cout << str[i];
		}
		cout << endl;
	}
	else	cout << "UNRESTORABLE\n";
	return 0;
}

Measured memory_bytes: 256
class Dice(object):
    """
    入力を保持してサイコロを転がすと各面の値がどう変わるかをreturnする
    Attributes
    ----------
    stat : str
        上面を[0]、前面を[1]としたサイコロの側面の値
    Figure :
            4
            ↓
           _＿__
        ／0   ／|
    3→ |1￣ |2 |
        |＿＿|／
          ↑
          5
    """
    def __init__(self, all_num):
        self.stat = all_num
    def roll_N(self):
        self.stat[0],self.stat[1],self.stat[4],self.stat[5] = self.stat[1],self.stat[5],self.stat[0],self.stat[4]
    def roll_E(self):
        self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[3],self.stat[0],self.stat[5],self.stat[2]
    def roll_S(self):
        self.stat[0],self.stat[1],self.stat[4],self.stat[5] = self.stat[4],self.stat[0],self.stat[5],self.stat[1]
    def roll_W(self):
        self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[2],self.stat[5],self.stat[0],self.stat[3]
    def top(self):
        return self.stat[0]


# インスタンス作成
dice = Dice(input().split())
orders = input()
# 各文字を取り出して命令を実行
for order in orders:
    if order == "N":
        dice.roll_N()
    elif order == "E":
        dice.roll_E()
    elif order == "S":
        dice.roll_S()
    elif order == "W":
        dice.roll_W()
print(dice.top())




Measured memory_bytes: 5588
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
using namespace std;
int main()
{
    fIO
    int a,b,c,d;
    cin>>a>>b;
    c=max(a,b);
    d=min(a,b);
    int ans=0;
    if(c-1>=d)
    {
        ans=2*c-1;
    }
    else
    ans=c+b;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import sys

mys = input()

list1 = ['R', 'U', 'D']
list2 = ['L', 'U', 'D']


mycnt = 1
 
for i in mys:
    if mycnt%2 != 0:
        if i not in list1:
            print('No')
            sys.exit()
    
    else:
        if i not in list2:
            print('No')
            sys.exit()
            
    mycnt += 1

print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-2, -1};
int dx[4] = {-1, -2};

int n, q;
vector<int> adj[200000];
ll cnt[200000];
ll ret[200000];
bool visited[200000];

void dfs(int here, ll pass) {
	visited[here] = true;
	ret[here] = pass + cnt[here];
	for(int i=0; i<adj[here].size(); ++i) {
		int there = adj[here][i];
		if(!visited[there]) {
			dfs(there, ret[here]);
		}
	}
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	memset(cnt, 0, sizeof(cnt));
	memset(ret, 0, sizeof(ret));
	cin >> n >> q;
	rep(i,0,n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	rep(i,0,q) {
		int p;
		ll x;
		cin >> p >> x;
		p--;
		cnt[p] += x;
	}
	dfs(0,0);
	rep(i,0,n) {
		cout << ret[i] << ' ';
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 25984
#include<stdio.h>
int main(void)
{int s[4],sum1,sum2,i;
  sum1=0;
  sum2=0;
  scanf("%d %d %d %d",&s[0],&s[1],&s[2],&s[3]);
  for(i=0; i<4; i++)
    sum1=sum1+s[i];

   scanf("%d %d %d %d",&s[0],&s[1],&s[2],&s[3]);
  for(i=0; i<4; i++)
    sum2=sum2+s[i];

  if(sum1>sum2)
    printf("%d\n",sum1);
  else
    printf("%d\n",sum2);

  return(0);

}

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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define For(i, a) for (int i=0; i<a; i++)
#define FORR(i,a,b) for (int i = a; i >= b; i--)
#define Forr(i,a) for (int i = a; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args)
{cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

const int INF=1e18;

void solve(){
  int a[4];
  int ans=-INF;
  For(i,4)cin >> a[i];
  for(int i=0;i<2;i++){
    for(int j=2;j<4;j++){
      ans=max(ans,a[i]*a[j]);
    }
  }
  cout << ans << "\n";
}


int32_t main(){
  ios_base:: sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  for(int tt=1;tt<=t;tt++){
    solve();
  }
}

Measured memory_bytes: 3632
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;

const INF : usize = 1000000007;

fn main() {
  input! {
    s : Chars,
    t : Chars,
  };
  
  let mut n = s.len();
  let mut m = t.len();
  
  let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
  
  for i in 0..=n {
    for j in 0..=m {
      if i == 0 || j == 0 {
        continue;
      }
      
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      if s[i - 1] == t[j - 1] {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
      }
    }
  }

  let mut ser = vec![];
  while n > 0 && m > 0 {
    if dp[n][m] == dp[n - 1][m] {
      n -= 1;
    } else if dp[n][m] == dp[n][m - 1] {
      m -= 1;
    } else {
      ser.push(s[n - 1]);
      n -= 1;
      m -= 1;
    }
  }
  
  let res = ser
    .iter()
    .rev()
    .collect::<String>();
  println!("{}", res);
}


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

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int h[n];
    int post[n];
    for(int i = 0; i<n; i++)
        scanf("%d", &h[i]);

    post[0]=0;
    post[1]=abs(h[0]-h[1]);
    for(int j = 2; j<n;j++){
        post[j]=min(post[j-1]+abs(h[j-1]-h[j]),post[j-2]+abs(h[j-2]-h[j]));
    }
	printf("%d",post[n-1]);
    return 0;
}

Measured memory_bytes: 1024
#-swank (eval-when (:compile-toplevel)
          (proclaim '(optimize (speed 3) (debug 0) (safety 0))))

(defparameter inf 2000000000)

(defun read-integer (&optional (in *standard-input*))
  (labels ((number-char-p (b)
             (<= #.(char-code #\0) b #.(char-code #\9)))
           (minus-char-p (b)
             (= b #.(char-code #\-)))
           (to-number (b)
             (- b #.(char-code #\0))))
    (let* ((minus-p nil)
           (x (loop for b = (read-byte in nil 0)
                    if (number-char-p b)
                      return (to-number b)
                      end
                    if (minus-char-p b)
                      do (setf minus-p t))))
      (loop for b = (read-byte in nil 0)
            and y = x then (+ (* y 10) (to-number b))
            unless (number-char-p b)
              return y))))

(defun split (x str &optional (acc nil))
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (split x (subseq str (+ pos size)) (cons (subseq str 0 pos) acc))
        (nreverse (cons str acc)))))

(defmacro minf (field &rest x)
  `(setf ,field (min ,field ,@x)))

(defmacro maxf (field &rest x)
  `(setf ,field (max ,field ,@x)))

(defun solve (stairs n)
  (let ((dp (make-array n :element-type 'integer :initial-element inf)))
    (setf (aref dp 0) 0)
    (dotimes (i (1- n))
      (minf (aref dp (1+ i)) (+ (aref dp i) (abs (- (aref stairs i) (aref stairs (1+ i))))))
      (if (< (+ i 2) n)
          (minf (aref dp (+ i 2)) (+ (aref dp i) (abs (- (aref stairs i) (aref stairs (+ i 2))))))))
    (aref dp (1- n))))

(let* ((n (parse-integer (read-line)))
       (stairs (make-array n :adjustable t :fill-pointer 0)))
  (dotimes (i n)
    (vector-push (read-integer *standard-input*) stairs))
  (format t "~A~%" (solve stairs n)))


Measured memory_bytes: 26240
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <queue>
#include <cmath>
#include <cstdio>

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> ins(3);
    for(int i=0; i<3; ++i) cin >> ins[i];
    vector<int> ls(n);
    for(int i=0; i<n; ++i) cin >> ls[i];
    int ans=numeric_limits<int>::max();
    for(int i=0; i<(1 << (2*n))-1; ++i){
        vector<int> cnts(4), lens(4);
        for(int j=0; j<n; ++j){
            int k=(i >> 2*j) & 0b11;
            ++cnts[k];
            lens[k]+=ls[j];
        }
        int cost=0;
        for(int j=0; j<3; ++j){
            if(cnts[j]==0){
                cost=numeric_limits<int>::max();
                break;
            }
            cost+=max(cnts[j]-1, 0)*10+abs(lens[j]-ins[j]);
        }
        ans=min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}


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

const int M=1e6+5;
int a[M];

int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}

int isp[M],pri[M],pre[M],npri=0;
void get_pri()
{
    for(int i=2;i<M;i++)
    {
        if(!isp[i])
        {
            pre[i]=i;
            //pre[i]=npri;
            pri[npri++]=i;
        }
        for(int j=0;j<npri&&pri[j]*i<M;j++)
        {
            isp[i*pri[j]]=1;
            //pre[i*pri[j]]=j;
            pre[i*pri[j]]=pri[j];
            if(i%pri[j]==0) break;
        }
    }
}
vector<int> get_factor(int nu)
{
    vector<int> fa;
    if(nu==1) return fa; // fa.push_back(1);
    while(nu!=1)
    {
        fa.push_back(pre[nu]);
        nu/=pre[nu];
    }
    return fa;
}

int cnt[M],cnt2[M];

int main()
{
	get_pri();
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);

	for(int i=0;i<n;i++)
	{
		vector<int> fas=get_factor(a[i]);
		for(int i:fas)
			cnt[i]++;
	}
	int f=1;
	for(int i=0;i<n;i++)
	{
		vector<int> fas=get_factor(a[i]);
		for(int i:fas)
			cnt2[i]++;
		for(int i:fas)
			if(cnt2[i]<cnt[i])
			{
				// cout<<i<<" "<<cnt[i]<<" "<<cnt2[i]<<endl;
				f=0;
				break;
			}
		if(f==0) break;
		for(int i:fas)
			cnt2[i]--;
	}
	if(f)
	{
		printf("pairwise coprime\n");
		return 0;
	}
	int g=a[0];
	for(int i=1;i<n;i++)
		g=gcd(g,a[i]);
	printf("%s\n",g==1 ? "setwise coprime" : "not coprime");
	return 0;
}

Measured memory_bytes: 19916
l, r = map(int, input().split())

ans = 2018**2
for i in range(l, min(r, l+2019)):
    v = i % 2019
    for j in range(l+1, min(r+1, l+2020)):
        w = j % 2019
        ans = min(ans, (v*w)%2019)
print(ans)

Measured memory_bytes: 9068
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	int n;
	cin>>n;
	ll a[n],sum=0,val[100001]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		val[a[i]]++;
		sum+=a[i];	
	}
	
	int q;
	cin>>q;
	while(q--){
		int b,c;
		cin>>b>>c;
		sum=sum+(c-b)*val[b];
		val[c]+=val[b];
		val[b]=0;
		cout<<sum<<endl;
	}
}



Measured memory_bytes: 5096
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n, w, h;
int pre[200005];
int cycn[200005];

void init()
{
	rep1(i, w + h) {
		pre[i] = i;
		cycn[i] = 0;
	}
}

int root(int x)
{
	return pre[x] == x ? x : pre[x] = root(pre[x]);
}

bool unite(int u, int v)
{
	u = root(u);
	v = root(v);
	int ccyc = u == v ? cycn[u] + 1 : cycn[u] + cycn[v];
	if(ccyc > 1) return false;
	pre[v] = u;
	cycn[u] = ccyc;
	return true;
}

pair<int, PII> edg[200005];

int main()
{
	scanf("%d%d%d", &n, &h, &w);
	rep(i, n) scanf("%d%d%d", &edg[i].second.first, &edg[i].second.second, &edg[i].first);
	sort(edg, edg + n);
	reverse(edg, edg + n);
	LL ans = 0;
	init();
	rep(i, n) if(unite(edg[i].second.first, edg[i].second.second + h)) ans += edg[i].first;
	printf("%lld\n", ans);
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  int count = 0;
  for(int i=0; i<n; i++){
    int tall;
    cin >> tall;
    if(tall >= k) count++;
  }
  cout << count << endl;
  return 0;
}
  
    

Measured memory_bytes: 256
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
count = 0
for i, j in zip(x, y):
    if i == j:
        count += 1
        continue
    if count >= 3:
        break
    count = 0
if count >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
cd = [list(map(int, input().split())) for i in range(m)]
for i in ab:
    l = []
    for j in cd:
        l.append(abs(i[0] - j[0]) + abs(i[1] - j[1]))
    print(l.index(min(l)) + 1)

Measured memory_bytes: 3064
<?php

class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();
$S = $sc->nextInt();
$diff=999;
for($i=0;$i<=strlen($S)-3;$i++){
        $sstr=substr($S,$i,3);
        $tempdiff = abs(753-$sstr);
        if($tempdiff < $diff) $diff=$tempdiff;
}
print($diff."\n");

Measured memory_bytes: 4856
#include <bits/stdc++.h>
#define MD 1000000007
using namespace std;
typedef long long ll;
typedef vector<int> vi;
ll dp[1010][1010];
bool g[1010][1010];
int h,w;
ll ds(int y, int x) {
	if(y == h-1 && x == w-1) {return 1;}
	if(dp[y][x] != -1) {return dp[y][x];}
	ll tp = 0;
	if(y+1 < h && g[y+1][x]) {tp += ds(y+1,x);}
	if(x+1 < w && g[y][x+1]) {tp += ds(y,x+1);}
	return dp[y][x] = tp%MD;
}
int main() {
	scanf("%d %d ",&h,&w);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<h;i++) 
		for(int j=0;j<w;j++) {
			char c;
			scanf("%c ",&c);
			g[i][j] = c=='.';
		}
	printf("%lld\n",ds(0,0));
}

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

void gcd(int &x, int &y){
    int c;
    c = y;
    y = x % y;
    x = c;
}

int main(){

    int x, y;
    cin >> x >> y;
    if(x < y) y = y % x;

    while(1){
        gcd(x, y);
        if(y == 0) break;
    };
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 1160
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


ABCXY = str(input()).split()
A = int(ABCXY[0])
B = int(ABCXY[1])
C = int(ABCXY[2])
X = int(ABCXY[3])
Y = int(ABCXY[4])
ans1 = 0
ans2 = 0
ans3 = 0

XY = X

ans3=C*2*Y + A*(X-Y)

if(X<Y):
  XY = Y
  ans3 = C*2*X + B*(Y-X)


ans1 = A*X+B*Y
ans2 = C*2*XY

ans = min(ans1,ans2)
ans = min(ans,ans3)


print(ans)



Measured memory_bytes: 38892
def main():
    n, k = [int(x) for x in input().split()]
    scores = [int(x) for x in input().split()]

    for remover, new_commer in zip(scores, scores[k:]):
        if remover < new_commer:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()


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

int n;
string s;
int pre[200200], suf[200200];

int main(){
	cin >> n >> s;
	pre[0] = (s[0] == 'W');
	for(int i = 1; i < s.size(); i++) pre[i] = pre[i-1] + (s[i] == 'W');
	suf[(int)s.size() - 1] = (s[(int)s.size() - 1] == 'R');
	for(int i = (int)s.size() - 2; i >= 0; i--) suf[i] = suf[i+1] + (s[i] == 'R');
	int ans = min(pre[(int)s.size() - 1], suf[0]);
	for(int i = 0; i < s.size() - 1; i++){
		ans = min(ans, max(pre[i], suf[i+1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5312
#include <iostream>
using namespace std;
int main() {
    int retsu,intial,end,kaisu,ninzu = 0;
    cin >> retsu;
    for (int i = 0; i < retsu; ++i) {
        cin >> intial >> end;
        kaisu = end - intial;
            for (int j = 0; j <= kaisu; ++j) {
                ninzu++;
            }
        }
    cout << ninzu << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int a;
    cin >> a;
    int n = a;
    int ans = 0;
    rep(i, 3){
        ans += n;
        n *= a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,k,a[100005];
ll t[42];
struct node
{
    ll x,v;
    node(ll x,ll v):x(x),v(v){}
    node();
    bool operator< (const node&o)const
    {
        return x>o.x;
    }
};
priority_queue<node>q;
int main()
{
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
    {
        int pos=0;
        while(a[i])
        {
            if(a[i]&1) t[pos]++;
            pos++;
            a[i]>>=1;
        }
    }
    ll ans=0;
    for(int i=41;i>=0;i--)
    {
        ll s=1ll<<i;
        if(t[i]>=n-t[i])
        {
            ans+=t[i]*s;
        }
        else
        {
            if(k>=s) ans+=(n-t[i])*s,k-=s;
            else ans+=t[i]*s;
        }
    }
    cout<<ans<<endl;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B, C, D;
	int L, R;
	cin >> A >> B >> C >> D;

	L = A + B;
	R = C + D;

	if(L > R){
		printf("Left\n");
	}
	else if(L == R){
		printf("Balanced\n");
	}
	else{
		printf("Right\n");
	}
	return 0;
}



Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n,m;
	cin >> n>> m;
	vector<int>v(n);
	int sum = 0;//総和
	for (int i = 0; i < n; i++) {
		cin >>  v[i];
		sum += v[i];
	}
	int count = 0;//OKな個数
	for (int i = 0; i < n; i++) {
		if ((sum-1) / (4 * m) < v[i]) {
			count++;
		}
	}
	if (count >= m) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

// 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) {
        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];
    }
} comb(2000005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

mint choose(int n, int a) {
    mint x = 1, y = 1;
    rep(i, a) {
        x *= n - i;
        y *= 1 + i;
    }
    return x / y;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= choose(n, a);
    ans -= choose(n, b);
    cout << ans.x << endl;
}


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

static const auto fast_io = [] {
 ios_base::sync_with_stdio(false); 
 cin.tie(nullptr); cout.tie(nullptr); 
 return nullptr;
}();

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class A> 
A rnd() {
 return uniform_int_distribution<A> (1, (int) 1e9) (rng);
}

template<class A> 
A rnd(A x, A y) {
 return uniform_int_distribution<A> (x, y) (rng);
}

string to_string(string s) {
 return '"' + s + '"';
}

string to_string(const char* ch) {
 return to_string((string)ch);
}

string to_string(char ch) {
 return (string)"'" + ch + (string)"'";
}

string to_string(bool b) {
 return (b ? "true" : "false");
}

template<class A, class B>
string to_string(pair<A, B> p) {
 return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<class A>
string to_string(A a) {
 string res = "{";
 bool first = true;
 for(const auto& x: a) {
  if(first == false) res += ", ";
  first = false;
  res += to_string(x);
 }
 res += "}";
 return res;
}

template<class A, class B, class C>
string to_string(priority_queue<A, B, C> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(priority_queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 reverse(res.begin(), res.end());
 return to_string(res);
}

template<class A>
string to_string(stack<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.top());
  a.pop();
 }
 return to_string(res);
}

template<class A>
string to_string(queue<A> a) {
 vector<A> res;
 while(a.empty() == false) {
  res.push_back(a.front());
  a.pop();
 }
 return to_string(res);
}

vector<string> __vector_tuple;
template<int index, class... A>
struct print_tuple {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<index>(a)));
  print_tuple<index-1, A...>{}(a);
 }
};

template<class... A>
struct print_tuple<0, A...> {
 auto operator() (tuple<A...> a) {
  __vector_tuple.push_back(to_string(get<0>(a)));
 }
};

template<class... T>
string to_string(tuple<T...> a) {
 const int ttsz = tuple_size<decltype(a)>::value;
 print_tuple<ttsz-1, T...>{}(a);
 string __ss = to_string(__vector_tuple);
 __vector_tuple.clear();
 return __ss;
}

void debug() {cerr << "]\n";}

template<class H, class... T>
void debug(H head, T... tail) {
 cerr << to_string(head) << " ";
 debug(tail...);
}

#ifdef LOCAL
 #define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else 
 #define debug(...) 
#endif

typedef long long int ll;

int main()
{
 vector<string> a = {"AC", "WA", "TLE", "RE"};
 map<string, int> mp;
 for(auto i: a) mp[i] = 0;
 int n;
 cin >> n;
 while(n--) {
  string s;
  cin >> s;
  mp[s]++;
 }
 for(auto i: a) {
  cout << i << " x " << mp[i] << '\n';
 }
 return 0;
}


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

struct nodata {
    long long x;
    int origin;
};

bool cmp(const nodata &a, const nodata &b) {
    return a.x < b.x;
}

int main() {
    cin >> n;
    vector<nodata> X;
    for(int i = 0; i < n; ++i) {
        nodata indat;
        cin >> indat.x;
        indat.origin = i;
        X.push_back(indat);
    }

    sort(X.begin(), X.end(), cmp);
    vector<long long> b(n, 0);

    for(int i = 0; i < n; ++i) {
        if(i < n/2) {
            b.at(X.at(i).origin) = X.at(n/2).x;
        }else {
            b.at(X.at(i).origin) = X.at(n/2 -1).x;
        }
    }

    for(int i = 0; i < n; ++i) {
        cout << b.at(i) << endl;
    }
}

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


int main()
{
    ll r,D,x2;
    cin>>r>>D>>x2;
    ll cnt=10;
      ll t=x2;
    while(cnt--)
    {
       t = r*t - D;
       cout<<t<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
typedef long double ld;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define endl '\n'
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mxe max_element
#define mne min_element
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int,int>
#define size(a)  (int)(a.size())
#define fill(s,x,n) vector
 x(n); rep(i,0,n) cin>>x[i];
#define mod 1e9+7
#define inf 1e9+5
void solve(){
   int n,w;
   cin>>n>>w;
   vi price(n),cost(n);
   int  sum=0;
   rep(i,0,n){
   	cin>>cost[i]>>price[i];
   	sum+=price[i];
   }
   int ans=0;
   vector<vi> dp(n+1, vi(sum+1,inf));
   dp[0][0]=0;
   rep(i,1,n+1){
   	  rep(j,0,sum+1){
   	  	dp[i][j] = dp[i-1][j];
   	  	if(j>=price[i-1]){
   	  		dp[i][j] = min({dp[i][j],dp[i-1][j-price[i-1]]+cost[i-1]});
   	  		if(dp[i][j]<=w){
   	  			ans=max(ans,j);
   	  		}
   	  	}
   	  }
   }
   cout<<ans;
 }
 

signed main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);  
    #endif
    */
	int test;
	//cin>>test;
	test=1;
	while(test--){
         solve();
         cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 80256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//222
	int n,tot;
	cin>>n>>tot;
	int mi = INT_MAX;
	int cnt = 0;
	while(n--) {
		int val;
		cin>>val;
		tot-=val;
		cnt++;
		mi=min(mi,val);
	}
	cnt+=tot/mi;
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main(){
    int N;
    string s;
    cin >> N >> s;
    int cntr = 0, cntb = 0;
    for(int i=0; i<N; i++){
        if(s[i]=='R') cntr++;
        else cntb++;
    }

    if(cntr>cntb) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n, *a_l= map(int, open(0).read().split())
lovedBy = [[] for _ in range(n)]
for i, a in enumerate(a_l):
    lovedBy[a-1].append(i)
cnt = 0
for i, a in enumerate(a_l):
    if a-1 in lovedBy[i]:
        cnt += 1
print(cnt//2)

Measured memory_bytes: 21940
#include <cstdio>
const double g = 9.8;
double pow (double d) {return d * d;}
double y (double d) {return 4.9 * pow(d);}

int main(int argc, char *argv[]) {
	float rcv;
	while (EOF != fscanf(stdin, "%f", &rcv)) {
		double tmp = rcv / g;
		//printf("%f\n", y(tmp));
		for (int i = 2;; i++) {
			if (y(tmp) < static_cast<double>(i * 5 - 5)) {
				printf("%d\n", i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

N = i_i()

for i in range(0, 10):
    for j in range(0, 10):
        if i * j == N:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

#define MAX_N 8

int main() {
    int N, x[MAX_N], y[MAX_N];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    int order[MAX_N];
    for (int i = 0; i < N; ++i) {
        order[i] = i;
    }

    double total_dist = 0;
    int num_of_orders = 0;
    do {
        num_of_orders++;
        double temp_dist = 0;
        for (int i = 1; i < N; i++) {
            int dx = x[order[i]] - x[order[i-1]];
            int dy = y[order[i]] - y[order[i-1]];
            temp_dist += sqrt(dx * dx + dy * dy);
        }
        total_dist += temp_dist;
    } while (next_permutation(order, order + N));
    double ave_dist = total_dist / num_of_orders;
    printf("%.6f\n", ave_dist);
    return 0;
}

Measured memory_bytes: 256
def main():
    number = int(raw_input())
    list = map(int, raw_input().split())
    sort(number, list)

def sort(number, list):
    output(list)
    for i in range(1, number):
        key = list[i]
        j = i - 1
        while j >= 0 and list[j] > key:
            list[j+1] = list[j]
            j -= 1
        list[j+1] = key
        output(list)

def output(list):
    print(" ".join(map(str, list)))

main()

Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <sstream>
#include <string>
#include <utility>
#include <map>
#include <memory>
#include <set>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>

using namespace std;

class LinearSearch
{
public:
  int solve( int n, int s[], int q, int t[] );
  bool search( int x, int n, int a[] );
};

bool LinearSearch::search( int x, int n, int a[] )
{
  for ( int i = 0; i < n; i++ )
    {
      if ( x == a[i] )
        return true;
    }
      
  return false;
}

int LinearSearch::solve( int n, int s[], int q, int t[] )
{
  int cnt = 0;

  for ( int i = 0; i < q; i++ )
    {
      if ( search( t[i], n, s ) )
        cnt++;
    }
  return cnt;
}

int main( void )
{
  int n, s[10000], q, t[500];

  cin >> n;

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

  for ( int i = 0; i < q; i++ )
    cin >> t[i];
  
  LinearSearch ls;

  cout << ls.solve(n, s, q, t) << endl;
  
  return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define lint long long int
using namespace std;
lint num_1=0;
lint num_2=0;
void max_dp(vector<lint> v,int n)
{
	vector<lint> dp(n+1);
	vector<lint> dp_2(n+1);
	dp[1]=v[0];
	for(int i=2;i<=n;++i)
	{
		dp[i]=max(dp[i-1],v[i-1]);
	}
	num_1=dp[n];
	for(int i=0;i<n;++i)
	{
		if(num_1==v[i])
		{
			v[i]=0;
			break;
		}
	}
	dp_2[1]=v[0];
	for(int i=2;i<=n;++i)
	{
		dp_2[i]=max(dp_2[i-1],v[i-1]);
	}
	num_2=dp_2[n];
}
int main()
{
	lint n=0;
	cin>>n;
	vector<lint> v(n);
	for(int i=0;i<n;++i)
	{
		cin>>v[i];
	}
	max_dp(v,n);
	for(int i=0;i<n;++i)
	{
		if(num_1==v[i])
		{
			cout<<num_2<<endl;
		}
		else
		{
			cout<<num_1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6528
def cum(n):
  cum = 0
  for i in range(n+1):
    cum += i
  return cum


s = input()

tmp = s[0]
count = 0
l = []

for each in s:
  if each == tmp:
    count += 1
  else:
    l.append(count)
    count = 1
    tmp = each

l.append(count)

ans = 0
if s[0] == "<":
  for i in range(0,len(l),2):
    tmp = l[i:i+2]
    if len(tmp) == 1:
      ans += cum(tmp[0])
    else:
      ans += cum(max(tmp)) + cum(min(tmp)-1)
else:
  ans += cum(l[0])
  for i in range(1, len(l),2):
    tmp = l[i:i+2]
    if len(tmp) == 1:
      ans += cum(tmp[0])
    else:
      ans += cum(max(tmp)) + cum(min(tmp)-1)

print(ans)

Measured memory_bytes: 6300
#include <iostream>

using namespace std;

int main()
{
    int a, b, k, min, ans[100], j = 0;
    cin >> a >> b >> k;
    if (a > b) min = b;
    else min = a;
    for (int i = 1; i <= min; i++)
    {
        if (a % i == 0 && b % i == 0)
        {
            ans[j] = i;
            j++;
        }
    }
    cout << ans[j - k] << endl;
    return (0);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,x,y,z;
	long n;
	long ans;
	String[] S;

	Main(){
		n = sc.nextLong();
		for(long i=1;i<n;i++){
			ans += i;
		}

		// 出力
		System.out.println(ans);
	}

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

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	static int n,W;
	static long memo[][];
	static final int uncalc = -1;
	static ArrayList<Integer> w ,v;
	static long dp (int i,int remW){
		if(i==n)return 0;
		if(memo[i][remW]!=uncalc)
			return memo[i][remW];
		long leave = dp(i+1,remW);
		long take = 0;
		if(remW>=w.get(i)) take = dp(i+1,remW-w.get(i))+v.get(i);
		memo[i][remW]=Math.max(take, leave);
		return memo[i][remW];
	}
	public static void main(String[] args) throws IOException {
		BufferedReader axa = new BufferedReader(new InputStreamReader(System.in));
		String[] x = axa.readLine().split(" ");
		n = Integer.parseInt(x[0]);
		W = Integer.parseInt(x[1]);
		v = new ArrayList<>();
		w = new ArrayList<>();
		memo = new long [n][W+1];
		for(long [] a : memo)
			Arrays.fill(a, -1);
		for (int i = 0; i < n; i++) {
			String[] tem = axa.readLine().split(" ");
			v.add(Integer.parseInt(tem[1]));
			w.add(Integer.parseInt(tem[0]));
		}
		System.out.println(dp(0,W));
		
	}

}


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

int gcd_func(int a, int b){
    return b? gcd_func(b, a%b) : a;
} 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    string s, t; cin >> s;
    cin >> t;
    int ns = 0;
    for(int i = 0; i<s.length(); i++){
        if(s[i]!=t[i])
            ns++;
    }
    cout << ns;
    return 0;
}

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

bool f(int n){
    string s = to_string(n);
    rep(i,s.size()){
        if(s[i]!=s[s.size()-i-1]) return false;
    }
    
    return true;
}

int main(){
    int a,b;
    cin>>a>>b;
    int ans = 0;
    for(int i=a;i<=b;i++){
        if(f(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int a[4];
  int b[4];

  int hit,blow;

  int i,j;
  char c;

  while(1) { 
   
    if(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])==EOF || scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3])==EOF) break;

    //fflush(stdin);
    hit=blow=0;
    
    for(i=0;i<4;i++) {
       
      for(j=0;j<4;j++) {

	if(a[i]==b[j]) {

	  if(i==j) hit++;
	  else blow++;

	}
	  
      }

    }

  printf("%d %d\n",hit,blow);

  }

  return 0;

}

Measured memory_bytes: 0
#include <algorithm>
#include <functional>
#include <iostream>
#include <cfenv>
#include <cmath>
using namespace std;

int main(){
    int N,H;
    cin >> N >> H;
    int a[N],b[N];
    int cnt=0;
    for(int i=0;i<N;i++){
        scanf("%d", &a[i]);
        scanf("%d", &b[i]);
    }
    sort(a,a+N,greater<>());
    sort(b,b+N,greater<>());
    for(int i=0;i<N;i++){
        if(a[0]<b[i]){
            H-=b[i];
            cnt++;
            if(H<=0){
                cout << cnt << endl;
                return 0;
            }
        }
    }
    cout << (int)ceil((double)H/a[0])+cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
	int a, b, c;
	int n;
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> a >> b >> c;

		if(c * c == a * a + b * b || a * a == b * b + c * c || b * b == a * a + c * c){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("");

        List<String> result = new ArrayList<>();
        for (String key : s) {
            if ("B".equals(key)) {
                if (!result.isEmpty()) {
                    result.remove(result.size() - 1);
                }
            } else {
                result.add(key);
            }
        }

        System.out.println(String.join("", result));
    }
}


Measured memory_bytes: 22740