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

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N), B(N), C(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }
    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    A.push_back(INT_MAX);
    B.push_back(INT_MAX);
    C.push_back(INT_MAX);

    int a = 0, b = 0, c = 0;
    string s;
    while (a < N || b < N || c < N) {
        if (c < N && C[c] <= A[a] && C[c] <= B[b]) {
            s += "C";
            c++;
        } else if (b < N && B[b] <= A[a] && B[b] <= C[c]) {
            s += "B";
            b++;
        } else if (a < N && A[a] <= B[b] && A[a] <= C[c]) {
            s += "A";
            a++;
        }
        //cout << s << endl;
    }

    long long Cnum = 0, BCnum = 0, ans = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == 'A') {
            ans += BCnum;
        } else if (s[i] == 'B') {
            BCnum += Cnum;
        } else {
            Cnum++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3424
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
L = L[::-1]
ans = 0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      if L[i] == L[j]:
        ans += 0
      elif L[i] == L[k]:
        ans += 0
      elif L[j] == L[k]:
        ans += 0
      elif L[i] < L[j]+L[k]:
        ans += 1
print(ans)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define maxn 3005
#define MOD 998244353
#define INF 10000000

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

ll dp[maxn][maxn];

void solve(){
    ll n, s, ans = 0;
    cin >> n >> s;
    ll a[n];
    for(ll i = 0; i < n; i++) cin >> a[i];

    for(ll i = 0; i < n; i++){
        memcpy(dp[i+1], dp[i], sizeof(dp[0]));

        dp[i+1][a[i]] = (dp[i+1][a[i]] + i+1)%MOD;
        for(ll j = 0 ; j+a[i]<= s; j++){
            dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j])%MOD;
        }
        ans  = (ans + dp[i+1][s])%MOD;
    }
    cout << ans ;
}

int main()
{
    fast();
    int t= 1; //cin >> t;
    while(t--){
        solve();
    }
}

/*
5
1 2
2 3
3 4
3 5
*/


Measured memory_bytes: 70656
import java.util.Scanner;

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



Measured memory_bytes: 26348
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AAtCoderContest {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string a, s, c;
	    in >> a >> s >> c;
	    out << "A" << s[0] << "C" << endl;
	}
};


