akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int)(n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<v.size(); i++) cin>>v[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int n, sum = 0;
	cin >> n;
	vector<int>vec2(n);
	vector<pair<int,int>>vec1(n-1);
	rep(i, n-1) {
		vec1[i].second = i;
		cin >> vec1[i].first;
	}
	sort(all(vec1));
	reverse(all(vec1));
	rep(i, n-1) {
		vec2[vec1[i].second] = vec1[i].first;
		vec2[vec1[i].second+1] = vec1[i].first;
	}
	rep(i, n) {
		sum += vec2[i];
	}
	cout << sum << endl;
}


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

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    int s, l;
    s = a*b;
    l = 2*a + 2*b;
    
    printf("%d %d\n", s, l);
    
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main () {
    map<int, long long> mp;
    long long N, K;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    long long k = 0;
    for (auto x: mp) {
        k += x.second;
        if (k >= K) {
            cout << x.first << endl;
            break;
        }
    }
}

Measured memory_bytes: 4224
#include <stdio.h>

int solve(int ,int);

int A[2000],n;

int main()
{
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);
  scanf("%d",&m);
  for(i=0;i<m;i++)
    {
      scanf("%d",&q);
      if(solve(0,q))
	printf("yes\n");
      else
	printf("no\n");
    }
  return 0;
}
int solve(int i, int m)
{
  int res;
  if(m==0)
    return 1;
  if(i >= n)
    return 0;
  res = solve(i + 1, m)|| solve(i + 1, m - A[i]);
  return res;
}



Measured memory_bytes: 2048
#include<iostream>
#include<vector>
int main(){
  int N,X;
  std::cin >> N >> X;
  std::vector<int> m(N,0);
  int minm=1000,sum=0;
  for(int i = 0; i < N; i++){
    std::cin >> m[i];
    sum+=m[i];
    minm=std::min(minm,m[i]);
  }
  int cnt=N;
  X-=sum;
  cnt+=(X/minm);
  std::cout << cnt << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n;cin >> n;
    vector<int> w(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> w[i];
        sum+=w[i];
    }
    int ans = INF;
    for(int i=0;i<n;i++){
        int tmp=0;
        for(int j=i;j<n;j++){
            tmp+=w[j];
        }
        ans = min(ans,abs(2*tmp-sum));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}




//https://github.com/kosakkun/procon_library/blob/master/graph/bellman_ford.cpp  
template<class T> struct BellmanFord {
    
    struct Edge {
        int from,to;
        T cost;
        Edge (int f, int t, T c) : from(f), to(t), cost(c) {}
    };
  
    const T INF = numeric_limits<T>::max() / 2;
    vector< vector< T > > d;
    vector< Edge > edge;
    BellmanFord (int n) : d(2,vector<T>(n)) {}
  
    void add_directed_edge(int from, int to, T cost) {
        edge.push_back(Edge(from,to,cost));
    }

    void init(int s) {
        for (int i = 0; i < d[0].size(); i++) d[0][i] = INF;
        d[0][s] = 0;
        for (int k = 0; k < 2; k++) {
            for (int j = 0; j < d[0].size(); j++) {
                for (int i = 0; i < edge.size(); i++) {
                    Edge e = edge[i];
                    if (d[k][e.from] != INF && d[k][e.to] > d[k][e.from] + e.cost) {
                        d[k][e.to] = d[k][e.from] + e.cost;
                    }
                }
            }
            if (k == 0) d[1] = d[0];
        }
    }
    
    bool find_negative_loop(int v) {
        return d[0][v] != d[1][v];
    }
    
    T dist(int v) {
        return d[0][v];
    }
    
};


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

  ll N; cin >> N ;
  ll M; cin >> M ;
  vector<ll>a,b,c;
  rep(i,M){
    ll ai,bi,ci; cin >> ai >> bi >> ci;
    ai--;
    bi--;
    ci *= -1;
    a.pb(ai);
    b.pb(bi);
    c.pb(ci);
  }

  BellmanFord<long long> bel(N);
  rep(i,M)
    bel.add_directed_edge(a[i],b[i],c[i]);

  bel.init((int)0);
  if(bel.find_negative_loop(N-1)) cout << "inf" << endl;
  else cout << (-1)*bel.dist(N-1) << endl;
    
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#define MAX 120
#define WHITE -1
#define GRAY 0
#define BLACK 1
#define INFTY (1 << 21)

using namespace std;

int n;
int M[MAX][MAX];
int color[MAX], d[MAX], p[MAX];

void dijkstra(){
    
    int mini;
    
    for(int i=0; i<n; i++){
        color[i] = WHITE;
        d[i] = INFTY;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    
    while(1){
        mini = INFTY;
        int u = -1;
        
        for(int i=0; i<n; i++){
            if(mini > d[i] && color[i] != BLACK){
                u=i;
                mini = d[i];
            }
        }
        
        if( u == -1){
            break;
        }
        
        color[u] = BLACK;
        
        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    
    
    for(int i=0; i<n; i++){
        if(d[i] != INFTY){
            cout << i << " " << d[i] << endl;
        }
        
        //cout << i << " " << d[i] << endl;
    }
    
}


int main(){
    cin >> n;
    
    int k, c, u, v;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = INFTY;
        }
    }
    
    for(int i=0; i<n; i++){
        cin >> u >> k;
        
        for(int j=0; j<k; j++){
            cin >> v >> c;
            
            M[u][v]=c;
        }
    }
    
    dijkstra();
    
    return 0;
}




Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define ll long long 
#define endl "\n"
using namespace std;

void solve()
{
	//Enter code here Tanmay::
	ll int n;
	cin>>n;
	ll int sum=0;
	for(ll int i=1;i<n;i++)
	{
		sum+=i;
	}
	cout<<sum;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}
void fastscan(int &number) 
{ 
    //variable to indicate sign of input number 
    bool negative = false; 
    register int c; 
  
    number = 0; 
  
    // extract current character from buffer 
    c = getchar(); 
    if (c=='-') 
    { 
        // number is negative 
        negative = true; 
  
        // extract the next character from the buffer 
        c = getchar(); 
    } 
  
    // Keep on extracting characters if they are integers 
    // i.e ASCII Value lies from '0'(48) to '9' (57) 
    for (; (c>47 && c<58); c=getchar()) 
        number = number *10 + c - 48; 
  
    // if scanned input has a negative sign, negate the 
    // value of the input number 
    if (negative) 
        number *= -1; 
} 

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);


  string s; cin >> s;
  for(auto &c:s){
    if(c=='9')c='1';
    else if(c=='1')c='9';
  }
  cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	ll k; cin >> k;
	const int n = 50;
	int a = (k + n - 1) / n;
	int b = (k % n == 0 ? 0 : n - (k % n));
	cout << n << endl;
	a += n - 1;
	rep(i, b) {
		cout << a - n + b - 1 << " ";
	}
	rep(i, n - b) {
		cout << a + b << " ";
	}
	cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3656
