akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

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

constexpr ll MOD = 1e18;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, m, r; cin >> n >> m >> r;
  vi town(r);

  rep(i, r) cin >> town[i];

  int dp[201][201];
  rep(i, 201) rep(j, 201) {
    if (i == j) dp[i][j] = 0;
    else dp[i][j] = MOD;
  }

  rep(i, m) {
    int a, b, c; cin >> a >> b >> c;
    chmin(dp[a-1][b-1], c);
    chmin(dp[b-1][a-1], c);
  }

  rep(k, n) rep(i, n) rep(j, n) {
    if (dp[i][k] == MOD || dp[k][j] == MOD) continue;
    if (dp[i][j] > dp[i][k] + dp[k][j]) {
      dp[i][j] = dp[i][k] + dp[k][j];
    }
  }

  ll ans = MOD;
  sort(all(town));

  do {
    ll score = 0;
    rep(i, r-1) score += dp[town[i]-1][town[i+1]-1];

    chmin(ans, score);

  } while (next_permutation(all(town)));

  cout << ans << endl;

  return (0);
}


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

#define SORT(v) sort(v.begin(),v.end())
#define si(n) scanf("%d",&n)
#define sii(n,m) scanf("%d %d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld %lld",&n,&m)
#define ss(cad) scanf("%s",cad)
#define PB push_back
#define fst first
#define scn second
#define DBG(x) cerr << #x << " = " << (x) << endl; 
#define M 1000000007
#define N_MAX 100010

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vp;

int main()
{
	int k;
	si(k);
	ll ans = 0;
	for(int i = 1; i <= k; i++)
		for(int j = 1; j <=k; j++)
			for(int m = 1; m <= k; m++)
			{
				int a = __gcd(i, j);
				a = __gcd(a, m);
				ans += a;
			}
	printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<set>
#include<map>
#define ll long long
using namespace std;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {
	
	int n, m, x;
	int a[150] = {};
	int countA = 0;
	int countB = 0;

	cin >> n >> m >> x;

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

	for (int i = 0; i < m; i++) {
		if (a[i] < x) {
			countA++;
		}
		if (x < a[i]) {
			countB++;
		}
	}

	cout << min(countA, countB) << endl;

}

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

int solution(int a , int b,int c, int k){

    if (k<=a) 
    return k;
    
    else if (k>a && k<=a+b)
    return a;

    else
    return 2*a + b - k;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b , c ,k;
    cin >>a >>b>>c >>k;

    cout << solution(a , b, c ,k);

    



    return 0;

}


Measured memory_bytes: 3652
def main():
    import sys
    from collections import Counter

    input = sys.stdin.readline
    input()
    a = tuple(map(int, input().split()))
    ans = sum(a)
    a = Counter(a)
    for _ in range(int(input())):
        b, c = map(int, input().split())
        if b in a:
            ans += (c - b) * a[b]
            a[c] = a[c] + a[b] if c in a else a[b]
            del a[b]
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21324
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,i,j,k,x=0,y,z;
    cin>>n>>m;
    /*y=min(n,m);
    z=y*2;
    if((n==1 && m==2) || (n==2 && m==1)){
        cout<<2<<endl;
        return 0;
    }
    while(1){
        long long a=z/n;
        long long b=z/m;
        long long c=(n*a);
        long long d=(m*b);
        if(c==z && d==z){
            cout<<z<<endl;
            return 0;
        }
        else{
            z=z+2;
        }
    }*/
    x=__gcd(n,m);
    y=(n*m)/x;
    cout<<y<<endl;
}




Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	ll E,T;
	cin>>E>>T;
	vll v(n);
	rep(i,n) cin>>v[i];
	v.PB(E);
	v.PB(INFL);
	n++;
	vll dp(n,INFL);
	dp[0]=0;
	int it = 0;
	int it2 = 0;
	rep(i,n-1){
		while(it<n){
			if(v[it]>v[i]+T/2) break;
			it++;
		}
		mins(dp[min(it,n-1)],dp[i]+T);
		while(it2<n){
			if(v[it2]>v[i]+T) break;
			it2++;
		}
		mins(it2, n-1);
		ll t = dp[i]-2*v[i];
		reep(j,it+1,it2+1){
			mins(dp[j], t+v[j-1]+v[j-1]);
		}
		// reep(j,i+1,n+1){
		// 	if(2*(v[j-1]-v[i])<=T){
		// 		mins(dp[j],dp[i]+T);
		// 	}
		// 	else{
		// 		mins(dp[j],dp[i]+2*(v[j-1]-v[i]));
		// 	}
		// }
	}
	cout<<dp[n-1]+E<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main() 
{
  ll n,m,x;
  cin>>n>>m>>x;
  vector<pair<int,vector<int>>>inp(n);
  for(int i=0;i<n;i++)
  {
    int c;
    cin>>c;
    vector<int>algo(m);
    for(int j=0;j<m;j++)
    {
      cin>>algo[j];
    }
    inp[i]={c,algo};
  }
  int limit=1<<n,ans=1e9;
  for(int i=0;i<limit;i++)
  {
    int cur=0;
    vector<int>skill(m,0);
    for(int j=0;j<n;j++)
    {
      if(i&(1<<j))
      {
        cur+=inp[j].first;
        for(int k=0;k<m;k++)
        {
          skill[k]+=inp[j].second[k];
        }
      }
    }
    for(int k=0;k<m;k++)
    {
      if(skill[k]<x)
        cur=1e9;
    }
    ans=min(ans,cur);
  }
  if(ans==1e9)
    ans=-1;
  cout<<ans<<endl;
  return 0;
}























Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,k,i,ans = 0;scanf("%lld%lld%lld",&n,&m,&k);
  ll a[n+1],b[m+1];a[0] = b[0] = 0;
  for(i=1;i<=n;i++) scanf("%lld",&a[i]);
  for(i=1;i<=m;i++) scanf("%lld",&b[i]);
  for(i=1;i<=n;i++) a[i] += a[i-1];
  for(i=1;i<=m;i++) b[i] += b[i-1];
  for(i=0;i<=n;i++){
    if(a[i]>k) break;
    auto s = lower_bound(b,b+m+1,k-a[i]);
    if(*s==k-a[i]) ans = max(ans,(long long)(i+s-b));
    else ans = max(ans,(long long)(i+s-b-1));
  }
  printf("%lld\n",ans);
}