int main() {
	AAtCoderContest solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
    int num,card[4][13]={{0}},i,temp;
    char face;
    scanf("%d\n",&num);
    for (i=0; i<num; i++) {
        scanf("%c %d\n",&face,&temp);
        if (face=='S') {
            card[0][temp-1]=1;
        } else if (face=='H') {
            card[1][temp-1]=1;
        } else if (face=='C') {
            card[2][temp-1]=1;
        } else if (face=='D') {
            card[3][temp-1]=1;
        }
    }
    for (i=0; i<13; i++) if (card[0][i]==0) printf("S %d\n",i+1);
    for (i=0; i<13; i++) if (card[1][i]==0) printf("H %d\n",i+1);
    for (i=0; i<13; i++) if (card[2][i]==0) printf("C %d\n",i+1);
    for (i=0; i<13; i++) if (card[3][i]==0) printf("D %d\n",i+1);
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int nc2(int x)
{
	return (x*(x-1))/2;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	cout<<nc2(n)+nc2(m)<<"\n";
}

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

using namespace std;

int isSheepFn(bool prevTest, int prevIsSheep, int prevprevIsSheep) {
    int ret = 0;
    if (prevIsSheep == 1 && prevTest) {
        if (prevprevIsSheep == 1) {
            ret = 1;
        }
        else {
            ret = -1;
        }
    }
    else if (prevIsSheep == 1 && !prevTest) {
        if (prevprevIsSheep == 1) {
            ret = -1;
        }
        else {
            ret = 1;
        }
    }
    else if (prevIsSheep == -1 && prevTest) {
        if (prevprevIsSheep == 1) {
            ret = -1;
        }
        else {
            ret = 1;
        }
    }
    else { // prevIsSheep == -1 && !prevTest
        if (prevprevIsSheep == 1) {
            ret = 1;
        }
        else {
            ret = -1;
        }
    }
    return ret;
}

bool check(vector<int>& isSheep, const vector<bool>& testemonies) {
    int N = testemonies.size();
    for (int i = 2; i < N; ++i) {
        isSheep[i] = isSheepFn(testemonies[i - 1], isSheep[i - 1], isSheep[i - 2]);
    }

    bool ret = false;
    if (isSheepFn(testemonies[N - 1], isSheep[N - 1], isSheep[N - 2]) == isSheep[0]
            && isSheepFn(testemonies[0], isSheep[0], isSheep[N - 1]) == isSheep[1]) {
        ret = true;
    }
    return ret;
}

void serializeAndOut(const vector<int>& isSheep) {
    for (int i = 0; i < isSheep.size(); ++i) {
        cout << (isSheep[i] == 1 ? "S" : "W");
    }
    cout << endl;
}

void Main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    vector<bool> testemonies(N, true);
    for (int i = 0; i < N; ++i) {
        testemonies[i] = (s[i] == 'o');
    }

    vector<int> isSheep(N, 0);
    // SS...
    isSheep[0] = 1;
    isSheep[1] = 1;
    if (check(isSheep, testemonies)) {
        serializeAndOut(isSheep);
        return;
    }

    // SW...
    isSheep[0] = 1;
    isSheep[1] = -1;
    if (check(isSheep, testemonies)) {
        serializeAndOut(isSheep);
        return;
    }

    // WS...
    isSheep[0] = -1;
    isSheep[1] = 1;
    if (check(isSheep, testemonies)) {
        serializeAndOut(isSheep);
        return;
    }

    // WW...
    isSheep[0] = -1;
    isSheep[1] = -1;
    if (check(isSheep, testemonies)) {
        serializeAndOut(isSheep);
        return;
    }

    cout << -1 << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

// 最大公約数
lint gcd(lint a, lint b) {
    // 引数の一方が 0 なら他方の値を返す
    return b ? gcd(b, a%b) : a;
}

int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    int g = gcd(a, b);
    if (c % g == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]

t = 0
for i in range(N):
    for j in range(i, N):
        t += ((X[i] - X[j])**2 + (Y[i] - Y[j])**2)**0.5
print(2*t/N)

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

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

   cout << (n-1) * (m-1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll q; cin >> q;
    ll sum = 0;
    priority_queue<ll,vector<ll>,less<ll>> up; ll up_sum = 0; // maxを優先
    priority_queue<ll,vector<ll>,greater<ll>> back; ll back_sum = 0; // minを優先
    rep(i,q){
        ll type; cin >> type;
        if(type == 1){
            ll a, b; cin >> a >> b;
            sum += b;
            if(up.size() > back.size()){
                ll check = up.top();
                if(a >= check){
                    back.push(a);
                    back_sum += a;
                }
                else{
                    up.pop();
                    up_sum -= check;
                    up.push(a);
                    up_sum += a;
                    back.push(check);
                    back_sum += check;
                }
            }
            else{
                if(up.empty()){
                    up.push(a);
                    up_sum += a;
                }
                else{
                    ll check = back.top();
                    if(a <= check){
                        up.push(a);
                        up_sum += a;
                    }
                    else{
                        back.pop();
                        back_sum -= check;
                        back.push(a);
                        back_sum += a;
                        up.push(check);
                        up_sum += check;
                    }
                }
            }
        }
        else{
            ll x = up.top();
            ll res = x*(ll)up.size()-up_sum + back_sum-x*(ll)back.size() + sum;
            cout << x << " " << res << endl;
        }
    }
    return 0;
}

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

#define int long long int
#define MOD 1000000007

int dp[1005][1005] ;

int32_t main()
{
    int t = 1 ;
    //cin >> t ;
    while(t--)
    {
        int h, w ;
        cin >> h >> w ;
        char a[h][w] ;
        for(int i = 0 ; i < h ; i++)
        {
            for(int j = 0 ; j < w ; j++)
            {
                cin >> a[i][j] ;
            }
        }
        dp[0][0] = 1 ;
        for(int i = 1 ; i < h ; i++)
        {
            if(a[i][0] == '#')
                dp[i][0] = 0 % MOD ;
            else
                dp[i][0] =  dp[i-1][0] % MOD ;
        }
        for(int i = 1 ; i < w ; i++)
        {
            if(a[0][i] == '#')
                dp[0][i] = 0 ;
            else
                dp[0][i] =  dp[0][i-1] % MOD ;
        }
        for(int i = 1 ; i < h ; i++)
        {
            for(int j = 1 ; j < w ; j++)
            {
                if(a[i][j] == '#')
                    dp[i][j] = 0 ;
                else
                {
                    dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD ;
                }
            }
        }
        cout << dp[h-1][w-1] ;
    }
    return 0 ;
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k =0;
		String bef = "";
		StringBuffer sb = new StringBuffer();
		for (int i=0;i<s.length();i++) {
			sb.append(s.charAt(i));
			if (sb.toString().equals(bef)==false) {
				bef= sb.toString();
				sb = new StringBuffer();
				k++;
			}
		}
		System.out.println(k);
	}
}

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