def main():
    from sys import stdin
    input=stdin.readline
    
    n, q = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in [0]*(n-1)]
    px = [list(map(int, input().split())) for _ in [0]*q]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]
    root = 0  # 根
    d = [-1]*n  # 根からの距離
    d[root] = 0
    q = [root]
    cnt = 0
    while q:  # BFS
        cnt += 1
        qq = []
        while q:
            i = q.pop()
            for j in g[i]:
                if d[j] == -1:
                    d[j] = cnt
                    qq.append(j)
        q = qq
    d2 = list(sorted(enumerate(d), key=lambda x: x[1]))

    ans = [0]*n
    for p, x in px:
        ans[p-1] += x
    for i, j in d2:
        for k in g[i]:
            if d[k] == j+1:
                ans[k] += ans[i]
    print(*ans)


main()


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

int main() {
  int K,A,B;
  cin >> K >> A >> B;

  for(int i=0;i<=1000;i++){
    if(A<=i*K && i*K<=B){
      cout << "OK" << "\n";
      return 0;
    }
  }
  cout << "NG" << "\n";

}


Measured memory_bytes: 3632
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <queue>
#define ll long long
using namespace std;

int main(){
    ll N,D,ans=0;
    cin>>N>>D;
    for(int i=0;i<N;i++){
        ll X,Y;
        cin>>X>>Y;
        if(X*X+Y*Y<=D*D) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	numSequence := GetArgs()
	InsertionSort(numSequence)
}

// GetArgs 数列の長さを表す整数 Nと数列を取得する
func GetArgs() []int {
	sc.Split(bufio.ScanWords)
	elmCount := NextInt()

	var numSequence []int
	for i := 0; i < elmCount; i++ {
		numSequence = append(numSequence, NextInt())
	}
	return numSequence
}

// NextInt 個々の数値を取得する
func NextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

// InsertionSort 挿入ソートを実行する
func InsertionSort(numSequence []int) {
	PrintNumSequence(numSequence)
	for i := 1; i < len(numSequence); i++ {
		v := numSequence[i]
		j := i - 1
		if j < 0 {
			continue
		}
		for numSequence[j] > v {
			numSequence[j+1] = numSequence[j]
			j = j - 1
			numSequence[j+1] = v
			if j < 0 {
				break
			}
		}
		PrintNumSequence(numSequence)
	}
}

// PrintNumSequence ソート結果を出力する
//func PrintNumSequence(numSequence []int) {
//	var outputStr []string
//	for _, n := range numSequence {
//		outputStr = append(outputStr, strconv.Itoa(n))
//	}
//	fmt.Println(strings.Join(outputStr, " "))
//
//}
func PrintNumSequence(src []int) {
	for i, v := range src {
		if i == len(src)-1 {
			fmt.Printf("%d\n", v)
		} else {
			fmt.Printf("%d ", v)
		}
	}
}


Measured memory_bytes: 1148
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<Integer> ch = new HashSet<Integer>();
        for (int i = 0; i < s.length(); i++) {
            ch.add((int) s.charAt(i));
        }
        System.out.println(ch.size() == 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 23764
//CODEFORCES:-
//coded by AMAN BHARTI NIT PATNA
//ALL RIGHTS RESERVED
//ECE 2K18
#include<bits/stdc++.h>
using namespace std;

//#define home
#define TASK "soln"
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define pb push_back
#define ll long long int
#define br cout<<endl;
#define fo for(int i=0;i<n;i++)
#define foo for(int i=1;i<=n;i++)
#define mod 1000000007


void solve(){
    ll n,x,t;
    cin>>n>>x>>t;
    ll c = n/x;
    if(n%x)c++;
    cout<<c*t;
    br;
}

int main(){
	#ifdef home
        assert(freopen(TASK".in","r",stdin));
        assert(freopen(TASK".out","w",stdout));
    #endif

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

    // int t;
    // cin>>t;
    // while(t-->0)
    solve();

    #ifdef home
        eprintf("Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif

    return 0;
}

Measured memory_bytes: 3608
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
ai = [0]
bi = [0]
 
for i in range(n):
    ai.append(ai[i] + a[i])
for i in range(m):
    bi.append(bi[i] + b[i])

ans, j = 0, m
for i in range(n+1):
    if ai[i] > k:
        break
    while bi[j] > k - ai[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 127048
#include <cstdio>
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<=b&&b<=c)
    printf("%d\n",a+b);
    else if(a<=b&&c<=b)
    printf("%d\n",a+c);
    else if(b<=a&&a<=c)
    printf("%d\n",a+b);
    else if(b<=a&&c<=a)
    printf("%d\n",b+c);
    else if(c<=a&&a<=b)
    printf("%d\n",a+c);
    else 
    printf("%d\n",b+c);
}

Measured memory_bytes: 128
// finish date: 2018/12/15

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    int N = s.length();
    int st = N;
    //最初のFの処理

    rep(i, N) {
        if (s[i] == 'F') x--;
        else {
            st = i + 1;
            break;
        }
    }
    vi X, Y;
    int sign = 1;
    int cnt = 0;

    //XとYの移動距離をリストに
    FOR(i, st, N) {
        if (s[i] == 'F') cnt++;
        if (i == N - 1 || s[i] == 'T') {
            if (sign == 1) Y.push_back(cnt);
            else X.push_back(cnt);
            sign *= -1;
            cnt = 0;
        }
    }

    vvb isReachedX(X.size() + 1, vb(16001, false)), isReachedY(Y.size() + 1, vb(16001, false));
    isReachedX[0][8000] = true;
    isReachedY[0][8000] = true;
    FOR(i, 1, isReachedX.size()) {
        rep(j, isReachedX[0].size()) {
            if (isReachedX[i - 1][j] == true) {
                isReachedX[i][j + X[i - 1]] = true;
                isReachedX[i][j - X[i - 1]] = true;
            }
        }
    }

    FOR(i, 1, isReachedY.size()) {
        rep(j, isReachedY[0].size()) {
            if (isReachedY[i - 1][j] == true) {
                isReachedY[i][j + Y[i - 1]] = true;
                isReachedY[i][j - Y[i - 1]] = true;
            }
        }
    }


    if (x + 8000>=0 && y+8000>=0 &&isReachedX[isReachedX.size() - 1][x + 8000] && isReachedY[isReachedY.size() - 1][y + 8000]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 16256
N, M = gets.split.map(&:to_i)
e = []
M.times do
  t = gets.split.map(&:to_i)
  t[2] = -t[2]
  e << t
end

arr = Array.new(N+1, Float::INFINITY)
arr[1] = 0
(N-1).times do
  e.each do |a,b,c|
    if arr[b] > arr[a] + c
      arr[b] = arr[a] + c
    end
  end
end

before = arr[N]
(N-1).times do
  e.each do |a,b,c|
    if arr[b] > arr[a] + c
      arr[b] = arr[a] + c
    end
  end
end

puts before == arr[N] ? -before : "inf"


Measured memory_bytes: 2172
gets
while s=gets
  x1,y1,x2,y2,x3,y3 = s.split.map(&:to_f)
  x1,y1,x2,y2 = x2,y2,x1,y1 if y1==y3
  x1,y1,x3,y3 = x3,y3,x1,y1 if y1==y2
  x3,y3,x2,y2 = x2,y2,x3,y3 if y2==y3
  a1 = -(x2-x1)/(y2-y1)
  b1 = -a1*(x2+x1)/2+(y1+y2)/2
  a2 = -(x3-x1)/(y3-y1)
  b2 = -a2*(x3+x1)/2+(y1+y3)/2
  x = (b2-b1)/(a1-a2)
  y = (b1*a2-b2*a1)/(a2-a1)
  r = Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1))
  puts printf("%.3f %.3f %.3f", x, y, r)
end

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

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

  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll MOD = 1000000007;

int n;
set<int> st;
vector<int> sd;
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP (i, n) {
        int a;
        cin >> a;
        if (st.count(a)) {
            sd.emplace_back(a);
            st.erase(a);
        } else {
            st.insert(a);
        }
    }

    sort(sd.begin(), sd.end());

    if (SZ(sd) < 2) {
        cout << 0 << endl;
    } else {
        cout << ll(sd[SZ(sd)-1]) * sd[SZ(sd)-2] << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
#include <complex>

#define f first
#define s second
#define ll long long
#define ld double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
 
using namespace std;
 
double start_moment = 0;
double get_runtime() { return 1.0*clock()/CLOCKS_PER_SEC; }
void reset_timer() { start_moment = get_runtime(); }
double timer_time() { return get_runtime() - start_moment; }
void runtime(){cout<<fixed<<setprecision(5)<<get_runtime()<<'\n';}
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<' ';cout<<'\n';}



int main()
{
    ios_base::sync_with_stdio(0);
//    freopen("INPUT.txt","r",stdin);
//    freopen("OUTPUT.txt", "w", stdout);
        
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d});
    
    
    
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		
		Scanner in = new Scanner(System.in);
		
		long A = in.nextLong();
		long B = in.nextLong();
		long C = in.nextLong();
		long K = in.nextLong();
		
		
		//[1,2,3] K=4
		
		if (K<A) {
			System.out.println(K);
		} else {
			if (K==A) {
				System.out.println(A);
			} else if (A+B >= K) {
				System.out.println(A);
			} else {
				System.out.println(A - (K-A-B));
			}
		}
		
		
	}
}