Measured memory_bytes: 6944
//
//  main.cpp
//  绌舵瀬閿洏
//
//  Created by RMBP on 2019/10/27.
//  Copyright 漏 2019 RMBP. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    string a;
    int i,b[12],j;
    cin>>a;
    for (i=0;i<12;i++){
        b[i]=2;
    }
    for (i=0;i<a.size();i++){
        if (a[i]!='B'){
            for (j=0;j<12;j++){
                if (b[j]==2){
                    b[j]=a[i]-'0';
                    break;
                }
            }
            
        }
        else {
            for (j=1;j<12;j++){
                if (b[j]==2){
                    b[j-1]=2;
                    break;
                }
            }
        }
    }
    for (i=0;i<10;i++){
        if (b[i]!=2)
            cout<<b[i];
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		Integer[] a = new Integer[A];
		Integer[] b = new Integer[B];
		Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
		Arrays.setAll(b, i -> Integer.parseInt(sc.next()));
		List<Integer> listA = new ArrayList<>(Arrays.asList(a));
		List<Integer> listB = new ArrayList<>(Arrays.asList(b));
		int waribiki = Integer.MAX_VALUE;
		for(int i=0; i<M; i++){
			int x = listA.get(Integer.parseInt(sc.next()) - 1);
			int y = listB.get(Integer.parseInt(sc.next()) - 1);
			int c = Integer.parseInt(sc.next());
			if(x + y - c < waribiki){
				waribiki = x + y - c;
			}
		}
		listA.sort(Comparator.naturalOrder());
		listB.sort(Comparator.naturalOrder());
		int min = listA.get(0) + listB.get(0);
		
		System.out.println(min < waribiki ? min : waribiki);
	}
}


Measured memory_bytes: 67000
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  double r;
  cin >> r;
  cout << fixed << setprecision(10) << r*r*PI << " " << 2*r*PI << endl;
  return 0;
}