int main(void){
	int a,b,C;

	scanf("%d %d %d", &a, &b, &C);

	double L = a + b + sqrt(a*a + b*b - 2.0*a*b*cos(C*M_PI/180));
	double h = b*sin(C*M_PI/180);
	double S = a*h/2.0;

	printf("%.8f\n%.8f\n%.8f\n", S,L,h);

	return 0;
}

Measured memory_bytes: 688
fun main(args: Array<String>) {
    val s = readInputLine().toCharArray()
    
    if (s[0] != 'A') {
        println("WA")
        return
    }
    
    var isCExists = false

    for ((i, c) in s.withIndex()) {
        if (i == 0) {
            continue
        }
        
        if (i == 1 && (c < 'a' || 'z' < c)) {
            println("WA")
            return
        }
        
        if (i < s.size - 1 && c == 'C') {
            if (isCExists) {
                println("WA")
                return
            }
            isCExists = true
            continue
        }
        
        if (c < 'a' || 'z' < c) {
            println("WA")
            return
        }
    }
    
    if (isCExists) {
        println("AC")
    } else {
        println("WA")
    }
}
 
fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 34216
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[][] map = new int[3][3];
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                map[i][j] = sc.nextInt();
            }
        }
        boolean bool = true;
        if(!(map[0][0]-map[0][1] == map[1][0]-map[1][1] && map[0][1]-map[0][2] == map[1][1]-map[1][2] && map[0][0]-map[0][1] == map[2][0]-map[2][1] && map[0][1]-map[0][2] == map[2][1]-map[2][2])) bool = false;
        if(!(map[0][0]-map[1][0] == map[0][1]-map[1][1] && map[1][0]-map[2][0] == map[1][1]-map[2][1] && map[0][0]-map[1][0] == map[0][2]-map[1][2] && map[1][0]-map[2][0] == map[1][2]-map[2][2])) bool = false;
        System.out.println(bool ? "Yes" : "No");
    }
}


Measured memory_bytes: 23636
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0]);
  d1 = new Array(n).fill(n);
  d1[0]=0;
  d2 = new Array(n).fill(n);
  d2[n-1]=0;
  side = new Array(n).fill([]);
  for(i=0;i<n-1;i++){
    var a = parseInt(input[i+1].split(" ")[0])-1;
    var b = parseInt(input[i+1].split(" ")[1])-1;
    if(side[a].length==0){
    side[a]=[b];
    }else{
    side[a].push(b);
    }
    if(side[b].length==0){
      side[b]=[a];
    }else{
    side[b].push(a);
    }
  }
  queue2 = new Array();
  function f(x,d){
    queue = new Array();
    queue[0]=x;
    while(queue.length!=0){
      for(i=0;i<side[x].length;i++){
        if(d[side[x][i]]>d[x]){
          d[side[x][i]]=d[x]+1;
          queue.push(side[x][i]);
        }
      }
      queue.shift();
      x=queue[0];
    }
    return d;
  }
  d1=f(0,d1);
  d2=f(n-1,d2);
  var x=0;
  for(i=0;i<n;i++){
    if(i!=0&&i!=n-1){
      if(d1[i]<=d2[i]){
        x++;
      }
    }
  }
  var ans="Fennec";
  if(x<=n-2-x){
    ans="Snuke";
  }

  console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 61716
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int ans=0;
    for(int i=1;i<N+1;i++){
    	ans+=i;
    }
    System.out.print(ans);
    System.out.flush();
    sc.close();
  }
}

