akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

n = i()
a = l()
deq = deque([])
for i in range(n):
    if i%2 == 0:
        deq.append(a[i])
    else:
        deq.appendleft(a[i])
if n%2 == 1:
    deq.reverse()
print(*deq)

Measured memory_bytes: 100068
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<string>
//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n,t,a[111000],dp[111000];

void marota(){
    std::cin>>n;
    for (int i=1;i<=n;i++){
        std::cin>>a[i];
    }   
    a[0]=a[1];
    for (int i=2;i<=n;i++){
        dp[i]=std::min(dp[i-1]+std::abs(a[i]-a[i-1])
                      ,dp[i-2]+std::abs(a[i]-a[i-2])
                    );
    }
    std::cout<<dp[n];

}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}

Measured memory_bytes: 4368
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int cur = 1;
        while(N>0){
            if(cur+K<2*cur) cur += K;
            else cur = cur*2;
            N--;
        }
        int ans = cur;
        System.out.println(ans);
    }
}

Measured memory_bytes: 19796
#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 f(int a){
  int cnt = 0;
  while(a%2 == 0){
    a /= 2;
    cnt++;
  }
  return cnt;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int ans = 1e9;
  REP(i, N){
    int tmp; cin >> tmp;
    ans = min(ans, f(tmp));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	deque<char>aq,bq;
	char c;
	deque<char>*aqq=&aq,*bqq=&bq;
	while(c=getchar(),c!='\n'){
		aqq->push_back(c);
		bqq->push_front(c);
	}
	int n;
	cin>>n;
	int a,b;
	for(int i=0;i<n;++i){
		cin>>a;
		if(a==1)
			swap(aqq,bqq);
		else{
			cin>>b>>c;
			if(b==1){
				aqq->push_front(c);
				bqq->push_back(c);
			}
			else{
				bqq->push_front(c);
				aqq->push_back(c);
			}
		}
	}
	while(!aqq->empty()){
		cout<<aqq->front();
		aqq->pop_front();
	}
	return 0;
}