Measured memory_bytes: 3228
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
ll x;
int main(){
    cin>>x;
    ll ans=0;
    ans+=x/500*1000;
    x=x%500;
    ans+=x/5*5;
    puts(ans);
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 pf(s): return print(s, flush=True)


class Edge():
    def __init__(self,t,f,r,ca,co):
        self.to = t
        self.fron = f
        self.rev = r
        self.cap = ca
        self.cost = co

class MinCostFlow():
    size = 0
    graph = []

    def __init__(self, s):
        self.size = s
        self.graph = [[] for _ in range(s)]

    def add_edge(self, f, t, ca, co):
        self.graph[f].append(Edge(t, f, len(self.graph[t]), ca, co))
        self.graph[t].append(Edge(f, t, len(self.graph[f])-1, 0, -co))

    def min_path(self, s, t):
        dist = [inf] * self.size
        route = [None] * self.size
        que = collections.deque()
        inq = [False] * self.size
        dist[s] = 0
        que.append(s)
        inq[s] = True
        while que:
            u = que.popleft()
            inq[u] = False
            for e in self.graph[u]:
                if e.cap == 0:
                    continue
                v = e.to
                if dist[v] > dist[u] + e.cost:
                    dist[v] = dist[u] + e.cost
                    route[v] = e
                    if not inq[v]:
                        que.append(v)
                        inq[v] = True

        if dist[t] == inf:
            return inf

        flow = inf
        v = t
        while v != s:
            e = route[v]
            if flow > e.cap:
                flow = e.cap
            v = e.fron

        c = 0
        v = t
        while v != s:
            e = route[v]
            e.cap -= flow
            self.graph[e.to][e.rev].cap += flow
            c += e.cost * flow
            v = e.fron

        return dist[t]

    def calc_min_cost_flow(self, s, t, flow):
        total_cost = 0
        for i in range(flow):
            c = self.min_path(s, t)
            if c == inf:
                return c
            total_cost += c

        return total_cost

def main():
    rr = []

    def f(n):
        a = sorted([LI() for _ in range(n)], key=lambda x: [x[1], x[0], -x[2]])
        mcf = MinCostFlow(368)
        s = 366
        t = 367
        for i in range(1,366):
            mcf.add_edge(i-1,i,2,0)
        for i,j,w in a:
            mcf.add_edge(i-1,j,1,-w)
        mcf.add_edge(s,0,2,0)
        mcf.add_edge(365,t,2,0)

        res = mcf.calc_min_cost_flow(s, t, 2)
        return -res

    while 1:
        n = I()
        if n == 0:
            break
        rr.append(f(n))

    return '\n'.join(map(str, rr))


print(main())



Measured memory_bytes: 9796
// #define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n = 3;
  std::vector<int> a(n); std::cin>>a;
  int sum = std::accumulate(all(a),0);
  int goal = n * *std::max_element(all(a));
  int dif = goal - sum;
  int ans = dif % 2 == 0 ? dif / 2 : (dif + 3) / 2;
  std::cout << ans << std::endl;
  return 0;
}

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

int main(){
	int n,i,p;
	cin>>n;
	i=n%2;
	vector<int> b(0);
	while(cin>>p){
		if(i%2)
			b.insert(b.begin(),p);
		else
			b.push_back(p);
		i++;
	}
	for(int j=0;j<n;j++){
		cout<<b[j]<<(b.size()==j+1?"":" ");
	}
}

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

using namespace std;
typedef long long ll;

const long long int MOD = 1000000007;
const int N = 701;
bool adj[N][N];
vector<int> adjc[N];
int col[N];
int in = 0;
vector<pair<int, int>> v;
bool dfs(int u, int c){
//  cout << u << ' ' << c << endl;
  col[u] = c;
  if(c == 1)
    v[in].first++;
  else
    v[in].second++;
  bool ok = 1;
  for(auto el : adjc[u]){
    if(!col[el]){
      ok = ok && dfs(el, 3 - c);
    }else{
      if(col[u] == col[el])
        return false;
    }
  }
  return ok;
}
int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  cin >> n >> m;
  int a, b;
  for(int i = 0;i < m;i++){
    scanf("%d %d", &a, &b);
    a--, b--;
    adj[a][b] = adj[b][a] = 1;
  }
  for(int i = 0;i < n;i++){
    for(int j = i + 1;j < n;j++){
      if(!adj[i][j]){
        adjc[i].push_back(j);
        adjc[j].push_back(i);

      }
    }
  }
  for(int i = 0;i < n;i++){
    if(!col[i]){
      v.push_back({0, 0});
      if(!dfs(i, 1)){
//        cout << i << endl;
        cout << -1;
        return 0;
      }
      in++;
    }
  }
  bitset<701> bt;
  bt[0] = 1;
//    cout << bt << endl;
  for(int i = 0;i < in;i++){
    bt = (bt << v[i].first) | (bt << v[i].second);
//    cout << bt << endl;
  }
  int res = 1e9;
//      cout << in << endl;
  for(int i = 0;i < n;i++){
    if(bt[i] == 1){
      res = min(res, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
    }
  }
  cout << res;
}



