akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, x;
  while (true) {
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      for (int j = i+1; j <= n; ++j) {
        for (int k = j+1; k <= n; ++k) {
          if (i+j+k == x) ans++;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}


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

long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main(void){
    long long a,b;
    cin>>a>>b;
    cout<<(a*b)/gcd(a,b);
}


Measured memory_bytes: 256
alphabet = {chr(c):0 for c in range(ord("a"),ord("z")+1)}
s = ""
while True:
    try:
        s += input().lower()
    except:
            break

for i in s:
    if i in alphabet:
        alphabet[i] += 1

for key in range(ord("a"),ord("z")+1):
    ck = chr(key)
    print("%s : %d" % (ck,alphabet[ck]))

Measured memory_bytes: 7476
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n[2];
	while(cin>>n[0]>>n[1],n[0],n[1]){
		int num[2][101],sum[2]={};
		for(int i=0;i<2;i++){
			for(int j=0;j<n[i];j++){
				cin>>num[i][j];
				sum[i]+=num[i][j];
			}
			sort(num[i],num[i]+n[i]);
		}
		int ans[2]={101,101};
		for(int i=0;i<n[0];i++){
			int now[2]={sum[0]-num[0][i],sum[1]+num[0][i]};
			for(int j=0;j<n[1];j++){
				if(now[0]+num[1][j]==now[1]-num[1][j]&&num[0][i]+num[1][j]<ans[0]+ans[1]){
					ans[0]=num[0][i];
					ans[1]=num[1][j];
				}
			}
		}
		if(ans[0]==101)cout<<-1<<endl;
		else cout<<ans[0]<<" "<<ans[1]<<endl;
	}
}

Measured memory_bytes: 1180
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		System.out.println(a+b+c-Math.max(a, Math.max(b, c)));
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


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

long long N, K;

int main() {
    cin >> N >> K;
    long long ans = 0;
    long long min, max;
    for (long long i = K; i <= N+1; i++)
    {
        min = (i-1) * i / 2;
        max = i * (2 * N - i + 1) / 2;
        ans += max - min + 1;
        ans = ans % (1000000007);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int main() {
	int N, L, S;
	cin >> N >> L;
	S = N * (L - 1) + N * (N + 1) / 2;
	if (L < 0 && L + N - 1 >= 0 ) {
		cout << S << endl;
	}
	else if (L < 0 && L + N - 1 < 0) {
		cout << S - ( L + N - 1 ) << endl;
	}
	else {
		cout << S - L << endl;
	}
	return 0;
}

Measured memory_bytes: 256
while True:
	q=int(input())
	if q==-1:
	    break
	x=q/2
	ep=0.00001*q
	while True:
		x2=x*x
		t=x2*x-q
		if -ep<t<ep:
		    break
		x=x-t/(3*x2)
	print("%.06f" %x)


Measured memory_bytes: 5608
#include<stdio.h>
#include<string.h>
int main(){
  int x;
  char s[10010];
  scanf("%d %s", &x, s);
  for(int i=0; i < strlen(s); i++){
      int a=s[i]-'A';
      a = (a+x)%26;
      putchar('A'+a);
  }
  printf("\n");
}

Measured memory_bytes: 128
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
W = map(int, raw_input().split())
ans = INF

for i in range(N):
    ans = min(ans, abs(sum(W[:i]) - sum(W[i:])))

print ans

Measured memory_bytes: 2812
function Main(s) {
  s = s.split("\n");
  s[0] = s[0].split(" ");
  const n = +s[0][0];
  const x = +s[0][1];
  var sum = 0;
  var min = 1e9;
  for(var i = 0; i < n; i++){
    sum += +s[i+1];
    min = Math.min(min, +s[i+1])
  }
  console.log(n + Math.floor((x - sum) / min));
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));


Measured memory_bytes: 29436
from collections import defaultdict
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B,C=[0]*n,[0]*n
    for i,a in enumerate(A):
        B[i]=a+i
        C[i]=i-a
    D=defaultdict(int)
    D[C[-1]]+=1
    ans=0
    for i in range(n-1)[::-1]:
        ans+=D[B[i]]
        D[C[i]]+=1
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 129276
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using System;

public class P
{
    public int y { get; set; }
    public int m { get; set; }
    public int d { get; set; }
}

public class hello
{
    public static void Main()
    {
        var z = new P[2];
        for (int i = 0; i < 2; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            z[i] = new P { y = int.Parse(line[0]), m = int.Parse(line[1]), d = int.Parse(line[2]) };
        }
        var ps = z.OrderBy(x => x.y).ThenBy(x => x.m).ThenBy(x => x.d).ToArray();
        var a = ps[0];
        var b = ps[1];
        var a1 = new List<int>();
        var b1 = new List<int>();
        if ((a.m == 2 && a.d == 29) | (b.m == 2 && b.d == 29))
        {
             a1 = getAge(a.y, a.m, a.d, 2996);
             b1 = getAge(b.y, b.m, b.d, 2996);
        }
        else
        {
             a1 = getAge(a.y, a.m, a.d,3000);
             b1 = getAge(b.y, b.m, b.d, 3000);
        }
        var ans = -1;
        for (int i = 0; i < a1.Count(); i++)
            ans = Max(ans, a1[i] - b1[i]);
        Console.WriteLine(ans);
    }
    public static List<int> getAge(int y, int m, int d, int yyyy)
    {
        var ans = new List<int>();
        var bd = new DateTime(y, m, d);
        var mo = new int[] { 1, 3, 5, 7, 8, 10, 12 };
        foreach (var x in mo)
        {
            for (int i = 1; i <= 31; i++)
            {
                var now = new DateTime(yyyy, x, i);
                var age = now.Year - bd.Year;
                if (bd > now.AddYears(-age)) age--;
                ans.Add(age);
            }
        }
        var mo2 = new int[] { 4, 6, 9, 11 };
        foreach (var x in mo2)
        {
            for (int i = 1; i <= 30; i++)
            {
                var now = new DateTime(yyyy, x, i);
                var age = now.Year - bd.Year;
                if (bd > now.AddYears(-age)) age--;
                ans.Add(age);
            }
        }
        var feb = yyyy == 3000 ? 28 : 29;
        for (int i = 1; i <= feb; i++)
        {
            var now = new DateTime(yyyy, 2, i);
            var age = now.Year - bd.Year;
            if (bd > now.AddYears(-age)) age--;
            ans.Add(age);
        }
        return ans;
    }
}





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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>>s(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>s[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int ans=0;
      if(s[i][j]=='.'){
        for(int k=-1;k<=1;k++){
          for(int l=-1;l<=1;l++){
            if((i+k>=0 && j+l>=0) && (i+k<h && j+l<w)){
              if(s[i+k][j+l]=='#') ans++;
            }
          }
        }
        s[i][j]='0'+ans;
      }
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j==w-1) cout<<s[i][j]<<endl;
      else cout<<s[i][j];
    }
  }  
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  long long X, Y; cin >> X >> Y;
  long long a = X;
  long long cnt = 0;
  while(true) {
    if(a <= Y) {
      a *= 2;
      cnt++;
    } else {
      cout << cnt << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main() {
	int N;
	int a[110];
	int max = -1;
	int min = pow(10, 9);

	cin >> N;

	for (int i = 0; i < N; ++i)cin >> a[i];

	for (int i = 0; i < N; ++i) {

		if (a[i] < min) min = a[i];
		if (a[i] > max) max = a[i];
	}

	cout << max - min << endl;


	return 0;
}

Measured memory_bytes: 256
from collections import deque

s = deque(input())
q = int(input())
flg = 0

for _ in range(q):
  Q = [x for x in input().split()]
  if Q[0] == '1':
    flg += 1
  else:
    if (Q[1] == '1' and flg%2==0) or (Q[1] == '2' and flg%2==1):
      s.appendleft(Q[2])
    else:
      s.append(Q[2])
if flg%2==1:
  s.reverse()

print('' . join(s))


Measured memory_bytes: 74584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
#include<cmath>
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;
/*ここから*/
vector<LL> d;
int D;//約数の個数
void divisor(LL x){
    d.clear();
    for(int i=1;i*i<=x;i++){
        if(x%i==0){d.push_back(i);}
    }
    D=d.size();
    for(int i=D-1;i>=0;i--){
        if(d[i]*d[i]<x){d.push_back(x/d[i]);}
    }
    D=d.size();
}

LL fac(LL x,LL i){
    if(i==0){return 1;}
    else if(i==1){return x;}
    else{
        LL y=fac(x,i/2);
        if(i%2==0){return (y*y)%MOD;}
        else{return (((y*y)%MOD)*x)%MOD;}
    }
}


/*ここまで*/
int main()
{ 
    LL n,k;
    cin>>k>>n;
    LL a[n+1];//iの倍数の個数のkじょう
    LL b[n+1];//iの倍数での総和
    LL ans=0;
    for(int i=1;i<=n;i++){
        a[i]=n/i;b[i]=0;
    }
    for(int i=n;i>0;i--){
        LL x=fac(a[i],k);
        LL y=((x+MOD-b[i])%MOD);
        ans=(ans+(y*i)%MOD)%MOD;
        divisor(i);
        for(int i=0;i<D-1;i++){
            b[d[i]]=(b[d[i]]+y)%MOD;
        }
        //cout<<y<<endl;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n,m,k;
  cin>>n>>m>>k;
  bool b=false;
  rep(x,n+1){
    rep(y,m+1){
      if(n*y+m*x-2*x*y==k){b=true; break;}
    }
  }
  if(b){cout<<"Yes";}
  else{cout<<"No";}
}

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

int main(void) {
	int H, W;
	cin >> H >> W;

	char c[H][W];

	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			cin >> c[i][j];
		}
	}

	for (int i=0; i<H; i++) {
		for (int j=0; j<2; j++) {
			for (int k=0; k<W; k++) {
				cout << c[i][k];
			}
			cout << endl;
		}
	}

	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

long long int C[51][51]; // C[n][k] -> nCk
void combTable(int N) {
  for(int i = 0; i <= N; ++i) {
    for(int j = 0; j <= i; ++j) {
      if(j == 0 || j == i) C[i][j] = 1LL;
      else C[i][j] = (C[i-1][j-1] + C[i-1][j]);
    }
  }
}


vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    string s;
    cin >> s;

    int l_num_max = 0;
    int count = 0;
    REP(i,s.size()){
      if(s[i]==')') count++;
      else count--;
      chmax(l_num_max,count);
    }

    int r_num_max = 0;
    count = 0;
    REP(i,s.size()){
      if(s[s.size()-i-1]=='(') count++;
      else count--;
      chmax(r_num_max,count);
    }

    REP(i,l_num_max) p("(")
    p(s)
    REP(i,r_num_max) p(")")
    pl("")

    return 0;
}

Measured memory_bytes: 256
n, y = list(map(int, input().split()))
ans = 0
 
for i in range(n+1):
    a1 = 10000 * i
    for j in range(n+1-i):
        a2 = 5000 * j
        k = n- (i+j)
        a3 = k*1000
        if a1 + a2 + a3  == y and i + j + k == n:
            print(i, j , k)
            ans += 1
            exit(0)
    if ans == 1:
        break
if ans == 0:
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    priority_queue<P> pq;
    REP(i, T) {
        cin >> a[i];
        pq.emplace(a[i], i);
    }
    while (pq.size() >= 2) {
        int b, c, i, j;
        tie(b, i) = pq.top();
        pq.pop();
        tie(c, j) = pq.top();
        pq.pop();
        if (b > 1) {
            pq.emplace(b - 1, i);
        }
        if (c > 1) {
            pq.emplace(c - 1, j);
        }
    }
    cout << pq.top().first - 1 << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n); i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)	
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define REVSORT(c) SORT(c);REVERSE(c)
#define ALL(x) (x).begin(),(x).end()
#define LOOP while(true)
#define INF 1e9
const long long MOD = 1000000007;
typedef long long ll;