Measured memory_bytes: 1152
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int N;
  cin >> N;
  int a = sqrt(N);
  //printf("%.11d", (int)pow(a, 2));
  cout << (ull)pow(a, 2) << endl; 
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// wrap,pair
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR (i,n) for(int i=n;i>0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

// pairをsecond基準で昇順sort
// sort(vector_name.begin(),vector_name.end(),compare_by_b);
bool compare_by_b(pair<int, int>a, pair<int, int>b) {
	if (a.second != b.second) return a.second < b.second;
	else return a.first < b.first;
}

// ----------------------------------------------------------------

int main(void) {

	string s;
	cin >> s;
	int n = s.length();

	int cnt0 = 0, cnt1 = 0;
	REP(i, n) {
		if (s[i] == '0') cnt0++;
		else cnt1++;
	}

	cout << min(cnt0, cnt1) * 2 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
	int n,l[110],i,j,k,ans = 0;
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> l[i];
	}
	for (i=0;i<n-2;i++) {
		for (j=i+1;j<n-1;j++) {
			if (l[i] == l[j]) {
				continue;
			}
			for (k=j+1;k<n;k++) {
				if ((l[i] == l[k]) || (l[j] == l[k])) {
					continue;
				}
				if ((l[i] < l[j] + l[k]) && (l[j] < l[i] + l[k]) && (l[k] < l[i] + l[j])) {
					//cout << i+1 << " " << j+1 << " " << k+1 << '\n';
					ans++;
				}

			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
        int n, v[22], c, ans = 0;
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
        {
                scanf("%d", &v[i]);
        }
        for (int i = 0; i < n; i++)
        {
                scanf("%d", &c);
                if (v[i] > c)
                {
                        ans += v[i] - c;
                }
        }
        printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <queue>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef pair <int, int> ii;
typedef long long ll;
typedef pair <ll, int> lli;

const int Maxn = 100005;
const int mod = 1000000007;
const ll Inf = 4000000000000000000ll;

int n, m;
int S, T;
vector <ii> neigh[Maxn];
ll distS[Maxn], distT[Maxn];
int waysS[Maxn], waysT[Maxn];

void Dist(int v, ll dist[], int ways[])
{
	fill(dist, dist + Maxn, Inf); dist[v] = 0;
	ways[v] = 1;
	priority_queue <lli> Q; Q.push(lli(-dist[v], v));
	while (!Q.empty()) {
		int v = Q.top().second;
		ll d = -Q.top().first; Q.pop();
		if (d != dist[v]) continue;
		for (int i = 0; i < neigh[v].size(); i++) {
			ii u = neigh[v][i];
			if (d + u.second == dist[u.first]) ways[u.first] = (ways[u.first] + ways[v]) % mod;
			else if (d + u.second < dist[u.first]) {
				ways[u.first] = ways[v];
				dist[u.first] = d + u.second;
				Q.push(lli(-dist[u.first], u.first));
			}
		}
	}
}

int main()
{
	scanf("%d %d", &n, &m);
	scanf("%d %d", &S, &T);
	for (int i = 0; i < m; i++) {
		int a, b, c; scanf("%d %d %d", &a, &b, &c);
		neigh[a].push_back(ii(b, c));
		neigh[b].push_back(ii(a, c));
	}
	Dist(S, distS, waysS);
	Dist(T, distT, waysT);
	int ways = ll(waysS[T]) * ll(waysT[S]) % mod;
	for (int i = 1; i <= n; i++) if (distS[i] + distT[i] == distS[T] && distS[i] == distT[i]) {
		int cur = ll(waysS[i]) * waysT[i] % mod * waysT[i] % mod * waysS[i] % mod;
		ways = (ways - cur + mod) % mod;
	}
	for (int v = 1; v <= n; v++)
		for (int j = 0; j < neigh[v].size(); j++) {
			int u = neigh[v][j].first;
			int d = neigh[v][j].second;
			if (distS[v] + d + distT[u] == distS[T]) {
				ll x2 = distT[u] + d - distS[v];
				if (0 < x2 && x2 < 2 * d) {
					int cur = ll(waysS[v]) * waysT[u] % mod * waysT[u] % mod * waysS[v] % mod;
					ways = (ways - cur + mod) % mod;
				}
			}
		}
	printf("%d\n", ways);
	return 0;
}

Measured memory_bytes: 14292
from itertools import *
N,M=map(int,input().split())
X=list(permutations(list(range(2,N+1))))
P=0
a,b=0,0
S=set()
for i in range(M):
  a,b=map(int,input().split())
  S.add((a,b))
  S.add((b,a))
for i in range(len(X)):
  for j in range(N-1):
    if not(((1 if j==0 else X[i][j-1]),X[i][j]) in S):
      break
    if j==N-2:
      P+=1
print(P)

Measured memory_bytes: 69012
#include <stdio.h>
#include <stdlib.h>

int main(){

    int A, B, C, X, Y, Z;

    scanf("%d %d %d", &X, &Y, &Z);

    A=Y;
    B=X;
    C=Z;
    A=Z;
    C=Y;

    printf("%d %d %d", A, B,C);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
string s,t;
int id;
string f()
{
	string ret="";
	while(id<t.size()&&t[id]!=']')
	{
		if(t[id]=='[')
		{
			id++;
			string now=f();
			reverse(now.begin(),now.end());
			ret+=now;
		}
		else
		{
			ret+=t[id];
			id++;
		}
	}
	id++;
	return ret;
}
main()
{
	while(cin>>s,s!=".")
	{
		t="";
		int x=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='['||s[i]==']')
			{
				t+=s[i];
			}
			else if(s[i]=='+'||s[i]=='-')
			{
				x+=s[i]=='+'?1:-1;
			}
			else
			{
				if(s[i]=='?')t+='A';
				else
				{
					int now=s[i]-'A';
					now+=x;
					now=(now%26+26)%26;
					t+=(char)(now+'A');
				}
				x=0;
			}
		}
		id=0;
		cout<<f()<<endl;
	}
}



Measured memory_bytes: 3072
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
typedef long long LL;

int main() {
	long double n, m, d;

	cin >> n >> m >> d;

	cout << fixed << setprecision(10);
	if(d == 0) cout << ((n - d) * 2) / (n * n) * (m - 1) / 2 << endl;
	else cout << ((n - d) * 2) / (n * n) * (m - 1) << endl;
	
	return 0;
}

Measured memory_bytes: 384
n, m = (int(x) for x in input().split())
if n != 0:
  if m != 0:
    ans = (n * (n - 1)) // 2 + (m * (m - 1)) // 2
  else:
  	ans =  (n * (n - 1)) // 2
else:
  if m != 0:
    ans = (m * (m - 1)) // 2
  else:
    ans = 0
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int i,s;
	while(1){
		char x[1001];
		s=0;
		scanf("%s",x);
		if(x[0]=='0'&&x[1]=='\0')break;
		for(i=0;x[i]!='\0';i++)s+=x[i]-'0';
		printf("%d\n",s);
	}
	return 0;
}


Measured memory_bytes: 2124
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in);
        Task task = new Task();
        task.solve(sc, out);
        out.flush();
        sc.close();
    }

    static class Task {
        public void solve(Scanner sc, PrintWriter out) {
            long w = nlong(sc);
            long a = nlong(sc);
            long b = nlong(sc);
            if (a+w < b){
                out.println(b-(a+w));
            }else if (a > b){
                out.println(a -(b+w));
            }else {
                out.println(0);
            }

        }
    }


    static int nint(Scanner sc) {


        return Integer.parseInt(sc.next());
    }

    static long nlong(Scanner sc) {
        return Long.parseLong(sc.next());
    }

    static double ndouble(Scanner sc) {
        return Double.parseDouble(sc.next());
    }

    static float nfloat(Scanner sc) {
        return Float.parseFloat(sc.next());
    }

    static String nstr(Scanner sc) {
        return sc.next();
    }

    static long[] longLine(Scanner sc, int size) {
        long[] lLine = new long[size];
        for (int i = 0; i < size; i++) {
            lLine[i] = nlong(sc);
        }
        return lLine;
    }

    static int[] intLine(Scanner sc, int size) {
        int[] iLine = new int[size];
        for (int i = 0; i < size; i++) {
            iLine[i] = nint(sc);
        }
        return iLine;
    }

    static String[] strLine(Scanner sc, int size) {
        String[] strLine = new String[size];
        for (int i = 0; i < size; i++) {
            strLine[i] = nstr(sc);
        }
        return strLine;
    }

    static long maxFromList(List<Long> longList) {
        return longList.stream().max(Comparator.naturalOrder()).get();
    }

    static long minFromList(List<Long> longList) {
        return longList.stream().min(Comparator.naturalOrder()).get();
    }

    public static int sumDigits(int n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    public static long sumDigits(long n) {
        long sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;
    }

    static List<Integer> getIntegerList(Scanner sc, int size) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nint(sc));
        }
        return list;
    }

    static List<Long> getLongList(Scanner sc, int size) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(nlong(sc));
        }
        return list;
    }

    private static long lcm(long a, long b) {
        return a * b / gcd(b, a % b);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <cctype>

using namespace std;

int main()
{
	char c;

	while(1) {
		scanf("%c", &c);
		if ( c == '\n' ) break;

		if (islower(c))
			c = toupper(c);
		else if (isupper(c))
			c = tolower(c);

		printf("%c", c);
	}
	printf("\n");
	

	return (0);
}

Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  if (a % 2 == 0) {
    int b = a / 2;
    cout << b * b << endl;
  }
  else {
    int c, d;
    c = a / 2 + 1;
    d = a / 2;
    cout << c * d << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <vector>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;

int main()
{
  long x, y;
  long n;
  cin >> n;

  vector<long> a(n);
  map<long, long> mp;

  for (long i = 0; i < n; ++i) {
    cin >> a[i];
    mp[a[i]]++;
  }
  long ans = 0;


  for (auto p: mp) {
    int x = p.first;
    int n = p.second;
    if (n < x) ans += n;
    else ans += n - x;
  }


  cout << ans;

  return 0;
}

Measured memory_bytes: 7040
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long LL;

LL prs[500005];
LL query(LL l,LL r){
	return prs[r] - prs[l - 1];
}

LL n,k,c;
LL pre[500005],ls[500005],lis[500005],lic = 0;
LL ans[500005],anc = 0;
string s;

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k >> c;
	cin >> s; s = ' ' + s;
	for(LL i = 1;i <= n;i ++){
		prs[i] = prs[i - 1] + (s[i] == 'o');
		pre[i] = (s[i] == 'o' ? i : pre[i - 1]);
		ls[i] = (i - c - 1 > 0 ? pre[i - c - 1] : 0);
	}
	LL tmp;
	for(LL i = n;i >= 1;i --){
		tmp = i;
		if(s[i] == 'o') break;
	}
	while(tmp){
		lis[++ lic] = tmp;
		tmp = ls[tmp];
	}
	sort(lis + 1,lis + 1 + lic); lis[0] = -c; lis[lic + 1] = n + c + 1;
	if(lic == k){
		for(LL i = 1;i <= lic;i ++){
			if(query(lis[i - 1] + c + 1,lis[i + 1] - c - 1) == 1) ans[++ anc] = lis[i];
			for(LL j = lis[i - 1] + c + 1;j <= lis[i];j ++){
				if(s[j] == 'o'){
					lis[i] = j;
					break;
				}
			}
		}
		for(LL i = 1;i <= anc;i ++) cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 19792
#include <iostream>
#include <math.h>
using namespace std;
void prime(int n);
bool subprime(int n);
int main(){
	int n;
	while (true){
		cin >> n;
		if (n == 1){ break; }
		prime(n);
	}
	return 0;
}
void prime(int n){
	cout << n << ":";
	int s = (int)sqrt(n);	//?????????
	int r = 0;
	int i = 6;
	while (i <= n){//6 8 13 15
		if (n%i == 0){
			if (subprime(i) == true){
				cout << " " << i ;
			}
		}
		i += 2;
		if (n%i == 0){
			if (subprime(i) == true){
				cout << " " << i;
			}
		}
		i += 5;
	}
	cout << endl;
}
bool subprime(int n){
	int i = 6;
	bool r;
	while (i < n){//6 8 13 15
		if (n%i == 0){
			return false;
		}
		if (i % 7 == 6){ i += 2; }
		if (i == n){ break; }
		if (n%i == 0){
			return false;
		}
		if (i % 7 == 1){ i += 5; }
	}
	return true;
}

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

int main(){
	string a,b,c;
	cin>>a>>b>>c;
  	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
  	else cout<<"NO"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int a, b, c, x, y; cin >> a >> b >> c >> x >> y;
    auto cost = [&](int i){ return (c * 2 * i) + (a * max(x - i, 0)) + (b * max(y - i, 0)); };
    int mxi = max(x, y) + 1;
    int minC = 1e9;
    rep(i, mxi) {
        // dump(cost(i));
        chmin(minC, cost(i));
    }
    cout << minC << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    dp = [[-1]*(N+1) for _ in range(N+1)]

    for i in range(N+1):
        dp[i][i] = 0

    for l in range(1,N+1):
        for i in range(N-l+1):
            j = i + l
            if (N-l)%2==0:
                dp[i][j] = max(dp[i+1][j]+A[i], dp[i][j-1]+A[j-1])
            else:
                dp[i][j] = min(dp[i+1][j]-A[i], dp[i][j-1]-A[j-1])

    print(dp[0][N])

if __name__ == '__main__':
    main()


Measured memory_bytes: 145596
sx, sy, tx, ty = map(int, input().split(" "))
dx = tx - sx
dy = ty - sy
s = "R" * dx + "U" * dy + \
      "L" * dx + "D" * dy + \
      "D" + "R" * (dx+1) + "U" * (dy+1) + "L" + \
      "U" + "L" * (dx+1) + "D" * (dy+1) + "R"
print(s)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
//#include<queue>
#include<algorithm>
//#include<iostream>
//#include<assert.h>
using namespace std;
 
int n;
#define maxn 200011
struct Node{int a,b;}p[maxn]; int lp;
bool cmp(const Node &a,const Node &b) {return a.b>b.b;}
#define LL long long
int main()
{
	scanf("%d",&n);
	LL t=0,ans=0,pp=0;
	for (int i=1,x,y;i<=n;i++)
	{
		scanf("%d%d",&x,&y);
		if (x<y) ans+=y,t+=y-x;
		else if (x==y) pp+=y;
		else p[++lp]=(Node){x,y};
	}
	if (t==0) {printf("%lld\n",ans); return 0;}
	ans+=pp;
	sort(p+1,p+1+lp,cmp);
	for (int i=1;i<=lp;i++)
	{
		if (p[i].a-p[i].b<t)
		{
			ans+=p[i].b;
			t-=p[i].a-p[i].b;
		}
		if (!t) break;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

s = input()
if s[0]=="R" and s[1]=="R" and s[1]==s[2]=="R":
  print(3)
elif s[0] == s[1]=="R" or s[1] == s[2]=="R":
  print(2)
elif "R" in s:
  print(1)
else:
  print(0)

Measured memory_bytes: 65360
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N, K;
	cin >> N;
	vector<int> A(N);

	rep(i, N) {
		int h;
		cin >> h;
		A[h-1] = i+1;
	}
	
	rep(i, N) {
		cout << A[i] << " ";
	}

	cout << endl;

}


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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int k;
    cin>>k;
    int n=7;
    auto len=[](int num){
        int cnt=0;
        while(num>0){
            ++cnt;
            num/=10;
        }
        return cnt;
    };
    for(int i=1;i<=1e6;i++){
        if(n%k==0){
            cout<<i<<"\n";
            return;
        }
        // deb(n);
        n=(n%k)*10+7;
    }
    cout<<"-1\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3672
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
const ll N = 1e6+10 ;
int main(){
   ll n,k;
   cin >> n>>k;
   ll sum = 0;
   for(int i = 1;i <= k;++i){
      ll a;
      cin >> a;
      sum += a;
   }
   if(sum >= n) puts("Yes");
   else puts("No");
}

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

typedef long long int lli;
typedef long double lld;
typedef long long ll;
//Datatype
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vvlli vector<vector<long long int>>
#define ppi pair<int, int>
#define rppi pair<int, pair<int, int>>
#define lppi pair<pair<int, int>, int>
#define vppi vector<pair<int, int>>
#define sppi stack<pair<int int>>
#define qppi queue<pair<int, int>>
//function
#define f first
#define s second
#define pb(x) push_back(x)
#define mkp(i, j) make_pair(i, j)
#define lmkp(i,j,k) make_pair(make_pair(i,j),k)
#define rmkp(i,j,k) make_pair(i,make_pair(j,k))
//loop
#define loop(i,n) for (i = 0; i < n; ++i)
#define loops(i,k,n) for (i = k; i <= n; ++i)
#define looprev(i,k,n) for (i = k; i >= n; --i)
//Const
#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
//Print
#define prd(n) printf("%d", n)
#define prl(n) printf("%lld", n)
#define prdn(n) printf("%d\n", n)
#define prln(n) printf("%lld\n", n)
#define prf(n) printf("%f", n)
//Scan
#define scd(n) scanf("%d", &n)
#define scd2(a, b) scanf("%d %d", &a, &b)
#define scd3(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scl(n) scanf("%lld", &n)
#define scl2(a, b) scanf("%lld %lld", &a, &b)
#define scl3(a, b, c) scanf("%lld %lld %lld", &a, &b, &c)
#define scf(n) scanf("%f", &n)

using namespace std;
char grid[1001][1001];
lli g[1001][1001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli i, j, k, N, M;
    cin>>N>>M;
    loop(i, N){
        loop(j, M){
            cin>>grid[i][j];
        }
    }
    loop(i, N){
        loop(j, M){
            if(i == 0 && j == 0) g[i][j] = 1;
            else if(grid[i][j] == '#') g[i][j] = 0;
            else if(i == 0 && j != 0) g[i][j] = g[i][j-1];
            else if(i != 0 && j == 0) g[i][j] = g[i-1][j];
            else g[i][j] = (g[i-1][j]+g[i][j-1])%MOD;
        }
    }
    /*loop(i, N){
        loop(j, M){
            cout<<g[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<g[N-1][M-1]<<endl;
  return 0;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 100005;

int n;
int a[N];

int main() {

	FAST;
	
	int a, b;
	string s;
	cin >> a >> b >> s;
	for (int i = 0; i < s.size(); i ++) {
		if (i != a) {
			if (!isdigit(s[i])) {
				cout << "No\n";
				return 0;
			}
		}
		else {
			if (s[i] != '-') {
				cout << "No\n";
				return 0;
			}
		}
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
N = int(input())

a = list(input() for _ in range(N))

AC_counter = 0
WA_counter = 0
TLE_counter = 0
RE_counter = 0

for value in a:
    if value == "AC":
        AC_counter+=1
    if value == "WA":
        WA_counter+=1
    if value == "TLE":
        TLE_counter+=1
    if value == "RE":
        RE_counter+=1


print ("AC x " + str(AC_counter))
print ("WA x " + str(WA_counter))
print ("TLE x " + str(TLE_counter))
print ("RE x " + str(RE_counter))

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 61)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n;
void solve(){
	cin >> n;
	
	i64 ans = 0;
	for(int i = n; i > 0; i--){
		i64 a = n/i;
		ans += i*a*(a+1)/2;
		//cout << ans << endl;
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>

#define WHITE 1
#define BLACK 0

/*typedef struct node{
  int num;
  struct node *left;
  struct node *right;
} Node;

Node *nil;
*/int n;
int color[25];
/*
Node *makeTree(int i,int x[],int l[],int r[]){
  Node *newNode;
  newNode = (Node *)malloc(sizeof(Node));

  color[i] = BLACK;

  int j=0;

  newNode->num = x[i];
  if(l[i]==-1) newNode->left = NULL;
  else{
    while(1){
      if(x[j]==l[i]) break;
      j++;
    }
    newNode->left = makeTree(j,x,l,r);
  }
  if(r[i]==-1) newNode->right = NULL;
  else{
    j=0;
    while(1){
      if(x[j]==r[i]) break;
      j++;
    }
    newNode->right = makeTree(r[i],x,l,r);
  }

  return newNode;
}*/

void xTox2(int x[],int x2[]){
  int i;
  for(i=0;i<n;i++){
    x2[x[i]] = i;
  }
}

void preorder(int j,int x[],int l[],int r[],int x2[]){
  printf(" %d",x[j]);
  if(l[j] != -1) preorder(x2[l[j]],x,l,r,x2);
  if(r[j] != -1) preorder(x2[r[j]],x,l,r,x2);
}

void inorder(int j,int x[],int l[],int r[],int x2[]){
  if(l[j] != -1) inorder(x2[l[j]],x,l,r,x2);
  printf(" %d",x[j]);
  if(r[j] != -1) inorder(x2[r[j]],x,l,r,x2);
}

void postorder(int j,int x[],int l[],int r[],int x2[]){
  if(l[j] != -1) postorder(x2[l[j]],x,l,r,x2);
  if(r[j] != -1) postorder(x2[r[j]],x,l,r,x2);
  printf(" %d",x[j]);
}

int main(){
  int i,j;
  int x[25],l[25],r[25];
  int x2[25];

  scanf("%d",&n);

  for(i=0;i<n;i++) color[i] = WHITE;

  for(i=0;i<n;i++){
    scanf("%d%d%d",&x[i],&l[i],&r[i]);

    if(l[i]!=-1) color[l[i]] = BLACK;
    if(r[i]!=-1) color[r[i]] = BLACK;
  }

  xTox2(x,x2);

  for(i=0;i<n;i++){
    if(color[i]==WHITE) j=i;
    //printf("%d %d\n",i,color[i]);
    color[i]=WHITE;
  }
  //printf("%d\n",j);

  for(i=0;i<n;i++){
    if(x[i]==j){
       j=i;
       break;
     }
    //printf("%d %d\n",i,x[i]);
  }


  //printf("%d\n",j);

  // nil = (Node *)malloc(sizeof(Node));
  // nil = makeTree(j,x,l,r);

  // for(i=0;i<n;i++){
  //   printf("%d %d\n",i,color[i]);
  // }


  printf("Preorder\n");
  preorder(j,x,l,r,x2);
  printf("\nInorder\n");
  inorder(j,x,l,r,x2);
  printf("\nPostorder\n");
  postorder(j,x,l,r,x2);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    Rep(i, 2, n) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1408
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    res = 0
    for i in s:
        if i=='C' and res==0:
            res += 1
        if i=='F' and res==1:
            res += 1
    if res==2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include <chrono>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pldll;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<ld> vld;
#define newl '\n'
const ll M = 1e9 + 7;
const ll N = 1e2;
const ll INF = LONG_MAX;
#define REP(i, a, b) for (int i = a; i < b; i++)
#define LOG_TWO_N 10

template <class T>
void print(vector<T> &vec, int inc = 0, bool lb = true)
{
    for (auto v : vec)
        cout << v + inc << " ";
    if (lb)
        cout << newl;
}

void solve(ll t)
{
    string s; cin >> s;
    int ans=0;
    int cnt = 0;
    for(char c: s){
        if(c=='R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << newl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve(t);
    }

    return 0;
}

Measured memory_bytes: 3636
k, a, b = map(int, input().split())

if b - a < 2 or a > k - 1:
    print(k + 1)
else:
    # get init
    num = a
    c = k - a + 1

    if c % 2 != 0:
        c -= 1
        num += 1

    num += c//2*(b-a)

    print(num)

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

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n-k){
    if(a[i] < a[i+k]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 4840
#include <iostream>

using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int a, t[n] = {0};
  for (int i = 0; i < q; i++) {
    cin >> a;
    t[a - 1]++;
  }
  for (int i = 0; i < n; i++) {
    if (t[i] + k - q > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

//qsort用降順
int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return 1;}
    else if(*(int*)a<*(int*)b){return -1;}
    else {return 0;}
}


int main(void){
    int a[5];
    for(int i=0;i<3;i++){
        scanf("%d",&a[i]);
    }

    qsort(a,3,sizeof(int),cmp);

        printf("%d ",a[0]);
        printf("%d ",a[1]);
                printf("%d",a[2]);
    printf("\n");
return 0;
}



Measured memory_bytes: 2060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main()
{
  long long int i,j,k;
  long long int N,M;
  long long int space;

  scanf("%lld %lld",&N,&M);
  
  if( N > M ){
    printf("safe\n");
  }
  else{
    printf("unsafe\n");
  }
  
  return 0; 
  
}

Measured memory_bytes: 1660
#include<stdio.h>
int main(){
    int k;
    scanf("%d",&k);
    char p[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    printf("%d\n",p[k-1]);
    return 0;
}

Measured memory_bytes: 128
s = input()
even = []
odd = []
for i in range(len(s)):
    if i % 2 == 0:
        even.append(s[i])
    else:
        odd.append(s[i])
a,b = even.count('0'),even.count('1')
c,d = odd.count('0'),odd.count('1')
print(min(a+d,b+c))

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

int main() {
  int D, G;
  cin >> D >> G;
  vector<pair<int, int>> V(D);
  for (int i = 0, p, c; cin >> p >> c; i++) V.at(i) = {p, c};
  int ans = 1e9;
  for (int bit = 0; bit < 1 << D; bit++) {
    int prob = 0, score = 0, last, cnt;
    for (int i = 0; i < D; i++) {
      auto[p, c] = V.at(i);
      if (bit >> i & 1) prob += p, score += (i + 1) * 100 * p + c;
      else last = i, cnt = p;
    }
    while (score < G && cnt--) score += (last + 1) * 100, prob++;
    if (score >= G) ans = min(ans, prob);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;


// ------------------------

void solve() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll ao = N/(A+B);
    ll ans = 0;
    ans += A * ao;
    ll amari = N%(A+B);
    if(amari > A){
        ans += A;
    }else{
        ans += amari;
    }

    cout << ans << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main(){
 int n, ma;
 cin >> n;
 for(int i=0; i<=n; i++){
  if (i * i > n){
   break;
  }else{
   ma = max(ma, i*i);
  }
 }
 cout << ma << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a+b){
    vector<int>v;
    for(int i=0;i<a+b;i++){
      int p;
      cin>>p;
      v.push_back(p);
    }
    sort(v.begin(),v.end());
    int ans=0,p=0;
    for(int i=0;i<a+b;i++){
      ans=max(ans,v[i]-p);
      p=v[i];
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3216
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

//#include "Union_Find.h"

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <array>

using namespace std;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
#define FLOAT setprecision(16)
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;

#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

int N;
string S;
int lmax, l, rmax, r;
int main() {
	cin >> N >> S;
	REP(i, 0, N) {
		S[i] == ')' ? ++l : --l;
		lmax = max(lmax, l);
	}
	REPM(i, N, 0) {
		S[i] == '(' ? ++r : --r;
		rmax = max(rmax, r);
	}

	string ans;
	REP(i, 0, lmax) ans += '(';
	ans += S;
	REP(i, 0, rmax) ans += ')';
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'

using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

double PI = acos((double)-1);
const ld eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
//const ll mod = 1e9 + 9;
const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

void solve() {
	int n, m, t;
	cin >> n >> m >> t;
	vector<int> a(n), b(m);
	int m1 = inf, m2 = inf;
	for (int& i : a) cin >> i;
	for (int& i : b) cin >> i;
	for (int i : a) m1 = min(m1, i);
	for (int i : b) m2 = min(m2, i);
	int ans = m1 + m2;
	for (int i = 0; i < t; i++) {
		int x, y, c;
		cin >> x >> y >> c; x--; y--;
		ans = min(ans, a[x] + b[y] - c);
	}
	cout << ans << endl;
	return;
}

Measured memory_bytes: 1792
def abc083_c():
    A, B, C, D, E, F = map(int, input().split())

    # 水と砂糖それぞれ別で、ありえる候補を出す
    wt = set()
    sg = set()
    for i in range(0, F+1, 100*A):
        for j in range(0, F+1, 100*B):
            if 0 < i + j and i + j <= F:
                wt.add(i + j)
    for i in range(0, F+1, C):
        for j in range(0, F+1, D):
            #if 0 < i + j and i + j <= F:
            if i + j <= F:
                sg.add(i + j)

    # 水と砂糖の組合せを試す
    ans_t, ans_s = -1, -1
    concent = -1
    for w in wt:
        for s in sg:
            if F < w + s: continue  # 総重量オーバー
            if E * w // 100 < s: continue  # 溶けきらない
            if concent < s / (w + s):
                ans_t, ans_s = w + s, s  # 濃度が高ければ答えを更新
                concent = s / (w + s)

    print('{} {}'.format(ans_t, ans_s))

abc083_c()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
double d(pdd p1, pdd p2) {
    double dx = p1.first - p2.first;
    double dy = p1.second - p2.second;
    return sqrt(dx * dx + dy * dy);
}
/* main */
int main(){
    int N;
    cin >> N;
    vector<pdd> v(N);
    for (int i = 0; i < N; i++) {
        double x, y;
        cin >> x >> y;
        v[i] = pdd(x, y);
    }
    vector<int> p(N);
    for (int i = 0; i < N; i++) p[i] = i;
    double sum = 0;
    double cnt = 0;
    do {
        cnt++;
        for (int i = 0; i < N-1; i++) sum += d(v[p[i]], v[p[i+1]]);
    } while(next_permutation(p.begin(), p.end()));
    cout << fixed << setprecision(10) << sum / cnt << '\n';
}


Measured memory_bytes: 3796
//#define LOCAL

#include <cstdio>

int A[110];

int main()
{
	#ifdef LOCAL
		freopen("E:\\Temp\\input.txt", "r", stdin);
		freopen("E:\\Temp\\output.txt", "w", stdout);
	#endif

	int n, i, j, minj, t, c = 0;
	scanf("%d", &n);
	for(i=0; i<n; ++i) scanf("%d", &A[i]);

	for(i=0; i<n; ++i) {
		minj = i;
		for(j=i+1; j<n; ++j) 
			if(A[j] < A[minj]) minj = j;
		if(minj != i) {
			t = A[i];
			A[i] = A[minj];
			A[minj] = t;
			++c; 
		}
	}

	for(i=0; i<n; ++i) {
		if(i) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n%d\n", c);

	return 0;
}

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

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  else return gcd(y, x % y);
}

vector<pair<ll, int>> f(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i*i <= n; i++) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while(n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}


int main() {
  ll a, b;
  cin >> a >> b;

  ll g = gcd(a,b);
  auto v = f(g);
  int ans = v.size() + 1;
  cout << ans << endl;

}

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

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);

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

  ll ans = 1000;

  for (int i = 0; i < n-1; i++) {
    ll kabu = 0;//株の個数
    if (a[i] < a[i+1]) {
      kabu = ans / a[i];
    }
    ans -= kabu*a[i];
    ans += kabu*a[i+1];
  }

  cout << ans << endl;

}


Measured memory_bytes: 3640
using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string S = Console.ReadLine();
        Console.WriteLine(N % 2 == 0 ?
            S.Substring(0, N / 2) == S.Substring(N / 2) ? "Yes" : "No" : "No");
        return;
    }
}

Measured memory_bytes: 27436
s = input()
r = [0 for _ in s]
s += 'R'
j = 0
try:
    while True:
        i = j
        j = s.index('L', i + 1)
        d = j - i
        r[j - 1] = (d + 1) // 2
        r[j] = d // 2
        i = j
        j = s.index('R', i + 1)
        d = j - i
        r[i - 1] += d // 2
        r[i] += (d + 1) // 2
except ValueError:
    pass
print(*r)


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pii>> edge(n), redge(n);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    edge[a].eb(mp(b, c));
    redge[b].eb(mp(a, c));
  }

  vector<bool> visited(n, false);
  visited[n - 1] = true;
  queue<int> Q;
  Q.push(n - 1);
  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    rep(i, redge[cur].size()) {
      int next = redge[cur][i].F;
      if (visited[next]) continue;
      visited[next] = true;
      Q.push(next);
    }
  }

  vector<ll> d(n, -INF);
  d[0] = 0;
  bool updated = true;
  rep(_, 2 * n) {
    updated = false;
    rep(i, n) if (d[i] != -INF) rep(j, edge[i].size()) {
      int next = edge[i][j].F;
      int cost = edge[i][j].S;
      if (d[next] < d[i] + cost) {
        d[next] = d[i] + cost;
        updated |= visited[next];
      }
    }
  }

  if (updated)
    cout << "inf" << endl;
  else
    cout << d[n - 1] << endl;
}


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

#define ll long long
#define MAX 100005

using namespace std;

int temp[MAX];

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1;i <= n;i++){
        int a;
        cin >> a;
        if(temp[a] == i)
            ans++;
        temp[i] = a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std ;
int main()
{
    string a ;
    int x = 0 ;
    cin >> a ;
    for(int i=0 ;i < 4 ;i++){
        if(a[i] == '-')
        x-- ;
        else
        x++;
    }
    cout << x ;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

ll n, m;

ll dp[310][310][310];

const ll MOD = 1e9 + 7;

int main(){
	cin>>n>>m;
	dp[0][1][1] = 1LL;
	for(int i = 0; i < m; i++) {
		for(int j = 0; j <= n; j++) {
			for(int k = 0; k <= n; k++) {
				(dp[i+1][j+1][k] += dp[i][j][k] * (n - j)) %= MOD;
				(dp[i+1][j][k] += dp[i][j][k] * (j - k)) %= MOD;
				(dp[i+1][j][j] += dp[i][j][k] * k) %= MOD;
			}
		}
	}
	cout << dp[m][n][n] << endl;
}

Measured memory_bytes: 220800
#include <bits/stdc++.h>
#define INT long long
#define MOD 998244353
#define OO 99999998765432100
using namespace std;
string s;
INT n,a,b,c[30], cnt;

int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    for(int i = 0 ; i < s.size()/2 ; i++ )
        if( s[i] != s[s.size()-i-1] ) cnt++;
    cout<<cnt<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return (a/gcd(a,b))*b;
}
int main() {
	ll N;
	cin >> N;
	ll T[N + 1];
	for (ll i = 0; i < N; i++) {
		cin >> T[i];
	}
	ll m = T[0];
	for (ll i = 0; i < N; i++) {
		m = lcm(m, T[i]);
	}
	cout << m << endl;
}

Measured memory_bytes: 256