Measured memory_bytes: 27028
# 1 円硬貨を A 枚と 500 円硬貨を無限枚持っています.
# これらの硬貨だけを使うことによって, ちょうど N 円を支払うことができるかを判定
n = gets.chomp.to_i
a = gets.chomp.to_i
b = n % 500

# 持っている 1 円硬貨と 500 円硬貨だけで,
# ちょうど N 円を支払うことができるならば Yes, そうでないならば No を出力しなさい.
if (a >= b)
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
int main(){
	double a,b;
	cin>>a>>b;
	int x1,x2,y1,y2;
	x1=(int)ceil(a/0.08);
	x2=(int)ceil(b/0.1);
	int s=(a+1)*125;
	if(s%10==0) y1=(a+1)*12.5-1;
	else y1=(a+1)*12.5;
	y2=(b+1)*10-1;
	//printf("%d %d %d %d\n",x1,y1,x2,y2);
	if(x1>y2||x2>y1) printf("-1");
	else{
        printf("%d",max(x1,x2));
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int L, R;
	cin >> L >> R;
	int minnum = 3000;
	if (R - L >= 2018)cout << 0;
	else
	{
		for (int i = L; i <= R; i++)
		{
			for (int j = i + 1; j <= R; j++)
			{
				minnum = min(minnum, ((i % 2019) * (j % 2019)) % 2019);
			}
		}
		cout << minnum;
	}
}


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

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

    if(a==b && b==c){
        cout << "No" << endl;
    }else if(a != b && b != c && c != a){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

}

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

def yakusu(A):
  arr = []
  limit = int(math.sqrt(A))
  for i in range(2,limit+1):
    if A % i == 0:
      arr.append(i)
      if i != A // i:
        arr.append(A//i)
  arr.append(A)
  arr.sort()
  return(arr)

yakusu_N = yakusu(N)
yakusu_N1 = yakusu(N-1)


      
def ope(a,N):
  while True:
    if N % a == 0:
      N = N / a
      if N == 1:
        return 1
        break
    else:
      N = N % a
      if N != 1:
        return 0
        break
      else :
        return 1
        break



count = 0 
for i in yakusu_N:  
  if ope(i,N) == 1:
    count += 1
if N != 2:
  print(count + len(yakusu_N1))
else:
  print(1)

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,a,b;

    {
        cin>>a>>b;
        cout<<a*b<<'\n';
    }
    return 0;
}

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

int main() {
	int N, ans = 0;
	cin >> N;
	vector<string> n(N + 1);
	for (int i = 1; i < N + 1; i++) {
		n.at(i) = to_string(i);
		if (n.at(i).size() % 2 == 1) ans++;
	}
	cout << ans << endl;
}

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  vector<int> A(N), B(N);
  REP(i, N) {
    cin >> A[i] >> B[i];
  }
  int ans = 0;
  REP(i, N) {
    if(A[i] >= H && B[i] >= W) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())))