Measured memory_bytes: 23124
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N;
  cin >> N;
  set<string> st;
  char prev;
  rep(i, N) {
    string s;
    cin >> s;
    if (i != 0) {
      if (s[0] != prev) { cout << "No" << endl; return 0; }
    }
    if (st.find(s) != st.end()) { cout << "No" << endl; return 0; }
    st.insert(s);
    prev = s[s.size() - 1];
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    M, K = map(int, input().split())
    N = 2**M
    if M == 1:
        if K == 0:
            print(*[0, 0, 1, 1])
        else:
            print(-1)
        return
    if K >= N:
        print(-1)
        return
    ans = [x for x in range(N) if x != K]
    ans = ans + [K] + ans[::-1] + [K]
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 69360
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int main()
{
	int n;
	cin >> n;
	deque< int > dq;
	int x;
	cin >> x;
	dq.push_front(x);
	for(int i = 1 ; i < n ; i++){
		int x;
		cin >> x;
		if(i%2)
			dq.push_back(x);
		else
			dq.push_front(x);
	}

	while(!dq.empty()){
		if(n % 2 == 0){
		cout << dq.back() <<" ";
		dq.pop_back();}
		else
		{
			cout << dq.front() <<" ";
			dq.pop_front();
			
		}
	}
	return 0;
} 




Measured memory_bytes: 2944
pow5 = [1, 5, 25, 125, 625, 3125, 15625, 78125]

while True:
	n = int(input())
	if n == 0: break
	ans, i = 0, 1
	while n >= pow5[i]:
		ans += n // pow5[i]
		i += 1
	print(ans)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    // ios_base :: sync_with_stdio(false);
    // cin.tie(NULL), cout.tie(NULL);
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    double ans;
    if((x == w || x == 0) || (y == h || y == 0))
    {
        cout << fixed << setprecision(12) << (db)(w * h) / 2.0 << " " << 0 << endl;
        return 0;
    }
    ans = w * h / (2.0);
    printf("%.9lf ", ans);
    if(2 * x == w && 2 * y == h)
        cout << 1;
    else
        cout << 0;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(int i=(s);i<(t);++i)
#define per(i,s,t) for(int i=((t)-1);i>=s;--i)
#define repb(i,s,t) for(int i=(s);i<=(t);++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define dd(x) cout<<#x<<'='<<x<<' '
#define de(x) cout<<#x<<'='<<x<<'\n'
#define fi first
#define se second
#define sq(x) ((x)*(x))
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;

const int inf = 0x3f3f3f3f;
const ll mod = 1e9+7;
const db eps = 1e-8;

char io[1<<15],*is=io,*ie=io+1;
#define rd if(++is==ie)ie=(is=io)+fread(io,1,sizeof(io),stdin)
template<class T>
inline bool Cin(T &a){
	a=0;bool s=0;
	if(is==ie)return 0;
	do{rd;if(*is=='-')s=1;}while(!isdigit(*is)&&is!=ie);
	if(is==ie)return 0;
	do{(a*=10)+=*is&15;rd;}while(isdigit(*is)&&is!=ie);
	if(s)a=-a;;return 1;}

inline int Gets(char a[]){
	int p=0;
	if(is==ie)return 0;
	do rd; while(!isgraph(*is)&&is!=ie);
	if(is==ie)return 0;
	do {a[p++]=*is;rd;}while(isgraph(*is)&&is!=ie);
	a[p]=0;return p;}

#define maxn 10005

vector<int> p;
bool isp[maxn];
ll a[502][502];

ll lcm(ll x,ll y){return x/__gcd(x,y)*y;}

int main()
{
	int n;
	Cin(n);
	if(n==2)return !printf("4 7\n23 10\n");
	mst(isp,0);p.clear();
	for(int i=2;sz(p)<2000;++i)
	{
		if(!isp[i])p.pb(i);
		for(int j=0;j<sz(p)&&p[j]*i<maxn;++j)
		{
			isp[p[j]*i]=1;
			if(i%p[j]==0)break;
		}
	}
	repb(i,0,n+1)a[0][i]=a[n+1][i]=a[i][0]=a[i][n+1]=1;

	repb(i,1,n)repb(j,1,n)if((i+j)%2==0)
		a[i][j]=p[(i+j)/2-1]*p[n+(i+n+1-j)/2-1];
	
	repb(i,1,n)repb(j,1,n)if((i+j)%2==1)
		a[i][j]=lcm(a[i-1][j],lcm(a[i+1][j],lcm(a[i][j-1],a[i][j+1])))+1;
	
	repb(i,1,n)repb(j,1,n)printf("%lld%c",a[i][j]," \n"[j==n]);
	
}

Measured memory_bytes: 5120
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;


int n, m;
string s;

int main() {
    cin >> n;

    Vi v(n);
    REP(i, n) cin >> v[i];

    int cnt = 0;
    int absmin = 1e9;
    ll sum = 0;
    REP(i, n) {
        if (v[i] < 0) cnt++;
        if (abs(v[i]) < absmin) absmin = abs(v[i]);
        sum += abs(v[i]);
    }

    if (cnt%2 == 0) {
        std::cout << sum << '\n';
    } else {
        std::cout << sum - absmin*2 << '\n';
    }

    return 0;
}


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

using ll=long long;
#define int ll

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

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

signed main(){
	while(true){
		int N=read();
		if(N==0) break;
		vector<vector<int>> p;
		p.resize(N);
		REP(i,N){
			int M=read();
			REP(j,M){
				p[i].push_back(read());
			}
		}
		int K=read();
		int l[K];
		REP(i,K){
			l[i]=read();
		}
		int ans=0;
		REP(i,N){
			REP(k,K){
				if(find(p[i].begin(),p[i].end(),l[k])==p[i].end()){
					break;
				}
				if(k==K-1){
					if(ans==0) ans = i+1;
					else ans = -1;
				}
			}
		}
		if(ans==0) cout << -1 << endl;
		else cout << ans << endl;
	}
	
	
	
}

Measured memory_bytes: 3284
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>

#define max  100000

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}