Measured memory_bytes: 3072
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String s = sc.next();

        if(k >= s.length()) {
            System.out.println(s);
        } else {
            for(int i=0; i<k; i++) {
                System.out.print(s.charAt(i));
            }
            System.out.println("...");
        }
    }
}

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

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];

    vector<vector<int>> res(H, vector<int>(W));
    int next_h = 0, next_w = 0;
    for (int a = 0; a < N; a++) {
        int n = A[a], cnt = 0;
        int h = next_h;
        for (int i = h; i < H && cnt < n; i++) {
            int w = next_w;
            if (i % 2 == 0) {
                for (int j = w; j < W && cnt < n; j++) {
                    res[i][j] = a + 1;
                    cnt++;
                    if (j == W - 1 && i <= H - 1) {
                        next_h = i + 1, next_w = j;
                    } else {
                        next_h = i; next_w = j + 1;
                    }
                }
            } else {
                for (int j = w; j >= 0 && cnt < n; j--) {
                    res[i][j] = a + 1;
                    cnt++;
                    if (j == 0 && i <= H - 1) {
                        next_h = i + 1, next_w = j;
                    } else {
                        next_h = i, next_w = j - 1;
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
  int n;
  long long S = 0;
  cin >> n;
  for(int i = 1;i < n + 1;i++) {
    if(i % 3 != 0 && i % 5 != 0) S += i;
  }
  cout << S << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N;
	cin >> N;
	vector<P>V(N);
	rep(i, N) {
		cin >> V[i].first >> V[i].second;
	}
	sort(V);
	cout << V[N-1].first + V[N-1].second << endl;
}


Measured memory_bytes: 1024
n = int(input())
ans = 0

c = [[0] * 10 for _ in range(10)]

for i in range(1,n + 1):
    c[int(str(i)[0])][int(str(i)[-1])]+=1

for i in range(10):
    for j in range(10):
        ans+=c[i][j] * c[j][i]
print(ans)

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

int main(){
int n; cin >> n;
vector<pair<double,double>> xy(n);
rep(i,n) {
  cin >> xy[i].first;
  cin >> xy[i].second;
}
double k=(n*(n-1))/2;
vector<double> ans(k); int o=0;
rep(i,n){
    rep(j,i){
        ans[o]=sqrt((xy[i].first-xy[j].first)*(xy[i].first-xy[j].first)+(xy[i].second-xy[j].second)*(xy[i].second-xy[j].second));
        o++;
    }
}
int ka=1; double kak=1;
//rep(i,n-2) ka*=(n+1);
rep(i,n) kak*=n+1;
double an=0;
rep(i,k) an+=ans[i]*((n-1)/k);
printf("%.16lf",an);
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
const int N = 120000;
int a[N];
int main() {
	int n, l;
	cin >> n >> l;
	for(int i = 1; i <= n; i ++ ) cin >> a[i];
	register int Cur = 1;
	while(Cur < n && a[Cur] + a[Cur+1] < l) Cur ++;
	if(Cur == n) {
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	for(int i = 1; i < Cur; i ++ ) {
		printf("%d\n", i);
	}
	for(int i = n-1; i > Cur; i -- ) {
		printf("%d\n", i);
	}
	printf("%d\n", Cur);
}


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

int main() {
    ll n;
    std::cin >> n;
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        ans += (i+1)*(n-i);
    }
    
    for (int i = 0; i < n-1; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        
        if(a>b)swap(a,b);
        
        ans -= (a+1)*(n-b);
    }
    
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3584
# coding: utf-8
# Your code here!
s=input()
t=input()

dp=[[0 for i in range(len(t)+1)] for j in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        if s[i-1]==t[j-1]:
            dp[i][j]=max(dp[i-1][j-1]+1,dp[i][j])
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1])
            
ans=[]
ns=len(s)-1
nt=len(t)-1

#print(dp)

while ns>-1 and nt>-1:
    #print(ns,nt)
    if s[ns]==t[nt]:
        ans.append(s[ns])
        ns-=1
        nt-=1
    elif dp[ns][nt]==dp[ns+1][nt]:
        ns-=1
    else:
        nt-=1

print("".join(ans[::-1]))

Measured memory_bytes: 120028
from heapq import heappush, heappop

x, y, _, _, c = map(int, input().split())


apples = []
cat_num = [x, y, c]
for cat in range(3):
    apples.append(sorted(map(int, input().split()))[-cat_num[cat]:])


h = []

for i in range(3):
    heappush(h, (-apples[i].pop(), i))


s = 0

cnt = x + y
while cnt:
    best_val, cat = heappop(h)
    s += best_val
    cnt -= 1
    if apples[cat]:
        heappush(h, (-apples[cat].pop(), cat))

print(-s)


Measured memory_bytes: 105444
#include <stdio.h>
#include <iostream>

using namespace std;

void hantei (double k[], double t, int kk[], int tt) {
	if (k[1] > t) {
		k[1] = t;
		kk[1] = tt;
	}
	if (k[0] > k[1]) {
		k[1] = k[0];
		kk[1] = kk[0];
		k[0] = t;
		kk[0] = tt;
	}
}

int main() {
	double a[4] = {100.0, 100.0, 100.0, 100.0};
	double b[4] = {100.0, 100.0, 100.0, 100.0};
	double c[4] = {100.0, 100.0, 100.0, 100.0};
	double k[2] = {100.0, 100.0};
	int aa[4];
	int bb[4];
	int cc[4];
	int kk[2];
	double d;
	int dd;
	for (int i = 0; i < 8; i++) {
		cin >> dd >> d;
		if (a[3] > d) {
			a[3] = d;
			aa[3] = dd;
		} 
		for (int j = 2; j >= 0; j--) {
			if (a[j] > a[j+1]) {
				a[j+1] = a[j];
				aa[j+1] = aa[j];
				a[j] = d;
				aa[j] = dd;
			}
		}
	}
	for (int i = 0; i < 8; i++) {
		cin >> dd >> d;
		if (b[3] > d) {
			b[3] = d;
			bb[3] = dd;
		}
		for (int j = 2; j >= 0; j--) {
			if (b[j] > b[j+1]) {
				b[j+1] = b[j];
				bb[j+1] = bb[j];
				b[j] = d;
				bb[j] = dd;
			}
		}
	}
	for (int i = 0; i < 8; i++) {
		cin >> dd >> d;
		if (c[3] > d) {
			c[3] = d;
			cc[3] = dd;
		}
		for (int j = 2; j >= 0; j--) {
			if (c[j] > c[j+1]) {
				c[j+1] = c[j];
				cc[j+1] = cc[j];
				c[j] = d;
				cc[j] = dd;
			}
		}
	}

	hantei(k,a[2],kk,aa[2]);
	hantei(k,a[3],kk,aa[3]);
	hantei(k,b[2],kk,bb[2]);
	hantei(k,b[3],kk,bb[3]);
	hantei(k,c[2],kk,cc[2]);
	hantei(k,c[3],kk,cc[3]);
	
	printf("%d %.2f\n%d %.2f\n%d %.2f\n%d %.2f\n%d %.2f\n%d %.2f\n%d %.2f\n%d %.2f\n", aa[0], a[0], aa[1], a[1], bb[0], b[0], bb[1], b[1], cc[0], c[0], cc[1], c[1], kk[0], k[0], kk[1], k[1]);
	return 0;
}

Measured memory_bytes: 1244
// *3 or /2

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n;

int calc_div2(int n) {
    int ret = 0;
    while (n % 2 == 0) {
        ret++;
        n /= 2;
    }
    return ret;
}

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

    int res = 0;
    int tmp;
    for (int i = 0; i < n; i++) {
        cin >> tmp;
        res += calc_div2(tmp);
    }
    cout << res << endl;

    return 0;
}


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

int nofact(int n)
{
    int ans=1;

    for(int i=2;i<=sqrt(n);i++)
    {
        int p=0;

        while(n%i==0)
        {
            p++;
            n/=i;
        }

        ans*=p+1;
    }

    if(n>1)
        ans*=2;

    return ans;
}

 
int main()
{
    #define int long long
    int n;
    cin>>n;

    long long zura=0;
    for(int c=1;c<n;c++)
    {
        int res=n-c;
        zura+=nofact(res);
    }

    cout<<zura;
}

Measured memory_bytes: 3680
#include<cstdio> 
#include<cstring> 
const int MAX_E=20005,MAX_V=205,INF=1e7; 
struct edge{ 
    int to,cap,rev,next; 
}g[2*MAX_E]; 
int k=0,h[MAX_V],level[MAX_V],iter[MAX_V],head=0,tail=0,q[MAX_V],n,m,S,T;
char map[105][105]; 
void add(int u,int v,int cap){ 
    g[++k].next=h[u]; h[u]=k; 
    g[k].to=v; g[k].cap=cap; g[k].rev=k+1; 
    g[++k].next=h[v]; h[v]=k; 
    g[k].to=u; g[k].cap=0; g[k].rev=k-1; 
} 
void bfs(int s){ 
    head=tail=0; 
    q[tail++]=s; level[s]=1; 
    while(head!=tail){ 
        int u=q[head]; 
        for(int i=h[u];i;i=g[i].next){ 
            if(!level[g[i].to]&&g[i].cap){ 
                level[g[i].to]=level[u]+1; 
                q[tail++]=g[i].to; 
            } 
        } 
        head++; 
    } 
} 
int dfs(int u,int t,int f){ 
    if(u==t) return f; 
    for(int &i=iter[u];i;i=g[i].next){ 
        if(level[g[i].to]==level[u]+1&&g[i].cap){ 
            int d=dfs(g[i].to,t,f<g[i].cap?f:g[i].cap); 
            if(d){ 
                g[i].cap-=d; 
                g[g[i].rev].cap+=d; 
                return d; 
            } 
        } 
    } 
    return 0; 
} 
int max_flow(int s,int t){ 
    int flow=0; 
    for(;;){ 
        for(int i=1;i<=n+m+2;++i) iter[i]=h[i]; 
        memset(level,0,sizeof(level)); 
        bfs(s); 
        if(level[t]==0) return flow; 
        int d=dfs(s,t,INF); 
        while(d>0){ 
            flow+=d; 
            d=dfs(s,t,INF); 
        } 
    } 
} 
int main(){
	scanf("%d%d",&n,&m);
	S=n+m+1,T=n+m+2;
	for(int i=1;i<=n;++i) scanf("%s",map[i]+1);
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j){
            if(map[i][j]!='.') add(i,j+n,1),add(j+n,i,1);
            if(map[i][j]=='S') add(S,i,INF),add(S,j+n,INF);
            else if(map[i][j]=='T') add(i,T,INF),add(j+n,T,INF);
        }
    int ans=max_flow(S,T);
    if(ans>=INF) puts("-1");
    else printf("%d\n",ans);
}

Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    string input;
    cin >> input;
    int result=0;
    int j = input.size()-1;
    for(int i=0;i<(input.size()/2);)
    {
        if(input[i]!=input[j])
        {
            //cout<< "i="<<input[i]<<","<<i<<" "<<"j="<<input[j]<<","<<j<<endl;
            result++;
        }
        i++;
        j--;
    }
        cout<<result;
    return 0;
}


Measured memory_bytes: 256
from copy import deepcopy

def getval():
    r,c,k = map(int,input().split())
    item = [[0 for i in range(c)] for i in range(r)]
    for i in range(k):
        ri,ci,vi = map(int,input().split())
        item[ri-1][ci-1] = vi
    return r,c,k,item

def main(r,c,k,item):
    #DP containing the information of max value given k items picked in i,j
    prev = [[0 for i in range(4)]]
    inititem = item[0][0]
    prev[0] = [0,inititem,inititem,inititem]
    for i in range(1,r):
        initval = prev[i-1][3]
        temp = []
        cur = item[i][0]
        for j in range(4):
            temp.append(initval)
        for j in range(1,4):
            temp[j] += cur
        prev.append(temp)

    for j in range(1,c):
        init = deepcopy(prev[0])
        for i in range(1,4):
            init[i] = max(prev[0][i],prev[0][i-1]+item[0][j])
        curcol = [init]
        for i in range(1,r):
            cur = item[i][j]
            left = curcol[-1]
            down = prev[i]
            temp = [max(left[3],down[0])]
            for k in range(1,4):
                temp.append(max(max(left[3],down[k-1])+cur,down[k]))
            curcol.append(temp)
        prev = curcol
            
    print(max(prev[-1]))
           
if __name__=="__main__":
    r,c,k,item = getval()
    main(r,c,k,item) 

Measured memory_bytes: 222884
#include<stdio.h>
#include<string.h>

int main(void){
#define WIN_POINT 3
#define DRAW_POINT 1

	int n=0;			// input; play times, n<=1000
	char t_card[101];	// input; taro's card, length<=100
	char h_card[101];	// input; hanako's card, length<=100
	int i=0;			// loop index
	int check=0;
	int t_point=0;		// output; taro's score
	int h_point=0;		// output; hanako's score

	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%s %s", t_card, h_card);
		check = strcmp(t_card, h_card);
		if(check < 0) h_point += WIN_POINT;
		else if(check > 0) t_point += WIN_POINT;
		else{
			t_point += DRAW_POINT;
			h_point += DRAW_POINT;
		}
	}
	printf("%d %d\n", t_point, h_point);

#undef WIN_POINT
#undef DRAW_POINT

	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <array>
#include <algorithm>
#include <cmath>

int main() {
  unsigned long X;
  std::cin >> X;

  std::array<unsigned long, 130> zizen;
  for (unsigned long i = 0; i < 130; ++i) {
    zizen.at(i) = std::pow(i, 5);
  }

  // case B >= 0
  for (unsigned int i = 0; i < 130; ++i) {
    unsigned long a_5 = zizen.at(i);
    if (a_5 < X) {
      continue;
    }
    // a_5 >= X
    unsigned long b_5 = a_5 - X;
    auto result = std::find(zizen.begin(), zizen.end(), b_5);
    if (result == zizen.end()) {
      continue;
    } else {
      unsigned int b_index = std::distance(zizen.begin(), result);
      std::cout << i << " " << b_index << std::endl;
      return 0;
    }
  }

  // case B < 0
  for (unsigned int i = 0; i < 130; ++i) {
    unsigned long a_5 = zizen.at(i);
    if (a_5 > X) {
      continue;
    }
    // a_5 <= X
    unsigned long b_5 = X - a_5;
    auto result = std::find(zizen.begin(), zizen.end(), b_5);
    if (result == zizen.end()) {
      continue;
    } else {
      unsigned int b_index = std::distance(zizen.begin(), result);
      std::cout << i << " -" << b_index << std::endl;
      return 0;
    }
  }
  return 0;
}


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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,light,ans=1;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    light = a[0];
    rep(i,n){
        if(light==2) break;
        light = a[light-1];
        ans++;
    }
    if(light!=2) ans = -1;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ': ' << x << endl

//const
const  ll INF = 1e18;

//どうせ使う
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;

int main(){
    ll k;cin >> k;
    ans = 0;
    ll now = 0;
    fr(i,k){
        now = now*10+7;
        now %= k;
        if(!now){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3568
import Control.Applicative
import Control.Monad.State
data SegTree a = Leaf a
               | Elem Int a
               | Tree Int a (SegTree a) (SegTree a)
               deriving (Show)

main = do
    [n,q] <- map read.words<$>getLine
    let init = if n == 1 then (Leaf (2^31-1)) else Elem n (2^31-1)
    evalStateT (query q) init

size (Leaf a) = 1
size (Elem n _) = n
size (Tree n _ _ _) = n

value (Leaf v) = v
value (Elem _ v) = v
value (Tree _ v _ _) = v

left (Elem n v)
  | n == 2 = Leaf v
  | n == 3 = Leaf v
  | otherwise = let n' = n `div` 2 in Elem n' v
left (Tree _ _ l _) = l
right (Elem n v)
  | n == 2 = Leaf v
  | otherwise = let n' = n `div` 2 in Elem (n-n') v
right (Tree _ _ _ r) = r

fromList xs = fl n xs
    where n = length xs

fl n xs = Tree n' m leftT rightT
    where n' = n `div` 2
          (xsL, xsR) = splitAt n' xs
          leftT = fl n' xsL
          rightT = fl n' xsR
          m = min (value leftT) (value rightT)

updateT s t x (Leaf v) = (Leaf x)
updateT s t x tr
  | n <= s = let lt = left tr
                 rt = updateT (s-n) (t-n) x (right tr)
                 m = min (value lt) (value rt)
              in Tree (size tr) m lt rt
  | n > t  = let lt = updateT s t x (left tr)
                 rt = right tr
                 m  = min (value lt) (value rt)
              in Tree (size tr) m lt rt
  | t-s+1 == size tr = Elem (size tr) x
  | otherwise = let lt = updateT s (n-1) x (left tr)
                    rt = updateT 0 (t-n) x (right tr)
                    m  = min (value lt) (value rt)
                 in Tree (size tr) m lt rt
  where n = size tr `div` 2

findT :: Ord a => Int -> Int -> SegTree a -> a
findT 0 0 (Leaf v) = v
findT s t tr
  | n <= s = findT (s-n) (t-n) (right tr)
  | n > t  = findT s t (left tr)
  | t-s+1 == size tr = value tr
  | otherwise = min (findT s (n-1) (left tr)) (findT 0 (t-n) (right tr))
  where n = size tr `div` 2


query :: Int -> StateT (SegTree Int) IO ()
query 0 = return ()
query n = getQuery >> query (n-1)

getQuery :: StateT (SegTree Int) IO ()
getQuery = do
    (x:xs) <- lift $ map read.words<$>getLine
    case x of
      0 -> let [s,t,x] = xs in modify (updateT s t x)
      1 -> let [s,t] = xs in get >>= \tr -> lift $ print $ findT s t tr


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

using namespace std;
#define ll long long
const long double EPS = 1e-8;
const long double PI = acos(-1);
const int N = 1e2 + 2;
const int mod = 1e9 + 7;
int n, k;

ll min_self(ll &mn, ll x) {
    return mn = min(mn, x);
}

int main() {
    cin >> n;
    vector<ll> arr(n);
    //dp[i][j] is the min cost of combining interval i ->j
    vector<vector<ll>> dp(n, vector<ll>(n, (ll) 1e15));
    for (int i = 0; i < n; i++)
        cin >> arr[i];

    auto getSum = [&](int L, int R) {
        ll s = 0;
        for (int i = L; i <= R; i++)s += arr[i];
        return s;
    };
    for (int L = n - 1; L >= 0; L--) {
        for (int R = L; R < n; R++) {
            if (L == R)dp[L][R] = 0;
            else {
                ll sum = getSum(L, R);
                for (int i = L; i <= R - 1; i++) {
                    min_self(dp[L][R], dp[L][i] + dp[i + 1][R] + sum);
                }
            }
        }
    }
    cout << dp[0][n - 1] << endl;
}





Measured memory_bytes: 1536
#include <stdio.h>

int a[100][100];
int n;

int main(int argc, char const *argv[]) {
  int i,j,k,v,u;

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

  for ( i = 0; i < n; i++) {
    scanf("%d%d", &u,&k);
    for(j=0;j<k;j++){
      scanf("%d", &v);
      a[u-1][v-1] = 1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ", a[i][j]);
    }
    printf("%d\n",a[i][j]);
  }

  return 0;
}

Measured memory_bytes: 632
import sys

stdin = sys.stdin


def na(): return map(int, stdin.readline().split())


def ns(): return stdin.readline().strip()

n = int(ns())
i = 1
mi = n
while i*i <= n:
    if n % i == 0:
        x = n//i
        mi = min(mi, x)
    i += 1
print(len(str(mi)))


Measured memory_bytes: 3060
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << (a >= 13 ? b : a >= 6 ? b / 2 : 0) << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int gcd(int a, int b)
{
    if(b == 0) return a;
    return gcd(b, a % b);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n == 2)
    {
        int a, b;
        cin >> a >> b;
        int val = gcd(a, b);
        for(int i = 1; i <= val; i++)
        {
            if(a % i == 0 && b % i == 0) cout << i << endl;
        }
    }
    if(n == 3)
    {
        int a, b, c;
        cin >> a >> b >> c;
        int val = gcd(gcd(a, b), gcd(b, c));
        for(int i = 1; i <= val; i++)
        {
            if(a % i == 0 && b % i == 0 && c % i == 0) cout << i << endl;
        }
    }
    return 0;
}




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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n;
    cin1(n);
    cout << n* n << endl;
}


Measured memory_bytes: 256
def read():
    return int(input())


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


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


N = read()
A = []
B = []
C = []
D = []
for _ in range(N):
    a, b = readmap()
    A.append(a)
    B.append(b)
    C.append(a+b)
    D.append((a, b))

# A.sort(key=dict(zip(A, C)).get)
# B.sort(key=dict(zip(B, C)).get)
#
# A.reverse()
# B.reverse()

D.sort(key=dict(zip(D, C)).get)
D.reverse()

# ans = 0
# for i in range(N):
#     if i % 2 == 0:
#         ans += A[i]
#     else:
#         ans -= B[i]

ans = 0
for i in range(N):
    if i % 2 == 0:
        ans += D[i][0]
    else:
        ans -= D[i][1]

print(ans)

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

int main(){
  int a, b;
  int ret = 0;
  /*処理系*/
  cin >> a >> b;
  if(a < 10){
    ret = 100 * (10 - a);
    ret += b;
  }
  else{
    ret = b;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
_ = input()
S = input()

needs_right = 0
needs_left = 0

for c in S:
    if c == '(':
        needs_right += 1
    else:
        if needs_right == 0:
            needs_left += 1
        else:
            needs_right -= 1

print('(' * needs_left + S + ')' * needs_right)



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

int main(int argc, const char * argv[]) {
    int n,k;
    cin >> n >> k ;
    int arr[1000];
    for(int i=0;i<n;i++){
        cin >> arr[i] ;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            if(arr[j]>arr[j+1])swap(arr[j],arr[j+1]);
        }
    }
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=arr[i];
    }
    cout << sum << endl ;
}


Measured memory_bytes: 3144
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;

 
#define forn(i,n)                   for(int i=0;i<n;i++)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
	
#define pb                          push_back
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int  main()
{
	int t;
	cin >> t;
	set<string> s;
	while(t--)
	{
		string a;
		cin >> a;
		s.insert(a);
	}
	cout << sz(s);
}

Measured memory_bytes: 19212