m = a[-1]
b = [True]*(m+1)
for i in range(n):
    if i > 0 and a[i] == a[i-1]:
        continue
    for j in range(2, m//a[i]+1):
        b[j*a[i]] = False
ans = 0
for i in range(n):
    if 0 < i and a[i] == a[i-1]:
        continue
    if i < n-1 and a[i] == a[i+1]:
        continue
    if b[a[i]]:
        ans += 1
print(ans)

Measured memory_bytes: 32344
import itertools

H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

hlist = []
for i in range(H+1):
    hlist += list(itertools.combinations(range(H), i))
wlist = []
for i in range(W+1):
    wlist += list(itertools.combinations(range(W), i))

answer = 0
for hchoice in hlist:
    for wchoice in wlist:
        count = 0
        for row in hchoice:
            for col in wchoice:
                if C[row][col]=='#':
                    count += 1
        if count == K:
            answer += 1
print(answer)

Measured memory_bytes: 68120
use proconio::input;


fn factorize(mut base: i64) -> Vec<(i64, i64)> {
    let mut fs = Vec::<(i64, i64)>::new();
    let mut i: i64 = 2;

    while i*i <= base {
        if base % i == 0 {
            let mut cnt: i64 = 0;

            while base % i == 0 {
                base /= i;
                cnt += 1;
            }

            fs.push((i, cnt));
        }

        i += 1;
    }

    if base > 1 {
        fs.push((base, 1));
    }

    return fs;
}


fn main() {
    input! {
        n: i32,
        a: [i64; n],
    }

    let mut ans = 0;

    for ai in a {
        for (i, c) in factorize(ai) {
            if i == 2 {
                ans += c;
            }
        }
    }

    println!("{}", ans);
}


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, c; // Capacity
	cin >> n >> c;
	vector<ll> w(n), v(n);
	rep(i, n) {
		cin >> w[i] >> v[i];
	}

	/*
	 *  dp[i][j] = i 番目までの品物と重さ j 以内、という制約での最大価値
	 */
	vector<vector<ll>> dp(n + 1, vector<ll>(c + 1, 0));

	repd(i, 1, n + 1) {
		repd(j, 1, c + 1) {
			dp[i][j] = max(dp[i-1][j], (j - w[i-1] >= 0) ? dp[i-1][j - w[i-1]] + v[i-1] : 0);
		}
	}

	cout << dp[n][c] << endl;

	return 0;
}