int main(void){
	int N, M;
	cin >> N;
	vector<string> C(N);
	map<string, int> mp;
	rep(i, N){
		cin >> C[i];
		if(mp.count(C[i])){
			mp[C[i]]++;
		} else {
			mp[C[i]] = 1;
		}
	}
	cin >> M;
	rep(i, M){
		string S;
		cin >> S;
		if(mp.count(S))mp[S]--;
		else continue;
	}
	int ans = 0;
	rep(i, N){
		ans = max(ans, mp[C[i]]);
	}
	cout << ans << endl;
}
	

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == '1') ++counter;
  if (s[1] == '1') ++counter;
  if (s[2] == '1') ++counter;
  cout << counter << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int n;
    cin >> n;
    string s; cin >> s;
    auto valid = [&](string&  str,int idx){
        for(; idx  <  s.size(); ++idx){
            int prev = (idx == 0 ? n - 1 : idx - 1);
            int next = (idx == n - 1 ? 0 : idx + 1);
            if((s[idx] == 'o' and str[idx] == 'S') or (s[idx] == 'x' and str[idx] == 'W')){
                if(next == n-1 and str[prev] != str[next]) return false;
                if(next == 0   and str[prev] != str[next]) return false;
                str[next] = str[prev];
            } else {
                if(next == n-1 and str[prev] == str[next]) return false;
                if(next == 0   and str[prev] == str[next]) return false;
                str[next] = (str[prev] == 'W' ? 'S' : 'W');
            }
        }
        return true;
    };
    for(int i = 0; i < 4; ++i){
        string str = string(n,'A');
        str[0] = (i & 1 ? 'W'  :'S');
        str[n-1] = (i & 2 ? 'W'  :'S');
        if(valid(str,0)){
            cout << str << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 1000000000000000000
#define MOD 1000000007
#define mod 1000000007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    set<ll>s;
    ll q;cin>>q;
    while(q--){
        ll a,x;cin>>a>>x;
        if(a==0){
            s.insert(x);
            cout<<s.size()<<endl;
        }
        else if(a==1){
            cout<<(s.find(x)!=s.end())<<endl;
        }
        else{
            if(s.find(x)!=s.end())
                s.erase(x);
        }
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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

int main() {
  int n;
  cin >>n;
  vector<vector<int>> v(n, vector<int>(3));
  for (int i = 0; i < n; ++i){
    cin >> v[i][0] >> v[i][1] >> v[i][2];
  }

  int Cx, Cy, H_a=0;

  for (int i = 0; i < 101; i++) {
    for (int j = 0; j < 101; j++) {
      int H = 0;
      for (int idx = 0; idx < n; idx++) {
        int x = v[idx][0], y = v[idx][1], h = v[idx][2];
        if(h==0) continue;
        H = h + abs(x - i) + abs(y - j);
        break;
      }
      for (int idx = 0; idx<n; idx++){
        int x = v[idx][0], y = v[idx][1], h = v[idx][2];
        if(h!=max(H-abs(i-x)-abs(j-y), 0)) break;
        if(idx==n-1){
          Cx = i;
          Cy = j;
          H_a = H;
          cout << Cx << ' ' << Cy << ' ' << H_a << endl;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3616
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#define lson i<<1
#define rson i<<1|1
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gc(x) scanf("%c",&x)
#define gc2(x,y) scanf("%c%c",&x,&y)
using namespace std;
const double eps=1e-8; 
typedef long long ll;
const double PI = acos(-1.0); 
const int MAXN=100005;
const ll mod=1e7+9;
const ll llinf = (ll)(1e18) + 500;
const int inf=0x3f3f3f3f;
vector<ll>ans;
int k;
void dfs(int cur,int pre,ll val,bool al){
	if(ans.size()>=k+1)return;
	if(cur==19){ans.push_back(val);return;}
	if(pre==-1||al){
		for(int i=0;i<=9;i++){
			if(i==0)
				dfs(cur+1,i,1LL*i,al);
			else dfs(cur+1,i,1LL*i,false);
		}
	}
	else{
		if(pre!=0)
			dfs(cur+1,pre-1,val*10+pre-1,false);
		dfs(cur+1,pre,val*10+pre,false);
		if(pre!=9){
			dfs(cur+1,pre+1,val*10+pre+1,false);
		}
	}
}
int main(){
	gi(k);
	dfs(1,-1,0,true);
	sort(ans.begin(),ans.end());
	cout<<ans[ans.size()-1]<<endl;
	
	
	
	
	return 0;
}



















Measured memory_bytes: 1400
#include <stdio.h>
using namespace std;
int main(){
	int n, t;
	while (~scanf("%d%d", &n, &t))
	{
		long long ans = t;
		int x;
		long long pre = t;
		scanf("%d", &x);
		
		for (int i = 1; i < n; i++)
		{
			scanf("%d", &x);
			if (x > pre)
			{
				pre = x + t;
				ans += t;
			}else
			{
				ans -= pre - x;
				ans += t;
				pre = x + t;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

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

int main() 
{ 
 int num; 
 int a;
 while(1){
  cin >>num; 
  if(num==0){
   break;}
  else
  {
  for(int i=1;i<10;i++)
    {
    cin>>a;
    num=num-a;
    }
  }
  cout<<num<<"\n";
 }
 return 0; 
} 

Measured memory_bytes: 1164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            String input = in.readLine();

            String[] inputs = input.split("\\s+");
            int a = Integer.parseInt(inputs[0]);
            int b = Integer.parseInt(inputs[1]);

            System.out.println(String.format("a %s b", a == b ? "==" : a > b ? ">" : "<"));
        } catch (IOException ex) {
            // no op
        }
    }
}


Measured memory_bytes: 24524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int a[109];
  cin>>n;
  double sum=0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  sum/=n;
  double temp=100000;
  for(int i=0;i<n;i++){
    temp=min(temp,(double)(abs(a[i]-sum)));
  }
  for(int i=0;i<n;i++){
    if(temp==(double)(abs(a[i]-sum))){
      cout<<i<<endl;
      return(0);
    }
  } 
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void call(int n){
    for(int i=1;i<=n;i++){
        int x=i;
        if(x%3==0)
            cout<<" "<<i;
        else
            while(x){
                if (x%10==3 ){
                    cout << " " << i;
                    break;
                }
                x/=10;
            }
    }
    cout<<endl;
}
int main()
{
    int n;
    cin>>n;
    call(n);
    return 0;
}



Measured memory_bytes: 3116
n, m = map(int, input().split())
p = list(map(lambda x: int(x) - 1, input().split()))
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if par[x] == x:
        return x
    par[x] = root(par[x])
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def union(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[y] == rank[x]:
            rank[x] += 1


for x, y in xy:
    union(x, y)

count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i) else 0
print(count)


Measured memory_bytes: 36044
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,a,b;
  cin >> n >> a >> b;
  long long blue = 0;
  blue = (n / (a + b)) * a;
  if(n % (a+b) > a){
    blue += a;
  }else{
    blue += n % (a+b);
  }
  cout << blue << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	p := make([]float64, n)
	for i := range p {
		fmt.Scan(&p[i])
	}

	sum := make([]float64, 0)
	for _, num := range p {
		sum = append(sum, (num*(num+1))/(2*num))

	}

	cnt := 0.0
	max := 0.0
	for i := 0; i < n; i++ {
		if i < k {
			cnt += sum[i]
			max = cnt
		} else {
			cnt -= sum[i-k]
			cnt += sum[i]
			if cnt >= max {
				max = cnt
			}
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
lld A[lim],B[lim],C[lim];
// map<lld,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc2(a,b);
    rep(i,1,3) {
        k = a * b * i;
        if(k&1) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 768
function Main(input) {
  input = input.split("\n")
 
  var n = parseInt(input[0].split(" ")[0], 10)
  var k = parseInt(input[0].split(" ")[1], 10)
  var h = input.slice(1, n + 1).map(n => parseInt(n ,10))
  var hSort = h.sort((n, m) => n - m)
 
  var abs = []
  for(var i = 0; i <= hSort.length - k; i++) {
    abs.push(Math.abs(hSort[i] - hSort[i + k -1]))
  }
  console.log(Math.min(...abs))
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31912
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

bool calc(vector<int>& a, string s, int num) {
  if (s.size() == 7) {
    if (num == 7) {
      cout << s << "=7" << endl;
      return true;
    } else {
      return false;
    }
  }

  if (s.size() == 0) {
    s += a[0] + '0';
    num = a[0];
  }

  int pos = (s.size() + 1) / 2;
  string sm = s + "-" + std::to_string(a[pos]);
  string sp = s + "+" + std::to_string(a[pos]);
  bool ok = calc(a, sm, num-a[pos]);
  if (!ok) {
    ok = calc(a, sp, num+a[pos]);
  }

  return ok;
}

int main() {
  string S;
  cin >> S;
  vector<int> a(4);
  rep(i, 4) {
    a[i] = S[i] - '0';
  }

  calc(a, "", 0);
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;


int main(){
  string s;
  cin>>s;
  for(int i=0;i<(int)s.length();i++){
    if(s[i] == ',')s[i] = ' ';
  }
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;
const ll mod=1e9+7;

int n,m;
vector<ll> a(100100);
vector<ll> dp(100100);

int main(){
    cin>>n>>m;
    rep(i,m){
        cin>>a[i];
        dp[a[i]]=1;
    }
    dp[0]=1;
    if(a[0]!=1) dp[1]=1;
    else dp[1]=0;

    for(int i=2;i<=n;i++){
        if(dp[i]==1){
            dp[i]=0;
        }
        else{
            dp[i]=dp[i-2]+dp[i-1];
            dp[i]%=mod;
        }
    }
    cout<<dp[n]<<"\n";
    return 0;
}

Measured memory_bytes: 4656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=100000000000000005;
const int maxn=1e6+5;
const int mod=433494437;
ll n,m,p;
int main()
{
    scanf("%lld%lld%lld",&n,&m,&p);
    if(p<=n)
        printf("%lld %lld\n",n-p,m);
    else if(p<=n+m)
        printf("%lld %lld\n",0ll,m-(p-n));
    else
        printf("0 0\n");
    return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, d int

	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)

	ans := 0
	for i := 0; i <= 100; i++ {
		if (a < i && i <= b) && (c < i && i <= d) {
			ans = ans + 1
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1832
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  string s,t; cin >> s >> t;
  string ans = "No";
  for (size_t i = 0; i < s.size(); i++) {
    if (s == t) {
      ans = "Yes";
      break;
    }
    s = s.back() + s.substr(0,s.size() - 1);
  }
  std::cout << ans << '\n';
}


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

function main()
    num=[0 for i in 1:4]
    for i in 1:3
        a,b=parseMap(split(readline()))
        num[a]+=1
        num[b]+=1
    end
    if sort(num)==[1,1,2,2]
        println("YES")
    else
        println("NO")
    end
end
main()

Measured memory_bytes: 115656
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s; cin>>s;
  int n = s.size();
  bool ans = true;
  for(int i=0; i<(n-1)/2; i++){
    if(s[i]!=s[(n-1)/2-i-1]) ans = false;
  }
  for(int i=(n+3)/2-1; i<n; i++){
    if(s[i]!=s[n-i-1]) ans = false;
  }
  if(ans) cout <<"Yes";
  else cout <<"No";

  return 0;
}


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

int main() {
	int N,al=0,sum=0,b=0,a[100]={};
	cin>>N;
	for(int i=0;i<N;i++){
	cin>>a[i];
	sum+=a[i];
	}
	sort(a,a+N);
	for(int i=N-1;i>=0;i-=2)
	{
		al+=a[i];
	}
	cout<<al*2-sum;
	}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void){

    string S; cin>>S;
    int K; cin>>K;
    set<string> st;
    for (int i = 0; i < S.length(); ++i) {
        for (int j = 0; j < K; ++j) {
            st.insert(S.substr(i,j+1));
        }
    }
    auto itr=st.begin();
    for (int i = 0; i < K-1; ++i) {
        itr++;
    }

    cout<<*itr<<endl;
}

Measured memory_bytes: 1664
#include <iostream>
#define TOSHI_MAX 100
#define COST_MAX 100000
using namespace std;

int prim(int data[TOSHI_MAX][TOSHI_MAX], int toshiNum) {
  bool visited[toshiNum];
  int cost[toshiNum];
  for(int i = 0; i < toshiNum; i++) {
    visited[i] = false;
    cost[i] = COST_MAX;
  }
  cost[0] = 0;
  while(1) {
    int min = COST_MAX;
    int p;
    for(int i = 0; i < toshiNum; i++) {
      if(!visited[i] && cost[i] < min) {
	min = cost[i];
	p = i;
      }
    }
    if(min == COST_MAX) break;

    visited[p] = true;
    for(int i = 0; i < toshiNum; i++) {
      if(!visited[i] && data[p][i] < cost[i]) {
	cost[i] = data[p][i];
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < toshiNum; i++) {
    if(cost[i] != COST_MAX) ans += cost[i];
  }

  return ans;
}

int main() {
  while(1) {
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    int data[TOSHI_MAX][TOSHI_MAX];
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
	data[i][j] = COST_MAX;
      }
    }

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

    cout << prim(data, n) << endl;
  }

  return 0;
}

Measured memory_bytes: 0
n, m, x = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(n)]

import itertools as it
import math

cost = math.inf
for comb in it.chain(*(it.combinations(C, r) for r in range(1, n+1))):
    c, *a = map(sum, zip(*comb))
    if min(a) >= x:
        cost = min(cost, c)

if cost is not math.inf:
    print(cost)
else:
    print(-1)

Measured memory_bytes: 9204
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <map>
#define ll long long

using namespace std;

const int M = 1000000007;

int x, k;

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> k >> x;
	
	for (int i = x-k+1; i < x+k; i++){
		cout << i << " ";
		
	}
	
return 0;
}




Measured memory_bytes: 256
//ihdignite

#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200005;

int n;
vector<int> adj[MAXN];

pair<int, int> dfs(int u, int p = -1, int d = 1) {
	pair<int, int> r = pair<int, int>(d, u);
	for(int v : adj[u]) {
		if(v == p) {
			continue;
		}
		r = max(dfs(v, u, d+1), r);
	}
	return r;
}

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

	cin >> n;
	for(int i = 1, a, b; i < n; i++) {
		cin >> a >> b;
		--a;
		--b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}

	cout << (dfs(dfs(0).second).first%3 == 2 ? "Second" : "First") << '\n';

	return 0;
}

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

#define ll long long

signed main()
{
  int A,B;
  cin >> A >> B;
  if(A==1) A = 14;
  if(B==1) B = 14;

  cout << (A>B ? "Alice": (B>A ? "Bob" : "Draw"));
}

Measured memory_bytes: 3540
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
using namespace std;
const int INF = 1000000000000;
const int mod = 1000000007;
int modpow(int x, int y, int m = mod) {
	int res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= m; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
signed main() {
	int n, a, b, x1 = 1, y1 = 1, x2 = 1, y2 = 1; cin >> n >> a >> b;
	for (int h = n - a + 1; h <= n; h++) { x1 *= h; x1 %= mod; }
	for (int h = 1; h <= a; h++) { y1 *= h; y1 %= mod; }
	for (int h = n - b + 1; h <= n; h++) { x2 *= h; x2 %= mod; }
	for (int h = 1; h <= b; h++) { y2 *= h; y2 %= mod; }
	int ans = modpow(2, n) - 1 - (x1 * modpow(y1, mod - 2) % mod) - (x2 * modpow(y2, mod - 2) % mod);
	while (ans < 0) { ans += mod; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define reg register
#define maxn 2001
#define mod 1000000007
using namespace std;
int nt[maxn], fi[maxn], go[maxn], c[maxn][maxn], siz[maxn], d[maxn], st[maxn], id[maxn];
int n, m, k, tag[maxn], dfn[maxn], top[maxn], topx, cnt, x[maxn], y[maxn], ans, hh, h[maxn]; 
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int ksm(int u, int v){
	int s = 1;
	for(int i = v; i; i >>= 1){
		if(i & 1) s = 1ll * s * u % mod;
		u = 1ll * u * u % mod;
	}
	return s;
}
int solve(int x){
	int res = 0;
	for(int i = 1; i <= x; i++){
		int y = __gcd(i, x);
		res = (res + ksm(k, y)) % mod;
	}
	res = 1ll * res * ksm(x, mod - 2) % mod;
	return res;
}
int rt;
void add(int u, int v){
	nt[++cnt] = fi[u]; fi[u] = cnt; go[cnt] = v; 
}
void tarjan(int u){
	if(rt==u&&fi[u]==0)return ;
	st[++topx] = u; dfn[u] = ++cnt; top[u] = cnt;
	int now = n; int t = 0;
	for(int i = fi[u]; i; i = nt[i]){
		int v = go[i]; 
		if(!dfn[v]) 
		{
			tarjan(v), top[u] = min(top[u], top[v]);
			if(top[v] >= dfn[u]){
				hh++;int w;
				while(w = st[topx]){
					topx--;
					tag[w] = hh; siz[hh]++; if(v == w) break;
				}++siz[hh];tag[u]=hh;
				for(int j = 1; j <= m; j++){
				if(tag[x[j]] == hh && tag[y[j]] == hh) id[j] = hh;
				}
			}
		}
		else top[u]=min(top[u],dfn[v]);
	}
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n = read(); m = read(); k = read();
	c[0][0] = 1;
	for(int i = 1; i <= 2000; i++){
		c[i][0] = 1; c[i][i] = 1;
		for(int j = 1; j < i; j++)
		c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
	}
	for(int i = 1; i <= m; i++){
		x[i] = read(), y[i] = read();
		add(x[i], y[i]); add(y[i], x[i]);
	}
	cnt = 0; ans = 1;
	for(int i = 1; i <= n; i++) if(!dfn[i]) rt=i,tarjan(i);
	for(int i = 1; i <= m; i++){
		if(!id[i]) ans = 1ll * ans * k % mod;
		else d[id[i]]++;
	}
	//cout << ans << endl;
	for(int i = 1; i <= hh; i++){
		//cout << siz[i] << " " << d[i] << endl;
		if(siz[i] > 1 && d[i] != siz[i]) ans = 1ll * ans * c[d[i] + k - 1][k - 1] % mod;
		else if(siz[i] > 1) ans = 1ll * ans * solve(siz[i]) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 30208
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x)
#define bb(x)      cerr<< x <<endl;
#define pii        pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M  = 1e9+7 ;
const ll inf = 1e18 ;
const int si = 1e5+9;
const int N = 1e5+5 ;
//////////////////////    Hi    ^_^  hack me if you can :P
int n,k;
ll mem[1010][1010];
ll dp(int i,int p)
{
    if(i==n)
        return 1LL;
    ll &r=mem[i][p];
    if(r!=-1)
        return r;
    r=0LL;
    lop(l,k)
    {
        if(l!=p)
            r+=dp(i+1,l);
    }
    return r;
}
int main()
{
    cin>>n>>k;
    ll ans = 0;
    ms(mem,-1);
    ans=dp(0,k+1);
    cout<<ans;
    r0;
}

/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}
Wj0944296025*
*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,-1, 1,1,-1,-1};
int my[]= {1,-1,0,0, 1,-1,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void gcd(LL n,LL m,LL &d,LL &xx,LL &yy){
    if(!m) {d=n; xx=1; yy=0;}
    else {gcd(m,n%m,d,yy,xx); yy-=xx*(n/m);}
}

int getm(int l,int r)
{
    if(l>r)
        return N;
    if(l==r)
        return 0;
    if(l==r-1)
        return s[l] != s[r];
    if(s[l]==s[r])
        return getm(l+1,r-1);
    else
        return 1+min(getm(l+1,r),getm(l,r-1));
}

int BIT[si], a[si], n;
void update(int x, int delta)
{
    for(; x <= N; x += x&-x)
        BIT[x] += delta;
}
int query(int x)
{
    int sum = 0;
    for(; x > 0; x -= x&-x)
        sum += BIT[x];
    return sum;
}

*/


Measured memory_bytes: 8320