akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The Value Of " << #val << " is : " << val << '\n';
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
ll n, a[20], maks=-1;
vector<vector<ll>>b(20), c(20);
	
int main(){
	IOS
	cin >> n;
	for(ll i=0;i<n;i++){
		cin >> a[i];
		for(ll j=0;j<a[i];j++){
			ll nomor, isi;
			cin >> nomor >> isi;
			nomor--;
			b[i].pb(nomor);
			c[i].pb(isi);
		}
	}
	for(ll mask=0;mask<(1<<n);mask++){
		bool ok=1;
		ll ans=0;
		for(ll i=0;i<n;i++){
			if(mask&(1<<i)){
				ans++;
				for(ll j=0;j<a[i];j++){
					if((mask&(1ll<<b[i][j]) && c[i][j])){
						continue;
					}
					else if((!(mask&(1ll<<b[i][j])) && !(c[i][j]))){
						 continue;
					}
					else{
						ok=0;
						break;
					}
				}
			}
		}
		if(ok){
			maks=max(maks, ans);
		}
	}
	cout << maks << '\n';
}


Measured memory_bytes: 3656
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
import java.lang

import scala.reflect.ClassTag

object Main {
  def get[T: ClassTag](implicit in: BufferedReader, converter: String => T): T = {
    converter(in.readLine)
  }

  def getArray[T: ClassTag](implicit in: BufferedReader, converter: String => T): Array[T] = {
    get[String].split("\\s+").map(converter)
  }

  implicit val intConverter: String => Int = s => Integer.parseInt(s)
  implicit val longConverter: String => Long = s => lang.Long.parseLong(s)

  def get[T1, T2](
                   implicit in: BufferedReader,
                   converter1: String => T1,
                   converter2: String => T2
                 ): (T1, T2) = {
    getArray[String] match {
      case Array(v1, v2) => (converter1(v1), converter2(v2))
    }
  }

  def get[T1, T2, T3](
                       implicit in: BufferedReader,
                       converter1: String => T1,
                       converter2: String => T2,
                       converter3: String => T3
                     ): (T1, T2, T3) = {
    getArray[String] match {
      case Array(v1, v2, v3) => (converter1(v1), converter2(v2), converter3(v3))
    }
  }

  implicit class TimesInt(val n: Int) {
    def times(f: Int => Unit): Unit = {
      for (i <- 0 until n) {
        f(i)
      }
    }
  }

  def main(args: Array[String]): Unit = {
    implicit val in: BufferedReader = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val (s, t) = get[String, String]
    val (a, b) = get[Int, Int]
    val u = get[String]

    out.println(
      if (s == u) {
        List(a - 1, b).mkString(" ")
      } else {
        List(a, b - 1).mkString(" ")
      }
    )

    out.flush()
  }
}

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

using namespace std;
#define ull unsigned long long
#define ll long long
const int inf = 1e9;
const int MAXN = 4e6+4;

vector<vector<int>> vect(3e5+1, vector<int>(0));
vector<bool> was(3e5+1, false);
vector<int> dp(3e5+1, 0);
vector<int> depth(3e5+1, 0);