Measured memory_bytes: 80256
k, x = list(map(int, input().split()))

if k == 1:
    print(x)
else:
    lower = []
    upper = []
    for i in range(1, k):
        lower.append(x-i)
        upper.append(x+i)
    
    res = lower[::-1] + [x] + upper

    r = [str(x) for x in res]
    print(" ".join(r))


Measured memory_bytes: 61944
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
const ll INF = 1e18;
const ld eps = 1e-4;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int d; cin >> d;
    int c[26];
    REP(i,26) cin >> c[i];
    int v[d][26];
    REP(i,d)REP(j,26) cin >> v[i][j];
    V<> sol;
    V<> loss(26,0);
    REP(i,d){
        V<pair<ld,ll>> score(26,{0.0,0});
        REP(j,26) score[j] = {v[i][j] - loss[j] + loss[j] * eps, j};
        sort(rall(score));
        int r = score[0].second;
        sol.pb(r + 1);
        REP(j,26){
            if(j == r) loss[j] = 0;
            else loss[j] += c[j];
        }
    }
    REP(i,d) cout << sol[i] << endl;
}

Measured memory_bytes: 3700
int main(void) {
    int n, x, i, j, k, count, sum ;
    sum=0;
    count = 0;
    while (1) {
 
        scanf("%d %d", &n, &x);
 
        if (n == 0 && x == 0) break;
 
        for (i = 1; i <= n; i++) {
            for (j = i + 1; j <= n; j++) {
                for (k = j + 1; k <= n; k++) {
                    sum = i + j + k;
                    if (sum == x) {
                        count++;
                    }
                }
            }
        }
        printf("%d\n", count);
        count = 0;
    }
    return 0;
}

