akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

typedef long long ll;
typedef pair<ll, ll> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const ll LINF = (ll)1 << 60;
const int MOD = 1e9 + 7;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;

    if (A > B) swap(A, B);

    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        ll res = N - A; // 右端
        res = min(res, B - 1); // 左端
        res = min(res, (N - B + 1) + (B - A - 1) / 2);
        res = min(res, A + (B - A - 1) / 2);
        cout << res << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x)).ToArray();
        var n = l[0]; var x = l[1];
        var al = Console.ReadLine().Split(' ')
            .Select(x => long.Parse(x))
            .OrderBy(x => x).ToArray();
        var ans = 0;
        for (var i = 0; n > i; i++)
        {
            if (x >= al[i])
            {
                x -= al[i];
                ans++;
            }
        }
        if (x > 0 && ans == al.Length)
        {
            ans--;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 28392
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int mx(int n){
    string s = to_string(n);
    int m = s.size();
    string t,u;
    int ret = 0;
    REP(i,1,m){
        t = s.substr(0,i);
        u = s.substr(i);
        chmax(ret, stoi(t)*stoi(u));
    }
    return ret;
}

int main(){
    int q; cin >> q;
    while(q--){
        int n; cin >> n;
        int ans = 0;
        while(n >= 10){
            ans++;
            ll t = mx(n);
            n = t;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
const long long int m=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unsigned long long int x,y,ans=1,c=0;
    cin>>x>>y;
    ans=x;
    while(ans<=y)
    {
        ans*=2;
        c++;
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int a,b,c;
	int e=0, f=0;

	cin>>a>>b>>c;


	e=a;
	f=b+c;
	if(e<b){
		e=b;
		f=a+c;
	}
	if(e<c){
		e=c;
		f=a+b;
	}

	cout<<e*10+f<<endl;





	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int x;cin>>x;
    int tmp=x/100;int tmp2=x-tmp*100;
    if(tmp*5>=tmp2)cout<<1<<endl;
    else cout<<0<<endl;
}


Measured memory_bytes: 3620
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf // clear structures
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define N 500050
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int asc[N],des[N];

int main(){

	string cad;
	cin >> cad;
	int n = sz(cad);
	fill(asc,0);
	fill(des,0);
	for(int i = n-1; i >= 0; --i){
		if(cad[i] == '<') asc[i] = asc[i+1]+1;
		else des[i] = des[i+1]+1;
	}

	int x = des[0];
	ll ans = x;
	for(int i = 0; i < n; ++i){
		if(cad[i] == '<'){
			x = max(x+1,des[i+1]);
		}else{
			x = min(x-1,des[i]-1);
		}
		ans += x;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4740
#include <stdio.h>

int main() {
	int ans = 0, stat = 0;
	int N;
	scanf("%d\n", &N);
	char c;
	for (int i = 0; i < N; i++) {
		c = getchar();
		if (c == 'A') {
			stat = 1;
		} else if (c == 'A' + stat) {
			if (c == 'C') {
				ans++;
				stat = 0;
			} else {
				stat++;
			}
		} else {
			stat = 0;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[100010];
int main()
{
    int i, j, k;
    ll H, N;
    ll ans = 0;
    cin >> N;
    ll cnt = 1;
    while(N) {
        N /= 2;
        ans += cnt;
        cnt += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repe(i, n) for(int i = 0; i <= (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#define elif else if
typedef long long ll;

int main(){
  int N,K;
  int MAX = pow(10,5);
  cin>>N>>K;
  ll h[MAX];
  rep(i,N){
    cin>>h[i];
  }
  sort(h,h+N,greater<ll>());
  int ans = h[0]-h[K-1];
  rep(i,N-K+1){
    if(h[i]-h[i+K-1]<ans)ans = h[i]-h[i+K-1];
  }

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


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

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 2000
 
int solve(int,int);
   
int A[N],M[N];
int n;
 
int main(void){
   
  int i,q;
   
  scanf("%d",&n);
  for( i=0 ; i<n ; i++ ){
    scanf("%d",&A[i]);
  }
   
  scanf("%d",&q);
  for( i=0 ; i<q ; i++ ){
    scanf("%d",&M[i]);
  }
 
  for( i=0 ; i<q ; i++ ){
    if((solve(0,M[i])) == 1) printf("yes\n");
    else printf("no\n");
  }
 
  return 0;
}
 

int solve(int i,int x){
 
  if(x == A[i])
    return 1;
 
  if(i+1 >= n)
    return 0;
 
  if(solve(i + 1, x) || solve(i + 1, x - A[i]) == 1)
  return 1;
 
  return 0;
 
}

Measured memory_bytes: 584
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
#def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

    
def fun(A,n,m):
    dp = list2d(n,m,0)
    for i in range(1,n): #initialising reachable first row
        if A[i][0]== '.':
            dp[i][0] = 1
        else:
            break
    for j in range(1,m): #initialising reachable first column
        if A[0][j] == '.':
            dp[0][j] = 1
        else:
            break
    dp[0][0] = 1
    for i in range(1,n):
        for j in range(1,m):
            if A[i][j] == "#":
                dp[i][j] = 0
                continue
            if A[i-1][j] == '.':
                dp[i][j] += dp[i-1][j]
                dp[i][j] %= MOD
            if A[i][j-1] == '.':
                dp[i][j] += dp[i][j-1]
                dp[i][j] %= MOD
    return int(dp[n-1][m-1])
        
H,W = ilele()
A = []
for i in range(H):
    B = [*input()]
    A.append(B.copy())
print(fun(A,H,W))

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

int main() {
	int m,min,max,ten[200],gap=10001,sa;
	
	cin>>m>>min>>max;
	
	while(1){
		if(m==0 && min==0 && max==0){
			break;
		}
	    for(int i=1;i<=m;i++){
    		cin>>ten[i];
    	}
    	for(int i=min;i<=max;i++){
    		if(gap>=ten[i+1]-ten[i]){
	    		gap=ten[i+1]-ten[i];
    			sa=i;
	    	}
	    }
    	cout<<sa<<endl;
    	gap=10001;
    	sa=0;
	    cin>>m>>min>>max;
	}

	
	return 0;
}

Measured memory_bytes: 3052
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
p=*0...gets.to_i;s=0;
f=->a{a==p[a]?a: p[a]=f[p[a]]}
a,b=$<.map{|s|s.split.map &:to_i}.transpose.map{|a|a.map.with_index.sort.each_cons(2).map{|(x,i),(y,j)|[y-x,i,j]}};
(a+b).sort_by{|a|a[0]}.map{|c,a,b|(s+=c;p[p[b]]=p[a])if f[a]!=f[b]}
p s

Measured memory_bytes: 94528
fun main(args: Array<String>) = abc155c()
// region
private inline fun printAnswer(function: StringBuilder.() -> StringBuilder) = print(StringBuilder().let(function))

private fun StringBuilder.println(message: Any?) = appendln(message)
private fun StringBuilder.print(message: Any?) = append(message)
// endregion
fun abc155c() = printAnswer {
    val n = readLine()!!.toInt()
    val list = (1..n).map { readLine()!! }

    val map = list.groupBy { it }.map { it.key to it.value.size }
    val max = map.maxBy { it.second }!!.second

    val answer = map.filter { it.second == max }.map { it.first }.sorted().toTypedArray()

    for (a in answer) println(a)

    return@printAnswer this
}


Measured memory_bytes: 111820
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const long long INF =1ll<<60;
const int DAM =-1;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int> dp(N+2,0);
  vector<int> broken(N+1,0);
  for(int i=0;i<M;i++){
    int a;
    cin>>a;
    broken.at(a)=1;
  }
  dp.at(0)=1;
  if (broken.at(1))
    dp.at(1) = 0;
  else
    dp.at(1) = 1;
  for(int i=2;i<=N;i++){
    if(broken.at(i)!=1){
      dp.at(i)=(dp.at(i-2)+dp.at(i-1))%mod;

    }
  }
  cout<<dp.at(N)<<endl;
    
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
 
int main() {
    long a, b, k, idx = 0;
    cin >> a >> b >> k;

    long c = min(a + k - 1, b);
 
    for(int i = a; i <= c; i++)
        cout << i << endl;
 
    if(c == b)
        return 0;
 
    long d = max(c + 1, b - (k - 1));
    for(int i = d; i <= b; i++)
        cout << i << endl;
}

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

using namespace std;
const int N=2e5+5;
int a[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<(int)s.size();i++)
    {
        int cnt=0;
        while(i<(int)s.size()&&s[i]=='R')
        {
            i++;
            cnt++;
        }
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3664
def main():
    s = input()
    if 1 <= int(s[:2]) <= 12 and 1 <= int(s[2:4]) <= 12:
        print('AMBIGUOUS')
    elif 1 <= int(s[:2]) <= 12 and 0 <= int(s[2:4]) <= 99:
        print('MMYY')
    elif 0 <= int(s[:2]) <= 99 and 1 <= int(s[2:4]) <= 12:
        print('YYMM')
    else:
        print('NA')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
import sys
N = int(input())
s = [int(input()) for _ in range(N)]
S = sum(s)
if S % 10 != 0:
    print(S)
    sys.exit()
M = 0
for si in s:
    T = S - si
    if T % 10 != 0:
        M = max(M, T)
print(M)

Measured memory_bytes: 9184
n = int(input())
c = 0
for i in range(1,n + 1):
    if i < 10:
        c += 1
        continue
    elif 100 <= i and i < 1000:
        c += 1
        continue
    elif 10000 <= i and i< 100000:
        c += 1
        continue
print(c)


Measured memory_bytes: 2940
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,c = map(int,input().split())
    xv = [list(map(int,input().split())) for i in range(n)]
    x = [xv[i][0] for i in range(n)]
    v = [xv[i][1] for i in range(n)]
    r1,r2,l1,l2 = [0]*(n+1),[0]*(n+1),[0]*(n+1),[0]*(n+1)
    ans = 0
    dis = 0
    for i in range(n):
        r1[i+1] = r1[i]+v[i]-(x[i]-dis)
        r2[i+1] = r2[i]+v[i]-2*(x[i]-dis)
        dis = x[i]
    dis = c
    for i in reversed(range(n)):
        l1[n-i] = l1[n-i-1]+v[i]-(dis-x[i])
        l2[n-i] = l2[n-i-1]+v[i]-2*(dis-x[i])
        dis = x[i]
    for i in range(n):
        l1[i+1] = max(l1[i+1],l1[i])
        r1[i+1] = max(r1[i+1],r1[i])
    for i in range(n+1):
        subans = max(r2[i]+l1[n-i],l2[i]+r1[n-i])
        ans = max(ans,subans)
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 49732
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n,x,t;
	cin>>n>>x>>t;
	if(n%x==0)cout<<(n/x)*t<<endl;
	else cout<<(n/x+1)*t<<endl;
	return 0;
}

/*always remember:
1.list all the things you know and find the breakthrough
*/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())
int H, W;
string S[1000];
vvi cnt(1000,vi(1000,-1));

void bfs(int h,int w) {
  queue<tuple<int,int,int>> q1,q2;
  q1.push({h,w,0});
  q2.push({h,w,0});
  while (1) {
    while (!q1.empty()) {
      auto t = q1.front();
      int x = get<0>(t), y = get<1>(t), c = get<2>(t);
      q1.pop();
      if (cnt[x][y] >= 0) {
        continue;
      }
      cnt[x][y] = c;
      if (x > 0 && S[x - 1][y] == '.')
        q1.push({x - 1, y, c});
      if (x < H-1 && S[x + 1][y] == '.')
        q1.push({x + 1, y, c});
      if (y > 0 && S[x][y - 1] == '.')
        q1.push({x, y - 1, c});
      if (y < W-1 && S[x][y + 1] == '.')
        q1.push({x, y + 1, c});
      reps(i,max(x-2,0), min(x+3,H)) {
        reps(j,max(y-2,0),min(y+3,W)) {
          if (S[i][j] == '.' && cnt[i][j] == -1) {
            q2.push({i,j,c+1});
            cnt[i][j]--;
          }
        }
      }
    }
    while (!q2.empty()) {
      auto t = q2.front();
      int x = get<0>(t), y = get<1>(t), c = get<2>(t);
      q2.pop();
      if (cnt[x][y]>=0)
        continue;
      q1.push({x,y,c});
    }
    if (q1.empty())
      break;
  }
}

int main() {
  cin >> H >> W;
  int Ch, Cw, Dh, Dw;
  cin >> Ch >> Cw >> Dh >> Dw;
  Ch--; Cw--; Dh--; Dw--;
  rep(i,H) cin >> S[i];
  bfs(Ch,Cw);
  print((cnt[Dh][Dw]<0)?-1:cnt[Dh][Dw]);
  return 0;
}

Measured memory_bytes: 9576
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val N, M, X = sc.nextInt
  val CA = Array.fill(N, M + 1)(sc.nextInt)
  val C = CA.map(_.head)
  val A = CA.map(_.tail)

  val a = (0 until N).foldLeft(Set(Set.empty[Int])) {
    (set, element) => set union (set map (_ + element))
  }
  val b = a.map(_.toSeq).filter(xs => {
    xs.map(A(_)).foldLeft(Array.fill(M)(0))((x, y) => {
      (x zip y).map { case (x, y) => x + y }
    }).forall(_ >= X)
  })
  val c = b.map(_.map(C(_)).sum)
  val x = if (c.isEmpty) -1 else c.min
  println(x)
}


Measured memory_bytes: 70952
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type NumCount struct {
	number int
	count int
}

type NumCounts []NumCount

func (nc NumCounts) Len() int {
	return len(nc)
}

func (nc NumCounts) Less(i, j int) bool {
	return nc[i].count < nc[j].count
}

func (nc NumCounts) Swap(i, j int) {
	nc[i], nc[j] = nc[j], nc[i]
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	bucket := map[int]int{}
	var ncs []NumCount

	for i := 0; i < N; i++ {
		bucket[nextInt()]++
	}

	for num, c := range bucket {
		ncs = append(ncs, NumCount{num, c})
	}

	sort.Sort(NumCounts(ncs))

	c := 0
	for i := 0; i < len(ncs); i++ {
		min := ncs[i].count
		if ncs[i].count - ncs[i].number >= 0 && min > ncs[i].count - ncs[i].number {
			min = ncs[i].count - ncs[i].number
		}

		c += min
	}

	fmt.Println(c)
}


Measured memory_bytes: 12288
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
int main() {
	int n;
	cin >> n;
	vector<int>p(n, 0);
	rep(i, n)cin >> p[i];
	int ans = 0;
	int con = 0;
	rep(i, n) {
		if (p[i] == i + 1) {
			con++;
		}
		else {
			ans += (int)ceil((double)con / 2);
			con = 0;
		}
	}
	ans += (int)ceil((double)con / 2);
	cout << ans;
	return 0;
}





Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int i,h[22],m[59],s[59],h2[22],m2[59],s2[59],t[10000],t2[10000],a[10000];
	int h3[22],m3[59],s3[59];
	for(i=0;i<3;i++){
		scanf("%d %d %d %d %d %d",&h[i],&m[i],&s[i],&h2[i],&m2[i],&s2[i]);
	}
	for(i=0;i<3;i++){
		t[i]=(h[i]*3600)+(m[i]*60)+s[i];
		t2[i]=(h2[i]*3600)+(m2[i]*60)+s2[i];
		a[i]=t2[i]-t[i];
		h3[i]=a[i]/3600;
		m3[i]=(a[i]%3600)/60;
		s3[i]=(a[i]%3600)%60;
	}
	for(i=0;i<3;i++){
		printf("%d %d %d\n",h3[i],m3[i],s3[i]);
	}
	return 0;
}


Measured memory_bytes: 2712
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
d = (-1, 0), (1, 0), (0, -1), (0, 1)
p = [(i, j) for i in range(h) for j in range(w) if a[i][j] == '#']

def f():
    s = []
    for i, j in p:
        for di, dj in d:
            di += i
            dj += j
            if 0 <= di < h and 0 <= dj < w and a[di][dj] == '.':
                a[di][dj] = '#'
                s.append((di, dj))
    return s

n = h * w - len(p)
r = 0
while n:
    r += 1
    p = f()
    n -= len(p)
print(r)


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

int main(){
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for(int i=0; i<S.length(); i++){
        if(S[i] != T[i]){
            ans += 1;
        }
    }
    cout << ans << endl;
    return 0;

}

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

using namespace std;

int main()
{
	int n, d, x;
	cin >> n >> d >> x;
	int choco = 0;
	
	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a.at(i);
	}

	for (int i = 0; i < n; i++)
	{
		int j = 0;
		while (j * a.at(i) + 1 <= d)
		{
			choco++;
			j++;
		}
	}
	choco += x;

	cout << choco << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=1; i<=ll(sqrt(N))+1; i++){//Mの候補
        if(N/i==N%i) ans+=i;
    }
    for(ll i=1; i<=sqrt(N)-1; i++){//あまりの候補
        if((N-i)%i==0){
            ans+=(N-i)/i;
        }
    }
    cout << ans;

    return 0;
}

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

int main(void){
    int short_hand, long_hand, hour, minute;
    scanf("%d %d %d %d", &short_hand, &long_hand, &hour, &minute);

    double short_angle, long_angle;
    short_angle = 2 * M_PI * ( hour + minute / 60.0) / 12 ;
    long_angle = 2 * M_PI * minute / 60.0;

    double angle;
    angle = fabs(short_angle - long_angle);

    double ans;
    ans = sqrt(pow(long_hand, 2) + pow(short_hand, 2) 
          - 2 * long_hand * short_hand * cos(angle));

    printf("%.20lf", ans);
}

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

using namespace std;

int main()
{
    int A, B;
    int c =0;
    int d = 0;
    cin >> A;
    cin >> B;
    int str[] = {2,3,4,5,6,7,8,9,10,11,12,13,1};
    int s = sizeof(str)/sizeof(int);

    for(int i=0; i<s; i++)
    {
        if(str[i] == A)
            c = i;

    }

    for(int j= 0; j<s; j++)
    {
        if(str[j] == B)
            d = j;
    }

    if(c>d)
    {
        cout << "Alice" <<endl;
    }
    else if(d>c)
    {
        cout<< "Bob" <<endl;
    }
    else if(c ==d)
    {
        cout <<"Draw" <<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100005
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;

int main() {
    ll N, i, j, k;
    ll F[100][10], P[100][11];
    cin >> N;
    for(i=0; i<N; i++) {
        for(j=0; j<10; j++) {
            cin >> F[i][j];
        }
    }
    for(i=0; i<N; i++) {
        for(j=0; j<11; j++) {
            cin >> P[i][j];
        }
    }
    
    ll ans=(-1)*INF, tmp;
    for(i=1; i<1<<10; i++) {
        ll cnt[100]={0};
        tmp=0;
        for(j=0; j<10; j++) {
            if(1&i>>j) {
                for(k=0; k<N; k++) {
                    if(F[k][j]) {
                        cnt[k]++;
                    }
                }
            }
        }
        
        for(k=0; k<N; k++) {
            tmp+=P[k][cnt[k]];
        }
        ans=max(ans, tmp);
    }
    
    cout << ans << endl;
}


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

int main(){
  int n;
  cin >> n;
  switch(n){
    case 22: 
      cout << "Christmas Eve Eve Eve";
      return 0;
    case 23: 
      cout << "Christmas Eve Eve";
      return 0;
    case 24: 
      cout << "Christmas Eve";
      return 0;
    case 25: 
      cout << "Christmas";
      return 0;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;
int modularExponentiation(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    //int arr[n];
    map<int,int> m;
    for(int i =0;i < n;i++){
        int no;
        cin>>no;
        m[no]++;
    }
    if(n%2==0){
        for(int i =1;i <n;i=i+2){
            auto it = m.find(i);
            if(it==m.end()){
                cout<<0<<endl;
                return 0;
            }
            else{
                if(it->second !=2){
                    cout<<0<<endl;
                    return 0;
                }
            }
        }
        cout<<modularExponentiation(2,n/2,mod)<<endl;



    }
    else{
        for(int i =0; i <n;i=i+2){
            auto it = m.find(i);
            if(it==m.end()){
                cout<<0<<endl;
                return 0;
            }
            else{
                if(i==0){
                    if(it->second !=1){
                    cout<<0<<endl;
                    return 0;
                    }
                }
                else{
                    if(it->second !=2){
                    cout<<0<<endl;
                    return 0;
                    }

                }


            }

        }
        cout<<modularExponentiation(2,n/2,mod)<<endl;

    }












}







Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
int n;
ll a[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    if(a[n]!=2){printf("-1\n");return 0;}
    ll l=2,r=3;
    for(int i=n-1;i>=1;i--)
    {
        ll ans=l/a[i]*a[i];
        if(ans<l) ans+=a[i];
        if(ans>r){printf("-1\n");return 0;}
        ll res=r/a[i]*a[i]+a[i]-1;
        l=ans;r=res;
    }
    printf("%lld %lld\n",l,r);
}


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

string S, T;
int dp[3005][3005];

void output(int i, int j) {
  if (i == 0 || j == 0) return;
  if (S[i-1] == T[j-1]) {
    output(i-1, j-1);
    cout << S[i-1];
  } else {
    if (dp[i][j-1] <= dp[i-1][j]) output(i-1, j);
    else output(i, j-1);
  }
}

int main() {
  cin >> S >> T;
  int N = S.size(), M = T.size();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (S[i] == T[j]) dp[i+1][j+1] = dp[i][j] + 1;
      else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
    }
  }
  output(N, M);
  cout << endl;
}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
const double pi=2*acos(0.0);
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // order_of_key // find_by_order()  

inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mod = 2e18;
const int maxn = 2e6+5;

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	int pt = n-1, st = 0; int ans = 0;
	while(st < pt){
		while(st < n && s[st] != 'W') st++;
		while(pt >= 0 && s[pt] != 'R') pt--;
		if(st >= pt) break; 
		swap(s[st], s[pt]); ++ans; --pt; ++st;
		//cout<<s<<"\n";
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);// io();
    cout<<setprecision(16);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
int main(){
    unsigned long long n;
    cin>>n;
    unsigned long long temp=n%11;
    if(temp==0)
        cout<<(n/11)*2;
    else{
        if(temp%2==0){
            if(temp<5||temp==6)
                cout<<(n/11)*2+1;
            else
                cout<<(n/11)*2+2;
        }
        else{
            if(temp<=5)
                cout<<(n/11)*2+1;
            else
                cout<<(n/11)*2+2;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}

#define PRINT_VECTOR_MAX 100
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)min(v.size(),PRINT_VECTOR_MAX); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)min(v.size(),PRINT_VECTOR_MAX); i++) {for (ll j = 0; j < (ll)min(v[i].size(),PRINT_VECTOR_MAX); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
	return 0;
}

void Main(){
    int n; cin >> n;
    int zoro = 0;
    Rep(n){
        int a,b; cin>>a>>b;
        if(a==b){
            zoro++;
            if(zoro >= 3){
                cout << "Yes\n";
                return;
            }
        }else{
            zoro = 0;
        }
    }
    cout << "No\n";
}

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


int main(){
    int N;
    cin >> N;
    vector<pair<pair<string, int>,int>> guide(N);
    for(int i=0; i<N; i++){
        int a;
        string b;
        cin >> b >> a;
        guide.at(i) = make_pair(make_pair(b,-a),i);
    }

    sort(guide.begin(), guide.end());
    for(int i=0; i<N; i++){
        int l;
        for(int j=0; j<N; j++){
            tie(ignore, l) = guide.at(j);
            if(j==i)break;
        }
        cout <<  l+1 << endl;
    }
}

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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> x(m);
  for (int i=0; i<m; i++){
    cin >> x[i];
  }
  
  sort(x.begin(), x.end());
  
  vector<int> x2(m-1);
  for (int i=0; i<x.size()-1; i++){
    x2[i] = x[i+1] - x[i];
  }
 
  sort(x2.begin(), x2.end());
  
  
  int sum=0;
  for (int i=0; i<m-n; i++){
    sum += x2[i];
  }
  
  cout << sum << endl;
   
}
  

Measured memory_bytes: 1024
#include <stdio.h>
#define L 6
#define putlong_unlocked(X) \
    do{ \
        long n=X; \
        char c[L]; \
        long i=L-1; \
        do{ c[i]=n%10+'0'; n/=10; i--; }while(n>0); \
        for(i++;i<L;i++){ putchar_unlocked(c[i]); } \
    }while(0)
#define puts_unlocked(X) \
    do { \
        for(size_t i=0; X[i]!='\0'; i++){ \
            putchar_unlocked(X[i]); \
        } \
        putchar_unlocked('\n'); \
    }while(0)

static void solve(const long n, const long a, const long b, long mask, const long common){
    if(n==1){
        putlong_unlocked(common|a);
        putchar_unlocked(' ');
        putlong_unlocked(common|b);
        putchar_unlocked(' ');
    }else{
        const long t = a^b;
        const long d = t&(-t);
        mask ^= d;
        const long aa = a & mask;
        const long ab = aa ^ (mask&(-mask));
        solve(n-1, aa,     ab, mask, common|(a&d));
        solve(n-1, ab, b&mask, mask, common|(b&d));
    }
}

int main(void){
    long n, a, b;
    scanf("%ld %ld %ld", &n, &a, &b);
    if(__builtin_parity(a) == __builtin_parity(b)){
        puts_unlocked("NO");
    }else{
        puts_unlocked("YES");
        solve(n, a, b, 0xFFFFFFFFFFFFFFFF, 0);
    }
    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
typedef long long LL;
const int MAXN = 1e5 + 8;
 
string s;
int a[MAXN];
int main()
{
    #ifdef LOCAL
    //freopen("c.txt", "r", stdin);
    //freopen("c.out", "w", stdout);
    int T = 1;
    while(T--){
    #endif // LOCAL
    //ios::sync_with_stdio(false); cin.tie(0);
 
    LL n, i, l, r, mid;
    bool f;
    cin >> n;
    l = 0, r = n - 1;
 
    cout << l << "\n"; fflush(stdout);
    cin >> s;
    if(s[0] == 'M'){
        a[l] = 1;
    }
    else if(s[0] == 'F'){
        a[l] = 2;
    }
    else{
        a[l] = -1;
        return 0;
    }
 
    cout << r << "\n"; fflush(stdout);
    cin >> s;
    if(s[0] == 'M'){
        a[r] = 1;
    }
    else if(s[0] == 'F'){
        a[r] = 2;
    }
    else{
        a[r] = -1;
        return 0;
    }
 
    while(l + 1 < r){
        mid = (l+r)>>1;
        cout << mid << "\n"; fflush(stdout);
        cin >> s;
        if(s[0] == 'M'){
            a[mid] = 1;
        }
        else if(s[0] == 'F'){
            a[mid] = 2;
        }
        else{
            a[mid] = -1;
            return 0;
        }
 
        if((r - mid - 1)&1){
            if(a[mid] == a[r]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
        else{
            if(a[r] != a[mid]){
                r = mid;
            }
            else{
                l = mid;
            }
        }
    }
 
 
 
 
 
    #ifdef LOCAL
    cout << endl;
    }
    #endif // LOCAL
    return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cassert>
#include<cmath>
#define EPS 1e-10
using namespace std;

int m,n;
double dp[110][110];
int Just;
//vector<double> matrix[110];
double matrix[110][110];
double rec(int next,int counter){
  if(dp[next][counter] != -10)return dp[next][counter];
  if(counter  == 0){
    return 1.0;
  }
  double HANMA = 0.0,test=0.0;
  
  
  for(int i=0;i<n;i++){  
     
    //HANMA = max(HANMA,rec(i,counter-1)*matrix[next][i]);
    test = rec(i,counter-1)*matrix[next][i];
    if(test > HANMA)HANMA = test;
  } 
  
  dp[next][counter] = HANMA;
  return HANMA;
}
 
 
int main(){
   
  double In;
  
  while(cin >> n >> m && n && m){
    //for(int i=0;i<=n;i++)matrix[i].clear();
     
    for(int i=m;i>=0;i--)for(int j=0;j<n;j++)dp[j][i] = -10;
    for(int i=0;i<n;i++)dp[i][0] = dp[i][1] = 1;
  
  
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
    //cin >> matrix[i][j];
    scanf("%lf",&matrix[i][j]);
    //matrix[i].push_back(In);
      }
    }
  
 
    double ans = -1;
  
   
      for(int I=0;I<n;I++){
    Just = I;
    double tes = rec(I,m);
    ans = max(ans,dp[Just][m]);
      }
     
 
      //for(int i=1;i<=m;i++)cout << dp[0][i] << " ";
      //cout << endl;
 
    printf("%.2f\n",ans);
 
  }
  return 0;
}

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

int main(){
  int H,W,K;  cin >> H >> W >> K;
  vector<string>Table(H);
  int ans2 = 0;
  for(int i=0;i<H;i++){
    string s;
    cin >> s;
    Table.at(i) = s;
  }
  for (int bit = 0; bit < (1<<H); ++bit) {
        vector<int> SH;
        for (int i = 0; i < H; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                SH.push_back(i);
            }
        }

        for (int bit = 0; bit < (1<<W); ++bit) {
            vector<int> SW;
            int ans = 0;
            for (int j = 0; j < W; ++j) {
                if (bit & (1<<j)) { // 列挙に i が含まれるか
                    SW.push_back(j);
                  }
            }
            vector<vector<bool> >flag(H,vector<bool>(W,true));
            for(int i=0;i<SH.size();i++){
              for(int j=0;j<W;j++){
                flag.at(SH.at(i)).at(j) = false;
              }
            }
            for(int i=0;i<SW.size();i++){
              for(int j=0;j<H;j++){
                flag.at(j).at(SW.at(i)) = false;
              }
            }
            for(int i=0;i<H;i++){
              for(int j=0;j<W;j++){
                if(flag.at(i).at(j) == true && Table.at(i).at(j) == '#') ans++;
              }
            }
            if(ans == K)  ans2++;
        }
  }
  cout << ans2 << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<long long> x(N), y(N), z(N);
    repeat(i, N) cin >> x[i] >> y[i] >> z[i];

    vector<long long> xyz(N);
    long long res = numeric_limits<long long>::lowest();
    for (int S = 0; S < (1 << 3); ++S) {
        for (int i = 0; i < N; ++i) {
            xyz[i] = ((S & 1) ? x[i] : -x[i]) + ((S >> 1) & 1 ? y[i] : -y[i]) + ((S >> 2) & 1 ? z[i] : -z[i]);
        }
        sort(xyz.rbegin(), xyz.rend());
        long long tmp = 0;
        for (int i = 0; i < M; ++i) {
            tmp += xyz[i];
        }
        setmax(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys
import os
import itertools

def file_input():
    f = open('Beginner_Contest_162/input.txt', 'r')
    sys.stdin = f

def gcd(a,b):
    if b==0: return a
    else: return gcd(b,a%b)

def main():
    #file_input()
    K=int(input())
    # map(int, input().split())
    sum=0

    combi_l = itertools.combinations_with_replacement(range(1,K+1),3)
    # print(combi_l)

    for combi in combi_l:
        # print(combi)
        if combi[0]==combi[1]==combi[2]:
            sum+=gcd(gcd(combi[0],combi[1]),combi[2])
        elif combi[0]==combi[1] or combi[1]==combi[2] or combi[2]==combi[0]:
            sum+=3*gcd(gcd(combi[0],combi[1]),combi[2])
        else:
            sum+=6*gcd(gcd(combi[0],combi[1]),combi[2])

    # for a in range(1,K+1):
    #     for b in range(1,K+1):
    #         tmp=fractions.gcd(a,b)
    #         for c in range(1,K+1):
    #             sum+=fractions.gcd(tmp,c)

    print(sum)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
const int N = 1e5+87;
int a[N],M;
vector<pii> ans;
void g(int &x,int y)
{
    ans.emplace_back(x,y);
    x -= y;
    M = x;
}
int main()
{
    int n;
    cin >> n;
    int on = n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a,a+n);
    if (a[n] < 0) {
        for (int i = 0; i < n-1; ++i)
            g(a[n-1], a[i]);
    } else if (a[0] > 0) {
        for (int i = 1; i < n-1; ++i) {
            g(a[0],a[i]);
        }
        g(a[n-1],a[0]);
    } else {
        int mx = a[n-1];
        n -= 2;
        while (n > 0 && a[n] > 0) {
            g(a[0],a[n]);
            --n;
        }
        while (n >= 0) {
            g(mx,a[n]);
            --n;
        }
    }
    assert(ans.size() == on-1);
    cout << M << '\n';
    for (auto p : ans)
        cout << p.F << ' ' << p.S << '\n';
}


Measured memory_bytes: 3188
class Array
  def product(ary)
    temp = self.clone
    result = []
    ary.each do |v|
      if temp.include?(v)
        result << temp.delete_at(temp.index(v))
      end
    end
    result
  end
end
 
# greatest common divisor(最大公約数)
def gcd(i)
  gcd_div = self.prime_div2.product(i.prime_div2)
  gcg_div.inject {|memo, item| memo * item }
end
 
# least common multiple(最小公倍数)
def lcm(i)
  lcm_div = self.prime_div2 + i.prime_div2
  lcm_div = lcm_div - self.prime_div2.product(i.prime_div2)
  lcm_div.inject {|memo, item| memo * item }
end
 
# エラトステネスの篩いによる素数列の生成
def eratosthenes(n)
  list = Array.new(n - 1).map.with_index {|i, k| k + 2}
  result = [1]
  while list.last >= result.last**2
    p = list.shift
    result << p
    list.delete_if {|v| v % p == 0 }
  end
  result.shift
  result = result + list
end
 
# 素因数分解して[2, 2, 2, 3]の様に返す。
def prime_div
  k = self
  c = 0
  result = []
  eratosthenes(n/2).each do |i|
    c = 0
    if k % i == 0
      while k % i == 0
        k = k / i
        result << k
      end
    end
  end
  result
end
 
while line = gets
  imput = line.chomp.split.map(&:to_i)
  print imput[0].gcd(imput[1]), " ", imput[0].lcm(imput[1]), "\n"
end

Measured memory_bytes: 6140
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = 0;

        if(a<b && a<c){
            System.out.print(a+" ");
            if(b<c){
                System.out.println(b+" "+c);
            }else {
                System.out.println(c+" "+b);
            }
        }else if(b<c){
            System.out.print(b+" ");
            if(a<c){
                System.out.println(a+" "+c);
            }else {
                System.out.println(c+" "+a);
            }
        }else{
            System.out.print(c+" ");
            if(a<b){
                System.out.println(a+" "+b);
            }else {
                System.out.println(b+" "+a);
            }
        }
        
        sc.close();
    }
}


Measured memory_bytes: 26112
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var n = cin.nextInt();
            var a = cin.ArrayInt(n);

            var ans = 1;
            var min = a[0];
            for (int i = 1; i < n; i++)
            {
                if(a[i] < min )
                {
                    ans++;
                }
                min = Math.Min(min, a[i]);
            }
            
            Console.WriteLine(ans);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 33116
n, m = map(int, input().split())

dp = [0] * (n + 1)
 
for _ in range(m):
  a = int(input())
  dp[a] = -1
  

if dp[0] != -1:
  dp[0] = 1
if dp[1] != -1:
  dp[1] = 1

mod = 10 ** 9 + 7

for i in range(2, n + 1):
  if(dp[i] != -1):
    if(dp[i - 1] != -1):
      dp[i] += dp[i - 1]
    if(dp[i - 2] != -1):
      dp[i] += dp[i - 2]
    if(mod <= dp[i]):
      dp[i] -= mod

print(dp[n])


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

int main(int argc, char const *argv[]) {
    int a, b;
    cin >> a >> b;

    int ans = a - 2 * b;
    if (ans < 0) cout << 0 << endl;
    else cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a>=b && a>=c) {
        printf("%d", b+c);
    } else if (b>=c && b>=a) {
        printf("%d", c+a);
    } else if (c>=a && c>=b) {
        printf("%d", a+b);
    } 
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if(a > b) System.out.println("a > b");
        else if(a < b) System.out.println("a < b");
        else System.out.println("a == b");
        scan.close();
    }
}


Measured memory_bytes: 26220