int main(void){
    long int q, i, flag=0, a, b, c, ans, k;

    scanf("%ld%ld%ld%ld", &a, &b, &c, &k);
    
    if (a>=k) {
        ans=k;
    } else {
        k=k-a;
        if (b>=k) {
            ans=a;
        } else {
            k=k-b;
            ans=a-k;
        }
    }

    printf("%ld", ans);
    
    return 0;
}


Measured memory_bytes: 1728
N = int(input())
evidence = [[] for _ in range(N)]
for i in range(N):
  A = int(input())
  for _ in range(A):
    x,y = map(int,input().split())
    evidence[i].append((x-1,y))
result = 0
for j in range(1,2**N):
  consistent = True
  for k in range(N):
    if (j >> k) & 1 == 0:
      continue
    for x,y in evidence[k]:
      if (j >> x) & 1 != y:
        consistent = False
        break
    if not consistent:
      break
  if consistent:
    result = max(result, bin(j)[2:].count("1"))
print(result)

Measured memory_bytes: 9152
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]){
        cout << "Bad" << endl;
        return 0;
    }
    cout << "Good" << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
 
int main(){
	int n, k;
	scanf("%d%d", &n, &k);
	if (n + 1 < k << 1){
		printf("-1\n");
		return 0;
	}
	for (int i = n - 1, j = n - 1, w = n >> 1; j >= 0; --i, j -= 2, ++w)printf("%d %d %d\n", k + w, k + n + j, k + 2 * n + i);
	for (int i = n / 2 - 1, j = n - 2, w = 0; j >= 0; --i, j -= 2, ++w)printf("%d %d %d\n", k + w, k + n + j, k + 2 * n + i);
}

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

const int maxn = 1e5+5;
int n, a[maxn];
int pre[maxn];

int bit[3*maxn];
void add(int i, int x) {
    i += maxn;
    for (; i < 3*maxn; i += i & (-i))
        bit[i] += x;
}

int sum(int i) {
    i += maxn;
    int r = 0;
    for (; i; i -= i & (-i)) {
        r += bit[i];
    }
    return r;
}

ll cnt(int x) {
    for (int i = 1; i <= n; i++) {
        pre[i] = a[i] < x ? -1 : 1;
        pre[i] += pre[i-1];
    }
    memset(bit,0,sizeof bit);
    ll res = 0;
    add(0,1);
    for (int i = 1; i <= n; i++) {
        res += sum(2*maxn)-sum(pre[i]);    
        add(pre[i],1);
    }
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    ll num = 1LL*n*(n+1)/4;
    int lo = 0, hi = 1e9+9;
    while (lo + 1 < hi) {
        int mid = (lo+hi)/2;
        //cout << mid << ": " << cnt(mid) << '\n';
        if (cnt(mid) <= num) lo = mid;
        else hi = mid;
    }
    cout << lo << '\n';
    /*
    cout << '\n';
    for (int i = hi-5; i <= hi+15; i++) {
        cout << i << ": " << cnt(i) << '\n';
    }
    */
}


Measured memory_bytes: 2176
N,x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
if a[0] > x:
    count += a[0] - x
    a[0] = x
for i in range(1,N):
    if a[i-1]+a[i] > x:
        count += (a[i-1]+a[i]) - x
        a[i] = x - a[i-1]
print(count)

Measured memory_bytes: 14052
def modinv(x, mod):
    a,b = x,mod
    u,v = 1,0
    while b:
        t = a//b
        a -= t*b; a,b = b,a
        u -= t*v; u,v = v,u
    return u%mod