Measured memory_bytes: 1756
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7056
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my $s = <STDIN>);
chomp (my $t = <STDIN>);
for my $i (0..($n-1)) {
  if (substr($s, $i, $n-$i) eq substr($t, 0, $n-$i)) {
    say $n + $i;
    exit;
  }
}
say 2 * $n;

Measured memory_bytes: 768
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	while (1) {
		string s;
		int line = 1;
		int now;
		int a, b, c, d;
		vector<string> t(10);
		string u;

		cin >> s;
		if (s[0] == '#') {
			break;
		}
		cin >> a >> b >> c >> d;

		FOR(i, 0, s.size() - 1) {
			//cout << i << endl;
			if (s[i] >= '1'&&s[i] <= '9') {
				FOR(j, 1, s[i] - '0') {
					t[line].push_back('.');
				}
			}
			if (s[i] == 'b') {
				t[line].push_back('b');
			}
			if (s[i] == '/') {
				line++;
			}
		}

		now = t[1].size();

		t[a][b - 1] = '.';
		t[c][d - 1] = 'b';

		int count = 0;
		char moji;
		FOR(i, 1, line) {
			count = 0;
			FOR(j, 0, now - 1) {
				if (t[i][j] == 'b') {
					if (count != 0) {
						moji = count + '0';
						u.push_back(moji);
						count = 0;
					}
					u.push_back('b');
				}
				else {
					count++;
				}
				if (j == now - 1 && count != 0) {
					moji = count + '0';
					u.push_back(moji);
				}
			}
			if (i != line) {
				u.push_back('/');
			}
		}
		
		cout << u << endl;

		//FOR(i, 1, line) {
		//	cout << t[i] << endl;
		//}

	}
	return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
vector<ll> G[100001];

map<ll,map<ll,ll>> en_g;
map<ll,map<ll,ll>> sn_g;

ll en[100001] = {};
ll sn[100001] = {};
using state = tuple<ll,ll>; // cost,pos
int main(){
  rep(i,100001) en[i] = sn[i] = LLINF;
  ll n,m,s,t; cin >> n >> m >> s >> t;
  rep(i,m){
    ll u,v,a,b; cin >> u >> v >> a >> b;
    en_g[u][v] = en_g[v][u] = a;
    sn_g[u][v] = sn_g[v][u] = b;
    G[u].pb(v),G[v].pb(u);
  }
  priority_queue<state,vt<state>,greater<state>> q;
  q.push(state{0,s});

  while(!q.empty()){
    ll now_pos, now_cost; tie(now_cost, now_pos) = q.top(); q.pop();
    if(en[now_pos] != LLINF || now_cost > 1000000000000000)  continue;
    en[now_pos] = now_cost;
    for(auto g: G[now_pos]){
      q.push(state{en_g[now_pos][g] + now_cost, g});
    }
  }
  q.push(state{0,t});
  while(!q.empty()){
    ll now_pos, now_cost; tie(now_cost, now_pos) = q.top(); q.pop();
    if(sn[now_pos] != LLINF || now_cost > 1000000000000000)  continue;
    sn[now_pos] = now_cost;
    for(auto g: G[now_pos]){
      q.push(state{sn_g[now_pos][g] + now_cost, g});
    }
  }
  vt<ll> ans;
  ll now_min = LLINF;
  rep(i,n){
    now_min = min(now_min, en[n-i] + sn[n-i]);
    ans.pb(now_min);
  }
  reverse(ALL(ans));
  rep(i,n)  cout << 1000000000000000 - ans[i] << endl;
}