void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c){
        cout<<"1";
    }
    else cout<<"0";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n=1;
    for(int i=0;i<n;i++) solve();
    return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main()
{
	long long N,C,K;
	cin >> N >> C >> K;
	vector<long long> t(N);
	for (long long i = 0;i < N;i++) {
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	int lim = t[0] + K;
	int bus = 1;int pas = 1;
	for (int i = 1;i < N;i++) {
		if (lim < t[i] || pas == C) {
			lim = t[i] + K;
			pas = 1;bus++;
		}
		else {
			pas++;
		}
	}

	cout << bus << endl;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	int ans; cin>>ans;
	for(int i=1;i<n;++i){
		int a; cin>>a;
		ans=__gcd(ans,a);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			while(sc.hasNext()) {
				String x = sc.nextLine();
				if(x.equals("0")) {
					break;
				}
				String strA ="";
				int Sum = 0;
				for(int i = 0; i < x.length(); i++) {
					strA = x.substring(i,i+1);
					Sum += Integer.parseInt(strA);
				}
				System.out.println(Sum);
			}
	}
}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'
#define PI 3.1415926535897932385
#define MOD 1000000007
typedef vector<ll> ve;




int main()
{ 
	ll n,m;
	cin>>n>>m;
	ll temp=0;
	for(ll i=0;i<m;i++)
	{   ll t;
		cin>>t;

      temp+=t;
    }	
    if(temp>n)
    {
    	cout<<"-1"<<endl;
    }
    else {
    	cout<<n-temp<<endl;
    }
 return 0;

}    
	 		
	    

Measured memory_bytes: 3624
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s,t;cin>>s>>t;
  int n = sz(s);
  int m = sz(t);

  map<char, vector<int>> pos;
  rep(i, n){
    pos[s[i]].pb(i);
  }
  dump(pos);

  int j = -1;
  int cnt = 0;
  rep(i, m){
    if (pos.find(t[i])==pos.end()){
      cout << -1 << endl;
      return 0;
    }

    auto it = ub(all(pos[t[i]]), j);
    if (it==pos[t[i]].end()) {
      cnt++;
      j = pos[t[i]][0];
    }
    else{
      j = *it;
    }

    dump(j, cnt);
  }

  cout << cnt*n + j + 1 << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 1736
// Problem - Vector and Matrix
import java.util.Scanner;

class Main {
  public static void main(String[] args){
    // config
    Scanner scanner = new Scanner(System.in);

    // input
    String[] nums = scanner.nextLine().split(" ");
    int n = Integer.parseInt(nums[0]);
    int m = Integer.parseInt(nums[1]);
    int[][] A = new int[n][m];
    int[] b = new int[m];
    for(int i=0; i<n; i++){ // A input
      String[] r = scanner.nextLine().split(" ");
      for(int j=0; j<m; j++){
        int tmp = Integer.parseInt(r[j]);
        A[i][j] = tmp;
      }
    }
    for(int i=0; i<m; i++){ // b input
      String r = scanner.nextLine();
      b[i] = Integer.parseInt(r);
    }

    // matrix calc
    int[] answer = new int[n];
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
        answer[i] += A[i][j] * b[j];
      }
    }

    // output ( b : n * 1)
    for(int i=0; i<n; i++){
      System.out.println(answer[i]);
    }

  }
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int k; cin >> k;
    bitset<18> T(0);
    
    for(ll i=0; i<pow(2,n); i++){
        if(i == 0){
            //printf("0:\n");
            continue;
        }else{
            bitset<18> A(i);
            int match = 0;
            rep(j,18){
                if(A.test(j)) match++;
            }
            if(match == k){
                printf("%ld:", i);
                rep(j,18){
                    if(A.test(j)) printf(" %d", j);
                }
                cout << endl;
            }
        }
    }
}


Measured memory_bytes: 3348
MODE = "stdio"

line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  47
  S 10
  S 11
  S 12
  S 13
  H 1
  H 2
  S 6
  S 7
  S 8
  S 9
  H 6
  H 8
  H 9
  H 10
  H 11
  H 4
  H 5
  S 2
  S 3
  S 4
  S 5
  H 12
  H 13
  C 1
  C 2
  D 1
  D 2
  D 3
  D 4
  D 5
  D 6
  D 7
  C 3
  C 4
  C 5
  C 6
  C 7
  C 8
  C 9
  C 10
  C 11
  C 13
  D 9
  D 10
  D 11
  D 12
  D 13
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
n =  line[0].to_i

card = Hash.new
result = Hash.new
SUIT = ['S','H','C','D']

SUIT.each do |s|
  card[s]=[]
  result[s]=[*1..13]
end

(1..n).each do |m|
  mark,num = line[m].split(" ")
  card[mark] << num.to_i
end

SUIT.each do |s|
  result[s] = result[s]-card[s]
  result[s].each do |n|
    puts "#{s} #{n}"
  end
end

Measured memory_bytes: 8636
import sys
input = sys.stdin.readline
N, M = map(int, input().split())

g = [[] for _ in range(N+1)]
ig = [[] for _ in range(N+1)]
for _ in range(M):
    x, y = map(int, input().split())
    g[x].append(y)
    ig[y].append(x)

dp1 = [0] * (N+1)
dp2 = [0] * (N+1)
dp1[1] = 1
# dp1 : iまでの到達確率
# dp2 : iからゴールへの到達距離期待値

for i in range(1, N+1):
    for j in ig[i]:
        dp1[i] += dp1[j]/len(g[j])
df = 0
for i in range(N, 0, -1):
    t = 0
    for v in g[i]:
        t += (dp2[v]+1)
    if len(g[i]) > 0:
        dp2[i] = t/len(g[i])
    if len(g[i]) == 1:
        continue
    for v in g[i]:
        pv = (t-dp2[v]-1)/(len(g[i])-1)
        # pv : i→vへのpathを削除した時の到達距離期待値
        df = max(df, dp1[i]*(dp2[i]-pv))
        # dp1[i]*(dp2[i]-pv) : iからvを削除したときに1からvの到達距離期待値がどれだけ減るか
print(dp2[1]-df)


Measured memory_bytes: 64604
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

typedef long long ll;

using namespace std;

