akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,m = LI()
    e = collections.defaultdict(list)
    for _ in range(m):
        a,b,c = LI_()
        e[a].append((b,c+1))

    t = [0] * n

    def search(s):
        d = collections.defaultdict(lambda: -inf)
        d[s] = 0
        q = []
        heapq.heappush(q, (0, s, -1))
        v = [{} for _ in range(n)]
        while len(q):
            k, u, mu = heapq.heappop(q)
            if mu in v[u] and v[u][mu] >= -k:
                continue
            if mu in v[u]:
                v[u][mu] = inf
            else:
                v[u][mu] = -k

            for uv, ud in e[u]:
                vd = -k + ud
                if u in v[uv] and v[uv][u] >= vd:
                    continue
                heapq.heappush(q, (-vd, uv, u))

        return v

    d = search(0)
    if max(d[n-1].values()) == inf:
        return 'inf'
    return max(d[n-1].values())


print(main())


Measured memory_bytes: 7748
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

void Main(){
	int n; string s;
	cin >> n >> s;
    vi r(n+1), b(n+1), g(n+1);
    ll ans = 0;
    r[0] = b[0] = g[0] = 0;
    rep3(i,1,n){
        if(s[i-1] == 'R') {
            r[i] = r[i-1] + 1;
            b[i] = b[i-1];
            g[i] = g[i-1];
        }
        else if(s[i-1] == 'B') {
            r[i] = r[i-1];
            b[i] = b[i-1] + 1;
            g[i] = g[i-1];
        }
        else{
            r[i] = r[i-1];
            b[i] = b[i-1];
            g[i] = g[i-1] + 1;
        }
    }
    
    int SUM = 'R' + 'B' + 'G';
    
    /* debug
    cout << "r: ";
    rep(i,n+1) cout << r[i] << " ";
    cout << endl;
    cout << "b: ";
    rep(i,n+1) cout << b[i] << " ";
    cout << endl;
    cout << "g: ";
    rep(i,n+1) cout << g[i] << " ";
    cout << endl;
    
    cout << SUM << endl;
    cout << char(SUM - 'R' - 'G') << endl;
    */
    
    rep(i,n-2){
        rep3(j,i+1,n-2){
            if(s[i] == s[j]) continue;
            
            int exc = j + (j-i);
            char temp = char(SUM - s[i] - s[j]);

            if(temp=='R') {
                ans += r[n] - r[j+1];
                if(exc <= n && s[exc]=='R') ans--;
            }
            else if(temp=='B') {
                ans += b[n] - b[j+1];
                if(exc <= n && s[exc]=='B') ans--;
            }
            else {
                ans += g[n] - g[j+1];
                if(exc <= n && s[exc]=='G') ans--;
            }
            // debug
            // cout << i << "," << j << ": " << ans << endl;
        }
    }
    cout << ans << endl;
	return;
}

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

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



int main() {
  int64_t Q=1000000007;
int64_t P=Q-2;
vector<int64_t> q(100005,1);
  for(int i=1;i<100005;i++){
    int64_t N=P; //ここから
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=i;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      } //ここまで
    q.at(i)=(c*q.at(i-1))%Q;
  }
vector<int64_t> r(100005,1);
  for(int i=1;i<100005;i++){
    r.at(i)=(i*r.at(i-1))%Q;
  }


  int M,E,a=-1,b,T=1;
  cin>>M;
  vector<int> s(M);
  vector<int> p(M+1);
  for(int i=0;i<=M;i++){
    cin>>p[i];
    p[i]--;
    s[p[i]]++;
  }
  for(int i=0;i<M;i++){
    if(s[i]==2){
      E=i;
      break;
    }
  }
  for(int i=0;i<=M;i++){
    if(a==-1&&p[i]==E){
      a=i;
    }
    else if(p[i]==E){
      b=M-i;
    }
  }
  for(int i=1;i<=a+b+1;i++){
    int64_t A=M+1,B=i,C=1;//A、Bを入れる
      C=(q.at(B)*q.at(A-B))%Q;
      C=(C*r.at(A))%Q;
      A=a+b,B=i-1;
    int64_t D=(q[B]*q[A-B])%Q;
    D=(D*r[A])%Q;
    cout<<(C+Q-D)%Q<<endl;
  }
  for(int i=a+b+2;i<=M+1;i++){
    int64_t A=M+1,B=i,C=1;//A、Bを入れる
      C=(q.at(B)*q.at(A-B))%Q;
      C=(C*r.at(A))%Q;
    cout<<C<<endl;
  }
}