Measured memory_bytes: 54384
#include<stdio.h>
#include<math.h>

int main(){
  int a,b;
  char* result="";
  scanf("%d %d",&a,&b);
  int sum=0;

  if(b>=100) sum=(a*1000)+b;
  else if(b>=10) sum=(a*100)+b;
  else sum=(a*10)+b;

  int sq=sqrt(sum);
  if(sq*sq==sum) result="Yes";
  else result="No";

  printf("%s\n",result);

  return 0;
  
}


Measured memory_bytes: 128
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

// Union-Find Tree
class DisjointSet {
private:
    struct Node {
        int parent;
        int rank;
    };

public:
    DisjointSet(size_t n) : _nodes(n) {
        int i = 0;
        for (auto& node : _nodes) {
            node.parent = i++;
            node.rank = 0;
        }
    }

    bool same(int a, int b) {
        return find(a) == find(b);
    }

    void unite(int a, int b) {
        link(find(a), find(b));
    }

    int find(int x) {
        if (x != _nodes[x].parent) {
            // path compression
            _nodes[x].parent = find(_nodes[x].parent);
        }
        return _nodes[x].parent;
    }

    void link(int a, int b) {
        if (_nodes[a].rank > _nodes[b].rank) {
            _nodes[b].parent = a;
        } else {
            _nodes[a].parent = b;
            if (_nodes[a].rank == _nodes[b].rank) {
                _nodes[b].rank += 1;
            }
        }
    }

private:
    std::vector<Node> _nodes;
};


struct edge {
    int src, dst;
    int weight;

    edge(int src, int dst, int w) : src(src), dst(dst), weight(w) {}
};