def _garner(xs, mods):
    M = len(xs)
    coeffs = [1]*M
    constants = [0]*M
    for i in range(M-1):
        mod_i = mods[i]
        v = (xs[i] - constants[i]) * modinv(coeffs[i], mod_i) % mod_i
        for j in range(i+1,M):
            mod_j = mods[j]
            constants[j] = (constants[j] + coeffs[j] * v) % mod_j
            coeffs[j] = (coeffs[j] * mod_i) % mod_j

    return constants[-1]


def bit_reverse(d):
    n = len(d)
    ns = n>>1; nss = ns>>1
    ns1 = ns + 1
    i = 0
    for j in range(0, ns, 2):
        if j<i:
            d[i], d[j] = d[j], d[i]
            d[i+ns1], d[j+ns1] = d[j+ns1], d[i+ns1]
        d[i+1], d[j+ns] = d[j+ns], d[i+1]
        k = nss; i ^= k
        while k > i:
            k >>= 1; i ^= k
    return d

class NTT:
    def __init__(self, mod, primitive_root):
        self.mod = mod
        self.root = primitive_root

    def _ntt(self, a, sign):
        n = len(a)
        mod, g = self.mod, self.root
        tmp = (mod - 1) * modinv(n, mod) % mod # -1/n
        h = pow(g, tmp, mod) # ^n√g
        if sign < 0: h = modinv(h, mod)

        a = bit_reverse(a)

        m = 1
        while m < n:
            m2 = m<<1
            _base = pow(h, n//m2, mod)
            _w = 1
            for x in range(m):
                for s in range(x,n,m2):
                    u = a[s]
                    d = a[s+m]* _w % mod
                    a[s] = (u+d)%mod
                    a[s+m] = (u-d)%mod
                _w = _w * _base % mod
            m <<= 1
        return a

    def ntt(self, a):
        return self._ntt(a,1)

    def intt(self, a):
        mod = self.mod
        n = len(a)
        n_inv = modinv(n, mod)
        a = self._ntt(a,-1)
        for i in range(n):
            a[i] = a[i]*n_inv%mod
        return a

    def convolution(self, a, b):
        mod = self.mod
        ret_size = len(a)+len(b)-1
        n = 1 << (ret_size-1).bit_length()
        _a = a + [0] * (n - len(a))
        _b = b + [0] * (n - len(b))
        _a = self.ntt(_a)
        _b = self.ntt(_b)
        _a = [x*y%mod for x,y in zip(_a,_b)]
        _a = self.intt(_a)
        _a = _a[:ret_size]
        return _a


def convolution_ntt(a, b, mod):
    a = [x%mod for x in a]
    b = [x%mod for x in b]

    mods = (167772161, 469762049, 1224736769, mod)

    ntt1 = NTT(mods[0], 3)
    ntt2 = NTT(mods[1], 3)
    ntt3 = NTT(mods[2], 3)

    x1 = ntt1.convolution(a, b)
    x2 = ntt2.convolution(a, b)
    x3 = ntt3.convolution(a, b)

    n = len(x1)
    ret = [0]*n
    for i in range(n):
        xs = [x1[i], x2[i], x3[i], 0]
        ret[i] = _garner(xs, mods)

    return ret

m,k = map(int,input().split())
f = list(map(int,input().split()))
n = max(f)+1
g = [0]*n
for x in f: g[x] += 1
h = convolution_ntt(g,g,10**11)
ans = 0
cnt = 0
for i in range(len(h)-1,-1,-1):
    if cnt + h[i] < k:
        ans += h[i]*i
        cnt += h[i]
    else:
        ans += (k-cnt)*i
        break
print(ans)


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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a, i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = 0; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

//* main */
int i, j, k;
int d[200000], t[200000];
int main() {
	int n, m, c = 0, f = 0;
	scanf("%d", &n);
	REP(i, n)scanf("%d", &d[i]);
	qsort(d, n, sizeof(int), cmp);
	scanf("%d", &m);
	REP(i, m)scanf("%d", &t[i]);
	qsort(t, m, sizeof(int), cmp);
	REP(i, m) {
		for (; c < n; c++) if (t[i] == d[c]) {
			f++;
			c++;
			break;
		}
	}
	YES(f == m);
	return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int64_t> p(N+1);
  for (int i = 0; i <= N; i++){
    if(i==0){
      p.at(i)=2LL;
    }
    else if(i==1){
      p.at(i)=1LL;
    }
    else{
      p.at(i)=p.at(i-1)+p.at(i-2);
    }
  }
  cout<<p.at(N)<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  string S;
  cin >> S;
  ll K;
  cin >> K;

  ll N = S.size();

  char lastChar = S[N-1];
  int len = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == lastChar) len++;
    else len = 0;
  }
  if (len == N) { // single char type
    cout << (N * K) / 2 << endl;
    return 0;
  }
  bool secondStartFromOdd = (len % 2 == 1 && S[0] == lastChar);
  int first = 0, second = 0;
  lastChar = S[0];
  len = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == lastChar) len++;
    else {
      lastChar = S[i];
      len = 1;
    }
    if (len % 2 == 0) first++;
  }
  lastChar = S[0];
  len = 0;
  if (secondStartFromOdd) len = 1;
  for (int i = 0; i < N; i++) {
    if (S[i] == lastChar) len++;
    else {
      lastChar = S[i];
      len = 1;
    }
    if (len % 2 == 0) second++;
  }

  cout << (first + second * (K-1)) << endl;

  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=readline()
    if occursin("RRR",s)
        println(3)
    elseif occursin("RR",s)
        println(2)
    elseif occursin("R",s)
        println(1)
    else
        println(0)
    end
