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

typedef long long ll;
const int mod = 1000000007;
const int oo = 1e9;
const int base = 27;
const int N = 100010;

typedef pair<int,int> pii;
 
int n , m ;
ll a[N],p1[N],p2[N];

void apply(ll a , ll b,int l , int r){
  if(l>r)return;
  p1[l] += a,p1[r+1] += -a,p2[l] += b , p2[r+1] -= b;
}
int main() {
  scanf("%d%d",&n,&m);
  for (int i = 1; i <= n; ++i)scanf("%lld",&a[i]);
  for (int i = 1; i+1 <= n; ++i){
    int s = a[i],t = a[i+1];
    if(s <= t){
      apply(-1,1+t,s+1,t); // -x+1+t
      apply(0,t-s,1,s); // t-s [1,s]
      apply(0,t-s,t+1,m);// t-s [t+1,m]
    }else{
      apply(-1,t+1+m,s+1,m); // - x + t  + 1 + m 
      apply(-1,1+t,1,t); // 1+t-x
      apply(0,m-s+t,t+1,s);//m-s+t
    }
  }
  ll ans = 1e18;
  for(int i= 1; i <= m ; ++i){
    p1[i] += p1[i-1],p2[i] += p2[i-1];
    ans = min(ans,p1[i]*i+p2[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2560
package main

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

var cache [100][100]int

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	tables := []table{}
	for i := 0; i < num; i++ {
		sc.Scan()
		num1, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		num2, _ := strconv.Atoi(sc.Text())
		t := table{num1, num2}
		tables = append(tables, t)
	}

	fmt.Println(minimum(0, len(tables)-1, tables))
}

type table struct {
	v int
	h int
}

func minimum(i int, j int, t []table) int {
	if i == j {
		return 0
	}

	// fmt.Printf("i:%v j:%v\n", i, j)
	if cache[i][j] != 0 {
		return cache[i][j]
	}

	min := math.MaxInt64
	for k := i; k < j; k++ {
		p := t[i].v
		n := t[k].h
		q := t[j].h
		val := minimum(i, k, t) + minimum(k+1, j, t) + p*n*q
		if val < min {
			min = val
		}
	}

	cache[i][j] = min
	return min
}



Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int A,B,i,sum=1,count=0;

cin >> A >> B;

for(i=0;i==0;i){

  if(sum<B){
    sum=sum-1+A;
    count++;
  }
  else{
    break;
  }
}
cout << count << endl;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    int nu[4];
    for (int i = 0; i < 4; i++)
    {
        char c;
        cin >> c;
        nu[i] = c - '0';
    }

    for (int b = 0; b < (1 << 3); b++)
    {
        int sum = nu[0];
        for (int i = 0; i < 3; i++)
        {
            sum += (((b >> i) & 1) == 0) ? nu[i + 1] : -nu[i + 1];
        }
        if (sum == 7)
        {
            char c = nu[0] + '0';
            cout << c;
            for (int i = 0; i < 3; i++)
            {
                c = nu[i + 1] + '0';
                cout << ((((b >> i) & 1) == 0) ? '+' : '-') << c;
            }
            cout << "=7" << endl;
            return 0;
        }
    }

    return 0;
}

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

typedef long long ll;
ll N;
ll A[100010];
ll B[100010];

int main(){
	cin >> N;
	ll sum = 0;
	for(int i=0;i<N;i++){
		cin >> A[i];
		sum += A[i];
	}
	ll t = (N*(N+1))/2;
	if(sum%t!=0) cout << "NO" << endl;
	else{
		for(int i=0;i<N;i++){
			B[i] = A[(i+1)%N]-A[i]-sum/t;
		}
		bool judge = true;
		for(int i=0;i<N;i++){
			if(B[i]>0 || B[i]%N!=0) judge = false;
		}
		if(judge) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<cstring>
#include<string>
using namespace std;
long long a,b,x;
long long s,e;
int main(){
    scanf("%lld %lld %lld",&a,&b,&x);
    if(a%x==0)s=a/x;
    	else s=a/x+1;
    e=b/x;
    printf("%lld\n",e-s+1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int a = 0;
	int N = n;

	while(n > 0){
		a += n % 10;
		n /=  10;
	}

		if (N % a == 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	
	return 0;
}

Measured memory_bytes: 256
H,W,K = map(int,input().split())
mod = 10**9+7
dp = [[0 for i in range(W)] for j in range(H+1)]
dp[0][0] = 1
dp_x = [[0,0] for i in range(W)]
dp_o = [[0,0] for i in range(W)]
dp_x[0][0] = 1
dp_x[0][1] = 1
for i in range(W-1):
    dp_x[i+1][0] = dp_x[i][0]+dp_x[i][1]
    dp_x[i+1][1] =dp_x[i][0]
dp_o[0][0] = 1
dp_o[0][1] = 0
for i in range(W-1):
    dp_o[i+1][0] = dp_o[i][0] + dp_o[i][1]
    dp_o[i+1][1] =dp_o[i][0]
dp_o = [sum(e) for e in dp_o]
dp_x = [sum(e) for e in dp_x]
dp_o = [1]+dp_o
dp_x = [1]+dp_x
if W == 1:
    print(1)
    exit()
for h in range(0,H):
    for w in range(W):
        if w == 0:
            dp[h+1][0] += dp[h][0]*dp_x[W-1-1]%mod
            dp[h+1][0] += dp[h][1]*dp_o[W-1-1]%mod
        elif w == W-1:
            dp[h+1][w] += dp[h][w]*dp_x[W-1-1]%mod
            dp[h+1][w] += dp[h][w-1]*dp_o[W-1-1]%mod
        else:
            #no connection
            dp[h+1][w] += dp[h][w]*dp_x[w-1]*dp_x[W-w-2]%mod
            #right connection
            dp[h+1][w] += dp[h][w+1]*dp_x[w-1]*dp_o[W-w-2]%mod
            #left connection
            dp[h+1][w] += dp[h][w-1]*dp_o[w-1]*dp_x[W-w-2]%mod
print(dp[H][K-1]%mod)


Measured memory_bytes: 3192
import io.StdIn._

object Main extends App {
  val s = readLine()

  var i    = 0
  var acgt = ""
  var list = Seq.empty[String]
  do {
    if ("ACGT".contains(s(i))) {
      acgt = acgt + s(i)
    } else {
      list = list :+ acgt
      acgt = ""
    }
    i = i + 1
  } while (i < s.length)
  list = list :+ acgt
  println(list.map(_.length).max)
}


Measured memory_bytes: 54828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	ll n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++) cin >> a[i];

	int pos = 1;
	int key = 0;
	vector<int> count(n + 1);
	for (int i = 1; i <= k; i++) {
		pos = a[pos];
		count[pos]++;
		if (count[pos] == 2) {
			key = pos;
			break;
		}
	}

	int preCount = 0;
	int keyCount = 0;
	pos = 1;
	vector<int> town;
	for (int i = 1; i <= k; i++) {
		pos = a[pos];
		if (pos == key) keyCount++;
		if (keyCount == 0) preCount++;
		else if (keyCount == 1) town.push_back(pos);
		else if (keyCount == 2) break;
	}
	if (0 <= k - preCount - 1)	cout << town[(k - preCount - 1) % town.size()] << endl;
	else {
		int pos = 1;
		for (int i = 1; i <= k; i++) pos = a[pos];
		cout << pos << endl;
	}
}


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

main(){

    std::ios::sync_with_stdio(0);
    std::cin.tie(0);

    int n;
    cin >> n;
    cout << fixed << setprecision(9) << 1 - (ceil(n / 2) * 1.0) / n << '\n';

}


Measured memory_bytes: 256
from copy import copy


class Card:

    def __init__(self, s):
        splited = s.split(' ')
        self.suit = splited[0]
        self.number = int(splited[1])

    def __gt__(self, other):
        return self.number > other.number

    def __ge__(self, other):
        return self.number >= other.number

    def __le__(self, other):
        return self.number <= other.number

    def __lt__(self, other):
        return self.number < other.number

    def __repr__(self):
        return '{} {}'.format(self.suit, self.number)

    def __str__(self):
        return self.__repr__()

    def __eq__(self, other):
        return self.suit == other.suit and self.number == other.number


s = 'A 0'
SENTINEL = Card(s)
SENTINEL.number = float('inf')


def main():
    n = int(input())
    cs_1 = [Card(input()) for _ in range(n)]
    cs_2 = copy(cs_1)
    merge_sort(cs_1, n, 0, n)
    quick_sort(cs_2, 0, n-1)
    if all([c1 == c2 for c1, c2 in zip(cs_1, cs_2)]):
        print('Stable')
    else:
        print('Not stable')
    print('\n'.join([str(c) for c in cs_2]))


def quick_sort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quick_sort(A, p, q-1)
        quick_sort(A, q+1, r)


def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1


def merge_sort(A, n, left, right):
    if left+1 < right:
        mid = (left+right) // 2
        merge_sort(A, n, left, mid)
        merge_sort(A, n, mid, right)
        merge(A, n, left, mid, right)


def merge(A, n, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    L.append(SENTINEL)
    R.append(SENTINEL)
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1


if __name__ == "__main__":
    main()




Measured memory_bytes: 34620
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        String s = scn.next();
        String answer = "No";
        if(s.charAt(0)!=s.charAt(1)&&s.charAt(0)!=s.charAt(2)&&s.charAt(1)!=s.charAt(2)) answer = "Yes";
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<int> v( N );
	rep( i, N ) cin >> v[i];

	UnionFind<int> uf( N );
	rep( i, M )
	{
		int x, y;
		cin >> x >> y;
		--x, --y;

		uf.unite( x, y );
	}

	ll cnt = 0;
	rep( i, N )
	{
		if ( uf.find( i ) == uf.find( v[i] - 1 ) )
		{
			cnt++;
		}
	}

	cout << cnt << endl;

	return ( 0 );
}


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

const int MOD = (int) 1e9 + 7;

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


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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	string s;
	cin>>s;
	int fb = 0, fw = 0;
	rep(i,s.size()){
		if(s[i]-'0' != i%2)fb++;
		if(s[i]-'0' != (i+1)%2)fw++;
	}
	cout<<min(fw,fb)<<endl;
	return 0;
}

Measured memory_bytes: 512
#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 rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll comb[51][51];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    rep(i,51) rep(j,i+1) {
        if(j == 0) comb[i][j] = 1;
        else comb[i][j] = comb[i-1][j-1]+comb[i-1][j];
    }
    rep(i,51) rep(j,i) comb[i][j+1] += comb[i][j];
    int n,k,s,t;
    cin >> n >> k >> s >> t;
    vi a(n);
    cin >> a;
    ll can = (1LL<<n)-1;
    int v = 0;
    rep(i,18) {
        if(s>>i&1) {
            if(t>>i&1) {
                rep(j,n) if(!(a[j]>>i&1)) can &= ~(1LL<<j);
            } else {
                cout << 0 << endl;
                return 0;
            }
        } else {
            if(t>>i&1) {
                v |= 1<<i;
            } else {
                rep(j,n) if(a[j]>>i&1) can &= ~(1LL<<j);
            }
        }
    }
    if(can == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    int bit = v;
    do {
        int cnt = __builtin_popcount(bit);
        map<int,int> mp;
        rep(i,n) {
            if(!(can>>i&1)) continue;
            mp[a[i]&bit]++;
        }
        ll ret = 0;
        for(auto &p : mp) {
            ret += comb[p.second][min(k,p.second)]-1;
        }
        if(cnt&1) ans -= ret;
        else ans += ret;
        bit = (bit-1)&v;
    } while(bit != v);
    cout << ans << endl;
}


Measured memory_bytes: 3668
import java.util.*;
public class Main 
{
	
	static int gcd(int a, int b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
  
    // Function to find gcd of array of 
    // numbers 
    static int findGCD(int arr[], int n) 
    { 
        int result = arr[0]; 
        for (int i = 1; i < n; i++) 
            result = gcd(arr[i], result); 
  
        return result; 
    }
  
    public static void main(String[] args) 
    { 
    	Scanner sc = new Scanner(System.in);
		// numOfMon: number of the monsters
		int numOfMon = sc.nextInt();

		int map[] = new int[numOfMon];

		for (int i=0; i<numOfMon; i++)
		{
			int Ai = sc.nextInt();
			map[i] = Ai;
		}
 
        System.out.println(findGCD(map, numOfMon));   
	}
}

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

int main()
{
    int a,b,cnt=0;
    cin>>a>>b;
    char arr[a+1][b+1];
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<b; j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<b; j++)
        {
           if(arr[i][j]=='.')
            {
                if(arr[i][j+1]=='#')
                    cnt++;
                if(arr[i][j-1]=='#')
                    cnt++;
                if(arr[i-1][j]=='#')
                    cnt++;
                if(arr[i+1][j]=='#')
                    cnt++;
                if(arr[i+1][j+1]=='#')
                    cnt++;
                if(arr[i+1][j-1]=='#')
                    cnt++;
                if(arr[i-1][j+1]=='#')
                    cnt++;
                if(arr[i-1][j-1]=='#')
                    cnt++;
            }
             if(arr[i][j]=='#')
            cout<<"#";
          else
            cout<<cnt;
             cnt=0;

        }
      cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
X=int(input())
li=[400,600,800,1000,1200,1400,1600,1800,2000]
li2=[8,7,6,5,4,3,2,1,0]
for i in range(8):
    if li[i]<=X and X<li[i+1]:
        print(li2[i])
        exit()

Measured memory_bytes: 9176
#include <stdio.h>

//voidは書いても書かなくてもいい.
int main() {
  int a, b;
  //%dでint,syort型の変換指定子
  scanf("%d%d", &a,&b);
  int c = a * b;
  printf("%d", c);
  //return 0は書いても書かなくてもいい.
  return 0;
}


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

bool check(char* p, string &t);
int main(void) {
    string Sdash,T,S;
    char *buf;
    bool found = false;
    int pos;

    cin >> Sdash >> T;
    
    found = false;
    for(int i=Sdash.size() - T.size();i>=0;i--) {
        if(check(&Sdash[i],T)) {
            found = true;
            pos = i;
            break;
        } 
    }

    if(found) {
        memcpy(&Sdash[pos], &T[0], T.size());
        for(int i=0;i<Sdash.size();i++) {
            if(Sdash[i] == '?') {
                Sdash[i] = 'a';
            }
        }
        cout << Sdash << "\n";
    } else {
        cout << "UNRESTORABLE\n";
    }
    return 0;
}

bool check(char* p, string &t) {
    bool ret = true;
    for(int i=0;i<t.size();i++) {
        if(p[i] == '?') {
        } else {
            if(p[i] != t[i]) {
                ret = false;
            }
        }
    }

    return ret;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

typedef long double ld;

char s[10];
int main(){
	ld ans = 0;
	int n; scanf("%d", &n);
	REP(i, n){
		ld a; scanf("%Lf%s", &a, s);
		if(s[0]=='B') ans +=a * 380000.0;
		else ans+=a;
	}
	printf("%.30Lf\n", ans);
}


Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] h = new int[n];
    for(int i = 0;i<n;i++){
      h[i] = sc.nextInt();
    }
    boolean check = false;
    for(int i = n-1;i>0;i--){
      if(h[i-1] > h[i]){
        h[i-1]--;
        if(h[i-1]!=h[i]){
          check = true;
          break;
        }
      }
    }
    if(check){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}


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


int main() {
  int q;
  cin >> q;
  vector<int> v;

  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x;
    if (x == 0) {
      cin >> y;
      v.push_back(y);
    }
    if (x == 1) {
      cin >> y;
      cout << v.at(y) << endl;
    }
    if (x == 2)
    v.pop_back();
  }

}


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

int main(){
  int a,b;cin >> a >> b;
  int prc=0;
  bool ans=false;
  for(int i=10000;i>=12;i--){
    int c=i*0.08;
    int d=i*0.1;
    if(c==a&&d==b){
      prc=i;
      ans=true;
    }
  }
  if(ans){
    cout << prc << endl;
  }else{
    cout << -1 << endl;
  }
}

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

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll c[100100];

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

int main(void){
	ll n,k,i,j,ans=0ll;
	n = 3;
	std::cin >> k;
	for(i=1ll; i<=k; ++i){
		add_mod(c[i],i);
		add_mod(ans,c[i]*rwpw(k/i,n)%MOD);
		for(j=i*2; j<=k; j+=i){
			add_mod(c[j],MOD-c[i]);
		}
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 3640
from itertools import permutations

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    D, N = mi()
    if N == 100:
        print(100**D*101)
    else:
        print(100**D*N)

if __name__ == '__main__':
    main()

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

  int sum = 0;
  int minValue = 50000000;
  for (int i = 1; i <= n; ++i) {
    int aji = i + l - 1;
    sum += aji;
    if (abs(aji) < abs(minValue)) {
      minValue = aji;
    }
  }
  int result = sum - minValue;
  cout << result << endl;

  return 0;
}


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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    if(N>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main(){
	int d,s;
	while(scanf("%d",&d)!=EOF){
		s=0;
		for(int i=1;i<600/d;i++)s+=d*d*d*i*i;
		cout<<s<<endl;
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=300050;
//ここまでテンプレ
int main(){
	int N,i;
	cin>>N>>i;
	cout<<N-i+1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a; i<=(b); ++i)
#define Fod(i,a,b) for(int i=a; i>=(b); --i)
#define fi first
#define se second
#define pback push_back
#define sz(x) (int) x.size()

using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> ii;
const int N = 2e5+1, oo = 1e9 + 7, K= 13;
const LL MOD = 998244353;
string s;
int n, a[N], x, ans;

int main()
{
    cin >> n >> x;
    For(i, 1, n) cin >> a[i];
    sort(a+1, a+n+1);
    For(i, 1, n-1) if (x >= a[i]) {
        x-= a[i];
        ++ans;
    }
    if (a[n] == x) ans++;
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
priority_queue<ll> L; ll lsum;
priority_queue<ll,vector<ll>,greater<ll> >R; ll rsum;
int main(){
  ll q;cin>>q;
  lsum=rsum=0; ll hoge=0,fi=1;
  while(q--){
      ll t,a,b;cin>>t;
      if(t==1){
	  cin>>a>>b; hoge+=b;
	  if(fi||a<=L.top()){L.push(a); lsum+=a;}
	  else{R.push(a); rsum+=a;}
	  while(L.size()>=R.size()+2){
	      ll x=L.top();
	      lsum-=x; L.pop();
	      R.push(x); rsum+=x;
	  }
	  while(R.size()>L.size()){
	      ll x=R.top();
	      rsum-=x; R.pop();
	      L.push(x); lsum+=x;
	  }
	  fi=0;
      }
      if(t==2){
	  ll x; if(L.size()>0)x=L.top(); else x=R.top();
	  //cout<<"#"<<L.size()<<" "<<R.size()<<endl;
	  //cout<<hoge<<" "<<rsum<<" "<<lsum<<endl;
	  cout<<x<<" "<<hoge+rsum-x*(ll)R.size()+x*(ll)L.size()-lsum<<endl;
      }
  }
  return 0;
}


Measured memory_bytes: 3828
n = int(input())
arr = list(map(int, input().split()))

for i in range(n):
  v = arr[i]
  j = i - 1
  while j >= 0 and arr[j] > v:
    arr[j + 1] = arr[j]
    j -= 1
  arr[j+1] = v
  print (" ".join([str(x) for x in arr]))


Measured memory_bytes: 5608
n, m, k = list(map(int, input().split()))

flag = False
for y in range(n+1):
    if n - 2 * y == 0:
        continue
        
    x = (k - m * y) / (n - 2 * y)
    
    if (k - m * y) % (n - 2 * y) == 0 and (0 <= x and x <= m):
        flag = True
        break
print("Yes" if flag else "No")

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

using namespace std;

class Doll {
public:
	int h, r;

	Doll() {
		h = r = 0;
	}
};

Doll DollData[200];
int DpResult[200];


bool cmp(const Doll& d1, const Doll &d2) {
	return d1.h < d2.h;
}

int main() {
	int n, m, i;

	while (cin >> n, n) {
		for (i = 0; i < n; i++) {
			cin >> DollData[i].h >> DollData[i].r;
		}
		cin >> m;
		m += n;
		for (; i < m; i++) {
			cin >> DollData[i].h >> DollData[i].r;
		}
		sort(DollData, DollData + m, cmp);
		for (i = 0; i < m; i++) {
			DpResult[i] = 1;
		}

		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				if ( DollData[i].h>DollData[j].h && DollData[i].r>DollData[j].r ) {
					DpResult[i] = max(DpResult[i], DpResult[j] + 1);
				}
			}
		}
		sort(DpResult, DpResult + m);
		cout << DpResult[m - 1] << endl;
	}

	return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>

using Map = std::map<int, int>;

long combi(long n)
{
  if (n < 2) return 0;
  return n * (n - 1) / 2;
}


long solve(
    int n,
    const std::vector<int>& values,
    const Map& counts,
    long sum,
    int k)
{
  auto it = counts.find(values[k]);
  return sum - combi(it->second) + combi(it->second - 1);
}

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

  std::vector<int> values(n);
  for (auto& v : values) {
    std::cin >> v;
  }

  Map counts;
  for (auto v : values) {
    counts[v] += 1;
  }

  long sum = 0;
  for (const auto& p : counts) {
    long c = p.second;
    sum += combi(c);
  }

  std::cout << std::setprecision(20);
  for (int i = 0; i < n; ++i) {
    std::cout << solve(n, values, counts, sum, i) << std::endl;
  }
}


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

int main() {
  int d,g;cin>>d>>g;
  vector<int> p(d),c(d);
  rep(i,d)cin>>p[i]>>c[i];
  int ans=1e9;
  rep(bit,1<<d){
    int cnt=0,sum=0,a=-1;
    rep(i,d){
      if(bit&(1<<i)){
        cnt+=p[i];
        sum+=100*(i+1)*p[i]+c[i];
      }
      else a=i;
    }
    if(sum<g){
      int sum1=100*(a+1);
      int x=(g-sum+sum1-1)/sum1;
      if(x>=p[a])continue;
      cnt+=x;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a;
    cin >> a;
    print(a + a * a + a * a * a);

}




//queue<pint>().swap(q); キュー内を全て削除
//priority_queue<ll, vector<ll>, greater<ll> > que;
//auto dp=make_v<int>(4,h,w);
//vector<vector<ll>> g;
//g.assign(n, vector<ll>()); g.resize(n);でも大丈夫っぽい
//fill_v(dp,0);

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 179, task b, 2020/09/19
//ms,

/*
*/

int main(void){
  int N;
  int d1, d2;
  int bingo=0;
  int ans=0;

  cin >>N;
  for(int i=0;i<N;i++){
    cin >>d1 >>d2;
    if(d1==d2) bingo++;
    else bingo=0;

    if(bingo==3) ans=1;
  }

  if(ans) cout <<"Yes"<<endl;
  else cout <<"No"<<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <cassert>
#include <fstream>
#include <algorithm>
#include <list>
#include <random>
#include <ctime>
#include <cmath>
#include <random>
#include <bitset>
#include <complex>
#pragma unroll
#pragma loop count N
#pragma ivdep
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ld, ld> pld;
typedef complex<double> base;

#define mmin(a, b) a = min(a, (b))
#define mmax(a, b) a = max(a, (b))
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ALL(a) a.begin(),a.end()
#define sqr(x) (x) * (x)
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define cint const int &
#define SZ(a) ((int)(a.size()))
#define f(cnt) (((cnt) + 1) * (cnt) / 2)
#define watch(x) cout << (#x) << " = " << x << endl;

const double PI = 2 * acos(0.0);

template<class T>
void show(const set<T> &a) {
    for (T x : a)
        cout << x << " ";
    cout << endl;
}

template<class T>
void show(const vector<T> &a) {
    for (T x : a)
        cout << x << " ";
    cout << endl;
}



signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    vi a(n);
    fori (i, n)
         cin >> a[i];
    int prev  = -1;
    int cnt = 0;
    int ans = 0;
    fori (i, n) {
        if (a[i] == prev) {
            cnt++;
        } else {
            ans += cnt >> 1;
            cnt = 1;
            prev = a[i];
        }
    }
    ans += cnt >> 1;
    cout << ans;
}


Measured memory_bytes: 256
solve :: String -> Int
solve s = minimum $ zipWith (+) (scanl (\n x -> if x == 'W' then n+1 else n) 0 (init s))
                                (scanr (\x n -> if x == 'E' then n+1 else n) 0 (tail s))

main :: IO ()
main = do
  _n <- read <$> getLine :: IO [Int]
  s <- getLine :: IO String
  print $ solve s


Measured memory_bytes: 58748
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[100001];
int flag=0;
bool winner(int ar[],int n,int k){
	for(int i=1;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i<ar[j]){
				continue;
			}
			if(dp[i-ar[j]]==0){
				dp[i]=1;
			}
		
		}
	}
	return dp[k];
	}



signed main(){
	int n,k;
	cin>>n>>k;
	int ar[n];
	for(int i=0;i<n;i++){
		cin>>ar[i];
	}
	memset(dp,0,sizeof dp);
	if(winner(ar,n,k)){
		cout<<"First\n";
	}
	else{
		cout<<"Second\n";
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,l[300];
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=2*n;i++)scanf("%d",&l[i]);
        sort(l+1,l+1+2*n);
        int ans=0;
        for(int i=1;i<n*2;i+=2)ans+=l[i];
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,str;
    cin>>s;
    cin>>str;
    int n=s.length();
    int i=0;
    while(i<n)
    {
        if(str[i]!=s[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
        i++;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
import java.util.Arrays;
import java.util.Set;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int[]l=new int[N];
        for(int i=0;i<N;i++){
            l[i]=sc.nextInt();
        }
        Arrays.sort(l);
        int sum=0;
        for(int i=N-1;i>N-K-1;i--){
            sum+=l[i];
        }
        System.out.println(sum);


}
        
        
    }


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

string s;
vector<char> ta = {};
int rin = 1;

signed main(){
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		ta.push_back(s[i]);
	}
	while (1) {
		rin = 1;
		ta.pop_back();
		ta.pop_back();
		for (int i = 0; i < ta.size() / 2; i++) {
			if (ta[i] != ta[i + ta.size() / 2]) {
				rin = 0;
			}
		}
		if (rin == 1) {
			cout << ta.size() << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;

#define EPS 1e-8

int main(){
	
	map<string, int> mp;
	
	int maxi = 0;
	string s;
	string longest = "";
	while(cin >> s){
		mp[s]++;
		maxi = max(maxi, mp[s]);
		if(longest.size() < s.size()) longest = s;
	}
	
	for(auto it : mp){
		if(maxi == it.second) cout << it.first;
	}
	cout << " " << longest << endl;

	
	return 0;
}

Measured memory_bytes: 3140
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++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 REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	auto is_digit = [](char c) {return '0' <= c & c <= '9'; };
	ll a = in(), b = in();
	string s; cin >> s;
	cout << (all_of(s.begin(), s.begin() + a, is_digit) && s[a] == '-' && all_of(s.begin() + a + 1, s.end(), is_digit) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	vector<int> a(n),b(n),c(n-1);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n-1)cin>>c[i];
	int sum=0;
	rep(i,n){
		sum+=b[a[i]-1];
		if(i>0){
			if(a[i]-a[i-1]==1){
				sum+=c[a[i-1]-1];
			}
		}
	}
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
a=map(int,input().split())

import collections
c = collections.Counter(a)
m=0
for i in range(n//2):
    if n//2==n/2:
        if c[n-1-2*i]!=2:
            m=1
    else:
        if (i!=n//2-1 and c[n-1-2*i]!=2):
            m=1
        if (i==n//2 and c[n-1-2*i]!=1):
            m=1
if m==0:
    print(2**(n//2)%(10**9+7))
else:
    print(0)


Measured memory_bytes: 54124
import sys
input = sys.stdin.readline

N,L,T = map(int,input().split())
XW = [[int(x) for x in input().split()] for _ in range(N)]

X,W = zip(*XW)

DX = [1 if w == 1 else -1 for w in W]

Y = [(x+dx*T)%L for x,dx in zip(X,DX)]
y0 = Y[0]
Y.sort()

# 番号1がすれ違わず進んだ場所に相当するアリの番号
# すれ違うたびに1増える（W1=1） or 1減る（W1=-1）
# T秒ちょうどもすれ違い終わったと考える

x = 0
x0,dx0 = X[0],DX[0]
for y,dy in zip(X[1:],DX[1:]):
    if dx0 == dy:
        continue
    if dx0 == 1 and dy == -1:
        # 正の向きに追い越すので番号がひとつ増える
        x += (2*T-(y-x0)-1)//L + 1
    if dx0 == -1 and dy == 1:
        x -= (2*T-(L+x0-y))//L + 1
x %= N

i = Y.index(y0)

Y += Y

answer = [None] * N
answer[x:N] = Y[i:i+N-x]
answer[0:x] = Y[i+N-x:i+N]

print('\n'.join(map(str,answer)))



Measured memory_bytes: 34272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,c;
    cin>>n>>k;
    n%=k;
    cout<<min(n,k-n)<<endl;
    /*if(n==1 || k==1){cout<<0<<endl; return 0;}
     int x=abs(n-k);
    while(1){


    int y=abs(x-k);

    }*/
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
s_amount = 0

l = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
  for j in range(i):
    s_amount += math.sqrt((l[i][0] - l[j][0]) ** 2 + (l[i][1] - l[j][1]) ** 2)
    
print(s_amount / sum([i for i in range(n)]) * (n-1))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	vector<vector<int>> vvi;
	for(int i=0;i<n;i++)
	{
		vector<int> vi;
		for(int j=0;j<d;j++)
		{
			int a;
			cin>>a;
			vi.push_back(a);
		}
		vvi.push_back(vi);
	}
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int sum = 0;
			for(int k=0;k<d;k++)
			{
				int a = vvi[i][k];
				int b = vvi[j][k];
				int c = abs(a-b);
				sum+=c*c;
			}
			double no = sqrt(sum);
			int yan = no;
			if(yan*yan == sum)ans++;
		}
	}
	cout<<ans<<endl;
}

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

const int N = 1e4 + 5;
int A[N];

int main () {
	int n;
	scanf("%d", &n);

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


	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (A[i] == A[i-1]) {
			ans++;
			i++;
		}
	}
	
	printf("%d\n", ans);
	return 0;
}

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

int f(int x) {
  int out = 0;
  while (x >= 1) {
    out += x%10;
    x /= 10;
  }
  return out;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for (int i = 1; i <= N; i++) {
    int x = f(i);
    if (A <= x && x <= B) sum += i;
  }
  cout << sum << endl;
}


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

int main() {
	int H, W;
	int c[10][10];
	cin >> H >> W;
	for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) cin >> c[i][j];
	int dist[10];
	using P = pair<int, int>;
	priority_queue<P, vector<P>, greater<P>> Queue;
	for (int i = 0; i < 10; i++) {
		dist[i] = c[i][1];
		Queue.push({ dist[i],i });
	}
	while (!Queue.empty()) {
		const auto item = Queue.top();
		Queue.pop();
		for (int i = 0; i < 10; i++) {
			int newdist = item.first + c[i][item.second];
			if (newdist < dist[i]) {
				dist[i] = newdist;
				Queue.push({ newdist, i });
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int a;
			cin >> a;
			ans += (a >= 0 ? dist[a] : 0);
		}
	}
	cout << ans << endl;
}


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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("20");
            //15800
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("60");
            //47200
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int N = int.Parse(InputList[0]);

        int X = 800 * N;
        int Y = N / 15 * 200;

        Console.WriteLine(X - Y);
    }
}


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



int main() {
  ll a;
  string s;
  cin>>a>>s;
  double b;
  b=stod(s);
  int B=int(b);
  b-=double(B);
  ll ans=0;
  ans+=a*B;
//  cout<<ans<<endl;
  char s1=s[s.size()-2];
  char s2=s[s.size()-1];

  int s3=s1-'0';
  int s4=s2-'0';
  int s5=s3*10+s4;
  //cout<<s5<<endl;
  ll ans2=s5*a;
  ans2/=100;
  ans+=ans2;
//  int temp=s1*10+s2;
  //cout<<s1<<' '<<s2<<endl;

  cout<<ans;

}


Measured memory_bytes: 3704
import java.util.*;

public class Main {

    static long pow(long a,int n) {
        long res=1;
        while (n>0) {
            if ((n-n/2*2)==1) {
                res=res*a;
            }
            a=a*a;
            n>>=1;
        }
        return res;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long ans = 0;
        for (int i=1;i<=N;i++) {
            String S = String.valueOf(i);
            int left = (int)S.charAt(0)-48;
            int right = (int)S.charAt(S.length()-1)-48;
            if (right==0) continue;
            if (left==right && N>=right) ans++;
            // if (left!=right) {
                // if (i==105) System.out.println("KKKKKKKKKKKKKK");
                // if (i==106) System.out.println("KKKKKKKKKKKKKK");
                for (int j=1;j<10;j++) {
                    long tmp = (long)right*pow(10, j)+left;
                    long nine_nine = pow(10, j)-10;
                    // System.out.println("i "+i);
                    // System.out.println(tmp+" "+(tmp+nine_nine));
                    // if (N>=tmp+nine_nine) {
                    if (N<tmp) {
                        long add = j==1?0:pow(10, j-2);
                        // ans += pow(10, j-1);
                        ans += add;
                        // System.out.println("i, add_N<tmp "+i+" "+add);
                        break;
                    } else if (tmp<=N && N<tmp+nine_nine) {
                        ans += j==1?0:pow(10, j-2);
                        ans += ((N-tmp)/10);
                        // System.out.println("i, tmp<=N "+i+" "+((N-tmp)/10));
                        // System.out.println("ans+ " + (N-tmp)/10);
                        String N_str = String.valueOf(N);
                        // System.out.println((int)N_str.charAt(N_str.length()-1)-48);
                        // if ((int)N_str.charAt(N_str.length()-1)-48>=left) ans++;
                        ans++;
                        break;
                    }
                    if (j>=2) ans += pow(10, j-2);
                }
            // } else { // left==right
            // }
            // System.out.println(left+" "+right);
        }
        System.out.println(ans);
    }
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> d(k);
    vector<bool> num(n);
    rep(i,0,k){
        int d;
        cin>>d;
        rep(j,0,d){
            int a;
            cin>>a;
            a--;
            num[a]=true;
        }
    }
    int ans=0;
    for(auto i:num)ans+=(!i);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include<algorithm>
  
using namespace std;
  
int main()
{
    int n,k,nn;
    int x[1000];
    int y[1000];
    int z[1000];
    cin>>n>>k;
  
    for(int i=0;i<k;i++){
        cin>>x[i];
        cin>>y[i];
    }
    for(int i=0;i<k;i++){
    if(n-x[i]<x[i])
        x[i]=n-x[i]+1;
    if(n-y[i]<y[i])
        y[i]=n-y[i]+1;
  
    if(x[i]>y[i])
        z[i]=y[i]%3;
    if(y[i]>x[i])
        z[i]=x[i]%3;
    if(x[i]==y[i])
        z[i]=x[i]%3;
    if(z[i]==0)
        z[i]=3;
    cout<<z[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1172
#include <queue>
#include <string>
#include <iostream>
#include <utility>
using namespace std;

int main() {
  queue<pair<string,int> > Q;
  int n,q;
  cin >> n >> q;
  string name;
  pair<string,int> task("0",0);
  int time,clock=0;
  for(int i =0; i< n;i ++){
    cin >> name >> time;
    Q.push(make_pair(name,time));
  }
  while(Q.size() != 0){
    task =Q.front();
    if(task.second <= q){
      clock+=task.second;
      cout << task.first <<" "<< clock <<endl;
      Q.pop();
    }
    else {
      task.second-=q;
      clock +=q;
      Q.pop();
      Q.push(task);
  }
}


  return 0;
}

Measured memory_bytes: 4408
N, X, Y = tuple(int(v) for v in input().split())

ans = [0 for _ in range(N)]

for i in range(N):
    for j in range(i+1, N):
        # 単純な距離
        d = j - i

        # 短絡パスを使った距離
        #   始点から X まで行く
        to_X   = abs(X-1 - i)
        #   Y から終点まで行く
        from_Y = abs(Y-1 - j)
        d_p = to_X + from_Y + 1
        ans[min(d, d_p)] += 1
        # if i <= X-1 and Y-1 <= j:
        #     d -= Y - X - 1
        # print(i+1, j+1, d)
        # ans[d] += 1

for n in ans[1:]:
    print(n)


Measured memory_bytes: 3444