int main() {
    int V, E;
    cin >> V >> E;

    vector<edge> edges;
    for (int i = 0; i < E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        edges.emplace_back(s, t, w);
    }

    // Kruskal's algorithm
    int total = 0;
    sort(edges.begin(), edges.end(), [](const edge& a, const edge& b) { return a.weight < b.weight; });
    auto S = DisjointSet(V+1);
    for (auto& e : edges) {
        if (!S.same(e.src, e.dst)) {
            total += e.weight;
            S.unite(e.src, e.dst);
        }
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 4524
#include <iostream>
using namespace std;
int main() {
    int a, b, x,ans;
    cin >> a >> b >> x;
    if (a/2<b) {
        ans = x/1000*a;
        if (x%1000) {
            if (x%1000>500) {
                ans+=a;
            } else {
                if(a<b) ans += a;
                else ans+= b;
            } 
        }
    } else {
        ans = x/500*b;
        if (x%500) {
            ans+=b;
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3104
//Littleboy123 Template 1.1

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

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

int main(){
	init();

	//debug
	/*
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());

	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
	*/
	//end debug

	int n;
	int ganjil = 0;
	cin >> n;
	int x;
	FOR(i, 0, n){
		cin >> x;
		if(x & 1)
			ganjil++;
	}
	if(ganjil & 1)
		cout << "NO\n";
	else
		cout << "YES\n";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String s = stdIn.next();
		
		int ans = 0;
		for(int i = 0; i < s.length();i++) {
			int cnt = 0;
			
		Outer:	if(s.charAt(i)== 'A' ||s.charAt(i)== 'C' ||s.charAt(i)== 'G' || s.charAt(i)=='T') {
				cnt++;
				for(int j = i+1 ;j < s.length();j++) {
					if(s.charAt(j)== 'A' ||s.charAt(j)== 'C' ||s.charAt(j)== 'G' || s.charAt(j)=='T') {
						cnt++;
					}else {
						ans = Math.max(ans, cnt);
						break Outer;
					}
				}
			}
			
			ans = Math.max(ans, cnt);
		}
		System.out.println(ans);
		
		
		
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h> //works like magic, but at cost.
using namespace std;
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout<<x<<endl;
#define fo(i, n) for(int i=0; i<n; i++)
#define fk(i, k, n) for(int i=k; i<n; i++)
#define fn(i, n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lli long long int
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<lli, lli>	pl;
typedef vector<int>		vi;
typedef vector<lli>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
bool ispresent(int,vector<int>);
int main() {
    int mi,max,s,x,n;
    cin>>x>>n;
    mi= x;
    max = x;
    if(n==0){
        cout<<x<<"\n";
        return 0;
    }
    vector<int> v;
    fo(i, n){
        cin>>s;
        v.push_back(s);
    }while(n){
      if(ispresent(mi,v)==true&&ispresent(max,v)==true){
         mi--;
         max++;
      }else{
         if(ispresent(mi, v)==false){
             cout<<mi<<"\n";
             return 0;
         }if(ispresent(max, v)==false){
             cout<<max<<"\n";
             return 0;
         }
         
    }
}
    return 0;
}





bool ispresent(int x, vector<int> v){
    vector<int>::iterator it = std::find(v.begin(), v.end(), x);
    if(it!=v.end()){
        return true;
    }else{
        return false;
    }
}

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

void shuffle(char *a , int h){
	char tmp[201];
	char mov[201];
	size_t len=strlen(a);
	strcpy(tmp , (const char*)a+h);
	strncpy(mov , a , h);
	mov[h]='\0';
	strcat(tmp , mov);
	strcpy(a , (const char*)tmp);
	return;
}

int main(){
	char card[201]={0};
	char ans[201]={0};
	int i , m;
	int h[100];
	while(1){
		cin>>card;
		m=strlen(card);
		if ( card[0]=='-'&& m==1 ) break;
	cin>>m;
		for(i=0;i<m;i++){
			cin>>h[i];
			shuffle(card , h[i]);
		}
		strcpy(ans , card);
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1176
import sys

input = sys.stdin.readline

def main():
    ans = 0
    S = input().rstrip('\n')
    p = t = ''
    for i in S:
        p += i
        if t != p:
            ans += 1
            p, t = '', p 
    print(ans)

if __name__ == '__main__':
    main()

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

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<char>> A(H, vector<char>(W));
 
	//int count = 0;
 
	queue<vector<int>> q;
 
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
			if (A[i][j] == '#') {
				q.push({ i,j });
			}
		}
	}
	if (q.size() == H * W) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> dirx = { -1,0,1,0 };
	vector<int> diry = { 0,-1,0,1 };
 
	int res = 0;
 
	vector<vector<int>> v(H, vector<int>(W, 1));
	int count = q.size();
	int step=0;
	while (count < H*W) {
		step++;
		int n = q.size();
		for (int i = 0; i < n; i++) {
			vector<int> tmp = q.front();
			q.pop();
			if (tmp[0] < 0 || tmp[0] >= H || tmp[1] < 0 || tmp[1] >= W || v[tmp[0]][tmp[1]] == 0) continue;
			else {
				v[tmp[0]][tmp[1]] = 0;
				if (A[tmp[0]][tmp[1]] != '#') {
					A[tmp[0]][tmp[1]] = '#';
					count++;
 
				}
				for (int k = 0; k < 4; k++) {
					q.push({ tmp[0] + dirx[k],tmp[1] + diry[k] });
				}
			}
		}
	}
 
	cout << step-1 << endl;
	return 0;
}

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


int main()
{
  int a,b;
  string s;
  cin >> a >> b;
  cin >> s;
  int flag = 1;
  int left = 0;
  int right = -1;
  int count = 0;
  for(int i = 0;i < s.size();i++){
    if(s[i] == '-'){
      flag = 2;
      count++;
    }
    if(flag == 1) left++;
    else if(flag == 2) right++;
  }

  if(left == a && right == b && count == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
for line in sys.stdin:
    a, b, c, d, e, f = map(int, line.split())
    n1, n2 = -b/a*d, c/a*d
    n1 += e
    n2 = -n2 + f
    y = n2/n1
    x = (c - b*y)/a
    print("{:.3f} {:.3f}".format(x, y))

Measured memory_bytes: 7716
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1.0),eps=1e-8;
const ll mod = 1e9+7;
const int inf = 1e18;
const int maxn = 5e5+5;
int main()
{
    int repeat;
    cin >> repeat;
    if(repeat==0)
        cout<<1<<endl;
    else if(repeat==1)
        cout<<0<<endl;

    return 0;
}


Measured memory_bytes: 3176