Measured memory_bytes: 5560
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<(n); i++)
#define REPS(i, n) for(int i=0; i<=(n); i++)
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define FORS(i, a, b) for(int i=a; i<=(b); i++)
// for container x
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define LB(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#pragma endregion

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int ans=0;

    for(int i=0; i<n; i+=2){
        if(a[i]%2==1) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

vector<vector<LL>> xy(MAX);
vector<LL> d(MAX, 0);
vector<bool> is_visit(MAX, false);

LL dfs(LL s){
    is_visit[s]=true;
    if(xy[s].size()==0){
        return 0;
    }

    LL ans=0;
    for(LL i=0; i<xy[s].size(); i++){
        if(is_visit[xy[s][i]]==true){
            d[s]=max(d[s], d[xy[s][i]]+1);
        }else{
            d[xy[s][i]]=dfs(xy[s][i]);
            d[s]=max(d[s], d[xy[s][i]]+1);
        }
    }

    return d[s];
}

int main(){
    LL n;
    LL m;
    LL x;
    LL y;
    cin >> n >> m;
    vector<LL> is_start(n, true);
    for(LL i=0; i<m; i++){
        cin >> x >> y;
        x--;
        y--;
        xy[x].push_back(y);
        is_start[y]=false;
    }

    LL ans=0;
    for(LL i=0; i<n; i++){
        if(is_start[i]==false){
            continue;
        }
        ans=max(ans, dfs(i));
    }

    //for(LL i=0; i<n; i++){
    //    cout << d[i] << endl;
    //}

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 17768
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    md = pow(2, n)
    dp = [10 ** 15] * md
    dp[0] = 0
    for i in range(m):
        a, b = list(map(int, readline().split()))
        c = sum([2 ** (v - 1) for v in list(map(int, readline().split()))])
        for j in range(md):
            dp[j | c] = min(dp[j | c], dp[j] + a)
    print(dp[-1] if dp[-1] != 10 ** 15 else -1)


if __name__ == '__main__':
    solve()


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

using namespace std;

int main() {
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for(int i = 0; i < N; i++){
        cout << S[i] << T[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<utility>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;

int main() {

	int n, m;

	cin >> n >> m;

	vector<int> ac(n, 0);
	vector<int> wa(n, 0);

	int i, p, ac_sum = 0, wa_sum = 0;

	string s;

	for (i = 0; i < m; i++) {
		cin >> p >> s;

		if (s == "WA" && ac[p - 1] != 1) {
			wa[p - 1]++;
		}

		if (s == "AC" && ac[p - 1] != 1) {
			ac[p - 1] = 1;
			ac_sum++;
			wa_sum += wa[p - 1];
		}
	}

	cout << ac_sum  << " " << wa_sum << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

#define MAXH 251

int main()
{
  int i, H;
  int T[MAXH];

  scanf("%d",&H);
  
  for(i = 1; i <= H; i++) {
    scanf("%d",&T[i]);
  }

  for(i = 1; i <= H; i++) {
    printf("node %d: key = %d, ", i, T[i]);

    if(i != 1) printf("parent key = %d, ", T[i/2]);
    if(i*2 <= H) printf("left key = %d, ", T[i*2]);
    if(i*2 + 1 <= H) printf("right key = %d, ", T[i*2 + 1]);
    printf("\n");
  }

  return 0;
}




Measured memory_bytes: 2112
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[10][10];
int main()
{
	int N;
	cin >> N;
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		int tmp = i;
		int num = 0;
		while (tmp > 0) {
			num *= 10;
			num += tmp % 10;
			tmp /= 10;
		}
		int first = num % 10;
		int second = i % 10;
		if (second == 0) continue;
		cnt[first][second]++;
		if (first == second) {
			ans += cnt[first][first] * 2 - 1;
		}
		else {
			ans += max(0,cnt[second][first] * 2);
		}
		//cout << i << " " << num << " " << ans << endl;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

int main(){

    long long n,m;
    cin >> n >> m;

    long long l,r;
    cin >> l >> r;

    for(int i=1;i<m;i++){
        long long tl,tr;
        cin >> tl >> tr;
        l = max(l,tl);
        r = min(r,tr);
    }

    if(r-l+1<0){
        cout << 0 << endl;
        return 0;
    }
    cout << r-l+1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    
    string s;
    while(cin>>s) {
      if(s.length()==2)
        cout<<s<<endl;
      else {
        for(int i=2;i>=0;i--)
          cout<<s[i];
          cout<<endl;
      }
    }
    
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int u[] = new int[N - 1];
		int v[] = new int[N - 1];
		int w[] = new int[N - 1];
		
		
		LinkedList list[] = new LinkedList[N];
		LinkedList list2[] = new LinkedList[N];
		for(int i = 0; i < N; i++) {
			list[i] = new LinkedList();
			list2[i] = new LinkedList();
		}
		
		for(int i = 0; i < N - 1; i++) {
			u[i] = sc.nextInt() - 1;
			v[i] = sc.nextInt() - 1;
			w[i] = sc.nextInt();
			if(w[i] % 2 == 1) {
				list[u[i]].add(v[i]);
				list[v[i]].add(u[i]);
			} else {
				list2[u[i]].add(v[i]);
				list2[v[i]].add(u[i]);
			}
		}
		int ans[] = new int[N];
		Queue<Integer> queue = new ArrayDeque<Integer>();
		Queue<Integer> queue2 = new ArrayDeque<Integer>();
		ans[0] = 0;
		if(list[0].size() != 0) {
		queue.add(0);
		}
		if(list2[0].size() != 0) {
		queue2.add(0);
		}
		Arrays.fill(ans, -1);
		//for(int k = 0; k < N; k++) {
			/*if(ans[k] == -1 && queue.size() == 0) {
				queue.add(k);
				ans[k] = 1;
			}*/
		while(queue.size() != 0 || queue2.size() != 0) {
			int i = 0;
			
			while(queue.size() != 0) {
				i = queue.poll();
				for(int j = 0; j < list[i].size(); j++) {
					if(ans[i] == 1 && ans[list[i].get(j)] == -1) {
						queue.add(list[i].get(j));
						queue2.add(list[i].get(j));
						ans[list[i].get(j)] = 0;
					} else if(ans[list[i].get(j)] == -1){
						queue.add(list[i].get(j));
						queue2.add(list[i].get(j));
						ans[list[i].get(j)] = 1;
					}
				}
			}
			while(queue2.size() != 0) {
				i = queue2.poll();
				for(int j = 0; j < list2[i].size(); j++) {
					if(ans[i] == 1 && ans[list2[i].get(j)] == -1) {
						queue.add(list2[i].get(j));
						ans[list2[i].get(j)] = 1;
						queue2.add(list2[i].get(j));
					} else if(ans[list2[i].get(j)] == -1){
						queue.add(list2[i].get(j));
						ans[list2[i].get(j)] = 0;
						queue2.add(list2[i].get(j));
					}
				}
			}
		}
		while(queue.size() != 0) {
			int i = queue.poll();
				for(int j = 0; j < list[i].size(); j++) {
					if(ans[i] == 1 && ans[list[i].get(j)] == -1) {
						queue.add(list[i].get(j));
						ans[list[i].get(j)] = 0;
					} else if(ans[list[i].get(j)] == -1){
						queue.add(list[i].get(j));
						ans[list[i].get(j)] = 1;
					}
				}
		}
		//}
		for(int i = 0; i < N; i++) {
			System.out.println(ans[i]);
		}
	}
}


class LinkedList {
	ArrayList<Integer> link = new ArrayList<Integer>();
	public void add(int vertex) {
		link.add(vertex);
	}

	public int get(int i){
		return link.get(i);
	}
	
	public void remove(int vertex) {
	}
	
	public void view() {
		for(int i = 0; i < link.size(); i++) {
			System.out.println(link.get(i));
		}
	}
	
	public boolean linked(int vertex) {
		if(link.contains(vertex)){
			return true;
		} else {
			return false;
		}
	}

	public int size() {
		return link.size();
	}
}


Measured memory_bytes: 121472
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;
const auto MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef vector<int> VI;
typedef vector<long long> VLL;


int n, m,a,b;
string s;

int main() {
	cin >> n >> m;
	int x[10][10];
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a;
			x[j][i] = a;
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = i+1; j < n; j++)
		{
			double c=0;
			for (int k = 0; k < m; k++)
			{
				c += (x[k][i] - x[k][j])*(x[k][i] - x[k][j]);
			}
			int f = sqrt(c);
			if (c == f * f)ans++;
		}
	}
	cout << ans<<endl;
}

Measured memory_bytes: 256
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define ld long double
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    string s;
    set<string> st;
    void solve()
    {
        cin>>n;
        fo(i,0,n)
        {
            cin>>s;
            st.insert(s);
        }

        cout<<st.size()<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 19248
from sys import stdin
input = stdin.readline

N, A = [int(x) for x in input().rstrip().split()]
x = [int(x) for x in input().rstrip().split()]

X = max(max(x), A)
# dp = [[[0]*(N*X+1) for _ in range(N+1)] for _ in range(N+1)]
# for j in range(N+1):
# 	for k in range(N+1):
# 		for s in range(N*X+1):
# 			if j == 0 and k == 0 and s == 0:
# 				dp[j][k][s] = 1
# 			elif j >= 1 and s < x[j-1]: # 探索先が総和より大きい
# 				dp[j][k][s] = dp[j-1][k][s]
# 			elif j >= 1 and k >= 1 and s >= x[j-1]:
# 				dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
# 			else:
# 				dp[j][k][s] = 0
# sum = 0
# for i in range(1, N+1):
# 	sum += dp[N][i][i*A]
# print(sum)

dp = [[0]*(2*N*X+1) for _ in range(N+1)]
y = [0] * len(x)
for i in range(len(x)):
	y[i] = x[i]-A

for j in range(N+1):
	for t in range(2*N*X+1):
		if j == 0 and t == N*X:
			dp[j][t] = 1
		elif j >= 1 and (t-y[j-1] < 0 or t-y[j-1] > 2*N*X):
			dp[j][t] = dp[j-1][t]
		elif j >= 1 and 0 <= t-y[j-1] <= 2*N*X:
			dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j-1]]
		else:
			dp[j][t] = 0
print(dp[N][N*X]-1)

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

int main() {
    int64_t N, K, S;
    cin >> N >> K >> S;
    for (int64_t i = 0; i < K; i++) {
        cout << S << " ";
    }
    for (int64_t i = 0; i < N - K; i++) {
        cout << (S + 1) % int64_t(1e9) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1280
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	static int N;
	static double[] r;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		r = new double[N];
		for (int i = 0; i < N; ++i)
			r[i] = sc.nextDouble();
		Arrays.sort(r);
		int s = 0;
		int t = r.length - 1;
		while (s < t) {
			double d = r[s];
			r[s] = r[t];
			r[t] = d;
			++s;
			--t;
		}
		double ans = 0;
		while (N >= 3) {
			int[] ord = new int[N];
			for (int i = 0; i < N; ++i)
				ord[i] = i;
			do {
				double min = Double.MAX_VALUE / 16;
				for (int i = 0; i < N; ++i)
					min = Math.min(min, r[ord[i]] * r[ord[(i + 1) % N]]);

				double upper = Math.PI;
				double lower = 0;
				double okSum = 0;
				for (int i = 0; i < 100; ++i) {
					double middle = (upper + lower) / 2;
					double sum = 0;
					for (int j = 0; j < N; ++j) {
						sum += Math.acos(min / (r[ord[j]] * r[ord[(j + 1) % N]]) * Math.cos(middle));
					}
					if (sum > 2 * Math.PI)
						upper = middle;
					else {
						lower = middle;
						okSum = sum;
					}
				}
				if (okSum / (2 * Math.PI) < 1e-5) {
					continue;
				}
				double tmp = 0;
				for (int i = 0; i < N; ++i) {
					double sin = min / (r[ord[i]] * r[ord[(i + 1) % N]]) * Math.cos(lower);
					tmp += 0.5 * r[ord[i]] * r[ord[(i + 1) % N]] * Math.sqrt(1 - sin * sin);
				}
				ans = Math.max(ans, tmp);

			} while (nextPermutation(ord));
			--N;
		}
		System.out.println(ans);
	}

	static boolean nextPermutation(int[] ord) {
		int n = ord.length;
		int i = n - 1;
		while (i - 1 >= 0 && ord[i - 1] > ord[i])
			--i;
		if (i == 0)
			return false;
		int j = i;
		while (j + 1 < n && ord[j + 1] > ord[i - 1])
			++j;
		int d = ord[i - 1];
		ord[i - 1] = ord[j];
		ord[j] = d;
		int t = n - 1;
		int s = i;
		while (s < t) {
			d = ord[s];
			ord[s] = ord[t];
			ord[t] = d;
			++s;
			--t;
		}
		return true;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

Measured memory_bytes: 30816
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N; cin>>N;
    int M = N*(N-1)/2 - N/2;
    cout << M << endl;
    vector<vector<int>> G(N+1, vector<int>(N+1, 1));
    if(N%2==0){
        FOR(i, 1, N/2+1){
            G[i][N-i+1] = 0;
        }
    } else {
        FOR(i, 1, N/2+1){
            G[i][N-i] = 0;
        }
    }
    FOR(i, 1, N+1){
        FOR(j, i+1, N+1){
            if(G[i][j]) {
                cout << i << " " << j << "\n";
            }
        }
    }
    cout << flush;
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    ans=0
    a=1
    N+=1
    while N>a:
        a*=K
        ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
from math import ceil
A, B, C, X, Y = map(int, input().split())
ans = float('inf')

ans = min(ans, A * X + B * Y)
ans = min(ans, C * max(X, Y) * 2)

if X > Y:
    num = 2 * Y
    ans = min(ans, num * C + ceil(X - Y) * A)
else:
    num = 2 * X
    ans = min(ans, num * C + ceil(Y - X) * B)
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<string>
#define ll long long
#define lld long double
#define llu unsigned long long int
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define gll(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define mod 1000000007
#define mod1 998244353
#define pi 3.1415926535897
using namespace std;
ll n,m,cnt=0;
string s[20002];
map<pair<ll, ll>, ll> vis;
void dfs(ll x, ll y)
{
    vis[mp(x,y)]=1;
    cnt++;
    if(x+1<n)
    {
        if(s[x+1][y]!='#' && vis[mp(x+1,y)]==0)
            dfs(x+1, y);
    }
    if(y+1<m)
    {
        if(s[x][y+1]!='#' && vis[mp(x,y+1)]==0)
            dfs(x, y+1);
    }
    if(x-1>=0)
    {
        if(s[x-1][y]!='#' && vis[mp(x-1,y)]==0)
            dfs(x-1, y);
    }
    if(y-1>=0)
    {
        if(s[x][y-1]!='#' && vis[mp(x,y-1)]==0)
            dfs(x, y-1);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("B-small-attempt0.in", "r", stdin);freopen("output.txt", "w", stdout);
    //std::cout << std::setprecision(9);
    //std::cout << std::fixed;
    ll i,j;
    cin>>n>>m;
    for(i=0;i<n;i++)
        cin>>s[i];
    ll ans=0;
    ll hor[n][m],ver[n][m];
    memset(hor,0,sizeof(hor));
    memset(ver,0,sizeof(ver));
    for(i=0;i<n;i++)
    {
        ll c=0,f=0;
        vector<ll> v;
        for(j=0;j<m;j++)
        {
            if(s[i][j]=='.')
            {
                c++;
                f=1;
            }
            else
            {
                if(f==1)
                {
                    v.pb(c);
                    f=0;
                }
                c=0;
            }
        }
        if(c!=0)
            v.pb(c);
        ll pos=0,flag=0;
        for(j=0;j<m;j++)
        {
            if(s[i][j]=='.')
            {
                ver[i][j]=v[pos];
                flag=1;
            }
            else
            {
                if(flag==1)
                {
                    pos++;
                    flag=0;
                }
            }
        }
    }

    for(j=0;j<m;j++)
    {
        ll c=0,f=0;
        vector<ll> v;
        for(i=0;i<n;i++)
        {
            if(s[i][j]=='.')
            {
                c++;
                f=1;
            }
            else
            {
                if(f==1)
                {
                    v.pb(c);
                    f=0;
                }
                c=0;
            }
        }
        if(c!=0)
            v.pb(c);
        ll pos=0,flag=0;
        for(i=0;i<n;i++)
        {
            if(s[i][j]=='.')
            {
                hor[i][j]=v[pos];
                flag=1;
            }
            else
            {
                if(flag==1)
                {
                    pos++;
                    flag=0;
                }
            }
        }
    }
    /*for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            cout<<hor[i][j]<<" ";
        cout<<endl;
    }*/
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            ans=max(ans,ver[i][j]+hor[i][j]-1);
        }
    }
    cout<<ans;
}


Measured memory_bytes: 67200
#include<stdio.h>
int main(void){
	int a,b,c,x;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){
		x=a;
		a=b;
		b=x;
	}if(a>c){
		x=a;
		a=c;
		c=x;
	}if(b>c){
		x=b;
		b=c;
		c=x;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

long long N,M;

int main(){
    cin>>N>>M;
    if(N==1&&M==1){
        out(1);
        return 0;
    }
    else if(M==1){
        out(N-2);
        return 0;
    }
    else if(N==1){
        out(M-2);
        return 0;
    }
    else if(N==2&&M==3){
        out(0);
        return 0;
    }
    else if(N==3&&M==2){
        out(0);
        return 0;
    }
    else{
        out((N-2)*(M-2));
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define tam 100000
#define se second
#define fi first
#define pitem item*
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1000000007 ;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef  double lld;
int txt[tam];
int val[tam];
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    forr(i,0,s.size())
    {
        if (s[i]=='o')
            txt[i]=0;
        else
            txt[i]=1;
    }    
    int cond,ult;
    forr(i,0,2)
    {
        val[0]=i%2;
        forr(j,0,2)
        {
            val[1]=j%2;
            ult=val[0]^txt[0]^val[1];
            //cout<<val[0]<<" "<<val[1]<<" "<<ult<<endl;
            forr(k,1,s.size()-1)
            {
                cond=val[k]^txt[k];
                val[k+1]=val[k-1]^cond;
            }
            
            if (val[n-1]==ult&& (val[n-2]^val[0])==(val[n-1]^txt[n-1]) )
            {
                forr(a,0,n)
                {
                    if (val[a]==1)
                        cout<<"W";
                    else
                        cout<<"S";
                }
                return 0;
            }
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[214514];
ll gya(ll n,ll p,ll m){
	ll b=1;
	while(p){
		if(p%2)b=(b*n)%m;
		n=(n*n)%m;
		p/=2;
	}
	return b;
}
int main(){
	ll n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	ll ans=0,mod=1e9+7,num=0;
	for(int i=0;i<n;i++){
		ans+=a[i];
		ans%=mod;
		num+=a[i]*a[i];
		num%=mod;
	}
	ans*=ans;
	ans%=mod;
	ans=(ans-num);
	ans+=mod;
	ans%=mod;
	ll x=gya(2,mod-2,mod);
	ans*=x;
	ans%=mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i++<n;)
ll INF=1e9;

int main(){
  ll n,m,a[55],b[55],c[55],d[55],e[55][55],f[55];
  cin>>n>>m;
  fr(i,n) cin>>a[i]>>b[i];
  fr(i,m) cin>>c[i]>>d[i];
  fr(i,n) f[i]=INF;
  fr(i,n){
    fr(j,m){
      e[i][j]=abs(a[i]-c[j])+abs(b[i]-d[j]);
      f[i]=min(f[i],e[i][j]);
    }
  }
  fr(i,n){
    fr(j,m){
      if(e[i][j]==f[i]){
        cout<<j<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define rap(i,j,k) for(int i=j;i>=k;--i)
#define ser(i,j)   for(int i=e[j].y;i;i=e[i].n)
#define ll         long long
using namespace std;
int read()
{
	int num=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())num=(num<<1)+(num<<3)+c-48;
	return num*f;
}
const int mn=110;
int n,m,t,H,len,ans,a[mn],cx,cy;
struct point
{
	int x,y,h;
}p[mn];
void fre()
{
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
}
int get(int x,int y)
{
	return abs(x-cx)+abs(y-cy);
}
void init()
{
	n=read();
	rep(i,1,n)
	{
		p[i].x=read();p[i].y=read();p[i].h=read();
	}
}
void bf_work()
{
	
}
void work()
{
	for(cx=0;cx<=100;cx++)
	{
		for(cy=0;cy<=100;cy++)
		{
			bool f=1;
			int ch=0;
			rep(i,1,n)
			{
				int xx=p[i].x,yy=p[i].y,hh=p[i].h;
				if(hh!=0)
				{
					ch=hh+get(xx,yy);
					break;
				}
			}
			rep(i,1,n)
			{
				int xx=p[i].x,yy=p[i].y,hh=p[i].h;
				if(hh==0)
				{
					if(ch-get(xx,yy)>0)
					{
						break;
					}
				}
				else
				{
					if(ch!=hh+get(xx,yy))
					{
						break;
					}
				}
				if(i==n)
				f=0;
			}
			if(f==0)
			{
				printf("%d %d %d",cx,cy,ch);
			}
		}
	}
}
void re_zero()
{
	
}
int main()
{
	//fre();
		init();
		bf_work();
		work();
		re_zero();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
const int MAX_N = 60;
 
int main(int argc, char const *argv[])
{
    int n;
    double sum = 0, v[MAX_N];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    sort(v, v+n);
    sum = (v[0] + v[1]) /2;
    for (int i = 2; i < n; ++i) {
        sum = (sum + v[i]) / 2;
    }
    printf("%.16lf\n", (double)(sum));
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;

#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define sz(x) (int)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const ll INF = 1e18;
const ll mod = 1e9+7;
const int N = 5e5+10;

int a[N];
int b[N];
int c[N];
ll dp[N][3];

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

dp[0][0]=a[0];
dp[0][1]=b[0];
dp[0][2]=c[0];

for(int i=1;i<n;i++) {
    dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
}

cout<<max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]))<<endl;
return 0;
}

Measured memory_bytes: 7076
import sys; input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	X = int(input())
	for i in range(-201, 201):
		for j in range(i + 1, 201):
			if j ** 5 - i ** 5 == X:
				print(j, i)
				return

	# for i in range(402):
	# 	for j in range(i + 1, 402):
	# 		if L[j] - L[i] == X:
	# 			print(L[j], L[i])
	# 			return

if __name__ == '__main__':
	main()

Measured memory_bytes: 68008
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
    int n;
    bool flag=false;
    string s[105];
    cin >> n;
    for(int i=1;i<=n;i++)
    {
        cin >> s[i];
        if(i!=1 && s[i][0]!=s[i-1][s[i-1].size()-1])
            flag=true;
    }
    sort(s+1,s+n+1);
    for(int i=2;i<=n;i++)
        if(s[i-1]==s[i])
            flag=true;
    if(flag==true)
        cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 256
a = list(input())
if len(a) == 1:
    print(a[0])
else:
    c = 0
    for i in range(len(a)):
        b = ""
        d = 0
        for j in range(len(a)):
            if i == j:
                b += str(max(int(a[i]) - 1, 0))
                d += max(int(a[i]) - 1, 0)
            else:
                b += "9"
                d += 9
        if int(b) <= int("".join(a)):
            c = max(c, d)
    c = max(c, sum(map(int, a)))
    print(c)


Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);
#define rep(i, a, b) for(register int i = a; i <= b; i++)
#define per(i, a, b) for(register int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }
    while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if(x < 0) putchar('-'), x = -x;
    if(x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 6666, md = 1e9 + 7;

inline int add(int x, int y) {
    x += y;
    if(x >= md) x -= md;
    return x;
}

inline void addx(int &x, int y) {
    x += y;
    if(x >= md) x -= md;
}

inline int sub(int x, int y) {
    x -= y;
    if(x < 0) x += md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

inline int fpow(int x, int y) {
    int ans = 1;
    while(y) {
        if(y & 1) ans = mul(ans, x);
        y >>= 1; x = mul(x, x);
    }
    return ans;
}

int f[N][N];
int n, m, k, lim, ans;

bool check(int x, int y) {
    return x <= n && y <= m && (n - x) % (k - 1) == 0 && (m - y) % (k - 1) == 0;
}

int main() {
    read(n); read(m); read(k); lim = (n + m - 1) / (k - 1);
    f[0][0] = 1;
    for(register int i = 0; i < lim; i++) {
        for(register int j = 0; j <= i * (k - 1); j++) {
            if(!f[i][j]) continue;
            for(register int t = 0; t <= k - 1; t++) {
                addx(f[i + 1][j + t], f[i][j]);
                if(t >= 1 && check(j + t, (k - 1) * i + k - j - t)) addx(ans, f[i][j]);
            }
        }
    }
    print(ans, '\n');
    return 0;
}

Measured memory_bytes: 102912
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    a = [int(i) for i in ipt().split()]
    pi = [-1]*(n+1)
    x1 = 0
    x2 = 0
    for i,ai in enumerate(a):
        if pi[ai] == -1:
            pi[ai] = i
        else:
            x1 = pi[ai]
            x2 = n-i
            break
    xt = x1+x2

    #nCrをmodで割った余りを求める。Nに最大値を入れて使用。
    N = n+1
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    def cmb(n,r,mod=(10**9+7)):
        if r<0 or r>n :
            return 0
        r = min(r,n-r)
        return g1[n]*g2[r]*g2[n-r]%mod
    for i in range(2,N+1):
        g1.append((g1[-1]*i)%mod)
        inverse.append((-inverse[mod % i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    for i in range(1,n+2):
        print((cmb(n+1,i)-cmb(xt,i-1))%mod)


    return None

if __name__ == '__main__':
    main()


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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n = 0;
    cin >> n;
    vector<int> a(n);
    for (int& it : a)
        cin >> it;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            for (int k = j + 1; k < n; k++) 
                if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k] && a[i] + a[j] > a[k]) 
                    ans++;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3604
<?php
  list($a,$b) = explode(" ", trim(fgets(STDIN)));

  $x=$a*pow(10, strlen($b))+$b;

  for($i=0;$i*$i<=$x;$i++){
    if($i*$i == $x){
      echo "Yes";
      exit;
    }
  }
  echo "No";
  exit;

Measured memory_bytes: 16012
N=int(input())
txy=list(list(map(int,input().split())) for _ in range(N))
for i in range(N):
    if i!=0 and not((txy[i][0]-txy[i-1][0]>=(txy[i][1]+txy[i][2])-(txy[i-1][1]+txy[i-1][2]))\
            and ((txy[i][0]-txy[i-1][0])%2==((txy[i][1]+txy[i][2])-(txy[i-1][1]+txy[i-1][2]))%2)):
        print('No')
        exit()
    elif i==0 and not((txy[i][0]>=(txy[i][1]+txy[i][2]))\
            and ((txy[i][0])%2==(txy[i][1]+txy[i][2])%2)):
        print('No')
        exit()
print('Yes')

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

vector<int> solve(int N) {
    vector<int> era(N+1);
    vector<int> ret;
    ret.push_back(N);
    for (int i = 2; i <= N; i++) {
        if (era[i] == 0 && (i%7 == 1 || i%7 == 6)) {
            if (N%i == 0) ret.push_back(i);
            for (int j = i; j <= N; j += i) {
                era[j] = 1;
            }
        }
    }
    return ret;
}

int main(void){
    int N;
    vector<vector<int>> ans;
    while (1) {
        cin >> N;
        if (N == 1) break;
        ans.push_back(solve(N));
    }
    for (auto &vec : ans) {
        for (size_t i = 0; i < vec.size(); i++) {
            if (i == 0) cout << vec[i] << ": ";
            else if (i == vec.size() - 1) cout << vec[i] << endl;
            else cout << vec[i] << " ";
            
        }
    }
    
}



Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
const int N = 410, INF = 1 << 29;
char s[N];
int a[N], cnt[N][3], ord[3][N];
int dp[N][N][3], tmp[N][N][3];
int mp[256];
int main() {
    mp['R'] = 0;
    mp['Y'] = 1;
    mp['G'] = 2;
    int n;
    scanf("%d%s", &n, s + 1);
    for (int i = 1; i <= n; ++i) {
        a[i] = mp[s[i]];
        for (int j = 0; j < 3; ++j) cnt[i][j] = cnt[i - 1][j] + (a[i] == j);
        ord[a[i]][cnt[i][a[i]]] = i;
    }
    fill(**dp, dp[N - 1][N - 1] + 3, INF);
    dp[0][0][0] = dp[0][0][1] = dp[0][0][2] = 0;
    int n0 = cnt[n][0], n1 = cnt[n][1], n2 = cnt[n][2];
    for (int i = 0; i < n; ++i) {
        memcpy(tmp, dp, sizeof(tmp));
        fill(**dp, dp[N - 1][N - 1] + 3, INF);
        for (int r0 = 0; r0 <= n0; ++r0)
            for (int r1 = 0; r1 <= n1; ++r1) {
                int r2 = i - r0 - r1;
                if (r2 > n2 || r2 < 0)
                    continue;
                for (int f = 0; f < 3; ++f) {
                    for (int t = 0; t < 3; ++t) {
                        if (t == f)
                            continue;
                        int q0 = r0 + (t == 0), q1 = r1 + (t == 1), q2 = r2 + (t == 2);
                        if (q0 > n0 || q1 > n1 || q2 > n2)
                            continue;
                        int cdp = tmp[r0][r1][f];
                        static int qa[3];
                        qa[0] = q0;
                        qa[1] = q1;
                        qa[2] = q2;
                        int pos = ord[t][qa[t]];
                        for (int j = 0; j < 3; ++j) cdp += max(0, cnt[pos][j] - qa[j]);
                        dp[q0][q1][t] = min(dp[q0][q1][t], cdp);
                    }
                }
            }
    }
    int ans = *min_element(dp[n0][n1], dp[n0][n1] + 3);
    printf("%d\n", ans < INF ? ans : -1);
    return 0;
}


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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] nums = sc.nextLine().split(" ");
        String[] ps = sc.nextLine().split(" ");

        int n = Integer.parseInt(nums[0]);
        int k = Integer.parseInt(nums[1]);

        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(ps[i]);
        }
        Arrays.sort(arr);
        int sum = 0;
        for (int j = 0; j < k; j++) {
            sum += arr[j];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 36672
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define MAX 5005
using namespace std;

LL pang(LL x, LL y) {
	if (y == 1) return x;
	LL res = pang(x, y/2);
	res = (res * res)%MOD;
	if (y & 1) return (res * x)%MOD;
	return res;
}

LL dp[MAX][MAX];
int n, len;
char K[MAX];
LL f(int i, int x) {
	if (x == 0) {
		if (i == len) return 1;
		return 0;
	}
	LL &ret = dp[i][x];
	if (ret >= 0) return ret;
	ret = f(max(i-1,0),x-1);
	ret += 2LL*f(i+1,x-1);
	ret %= MOD;
	return ret;
}

int main() {
	scanf("%d",&n);
	scanf("%s",K);
	len = strlen(K);
	memset(dp,-1,sizeof(dp));
	//cout << f(0, n) << " " << len << endl;
	printf("%lld\n",(f(0,n)*pang(pang(2,len),MOD-2))%MOD);
}

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

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

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n, k; cin >> n >> k;
  int scores[n];
  for(int i = 0; i < n; ++i) {
    cin >> scores[i];
  }
  for(int i = k; i < n; ++i) {
    if(scores[i] > scores[i-k]) {
      cout << "Yes" << "\n";
    } else {
      cout << "No" << "\n";
    }
  }
  return 0;
}
/***** MAIN *****/


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

const int mod = 1000000007;

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

    int64_t res = 0;
    for (int64_t i = k; i <= n + 1; i++)
    {
        int64_t mn = (i - 1) * i / 2;
        int64_t mx = (n + n - i + 1) * i / 2;
        res = (res + mx - mn + 1) % mod;
    }
    cout << res << endl;
}

Measured memory_bytes: 3588
s=input()
n=len(s)
if not(s==s[::-1]):
  print("No")
  exit()
if not(s[:(n-1)//2]==s[:(n-1)//2][::-1]):
  print("No") 
  exit()
if not(s[(n+3)//2-1:]==s[(n+3)//2-1:][::-1]):
  print("No")
  exit()
print("Yes")

       


Measured memory_bytes: 38384
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
  int n,k;
  int a[100001];
  cin>>n>>k;
  for(int i=0;i<n;i++)
    cin>>a[i];
  cout<<(n-2)/(k-1)+1<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=105;
int s[N];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	int cnt=0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",s+i);
		if(s[i]&1)cnt++;
	}
	if(cnt>2)printf("Impossible\n");
	else 
	{
//		if(cnt==1)while(1){printf("caonidaoye\n");}

		if(m==1)
		{
			if(s[1]>1)printf("%d\n2\n%d %d\n",s[1],1,s[1]-1);
			else printf("1\n1\n1\n");
		}
		else 
		{
			for(int i=1;i<=m;i++)if(s[i]&1){std::swap(s[1],s[i]);break;}
			for(int i=2;i<=m;i++)if(s[i]&1){std::swap(s[m],s[i]);break;}

			for(int i=1;i<=m;i++)printf("%d ",s[i]);printf("\n");

			printf("%d\n",m-(s[m]==1));
			printf("%d ",s[1]+1);
			for(int i=2;i<m;i++)printf("%d ",s[i]);
			if(s[m]>1)printf("%d\n",s[m]-1);
		}
	}
	return 0;
}


Measured memory_bytes: 256
import { Hash } from "crypto";
import { access } from "fs";

class Input {
    private lines: string[];
    constructor(lines: string[]) {
        this.lines = lines;
    }

    public string(): string { return this.lines.shift() as string; }
    public int(): number { return parseInt(this.string()); }
    public intArray(): number[] { return this.string().split(" ").map(n => parseInt(n)); }
    public stringArray(): string[] { return this.string().split(" "); }

    public allLines(): string[] { return this.lines; }
    public allLinesInt(): number[] { return this.lines.map(s => parseInt(s)); }
    public allLinesIntArray(): number[][] { return this.lines.map(s => s.split(" ").map(n => parseInt(n))); }
    public allLinesStringArray(): string[][] { return this.lines.map(s => s.split(" ")); }
}


function calc(stdin: Input) {
    const first = stdin.intArray();
    const A = first[0];
    const B = first[1];
    const Q = first[2];
    const lines = stdin.allLinesInt();
    const s = [-1000000000000].concat(lines.slice(0, A));
    const t = [-1000000000000].concat(lines.slice(A, A + B));
    s.push(1000000000000);
    t.push(1000000000000);

    const x = lines.slice(A + B, A + B + Q);
    const sortedX = x.concat().sort((a, b) => a - b);

    const res = new Map<number, number>();
    let i = 1;
    let j = 1;
    sortedX.forEach(a => {
        while (true) {
            if (a < s[i]) {
                while (a > t[j]) j++;
                res.set(a, CalcPoint(a, t[j - 1], t[j], s[i - 1], s[i]));
                break;
            }

            if (a < t[j]) {
                while (a > s[i]) i++;
                res.set(a, CalcPoint(a, t[j - 1], t[j], s[i - 1], s[i]));
                break;
            }

            ++i, ++j;
        }
    });
    return x.map(i => res.get(i)).join("\n");
}

function CalcPoint(a: number, s1: number, s2: number, t1: number, t2: number): number {
    return Math.min(
        a - s1 + Math.abs(s1 - t1),
        a - s1 + Math.abs(s1 - t2),
        a - t1 + Math.abs(s1 - t1),
        a - t1 + Math.abs(s2 - t1),
        s2 - a + Math.abs(s2 - t1),
        s2 - a + Math.abs(s2 - t2),
        t2 - a + Math.abs(s1 - t2),
        t2 - a + Math.abs(s2 - t2),
    );
}

function main(stdin: string) {
    console.log(calc(new Input(stdin.split("\n"))));
}

if (require.main && require.main.filename.indexOf("Main") >= 0) {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
} else {
    main(require('fs').readFileSync('input.txt', 'utf8').trim());
}

Measured memory_bytes: 87236