akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    cin>>S>>t;
    while(t--)
    {
        cin>>n;
        if(n==1) reverse(all(S));
        else
        {
            char c;
            cin>>m>>c;
            if(m==1)
            {
                reverse(all(S));
                S.pb(c);
                reverse(all(S));
            }
            else
            {
                S.pb(c);
            }
        }
    }
    cout<<S;
}
 
 
signed main()
{

    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
 int N ;
  cin  >> N ;
  int A[N] ;
  rep(i,N) cin >> A[i] ;
  int ans = 1001001001 ;
  int count = 0 ;
  rep(i,N){
    while( A[i]%2 == 0 ){
      A[i] = A[i]/2 ;
      count++ ;
    }
    ans = min(count,ans) ;
    count = 0 ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i

cnt = Hash.new { 0 }

1.upto(N) do |x|
  x.upto(N) do |y|
    subtotal = x**2 + y**2 + x*y
    break if subtotal > 10000

    y.upto(N) do |z|
      total = subtotal + z**2 + y*z + z*x

      break if total > 10000

      case
      when x == y && y == z then cnt[total] += 1
      when x == y || y == z then cnt[total] += 3
      else                       cnt[total] += 6
      end
    end
  end
end

1.upto(N) do |i|
  puts cnt[i]
end



Measured memory_bytes: 14620
#S = input()
#i = 0
#while i < 3:
#    if S[i] == S[i+1]:
#        print("Bad")
#        break
#    i += i
#    if i == 3:
#        print("Good")


S = input()
if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    bool ans = false;
    for(int i = 1; i <= B; i++){
        if(A * i % B == C){
            ans = true;
        }
    }
    if(ans){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
    int a,b;

    while(cin>>a>>b)
    {
        getchar();

        char str[15];
        cin>>str;
        int len =strlen(str);
        int k=0,flag=0;

        if(a<1||a>5||b<1||b>5|| len!=a+b+1 ||str[a]!='-')
        {
            cout<<"No"<<endl;
            continue;
        }

        for(int i=0;i<a;i++)
        {
            if(str[i]>'9'||str[i]<'0')
            {
                cout<<"No"<<endl;
                k=1;
                break;
            }
        }

        if(k==1)
            continue;

        for(int i=a+1;i<len;i++)
        {
            if(str[i]>'9'||str[i]<'0')
            {
                cout<<"No"<<endl;
                flag=1;
                break;
            }
        }

        if(flag==1)
            continue;
        else
            cout<<"Yes"<<endl;

    }
    return 0;
}


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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 998244353;

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int cnt[3];
int cnt2[3];

int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	FOR(i, 1, n + 1)
		ans = mult(ans, i);
	for(char c: s)
	{
		int id;
		if(c == 'R')
			id = 0;
		else if(c == 'G')
			id = 1;
		else
			id = 2;
		if(cnt2[id] != 0)
			ans = mult(ans, cnt2[id]--);
		else
		{
			int id1 = 0;
			while(id1 < 3 && (id1 == id || cnt[id1] == 0))
				id1++;
			if(id1 < 3)
			{
				ans = mult(ans, cnt[id1]--);
				cnt2[3 - id - id1]++;
			}
			else
				cnt[id]++;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 900
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    a, b, m = list(map(int,ipti().split()))
    a_list = list(map(int,ipti().split()))
    b_list = list(map(int,ipti().split()))

    xyc = [0]* m

    for i in range(m):
        xyc[i] = list(map(int,ipti().split()))

    ans = min(a_list) + min(b_list)

    for i in range(m):
        x, y, c = xyc[i][0], xyc[i][1], xyc[i][2]
        temp = a_list[x-1] + b_list[y-1] - c
        ans = min(ans, temp)

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 74204
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    ll N;
    cin >> N;
    vector<ll> A(N+1, 0);
    REP(i, N) cin >> A[i+1];

    vector<ll> d(N+1);
    REP(i, N) d[i] = abs(A[i+1] - A[i]);
    ll sum = abs(A[N]);
    d[N] = sum;
    REP(i, N) sum += d[i];

    ll tmp;
    rep(i, 1, N+1){
        if ((A[i-1] < A[i] && A[i] < A[i+1]) || (A[i+1] < A[i] && A[i] < A[i-1])) tmp = sum;
        else tmp = sum - 2 * min(d[i-1], d[i]);
        cout << tmp << endl;

    }
    return 0;
}


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

using namespace std;

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

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

    vector<int> L(n), R(n);
    for (int i = 1; i < n; i++) {
        L[i] = max(L[i - 1], as[i - 1]);
    }
    for (int i = n - 2; i >= 0; i--) {
        R[i] = max(R[i + 1], as[i + 1]);
    }
    for (int i = 0; i < n; i++) {
        cout << max(L[i], R[i]) << '\n';
    }
}

Measured memory_bytes: 3968
#include<stdio.h>
#include<algorithm>

using namespace std;

long long inp_n1, inp_n2, inp_n3, i1;

long long readNumber() {
	long long temp_func;
	scanf("%lld", &temp_func);
	return temp_func;
};
long long printNumber(long long temp_func) {
	printf("%lld", temp_func);
	return 0;
};

long long caler() {
	
	return inp_n1 * min(inp_n2 - 1, inp_n3) / inp_n2;
	
};

int main() {
	
	inp_n1 = readNumber();
	
	inp_n2 = readNumber();
	
	inp_n3 = readNumber();
	
	printNumber(caler());
	
}

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

int main(){
  int sn[100],sm[100];
  int i,j,n,m,cn=0,cm=0;
    cin >> n >> m;
  while (n!=0&&m!=0){
    cn=0;
    cm=0;
    for (i=0;i<n;i++) {
      cin >> sn[i];
      cn+=sn[i];
    }
    for (j=0;j<m;j++) {
      cin >> sm[j];
      cm+=sm[j];
    }
    sort(&sn[0],&sn[n]);
    sort(&sm[0],&sm[m]);
    i=0;j=0;
    //printf("%d %d\n",cm,cn);
    while (i<n&&j<m){
      // printf("%d %d %d %d %d %d\n",i,j,sn[i],sm[j],cm-sm[j]+sn[i],cn+sm[j]-sn[i]);
      if (cm+sn[i]-sm[j]<cn+sm[j]-sn[i]){
	i++;
      }else if (cm+sn[i]-sm[j]>cn+sm[j]-sn[i]){
	j++;
      }else if (cm+sn[i]-sm[j]==cn+sm[j]-sn[i]){
	cout << sn[i] <<" "<<sm[j]<<endl;
	break;
      }
    }
    if (!(i<n&&j<m)) cout << "-1" << endl;
    cin >> n >> m;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long  X;
  int N,K;
  string S;
  cin >> K >> S;

  if(S.size() <= K){
    cout << S << endl;
  }
  else{
    cout << S.substr(0,K);
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3632
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		Map<String, Integer[]> map = new HashMap<String, Integer[]>();
		int N = reader.nextInt();
		for (int i = 0; i < N; i++) {
			String s = reader.next();
			if (map.containsKey(s)) {
				map.get(s)[0]++;
			} else {
				Integer[] arr = new Integer[2];
				arr[0] = 1;
				arr[1] = 0;
				map.put(s, arr);
			}
		}
		int M = reader.nextInt();
		for (int i = 0; i < M; i++) {
			String s = reader.next();
			if (map.containsKey(s)) {
				map.get(s)[1]++;
			} else {
				Integer[] arr = new Integer[2];
				arr[0] = 0;
				arr[1] = 1;
				map.put(s, arr);
			}
		}
		int ans = 0;
		for (Entry<String, Integer[]> entry : map.entrySet()) {
			Integer[] arr = entry.getValue();
			int gap = arr[0] - arr[1];
			ans = Math.max(gap, ans);
		}

		System.out.println(ans);
		reader.close();
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin >> N;
  long long result = 0;
  for(int a = 1;a <= N;a++){
  if(a % 3 != 0&&a % 5 != 0){
    result += a;
  }
  }
 
cout<<result<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int N,K;
    cin>>N>>K;

    int ans=0;

    for(int b=K+1;b<=N;b++){
        ans+=N/b*(b-K);
        ans+=max(N%b-K+1,0ll);
    }
    if(K==0)ans-=N;
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int n;
	while(cin >> n, n != 0){
		vector<int> b(n);
		for(int i = 0;i < n;i++){
			cin >> b[i];
		}
		
		int cnt = 0;
		while(1){
			if(cnt == 10001){
				break;
			}
			
			bool f = (b[0] == 1);
			for(int i = 0;i < b.size()-1;i++){
				f = (f && (b[i] == b[i+1]-1));
			}
			if(f) break;
			
			vector<int> c;
			for(int i = 0;i < b.size();i++){
				if(b[i] - 1 > 0){
					c.push_back(b[i]-1);
				}
			}
			c.push_back(b.size());
			b = c;
			cnt++;
		}
		cout << (cnt == 10001 ? -1 : cnt) << endl;
	}
	return 0;
}



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

int main(){
  long long H;
  cin >> H;
  long long ruijo = 0, result;
  while(true){
    if(pow(2, ruijo) <= H){
      result = ruijo;
      ruijo++;
    }
    else break;
  }
  cout << (long long)pow(2, result + 1) - 1 << endl;
}

Measured memory_bytes: 4096
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static final int INF = 2000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}

			TreeMap<Integer, LinkedList<Point>> map = new TreeMap<Integer, LinkedList<Point>>();
			
			Point start = null, goal = null;
			int max = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String s = sc.next();
					if(s.equals("S")){
						start = new Point(0, i, j);
						LinkedList<Point> temp = new LinkedList<Point>();
						temp.add(start);
						map.put(0, temp);
					}else if(s.equals("G")){
						goal = new Point(INF, i, j);
					}else if(s.matches("[0-9]+")){
						int num = Integer.parseInt(s);
						max = max < num ? num : max;
						if(map.containsKey(num)){
							map.get(num).add(new Point(INF, i, j));
						}else{
							LinkedList<Point> temp = new LinkedList<Point>();
							temp.add(new Point(INF, i, j));
							map.put(num, temp);
						}
					}
				}
			}
			LinkedList<Point> temp = new LinkedList<Point>();
			temp.add(goal);
			map.put(max + 1, temp);
			System.out.println(fm(map));
			System.gc();
		}
		sc.close();
	}
	static int fm(TreeMap<Integer, LinkedList<Point>> map){
		int m = 1;
		LinkedList<Point> from = map.get(0);
		LinkedList<Point> to = null;
		while(true){
			if(!map.containsKey(m)){
				break;
			}
			to = map.get(m);
//			System.out.print(m+":");
			for(Point p : to){
				for(Point s : from){
					int temp = Math.abs(p.x - s.x) + Math.abs(p.y - s.y);
					p.c = p.c > temp + s.c ? temp + s.c : p.c;
				}
//				System.out.print("[" + p.c + "]");
			}
//			System.out.println();
			from = to;
			m++;
		}		
		return map.get(m - 1).get(0).c;
	}
}
class Point{
	int c;
	int x;
	int y;
	Point(int c, int y, int x){
		this.c = c;
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 43928
#include <iostream>
#include <vector>

using namespace std;

using VI = vector<int>;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define OUT(v) cout<<v<<endl

int main() {
  string S;
  cin >> S;

  VI res;
  REP(i, S.size()) {
    int j = i;
    while (S[j] == 'R') {
      ++j;
      res.push_back(0);
    }
    res.pop_back();
    // Rは[i,j)の範囲
    int k = j;
    // Lは[j,k)の範囲
    while (k < S.size() && S[k] == 'L') ++k;
    res.push_back((j-i) / 2 + (j-i) % 2 + (k-j) / 2);
    res.push_back((j-i) / 2 + (k-j) / 2 + (k-j) % 2);
    REP(hoge, k-j-1) res.push_back(0);
    i = k - 1;
  }
  cout << res.front();
  for (auto it = res.begin() + 1; it != res.end(); ++it)
    cout << " " << *it;
  cout << endl;
  return 0;
}


Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+5;
const int INF = 0x3f3f3f3f;

int main(){
	ll n,k;
	cin >> n >> k;
	if(n > k) n = (n-1)%k+1;
	printf("%lld\n",min(n,k-n));
    return 0;
}


Measured memory_bytes: 256
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(x) REP(i,SZ(x))cerr<<i<<x<<"="<<x[i]<<endl;
const int MOD = 1000000007;
int main()
{
	int RGB=0,num;
	cin >> num;
	RGB += num * 100;
	cin >> num;
	RGB += num * 10;
	cin >> num;
	RGB += num * 1;
	RGB % 4 == 0 ? cout << "YES" << endl : cout << "NO" << endl;
#ifdef _DEBUG
	while(1);
#endif
	return 0;
}

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

int N, Q;
vector<int> g[200010];
int c[200010];

void dfs(int v, int p){
    c[v] += c[p];
    for(int i = 0; i < g[v].size(); ++i){
        if(g[v][i] != p) dfs(g[v][i], v);
    }
}


signed main(){
    cin >> N >> Q;
    for(int i = 0; i < N - 1; ++i){
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for(int i = 0; i < Q; ++i){
        int p, x;
        cin >> p >> x;
        c[p] += x;
    }

    dfs(1, 0);

    for(int i = 1; i < N; ++i) cout << c[i] << ' ';
    cout << c[N] << endl;

    return 0;
}


Measured memory_bytes: 23424
//#define MYDEBUG
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define debug(x)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define rep(i,from,to) for(int i=from; i<to; ++i)
#define REP(i,from,to) for(int i=from; i<=to; ++i)
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::ostream;
using std::swap;
using std::max;
using std::min;
using std::queue;
typedef struct edge edge;
typedef struct unionFind unionFind;
typedef struct Graph Graph;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

struct unionFind{
	vector<int> par;
	vector<int> rank;
	unionFind(int n) {
		par = vector<int>(n);
		rank = vector<int>(n);
		rep(i,0,n){
			par[i] = i;
			rank[i] = 1;
		}
	}
	
	int find(int x){
		if(par[x] == x){
			return x;
		}
		return par[x] = find(par[x]);
	}
	
	bool same(int x, int y){
		return find(x) == find(y);
	}
	
	void unite(int x, int y){//rank[x] > rank[y]
		x = find(x);
		y = find(y);
		if(x == y){
			return;
		}
		if(rank[x] < rank[y]){
			swap(x,y);
		}
		par[y] = x;
		rank[x] += rank[y];
		rank[y] = 0;
	}
	
	int size(int x){
		return rank[x];
	}
};

struct edge{
	int from, to, cost;
	edge(int from, int to, int cost){
		this->from = from;
		this->to = to;
		this->cost = cost;
	}
	
	edge(){
		*this = edge(-1,-1,-1);
	}
	
	bool operator<(const edge& e) const{
		return cost < e.cost;
	}
};

class Graph{
	public:
	static int kruskal(vector<edge>& es, int n){
		sort(es.begin(), es.end());
		unionFind uf(n);
		int min_cost = 0;
		rep(i,0,es.size()){
			edge& e = es[i];
			if(!uf.same(e.from, e.to)){
				min_cost += e.cost;
				uf.unite(e.from, e.to);
			}
		}
		return min_cost;
	}
};


int V,E;
vector<edge> es;
void solve(){
	ifcin("/storage/emulated/0/AppProjects/past15/jni/in.txt");
	cin >> V >> E;
	rep(i,0,E){
		int s,t,d;
		cin >> s >> t >> d;
		es.push_back(edge(s,t,d));
		if(s==V||t==V){
			cout << s << "," << t<< endl;
		}
	}
	cout << Graph::kruskal(es, V) << endl;
}

int main() {
	solve();
}

Measured memory_bytes: 4436
#include <cstdio>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
using namespace std;
typedef pair<int,int> ii;
typedef pair<ii, int> iii;
int n,m,l;
vector<ii> al[305];
ii w[305];
int ans[305][305];
priority_queue<iii, vector<iii> ,greater<iii> > pq;
ii add(ii i, int j){
    if (l-j<i.second) return ii(i.first+1,j);
    else return ii(i.first,i.second+j);
}
int main(){
    //freopen("input.txt","r",stdin);
    scanf("%d%d%d",&n,&m,&l);
    int a,b,c;
    while (m--){
        scanf("%d%d%d",&a,&b,&c);
        if (c>l) continue;
        al[a].push_back(ii(b,c));
        al[b].push_back(ii(a,c));
    }
    ii temp;
    int node;
    for (int x=1;x<=n;x++){
        memset(w,127,sizeof(w));
        w[x]=ii(0,0);
        pq.push(iii(w[x],x));
        while (!pq.empty()){
            temp=pq.top().first,node=pq.top().second,pq.pop();
            if (w[node]!=temp) continue;
            for (vector<ii>::iterator it=al[node].begin();it!=al[node].end();it++){
                if (w[(*it).first]>add(temp,(*it).second)){
                    w[(*it).first]=add(temp,(*it).second);
                    pq.push(iii(w[(*it).first],(*it).first));
                }
            }
        }
        for (int y=1;y<=n;y++){
            ans[x][y]=(w[y].first==2139062143)?-1:w[y].first;
        }
    }
    scanf("%d",&m);
    while (m--){
        scanf("%d%d",&a,&b);
        printf("%d\n",ans[a][b]);
    }
}


Measured memory_bytes: 2048
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    s = sc.strarr()[0]

    if s == 'Sunny':
        print('Cloudy')
    elif s == 'Cloudy':
        print('Rainy')
    elif s == 'Rainy':
        print('Sunny')
    else:
        print('error')


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	string s;
	int n,m;
	int ns = 0;
	char a='0',b='0';
	cin >> s;
	int flag = 0;
	int ans = 0;
	int ne = s.length() - 1;
	rep(i, 0, s.length()) {
		n = 0;
		m = 0;
		rep(j, ns, s.length()) {
			ns++;
			if (s[j] == 'x') {
				n++;
			}
			else {
				a = s[j];
				break;
			}
		}
		for (j = ne;j != -1;j--) {
			ne--;
			if (s[j] == 'x') {
				m++;
			}
			else {
				b = s[j];
				break;
			}
		}
		if (a != b) {
			flag = 1;
			break;
		}
		else {
			ans += abs(n - m);
		}
		if (ns >= ne) {
			break;
		}
	}
	if (flag) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  int K;
  cin>>S>>K;
  int N = S.size();
  map<string, int> amap;
  vector<string> arr;
  for(int i=1;i<=5;++i) {
    for(int j=0;j<=N-i;++j) {
      if(amap[S.substr(j, i)]==0) {
        arr.push_back(S.substr(j, i));
      }
      amap[S.substr(j, i)]++;
    }
  }
  sort(arr.begin(), arr.end());
  cout<<arr[K-1]<<endl;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int ans = 0;
	int N;
	int L;
	cin >> N >> L;

	int mina = INF;
	rep(i, 0, N)
	{
		ans += L + i;
		chmin(mina, abs(L + i));
	}

	if (L < 0)cout << ans + mina << endl;
	else cout << ans - mina << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, ans = 0;
	cin >> n;
	vll v(n);
	rep(i, n) cin >> v[i];
	REP(i, 1, 101) {
		bool x = false;
		ll co = 0;
		rep(j, n) {
			//cout << x << " " << co << endl;
			if (x) {
				if (v[j] < i) x = false;
			}
			else {
				if (v[j] >= i) x=true,co++;
			}
		}
		//cout << co <<  endl;
		ans += co;
	}
	cout << ans << endl;
	return 0;
}

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

int main (void){
	int a,b,k,i;
	cin >> a >> b >> k;
	for(i=a;i<=b;i++){
		if(i-a<k||b-i<k) cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main() {
  int n;
  cin >> n;
  vector<int> a(n), l(n+1), r(n+1);
  rep(i,n) cin >> a[i];
  l[0] = 0;
  for(int i = 1; i <= n; i++) {
    l[i] = gcd(l[i-1],a[i-1]);
  }
  r[n] = 0;
  for(int i = n-1; i >= 0; i--) {
    r[i] = gcd(r[i+1],a[i]);
  }
  int ans = 0;
  rep(i,n) {
    int g = gcd(l[i],r[i+1]);
    ans = max(ans,g);
  }

  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 4584
from collections import Counter

N=input()
A=map(int, raw_input().split())

C=Counter(A)

if len(C)==1:
	if C.keys()==[0]:
		print "Yes"
		quit()
elif len(C)==3:
	a,b,c=C.keys()
	na,nb,nc=C.values()
	if a^b==c and na==nb==nc:
		print "Yes"
		quit()
elif len(C)==2:
	if N%3==0:
		L=C.items()
		L.sort()
		a,b=L[0][0],L[1][0]
		na,nb=L[0][1],L[1][1]
		if a==0 and na==N/3:
			print"Yes"
			quit()

else:
	print "No"
	quit()


print "No"

Measured memory_bytes: 48840
import copy
K,N = (int(x) for x in input().split())
a = list(map(int,input().split()))
b = copy.copy(a)
tmp = a[N-1]
for i in range(N-1):
  a[i+1] -= a[i]
a[0] += K-tmp
d1 = sum(a)-max(a)
b = b[::-1]
tmp =b[0] 
for i in range(N-1):
  b[i] -= b[i+1] 
b[N-1] += K-tmp
d2 = sum(b)-max(b)
print(min(d1,d2))

    

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

int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
  }
  string s="even";
  int cnt=0;
  for(int i=1; i<=n-1; i++){
    if(s=="even")
    {
      if(a[i-1]<a[i]) s="up";
      if(a[i-1]>a[i]) s="down";
    }
    else if(s=="up" && a[i-1]>a[i])
    {
      cnt++;
      s="even";
    }
    else if(s=="down" && a[i-1]<a[i])
    {
      cnt++;
      s="even";
    }
  }
  cnt++;
  cout<<cnt<<endl;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    int b = 0, c = 0;
    rep(i, 0, m){
        cin >> a[i];
        if(a[i] < x) b++;
        else c++;
    }
    cout << min(b, c) << endl;
}

Measured memory_bytes: 256
N = int(input())
DP = [[0]*3 for i in range(N+1)]
for i in range(1,N+1):
    a,b,c = list(map(int,input().split()))
    DP[i][0] = max(DP[i-1][1]+a,DP[i-1][2]+a)
    DP[i][1] = max(DP[i-1][0]+b,DP[i-1][2]+b)
    DP[i][2] = max(DP[i-1][0]+c,DP[i-1][1]+c)
print(max(DP[-1]))

Measured memory_bytes: 22832
#include <bits/stdc++.h>
using namespace std;
int n,a[2][999];
int main(){
  int n;
  cin>>n;
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      cin>>a[i][j];
  for(int i=1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      if(j!=n-1&&i==0)a[i][j]+=max(a[i][j+1],a[i+1][j]);
      else if(j!=n-1)a[i][j]+=a[i][j+1];
      else if(i==0)a[i][j]+=a[i+1][j];
    }
  }
  cout<<a[0][0]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,s,m,t;
    cin>>n>>k;
    if(k==0)
    {
        cout<<n<<"\n";
    }
    else if(n>=k && k!=0)
    {
    s=n/k;
    t=n-(s*k);
    m=abs(t-k);
    if(m<t)
    {
        cout<<m<<"\n";
    }
    else cout<<t<<"\n";
    }
    else if (k>=n)
    {
        m=abs(k-n);
        if(m<n)
         {
            cout<<m<<"\n";
         }
        else cout<<n<<"\n";
    }
    return 0;
}

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

int main(){

  long int x, y;
  cin >> x >> y;
  //find maximum m such that pow(2, m) * x <= y
  int m = 1;
  while(2*x <= y){
      m++;
      x *= 2;
  }
  cout << m << endl;

}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
#まずaの条件がありうるかを判定する。

def kaijo(n):
  temp=1
  for i in range(n):
    temp*=2
    temp%=mod
  return temp

#nが奇数の場合…
if n%2:
  ki=[0]*((n+1)//2)
  for i in a:
    if i==0: #0の場合は2個なので2を足す
      ki[0]+=2
    elif i%2==0: #ちゃんと偶数かを判定
      ki[i//2]+=1
  if len(set(ki))==1:
    print(kaijo((n-1)//2))
  else:
    print(0)
else:
  ki=[0]*(n//2)
  for i in a:
    if i%2: #ちゃんと奇数かを判定
      ki[i//2]+=1
  if len(set(ki))==1:
    print(kaijo((n//2)))
  else:
    print(0)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> b(a);
    sort(all(b), greater<int>());
    rep(i, n)
    {
        int ans = b[0];
        if (a[i] == ans)
        {
            ans = b[1];
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
for i in range(N):
  if (A[i] - B[i]) >= 0:
    ans += B[i]
  else :
    ans += A[i]
    if (A[i+1] -(B[i] - A[i])) >= 0:
        A[i+1] -= (B[i] - A[i])
        ans += (B[i] - A[i])
    else :
        ans += A[i+1]
        A[i+1] = 0

print(ans)

Measured memory_bytes: 18376
from heapq import heapify,heappush,heappop
from math import ceil
n,m,*a=map(int,open(0).read().split())
a=[(-1)*x for x in a]
heapify(a)
for _ in range(m):
	x=heappop(a)
	heappush(a,ceil(x/2))
print(-sum(a))

Measured memory_bytes: 14180
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
int main(){
	int n,d; cin>> n >> d;
	double p[n+5][d+5];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < d; j++){
			double x; cin >> x;
			p[i][j] = x;
		}
	}
	int cnt = 0;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n;j++){
			double D = 0;
			for(int k = 0; k < d;k++){
				double a = fabs(p[i][k] - p[j][k]);
				D += a*a;
			}
			double dd = sqrt(D);
			//cout << D << ". " << dd << endl;
			if(ceil(dd) == floor(dd) && dd != 0)cnt++;
		}
	}
	cout << cnt/2 << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rep2(i,n) for(i=2;i<=n;i++)
#define test(a) cout << "*" << a << endl
#define ll long long
int main(){
  ll i,j;
  ll n; 
  ll nSyou=0;
  ll a;
  ll b = 0;
  ll countWari=0;
  ll maxAB;
  
  cin >> n;
  
  rep1(i,sqrt(n)+1){
    if(n%i==0){  
      a = i;
      b = n/i;        
    }
    //nSyou = n/i;            
  }
  
  //test(a);
  //test(b);
  maxAB = max(a,b);
  /*while(maxAB > 0){
    maxAB /= 10;
    countWari++;
  }*/
  
  cout << int(log10(maxAB)) +1 << endl;
  //cout << countWari << endl;
  //if(max(a,b)
 
}

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

typedef pair<long long,long long> PA;
typedef pair<int,PA> PPA;

const long long INF = (1LL<<40);

struct SegTree{
  
  int size;
  vector<long long> vec;
  
  void init(int n){
    size = 1;
    while(size < n) size <<= 1;
    for(int i=0;i<2*size-1;i++) vec.push_back(INF);
  }
  
  void update(int k,long long a){
    k += size-1;
    vec[k] = a;
    while(k > 0){
      k = (k-1)/2;
      vec[k] = min(vec[2*k+1],vec[2*k+2]);
    }
  }
  long long query(int a,int b){
    return (query(a, b, 0, 0, size - 1));
  }
  long long query(int a,int b,int k,int l,int r){
    if(r < a || b < l) return INF;
    if(a <= l && r <= b) return vec[k];
    long long nl = query(a,b,2*k+1,l,(l+r)/2);
    long long nr = query(a,b,2*k+2,(l+r)/2+1,r);
    return min(nl, nr);
  }
  

};

vector<PPA> p;
SegTree lx,rx,ly,ry;

int main(){

  int n,d;
  cin >> n >> d;
 
  lx.init(n);
  rx.init(n);
  ly.init(n);
  ry.init(n);

  long long x,y;
  int b;
  for(int i=0;i<n;i++){
    cin >> x >> y >> b;
    p.push_back(PPA(b,PA(x,y)));
  }
  
  sort(p.begin(),p.end());

  for(int i=0;i<n;i++){
    
    lx.update(i,p[i].second.first);
    rx.update(i,-p[i].second.first);
    ly.update(i,p[i].second.second);
    ry.update(i,-p[i].second.second);
    
  }
  
  int mi = 0;
  long long h,w,s=0;
  for(int i=0;i<n;i++){
    while(p[i].first-p[mi].first > d) mi++;
   
    w = -rx.query(mi,i) -lx.query(mi,i);
    h = -ry.query(mi,i) -ly.query(mi,i);

    s = max(s,w*h);
  }
  
  cout << s << endl;
  return(0);
}



Measured memory_bytes: 28612
n = int(input())
t, a = map(int, input().split())
listh = list(map(int, input().split()))
temp = 100000
index = 0

for i in range(n):
    diff = abs((t - listh[i] * 0.006)-a)
    if temp > diff:
        temp = diff
        index = i+1

print(index)


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

int main(){

  int N,pt[200][3],pt2[200][3];
  cin >> N;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      cin >> pt[i][j];
      pt2[i][j] = pt[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int k=i+1;k<N;k++){
      for(int j=0;j<3;j++){
	if(pt[i][j] == pt[k][j]){
	  pt2[i][j] = 0;
	  pt2[k][j] = 0;
	}
      }
    }
  }
  for(int i=0;i<N;i++){
    cout << pt2[i][0]+pt2[i][1]+pt2[i][2] << endl;
  }
}

Measured memory_bytes: 1164
package main

import (
	"bufio"
	"fmt"
	"os"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, m int
	fmt.Fscan(r, &n, &m)
	a := make([]int, m)
	c := make([]int, m)
	inf := 0
	for i := 0; i < m; i++ {
		var b int
		fmt.Fscan(r, &a[i], &b)
		inf += a[i]
		for j := 0; j < b; j++ {
			var x uint
			fmt.Fscan(r, &x)
			c[i] |= 1 << (x - 1)
		}
	}
	inf++

	f := 1 << uint(n)
	dp := make([][]int, m+1)
	for i := 0; i < m+1; i++ {
		dp[i] = make([]int, f)
		for j := 0; j < f; j++ {
			dp[i][j] = inf
		}
	}
	dp[0][0] = 0

	for i := 0; i < m; i++ {
		for j := 0; j < f; j++ {
			dp[i+1][j] = min(dp[i][j], dp[i+1][j])
			dp[i+1][j|c[i]] = min(dp[i][j]+a[i], dp[i+1][j|c[i]])
		}
	}

	if dp[m][f-1] == inf {
		fmt.Println(-1)
	} else {
		fmt.Println(dp[m][f-1])
	}
}


Measured memory_bytes: 33792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		string S = rs();
		string T = rs();

		int ans = T.Length;
		for (int i = 0; i < S.Length - T.Length + 1; i++)
		{
			int diffCnt = 0;
			for (int j = 0; j < T.Length; j++)
			{
				if(S[i + j] != T[j]) diffCnt++;
			}

			ans = Math.Min(ans, diffCnt);
		}

		
		Console.WriteLine(ans);
		Console.ReadLine();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


Measured memory_bytes: 25964
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
    divisors.sort()
    return divisors

n = int(input())
ls = make_divisors(n)
d = 10 ** 13 + 1
for i in ls:
    d = min(d, (i - 1) + (n // i - 1))

print(d)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <climits>
using namespace std;

int main(){
    long long n, c;
    cin >> n >> c;
    vector<vector<long long> > d(c, vector<long long>(c)), a(n, vector<long long>(n));
    for(int i = 0; i < c; ++i)
        for(int j = 0; j < c; ++j) cin >> d[i][j];

    vector<map<long long, long long> > cnt(3);

    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j){
            cin >> a[i][j];
            cnt[(i + j + 2) % 3][a[i][j] - 1]++;
        }
    long long ans = 1e9;
    for(int i = 0; i < c; ++i){
        for(int j = 0; j < c; ++j){
            if(i == j) continue;
            for(int x = 0; x < c; ++x){
                if(x == i || x == j) continue;
                long long a1 = 0;
                for(int y = 0; y < c; ++y) a1 += cnt[0][y] * d[y][i];
                for(int y = 0; y < c; ++y) a1 += cnt[1][y] * d[y][j];
                for(int y = 0; y < c; ++y) a1 += cnt[2][y] * d[y][x];
                ans = min(ans, a1);
            }
        }
    }
    cout  << ans;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

ll n;
int main() {
    cin >> n;
    ll x[n],y[n],t[n];
    rep(i,0,n){
        cin >> t[i] >> x[i] >> y[i];
    }
    rep(i,0,n){
        if((t[i] < (x[i] + y[i])) || ( (t[i] % 2) != ((x[i] + y[i]) % 2))){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  if(A>=13){
    cout << B << endl;
  }
  else if(A>=6){
    cout << B/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  priority_queue<pair<ll, int>> pq;  
  for(int &xe: p) {
    cin >> xe;
    pq.push({xe, 1});
  }
  for(int &xe: q) {
    cin >> xe;
    pq.push({xe, 2});
  }
  for(int &xe: r) {
    cin >> xe;
    pq.push({xe, 0});
  }
  ll res = 0;
  int ot = 0;
  while(!pq.empty() && (x || y)) {
    auto xp = pq.top(); pq.pop();
    if(xp.second == 1) {
      if(x) {
        res += xp.first;
        x--;
      }
    } else if (xp.second == 2) {
      if(y) {
        res += xp.first;
        y--;
      }
    } else {
      ot++;
      res += xp.first;
    }
    if(ot == x + y) break;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 11500
using System;
using System.Collections;
using System.Linq;
class Pair //二つの整数のペア
{
    public int x;
    public int y;
    public Pair(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
    public void Show()
    {
        Console.WriteLine("{0} {1}", x, y);
    }
}
class Program
{
    static int n;
    static int[] a;
    static ArrayList ans1 = new ArrayList();
    static int ans2 = 0;
    static void Posi() //非負整数数列に対してやること
    {
        for (int i = 0; i < n - 1; i++)
        {
            if (a[i] <= a[i + 1])
                continue;
            else
            {
                ans2++;
                a[i + 1] += a[i];
                ans1.Add(new Pair(i + 1, i + 2));
            }
        }
    }
    static void Nega() //非正整数列に対してやること
    {
        for (int i = n - 1; i > 0; i--)
        {
            if (a[i - 1] <= a[i])
                continue;
            else
            {
                ans2++;
                a[i - 1] += a[i];
                ans1.Add(new Pair(i + 1, i));
            }
        }
    }
    static void Main()
    {
        //以下入力の受け取り
        n = int.Parse(Console.ReadLine());
        a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        //以下処理内容
        if (a.Min() >= 0)
            Posi();
        else if (a.Max() <= 0)
            Nega();
        else if (-a.Min() <= a.Max())
        {
            int maxindex = 0;
            for (int i = 0; i < n; i++)
                if (a[i] == a.Max())
                    maxindex = i;
            for (int i = 0; i < n; i++)
            {
                ans2++;
                a[i] += a[maxindex];
                ans1.Add(new Pair(maxindex + 1, i + 1));
            }
            Posi();
        }
        else
        {
            int minindex = 0;
            for (int i = 0; i < n; i++)
                if (a[i] == a.Min())
                    minindex = i;
            for (int i = 0; i < n; i++)
            {
                ans2++;
                a[i] += a[minindex];
                ans1.Add(new Pair(minindex + 1, i + 1));
            }
            Nega();
        }


        //以下解答の出力
        Console.WriteLine(ans2);
        for (int i = 0; i < ans1.Count; i++)
            ((Pair)ans1[i]).Show();
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
long long comb(long long n,long long r){
    long long a=1,b=1,c=1;
    for(long long i=1;i<=n;i++){
        a *= i;
    }
    for(long long i=1;i<=r;i++){
        b *= i;
    }
    for(long long i=1;i<=n-r;i++){
        c *= i;
    }
    return a/(b*c);
}

int main() {
    int N;
    cin >> N;
    vector<double> a(N);
    for(int i=0; i<N; i++){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    double center = (a.at(N-1))/2;
    vector<double> diff(N-1);
    for(int i=0; i<N-1; i++){
        diff.at(i) = abs(center - a.at(i));
    }
    int x = distance(diff.begin(), min_element(diff.begin(),diff.end()));
    long long b = a.at(N-1);
    long long c = a.at(x);
    cout << b << ' ' << c << endl;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	int x,a,b,c,ans=0;
	cin>>a>>b>>c>>x;
	for(int i=a; i>=0; i--) {
		if(i*500>x)continue;
		for(int o=b; o>=0; o--)
			if(i*500+o*100>x)continue;
			else if((x-i*500-o*100)/50<=c)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256