int main(){

    int x,t;
    cin >> x >> t;

    cout << max(0, x - t) << endl;

    

    return 0;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

string t="NWSE";

int main(){
   string s; cin>>s;
   int cnt[4]={};
   rep(i,0,s.size())cnt[t.find(s[i])]++;
   rep(i,0,2){
      if(cnt[i]==0&&cnt[i+2]!=0){
         puts("No"); return 0;
      }
      if(cnt[i]!=0&&cnt[i+2]==0){
         puts("No"); return 0;
      }
   } puts("Yes");
   return 0;
}

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

int32_t main() {
    int x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    int val = x / d;
    if (d > x) {
        if (k & 1) {
            cout << min(abs(x - d), abs(x + d)) << endl;
        } else {
            cout << x << endl;
        }
    } else {
        if (k < val) {
            cout << x - k * d << endl;
        } else if (val == k) {
            cout << abs(x - val * d) << endl;
        } else {
            k -= val;
            if (k & 1) {
                cout << abs(x - val * d - d) << endl;
            } else {
                cout << abs(x - val * d) << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int x[10];
int main(){
    int x;
    int ans = 0;
    rep(i,5){
        cin >> x;
        if(x == 0){
            ans = i+1;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n[] = new int[3];
		for (int i = 0; i < 3; i++) {
			n[i] = sc.nextInt();
		}
		Arrays.sort(n);
		System.out.println(n[2]*10 + n[1] + n[0]);
	}
}


Measured memory_bytes: 23892
n=gets.to_i
h=gets.split.map(&:to_i)
dp=[0,(h[0]-h[1]).abs]
2.upto(n-1){|i|
  dp << [dp[i-2]+(h[i]-h[i-2]).abs,dp[i-1]+(h[i]-h[i-1]).abs].min
}
puts dp.last

Measured memory_bytes: 11396
import java.util.*;
public class Main {
  
  public static int p[];
  public static int min = 2*10*10*10*10*10 + 1;
  
  private static boolean judge(int i){
    
    //新たに見る配列がこれまでで最小か。
    if(min > p[i-1]){
      min = p[i-1];
      return true;
    }
    else{
      return false;
    }
    
    /*
    for(int j = 1; j <= i; j++){
      if(p[i-1] > p[j-1]){
        return false;
      }
    }
    return true;
    */
    //System.out.println();
  }
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    p = new int[n];
    for(int i = 0; i < n; i++){
      p[i] = sc.nextInt();
    }
    
    int count = 0;
    
    for(int i = 1; i <= n; i++){
      if(judge(i)){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 87480
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll d,mod = 1000000007;
ll dp[10009][109][9];
string s;
ll bt(ll id,ll sum,ll t){
	if(id == s.size()) return (sum%d==0);
	ll &ret = dp[id][sum][t];
	if(ret != -1) return ret;
	ret = 0;
	if(t == 1){
		for(int i=0;i<=9;i++){
			ret = (ret + bt(id+1,(sum+i)%d,1)) % mod;
		}
	}
	else{
		ll n = s[id] - '0';
		for(int i=0;i<n;i++){
			ret = (ret + bt(id+1,(sum+i)%d,1)) % mod;
		}
		ret = (ret + bt(id+1,(sum+n)%d,0)) % mod;
	}
	return ret;
}
int main(){
	cin>>s>>d;
	memset(dp,-1,sizeof(dp));
	cout<<(bt(0,0,0)+mod-1)%mod<<endl;
}


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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {

   string S;
   cin >> S;
   int min_ = 1000;
   REP(i, S.length()-2){
       int num = atoi(S.substr(i, 3).c_str());
       min_ = min(min_, abs(753-num));
   }

   cout << min_ << endl;

}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
#include <chrono>
#include<bitset>
#include<deque>
#include <map>
#define vint vector<int>
#define vint2 vector<vint>
#define vchar vector<char>
#define vchar2 vector<vchar> 
#define vchar3 vector<vchar2> 
#define pr pair<int,int>
#define vpr vector<pr>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
typedef  long long int ll;
using namespace std;
//CHAR_BIT	ビット フィールドではない最小変数のビット数。	8
//SCHAR_MIN	signed char 型変数の最小値。	–128
//SCHAR_MAX	signed char 型変数の最大値。	127
//UCHAR_MAX	unsigned char 型変数の最大値。	255 (0xff)
//CHAR_MIN	char 型変数の最小値。 - 128、 / J オプション使用時は 0
//CHAR_MAX	char 型変数の最大値。	127、 / J オプション使用時は 255
//MB_LEN_MAX	多文字定数の最大バイト数。	5
//SHRT_MIN	short 型変数の最小値。	–32768
//SHRT_MAX	short 型変数の最大値。	32767
//USHRT_MAX	unsigned short 型変数の最大値。	65535 (0xffff)
//INT_MIN	int 型変数の最小値。	–2147483647 – 1
//INT_MAX	int 型変数の最大値。	2147483647
//UINT_MAX	unsigned int 型変数の最大値。	4294967295 (0xffffffff)
//LONG_MIN	long 型変数の最小値。	–2147483647 – 1
//LONG_MAX	long 型変数の最大値。	2147483647
//ULONG_MAX	unsigned long 型変数の最大値。	4294967295 (0xffffffff)




int  main() {
	int n;
	cin >> n;
	vint a = vint(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cerr << "-------" << endl;
	REP(i, n) {
		cerr << a[i]<<endl;
	}
	int s=0,e=n-2;
	int sv = a[n - 1];
	int ev = a[n - 1];
	long long int ret = 0;
	int cnt=0;
	while (s<=e) {
		int sv_s = abs(sv - a[s]);//0
		int mi = 0; int m = sv_s; //cerr << "m"<<mi<<"\t"<<m << endl;
		int ev_s = abs(ev - a[s]);//1
		if (ev_s > m) { mi = 1; m = ev_s; }
		int sv_e = abs(sv - a[e]);//2
		if (sv_e > m) { mi = 2; m = sv_e; }
		int ev_e = abs(ev - a[e]);//3
		if (ev_e > m) { mi = 3; m = ev_e; }
		cerr << "m\t" << m << endl;
		ret += m;
		if (mi<2) {
			
			if (mi % 2 == 0) {
				sv = a[s];
			}
			else {
				ev = a[s];
			}
			s++;
		}
		else {
			if ( mi % 2 == 0) {
				sv = a[e];
			}
			else {
				ev = a[e];
			}
			e--;
		}
		cerr << "sv\t" << sv << "ev\t" << ev << endl;

	}
	//ret += a[s];
	cout << ret << endl;

//while (true) {}

	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  int n='A'-'a';
  s1[0]+=n;
  s2[0]+=n;
  s3[0]+=n;
  cout<<s1[0]<<s2[0]<<s3[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
const int MOD = 1e9 + 7;
struct segK{//非再帰
    int n;
    long long MIN;
    int size;
    vector<long long> dat;
    segK(int n_){
        n = 1;
        MIN = 0;
        size = n_;
        while(n < n_) n *= 2;
        dat.resize(2 * n);
        for(int i = 1; i < 2 * n; i++) dat[i] = MIN;
    }
    void update(int k, long long a){
        k += n;
        dat[k] = a;
        while(k > 0){
            k >>= 1;
            dat[k] = max(dat[k << 1 | 0], dat[k << 1 | 1]);
        }
    }
    long long query(int l, int r){
        long long res = 0;
        l += n;
        r += n;
        while(r > l){
            if(l & 1) res = max(res, dat[l++]);
            if(r & 1) res = max(res, dat[--r]);
            l >>= 1;
            r >>= 1;
        }
        return res;
    }
    int right_bin(int l, long long v) {
        if(l == size) return l;
        l += n;
        long long zero = -1;
        do {
            while (l % 2 == 0) l >>= 1;
            if (dat[l] >= v) {
                while (l < n) {
                    l = (2 * l);
                    if (dat[l] < v) {
                        zero = max(zero, dat[l]);
                        l++;
                    }
                }
                return l - n;
            }
            zero = max(zero, dat[l]);
            l++;
        } while ((l & -l) != l);
        return size;
    }
    int left_bin(int r, long long v) {
        if(r == 0) return r;
        r += n;
        long long zero = -1;
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (dat[r] <= v) {
                while (r < n) {
                    r = (2 * r + 1);
                    if (dat[r] > v) {
                        zero = max(zero, dat[r]);
                        r--;
                    }
                }
                return r + 1 - n;
            }
            zero = max(zero, dat[r]);
        } while ((r & -r) != r);
        return 0;
    }
};
int op(int a, int b){
    return max(a, b);
}
int e(){
    return 0;
}

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    segtree<int, op, e> segk(300100);
    for(int i = 0; i < N; i++){
        if(i == 0) segk.set(A[i], 1);
        else{
            int l = max(0, A[i] - K);
            int r = min(300050, A[i] + K);
            int res = segk.prod(l, r + 1);
            segk.set(A[i], res + 1);
        }
    }
    cout << segk.all_prod() << endl;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)


typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
//////////////////////////


ll SOLVE(){
    ll n,m;cin>>n>>m;
    vector<ll>v[n+1];
    rep(i,1,m){
        ll a,b;cin>>a>>b;
        v[a].pb(b);
    }
    ll s,t;cin>>s>>t;
    ll dis[n+1][3];rep(i,1,n)rep(j,0,2)dis[i][j]=inf;
    queue<l_l>q;q.push({s,0});
    dis[s][0]=0;
    while(!q.empty()){
        l_l top=q.front();q.pop();
        for(auto x:v[top.fi]){
            if(chmin(dis[x][(top.se+1)%3],dis[top.fi][top.se]+1)){
                q.push({x,(top.se+1)%3});
            }
        }
    }
    if(dis[t][0]==inf)cout<<-1;
    else cout<<dis[t][0]/3;
    
    return 0;
}

int main(){fastio
    
    clock_t start = clock();
    SOLVE();
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    cerr<<endl<<time<<"ms"<<endl;
    
    return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define For(i, j, k) for(int i = j; i <= k; ++i)
#define Forr(i, j, k) for(int i = j; i >= k; --i)
using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') p = -1; c = getchar(); }
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return x *= p;
}

template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

inline void File() {
	freopen("ARC080C.in", "r", stdin);
	freopen("ARC080C.out", "w", stdout);
}

const int N = 1e5 + 10, M = 30 + 10;
int n, A[N], F[M], tmp[N];

int main() {
	For(i, 0, 29) F[i] = 1 << i;
	n = read();
	For(i, 1, n) {
		int x = read();
		Forr(j, 29, 1) if(!(x % F[j])) x /= F[j], A[i] += j;
	}
	sort(A + 1, A + 1 + n);

	int cnt = 0;
	For(i, 1, n + 1 >> 1) {
		tmp[++cnt] = A[i], tmp[++cnt] = A[n + 1 - i];
		if(i == n + 1 - i) -- cnt;
	}
	
	int flag = 1;
	For(i, 1, n - 1) if(tmp[i] + tmp[i + 1] < 2) flag = 0;
	printf("%s\n", flag ? "Yes" : "No");		
	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
const int MAXN = 505;
int A[MAXN];
int B[MAXN];
int K, N;

bool check(int M) {
  for (int i = 0; i < N; ++i) {
    B[i] = A[i] % M;
  }
  std::sort(B, B+N);
  int lo = 0;
  int hi = N-1;
  int cost = 0;
  while (lo < hi) {
    int sum = B[lo] + B[hi];
    if (sum < M) {
      cost += B[lo];
      B[hi] += B[lo];
      B[lo] = 0;
      ++lo;
    } else {
      // (sum >= M)
      cost += M - B[hi];
      B[hi] = M;
      B[lo] = sum - M;
      if (!B[lo]) ++lo;
      --hi;
    }
  }
  return (B[lo] % M == 0) && (cost <= K);
}

int main() {
  scanf(" %d%d", &N, &K);
  int S = 0;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
    S += A[i];
  }
  int ret = 1;
  int sqrtS = sqrt(S);
  for (int i = 1; i <= sqrtS; ++i) if ((S % i) == 0) {
    int j = S / i;
    if (check(i)) ret = std::max(i, ret);
    if (check(j)) ret = std::max(j, ret);
  }
  printf("%d\n", ret);
  return 0;
}

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

int main(void){
    int n,t; cin >> n >> t;
    ll x, finish_time; cin >> finish_time;
    x = t; finish_time += t;
    for(int i=1;i<n;i++){
        ll tmp; cin >> tmp;

        if(finish_time <= tmp){
            x += t;
            finish_time = tmp + t;
        }else{
            ll add_time = max((ll)0,(t - (finish_time - tmp)));
            x += add_time;
            finish_time += add_time;
        }

    }
    cout << x << endl;
    return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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


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

    int a[200] = {0};
    rep(i,K){
        int d;
        cin >> d;
        rep(j, d){
            int tmp;
            cin >> tmp;
            a[tmp-1]++;
        }
    }

    int ans = 0;
    rep(i, N){
        if(a[i] == 0) ans++;
    }

    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    cout << ans;
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3676
l, r = gets.chomp.split.map(&:to_i)
if l%2019 == 0 || r-l >= 2019 || r%2019 < l%2019
  puts(0)
  exit
end

l, r = l%2019, r%2019

min = 2018
(l..r).each do |i|
  ((i+1)..r).each do |j|
    tmp = (i*j)%2019
    min = tmp if min > tmp
  end
end

puts(min)

Measured memory_bytes: 3836
import java.util.*;

class Main{
    void solve(){
        int N;
	Scanner sc = new Scanner(System.in);
	N = sc.nextInt();
	
	if ('A' <= N && N <= 'Z' ) System.out.println("1");
	else if ( 'a' <= N && N <= 'z' ) System.out.println("2");
	else System.out.println("0");

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



Measured memory_bytes: 26336
#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    if (N==11|| N==13 || N==17 || N==19 || N==22 || N==23|| 
        N==26|| N==29|| N==39|| N==33|| N==34|| N==37|| N==38|| N==39|| N==41|| N==43||
        N==44|| N==46|| N==47|| N==50|| N==51|| N==52|| N==53|| N==54|| N==55|| N==57|| 
        N==58|| N==59|| N==60|| N==61|| N==62|| N==65|| N==66|| N==67|| N==68|| N==69||
        N==70|| N==71|| N==72|| N==73|| N==74|| N==75|| N==76|| N==77|| N==78|| N==79||
        N==80|| N > 81) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;

int lst[Max];
string ls[Max];
map<string, int> ma1, ma2;

int main()
{
	int n, m, g = 0;
	cin >> n;
	for (int i = 1;i <= n;i++)
	{
		string t;
		cin >> t;
		ma1[t]++;
		ls[++g] = t;
	}
	cin >> m;
	for (int i = 1;i <= m;i++)
	{
		string t;
		cin >> t;
		ma2[t]++;
		ls[++g] = t;
	}
	int ma = -1e9 - 5;
	for (int i = 1;i <= g;i++)
	{
		ma = max(ma, ma1[ls[i]] - ma2[ls[i]]);
	}
	cout << max(0,ma);
}

Measured memory_bytes: 26600
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Diagnostics;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrrrr
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());

            //t,x,y
            int[] now = { 0, 0, 0 };
            for (int i = 0; i < n; i++)
            {
                int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
                int t = s[0];
                int x = s[1];
                int y = s[2];
                int distance = Abs(now[1] - x) + Abs(now[2] - y);
                if (distance <= t)
                {
                    if (((t-now[0]) - distance) %2 != 0)
                    {
                        WriteLine("No");
                        return;
                    }
                }
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 15404
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]

a = [[-1] * W for _ in range(H)]

sbs = []
n = 1
for i in range(H):
    si = s[i]
    for j in range(W):
        if si[j] == '#':
            a[i][j] = n
            n += 1
            sbs.append((i, j))

for sb in sbs:
    i, j = sb
    n = a[i][j]
    t, l = i - 1, j - 1
    r = j + 1
    while t > -1:
        if a[t][j] != -1:
            break
        t -= 1
    t += 1
    while l > -1:
        if a[i][l] != -1:
            break
        l -= 1
    l += 1
    while r < W:
        if a[i][r] != -1:
            break
        r += 1
    r -= 1
    for y in range(t, i + 1):
        ay = a[y]
        for x in range(l, r + 1):
            ay[x] = n

for h in range(H - 1, -1, -1):
    if a[h][0] != -1:
        break
h += 1

for i in range(h, H):
    ai1 = a[i - 1]
    ai = a[i]
    for j in range(W):
        ai[j] = ai1[j]

for i in range(H):
    print(*a[i])


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

int main() {
    int N;
    while (cin >> N, N) {
        vector<int> v(N);
        for (auto& i : v) cin >> i;

        int sum = 32;
        int c = 0;
        while (sum) {
            if (c % 2 == 0) {
                sum -= (sum - 1) % 5;
            } else {
                sum = max(0, sum - v[(c/2)%N]);
            }
            c++;
            cout << sum << endl;
        }
    }

    return 0;
}

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

int w[1501]={0}, h[1501]={0};
int W[2250000]={0}, H[2250000]={0};

int sum(int* a , int i,int n,int size){
	int s = 0;
	for(int j=n ; j-- ; ){
		if( i >= size ){
			return 0;
		}
		s += a[i++];
	}
	return s;
}

int main(){
	int n,m,w_,h_;
	while( cin >> n >> m , n||m ){
		//int cnt_h[1001] = {0}
		int cnt_w[1000000] = {0};
		
		for(int i=0 ; i<n ; i++ ){
			cin >> h[i];
		}
		int i_=0;
		for(int j=1 ; j <= n ; j++ ){
			for(int i=0 ; i+j <= n ; i++ ){
				H[i_++] = sum( h , i , j , n );
			}
		}
		/*for(int i=0 ; i<i_ ; i++ ){
			cnt_h[ H[i] ]++;
		}*/
		
		for(int i=0 ; i<m ; i++ ){
			cin >> w[i];
		}
		int j_=0;
		for(int j=1 ; j <= m ; j++ ){
			for(int i=0 ; i+j <= m ; i++ ){
				W[j_++] = sum( w , i , j , m );
			}
		}
		for(int i=0 ; i<j_ ; i++ ){
			cnt_w[ W[i] ] += 1;
		}
		/*for(int i=0 ; i<j_ ; i++ ){
			cout << "W[" << i << "] : " << W[i] << endl;
		}*/
		
		int ans = 0;
		for(int i=0 ; i < i_ ; i++ ){
			//if( H[i] <= 1000 && H[i] >= 0 )
				ans += cnt_w[ H[i] ];
			//for(int j=0 ; j < j_ ; j++ ){
			//	if( W[j] == H[i] ) ans++;
			//}
		}
		//cout << "ans : " << ans << endl;
		cout << ans << endl;
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>

using namespace std;

ifstream fin("../data.txt");

long long x, moves;

int main() {

  cin >> x;
  moves += (1LL*x/11) * 2;
  moves += 2;
  if (x % 11 == 0) moves -= 2;
  else if (x%11 <= 6) moves -= 1;
  cout << moves;
  return 0;
}


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

public class Main {
	public static void main(String[]  args) {
		Scanner scanner = new Scanner(System.in);
		
		int H = scanner.nextInt();
		long[] heap = new long[H];
		for (int i = 0; i < heap.length; i ++) {
			heap[i] = scanner.nextLong();
		}
		
		scanner.close();
		
		for (int i = 0; i < heap.length; i ++) {
			System.out.print("node ");
			System.out.print(i + 1);
			System.out.print(": key = ");
			System.out.print(heap[i]);
			System.out.print(", ");
			if (i != 0) {
				System.out.print("parent key = ");
				System.out.print(heap[(i  - 1) / 2]);
				System.out.print(", ");
			}
			int left = i * 2 + 1;
			if (left < heap.length) {
				System.out.print("left key = ");
				System.out.print(heap[left]);
				System.out.print(", ");
			}
			int right = left + 1;
			if (right < heap.length) {
				System.out.print("right key = ");
				System.out.print(heap[right]);
				System.out.print(", ");
			}
			System.out.println();
		}
	}
} 



Measured memory_bytes: 27708
import math

a,b,c = map(float,input().split())
s = (a*b*math.sin(math.pi*c/180))/2
l = math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*c/180))+a+b
h = s*2/a
print(s)
print(l)
print(h)


Measured memory_bytes: 5692
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
P p[100000];
signed main(){
	int a,b,ans=0;
	cin>>a>>b;
	f(i,a) cin>>p[i].F>>p[i].S;
	sort(p,p+a);
	f(i,a){
		if(b<=p[i].S){
			cout<<ans+p[i].F*b<<endl;
			return 0;
		}
		ans+=p[i].F*p[i].S;
		b-=p[i].S;
	}
}


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

#define max(a,b) (((a) < (b)) ? (b) : (a))
int main(void) {

    char buf[16];
    char *p;

    int N;
    int i;
    int *T,*A;

    uint64_t votes, vt,va;
    uint64_t n,n1,n2;
    uint64_t ratio;
//    int T[] = {3, 48, 31, 231, 3};
//    int A[] = {10, 17, 199, 23, 2};

    p = fgets(buf, 16, stdin);
    N = atoi(buf);

    T = malloc(sizeof(int) * N * 2);
    A = T + N;

    for(i=0;i<N;i++) {
        p = fgets(buf, 16, stdin);
        (void)sscanf(buf, "%d %d", &T[i], &A[i]);
    }
//    N = 5;

    vt = 1;
    va = 1;
    for(i=0;i<N;i++){
        n1 = (vt % T[i]) ? ((vt/T[i])+1):vt/T[i];
        n2 = (va % A[i]) ? ((va/A[i])+1):va/A[i];
        n = max(n1,n2);
// printf("%lu\n", n);
        vt = n * T[i];
        va = n * A[i];
        votes = vt + va;
    }

    printf("%lu\n", votes);

    free(T);

    return 0;
}


Measured memory_bytes: 128
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>

using namespace std;



int main() {
	long long N,K,R,S,P;
	cin >> N >> K;
	cin >> R >> S >> P;
	string input;
	cin >> input;
	// r= gu	-> p
	// s= cyoki	-> r
	// p= pa-	-> s

	// 同じ手をN回置きにM回出したいけど出せないパターン　・・・　いくつ連続してもM/2(切り上げ)回そのまま、それ以外変更で良い
	// ３回連続なら、２回勝ちにする　４回連続なら２回勝ちにする
	// 変更したときの先頭は、そのN回前と競合しない手が確実に選べる

	// K回前と競合する手がどこにあるかを検索し、r,s,p毎に連続数をvectorに格納してゆく
	// カウント済みの個所はxに変更する
	vector<int> r_continus;
	vector<int> s_continus;
	vector<int> p_continus;
	for (int i = input.size() - 1; i >= K; i--) {
		if (input[i] == 'x') continue;
		if (input[i] == 'r') {
			int count = 1;
			while (input[i - count * K] == 'r') {
				count++;
				if ((i - count * K) < 0) break;
			}
			if (count > 1) { // 連続する個所を見つけたら
				r_continus.push_back(count); // 連続数を保存
				for (int j = 0; j < count; j++) {
					input[i - j * K] = 'x';
				} // 該当文字列をxに置き換え
			}
		}
		else if (input[i] == 's') {
			int count = 1;
			while (input[i - count * K] == 's') {
				count++;
				if ((i - count * K) < 0) break;
			}
			if (count > 1) { // 連続する個所を見つけたら
				s_continus.push_back(count); // 連続数を保存
				for (int j = 0; j < count; j++) {
					input[i - j * K] = 'x';
				} // 該当文字列をxに置き換え
			}
		}
		else if (input[i] == 'p') {
			int count = 1;
			while (input[i - count * K] == 'p') {
				count++;
				if ((i - count * K) < 0) break;
			}
			if (count > 1) { // 連続する個所を見つけたら
				p_continus.push_back(count); // 連続数を保存
				for (int j = 0; j < count; j++) {
					input[i - j * K] = 'x';
				} // 該当文字列をxに置き換え
			}
		}
	} // カウント&置換終了

	long long r_win = 0;	// count of s
	long long s_win = 0;	// count of p
	long long p_win = 0;	// count of r
	for (int i = 0; i < input.size(); i++) {
		if (input[i] == 's') r_win++;
		else if (input[i] == 'p') s_win++;
		else if (input[i] == 'r') p_win++;
	}
	for (int i = 0; i < s_continus.size(); i++) {
		if (s_continus[i] % 2 == 0) r_win += s_continus[i] / 2;
		else r_win += s_continus[i] / 2 + 1;
	}
	for (int i = 0; i < p_continus.size(); i++) {
		if (p_continus[i] % 2 == 0) s_win += p_continus[i] / 2;
		else s_win += p_continus[i] / 2 + 1;
	}
	for (int i = 0; i < r_continus.size(); i++) {
		if (r_continus[i] % 2 == 0) p_win += r_continus[i] / 2;
		else p_win += r_continus[i] / 2 + 1;
	}

	cout << r_win * R + s_win * S + p_win * P << endl;
	return 0;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

//最大公約数(引数の型に注意)
ll gcd(ll a, ll b)
{
    if (a * b == 0)
        return max(a, b);
    if (a < b)
        swap(a, b);
    if (a % b == 0)
        return b;
    return gcd(a % b, b);
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    //iまでの累積GCD(iも含む),iからn-1までの累積GCD(iも含む)
    vector<ll> L(n), R(n);
    ll tmp = 0;
    rep(i, n)
    {
        tmp = gcd(A[i], tmp);
        L[i] = tmp;
    }
    tmp = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        tmp = gcd(A[i], tmp);
        R[i] = tmp;
    }

    ll ma = 0;
    rep(i, n)
    {
        ll tmp;
        if (i == 0)
            tmp = R[i + 1];
        else if (i == n - 1)
            tmp = L[i - 1];
        else
            tmp = gcd(L[i - 1], R[i + 1]);
        ma = max(tmp, ma);
    }

    cout << ma << endl;
}

Measured memory_bytes: 5632
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll binomialCoeff(ll n, ll k) 
{ 
	ll C[n + 1][k + 1]; 
	ll i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = (C[i - 1][j - 1] + 
										C[i - 1][j])%MOD; 
		} 
	} 

	return C[n][k]; 
}
bool compare(const string &a , const string&b){
	
}
 
void solve()
{
   int l ,r , d ;
   cin>>l>>r>>d ;
   int ans = 0 ;
   repu(i , l , r){
   	if(i%d==0){
   		ans++;
   	}
   }
   cout<<ans<<endl;
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

#include <map>
#include <string>

#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cinttypes>


using namespace std;

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

	static int p[200000];

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

	int sum = 0;

	for (int i = 0; i < k - 1; ++i)
	{
		sum += p[i];
	}

	int ans = 0;

	for (int i = k - 1; i < n; ++i)
	{
		sum += p[i];
		if (ans < sum) ans = sum;
		sum -= p[i - k + 1];
	}

	
	cout << std::setprecision(10) << fixed << (ans * 0.5) << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

int inf = std::numeric_limits<int>().max();

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define ll long long
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<int>> v(n+1, vector<int>(m+1, 0)); 
	vector<vector<int>> t(n+1, vector<int>(m+1, 0)); 
	for(int i=1; i<=n; i++) {
		string s;
		cin >> s;
		for(int j=1; j<=m; j++) {
			if (s[j-1] == '#') v[i][j] = 1;
		}
	}

	t[1][1] = 1;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			if (!v[i-1][j]) t[i][j] += t[i-1][j];
			if (!v[i][j-1]) t[i][j] += t[i][j-1];
			t[i][j] %= mod;
		}
	}

	cout << t[n][m] << endl;

}


Measured memory_bytes: 8320
import bisect
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  

n, x = map(int,input().split())
a = list(map(int,input().split()))

index = bisect.bisect_left(a, x)
a.insert(index, x)
d = [0]*(n)
for i in range(n):
    d[i] = a[i+1] - a[i]
ans = gcd(*d)
print(ans)

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

int main()
{
    ios::sync_with_stdio(false);

    int x, t = 0, k = 10;
    for (int i = 0; i < 5; i++)
    {
        cin >> x;
        t += x;
        x %= 10;
        if (x)
            t += 10 - x;
        if (x < k && x)
            k = x;
    }
    if (k < 10)
        t -= (10 - k);
    cout << t<<endl;;

    return 0;
}

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


Measured memory_bytes: 3588
#! /usr/bin/python

import sys

def main():
	for input in sys.stdin:
		dx = int(input)
		area = integral(dx)
		print(area)

def integral(dx):
	x = 0
	area = 0
	while x < 600:
		area += f(x) * dx
		x += dx

	return area;

def f(x):
	return x * x

main()

Measured memory_bytes: 4220