end
main()

Measured memory_bytes: 155648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, R; cin >> N >> R;
  if(N >= 10){
    cout << R << endl;
  }else{
    cout << R + 100 * (10 - N) << endl;
  }
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] x = new int[M];
        int[] y = new int[M];
        for (int i = 0; i < M; ++i) {
            x[i] = sc.nextInt() - 1;
            y[i] = sc.nextInt() - 1;
        }
        boolean[] memo = new boolean[N];
        memo[0] = true;
        int[] count = new int[N];
        Arrays.fill(count, 1);

        for (int i = 0; i < M; ++i) {
            if (memo[x[i]]) {
                memo[y[i]] = true;
            }
            --count[x[i]];
            ++count[y[i]];
            if (count[x[i]] == 0) {
                memo[x[i]] = false;
            }
        }
        int ans = 0;
        for (int i = 0; i < N; ++i) {
            if (memo[i]) {
                ++ans;
            }
        }
        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 64648
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output14.txt", "w", stdout);
#endif
	long long n;
	cin >> n;
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += i * (n / i) * (1 + n / i) / 2;
		///cout << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
from collections import deque
N = int(input())
g = [[] for i in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  g[b-1].append(a-1)
  g[a-1].append(b-1)
a = [-1]*N
b = [-1]*N
def bfs(n):
  q=deque()
  q.append(n)
  a[n] = 0
  while len(q):
    x=q.popleft()
    for i in g[x]:
      if a[i]==-1: 
        a[i]=a[x]+1
        q.append(i)
bfs(0)
def bfs2(n):
  q=deque()
  q.append(n)
  b[n] = 0
  while len(q):
    x=q.popleft()
    for i in g[x]:
      if b[i]==-1: 
        b[i]=b[x]+1
        q.append(i)
bfs2(N-1)
cnt = 0
for i in range(N):
  if a[i] <= b[i]:
    cnt += 1
  else:
    cnt -= 1
if cnt > 0:
  print('Fennec')
else:
  print('Snuke')

Measured memory_bytes: 29308
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    VLL X(N);
    rep(i,N){
        cin >> X[i];
    }
    VLL dif(N);
    rep(i,N-1){
        dif[i]=X[i+1]-X[i];
        dif[i]*=A;
    }
    ll ans=0;
    rep(i,N-1){
        if(dif[i]>=B){
            ans+=B;
        }
        else{
            ans+=dif[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4696
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int L = A + B;
		int R = C + D;
		if(L > R) {
			System.out.println("Left");
		}else if(L < R) {
			System.out.println("Right");
		}else if(L == R) {
			System.out.println("Balanced");
		}
		sc.close();
	}

}


Measured memory_bytes: 21844
def f():
    N = int(input())
    UP = []
    DOWN = []

    for _ in range(N):
        S = input()
        c = 0
        minC = 0

        for s in S:
            if s == '(':
                c += 1
            else:
                c -= 1
                minC = min(minC, c)

        if c >= 0:
            UP.append((minC, c))
        else:
            DOWN.append((c - minC, c))


    c = 0
    for up in sorted(UP, reverse=True):
        if c + up[0] < 0:
            return False

        c += up[1]

    for down in sorted(DOWN, reverse=True):
        if c + down[1] - down[0] < 0:
            return False

        c += down[1]

    if c != 0:
        return False

    return True


if  f():
    print('Yes')
else:
    print('No')


Measured memory_bytes: 84264
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
long gcd(long x, long y){ if (x > y){ return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y){ return (x / gcd(x, y) * y); }

using pll = pair<long, long>;
using W_graph = vector<vector<pll>>; // (next , cost)

int main(){

	long N; cin >> N;
	vector<long> A(N); for (int i = 0; i < N; i++) cin >> A[i];

	sort(A.begin(), A.end());
	long res = A[0];
	for (int i = 0; i < N - 1; i++){
		if (abs(2 * res - A[N - 1]) > abs(2 * A[i] - A[N - 1])) res = A[i];
	}

	cout << A[N - 1] << " " << res << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll cnt = 0;
  vector<int> r(n + 1, 0), g(n + 1, 0), b(n + 1, 0);
  for(int i = 0; i < n; i++){
    if(s[i] == 'R'){
      r[i + 1] = r[i] + 1;
      g[i + 1] = g[i];
      b[i + 1] = b[i];
    } else if(s[i] == 'G') {
      r[i + 1] = r[i];
      g[i + 1] = g[i] + 1;
      b[i + 1] = b[i];
    } else {
      r[i + 1] = r[i];
      g[i + 1] = g[i];
      b[i + 1] = b[i] + 1;
    }
  }
    for(int i = 0; i < n; i++) {
      for(int j = i + 1; j < n; j++) {
        if(s[i] == s[j]) {
          continue;
        }
        if(s[i] == 'R' && s[j] == 'G' || s[i] == 'G' && s[j] == 'R') {
          if(2 * j - i < n && s[2 * j - i] == 'B'){
            cnt += max(b[n] - b[j] - 1, 0);
          }else{
            cnt += b[n] - b[j];
          }
        }else if(s[i] == 'R' && s[j] == 'B' || s[i] == 'B' && s[j] == 'R'){
          if(2 * j - i < n && s[2 * j - i] == 'G'){
            cnt += max(g[n] - g[j] - 1, 0);
          }else{
            cnt += g[n] - g[j];
          }
        }else{
          if(2 * j - i < n && s[2 * j - i] == 'R'){
            cnt += max(r[n] - r[j] - 1, 0);
          }else{
            cnt += r[n] - r[j];
          }
        }
      }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3668
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))
else:
    m = max(-2*A[N//2-1] + A[N//2] + A[N//2+1], - A[N//2-1] - A[N//2] + 2*A[N//2+1])
    print(-2*sum(A[:N//2-1]) + m + 2*sum(A[N//2+2:]))

Measured memory_bytes: 7504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll mod = 1000000007;

  int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> t(n);
    vector<ll> y(m);
    rep(i,n) cin >> t[i];
    vector<ll> kei(n,0);
    rep(i,m) cin >> y[i];
    vector<ll> suu(m,0);
    ll ans=0;
    ll ans2=0;
    rep(i,n){
      kei[i]+=i;
      kei[i]-=n-1-i;
    }
    rep(i,n) {
      ans+=t[i]*kei[i];
      ans%=mod;
      if (ans < 0) ans+=mod;
    }
    rep(i,m){
      suu[i]+=i;
      suu[i]-=m-1-i;
    }
    rep(i,m) {
      ans2+=y[i]*suu[i];
      ans%=mod;
      if (ans < 0) ans+=mod;
    }
    ans%=mod;
    ans2%=mod;
    cout << (ans*ans2)%mod << endl;
    return 0;
  }


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

#define ll long long int 
#define fon(n) for(ll i=0;i<n;i++)

int main(){

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    cin>>t;

    cout<< fixed << setprecision(20)<<(double)(2*M_PI*(double)t);
	return 0;
}

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

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

	int64_t N, K;
	cin >> N >> K;

	vector<int> A( N );
	for( auto& v : A ) { cin >> v; }

	int64_t x = 0;
	for( int i = 0; i < N-1; ++i ) {
		for( int j = i+1; j < N; ++j ) {
			if( A[i] > A[j] ) { x += 1; }
		}
	}

	int64_t y = 0;
	for( int i = 0; i < N; ++i ) {
		for( int j = 0; j < N; ++j ) {
			if( A[i] < A[j] ) { y += 1; }
		}
	}

	int64_t m = 1000000007;
	int64_t a = x * K % m;
	int64_t b = y * (K * (K-1) / 2 % m) % m;
	cout << (a + b) % m << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   cin >> s;
   ll num = 0;
   for(ll i = 0;i < s.length();i++) {
      ll n = s[i]-'0';
      num+=n;
      num%=9;
   }
   if (num%9==0) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 3780