akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long INF = 10000000;
int main(){
  int N, A, B, C;
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  for (int i = 0; i < N; i++){
    cin >> l[i];
  }
  int ans = INF;
  for (int i = 0; i < (1 << (N * 2)); i++){
    int a = 0;
    int b = 0;
    int c = 0;
    int tmp = 0;
    for (int j = 0; j < N; j++){
      if ((i >> (j * 2)) & 1){
        if ((i >> (j * 2 + 1)) & 1){
          if (a != 0){
            tmp += 10;
          }
          a += l[j];
        } else {
          if (b != 0){
            tmp += 10;
          }
          b += l[j];
        }
      } else {
        if ((i >> (j * 2 + 1)) & 1){
          if (c != 0){
            tmp += 10;
          }
          c += l[j];
        }
      }
    }
    if (a != 0 && b != 0 && c != 0){
      vector<int> L(3);
      L[0] = a;
      L[1] = b;
      L[2] = c;
      sort(L.begin(), L.end());
      tmp += abs(L[0] - C);
      tmp += abs(L[1] - B);
      tmp += abs(L[2] - A);
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  vector<int> r(n);
  int ans = 0;
  rep(i,n){
    cin >> l[i] >> r[i];
    ans += r[i]-l[i]+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
A=input()
cnt={chr(code): 0 for code in range(ord('a'),ord('z')+1)}
for i in A:
  cnt[i]+=1

a=len(A)
if a==1:
  print(1)
  exit()
b=0
for i in cnt.values():
  if i>=2:
    b+=i*(i-1)//2
ans=a*(a-1)//2-b
print(ans+1)

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

using namespace std;

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

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector<int> a,x;
vector<int> ans;

int main(void){
  int n;
  cin >> n;
  a.resize(n*3, 0);
  x.resize(n*3, 0);
  rep(i,n) cin >> a[i+1];

  for(int i = n; i > 0; --i){
    int tmp = a[i*2];
    for(int j = 3; j * i <= n; j+=2){
      if(x[i*j] == 1)
        tmp++;
    }
    if(tmp%2 == 1){
      if(a[i] == 0){
        x[i] = 1;
        ans.pb(i);
      }
    }else{
      if(a[i] == 1){
        x[i] = 1;
        ans.pb(i);
      }
    }
  }
  cout << ans.size() << endl;
  rep(i, ans.size()){
    cout << ans[i];
    if(i != ans.size() -1){
      cout << " ";
    }else{
      cout << endl;
    }
  }
  return 0;
}


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

bool isPrime(int x) {
	for(int i = 2; i*i<=x; i++) {
		if(x % i == 0) return false;
	}
	return true;
}

int main() {
	int x;
	cin >> x;
	
	while(!isPrime(x)) x++;
	
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  	long n, k;
  	cin >> n >> k;
  	if (n > k) {
      	n %= k;
    }
  	if (n < k - n) {
      	cout << n << endl;
    } else {
      	cout << k - n << endl;
    }
  
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll x;
    cin >> x;
    ll res =  (x/11)*2;
    x%=11;
    res += x/6;
    x%=6;
    if(x)res++;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B,s,d,i;
    scanf("%d %d",&A,&B);
    s=A+B;
    d=A-B;
    i=A*B;
    if(A==0 && B==0)printf("0\n");
    if(s>=d && s>i)printf("%d\n",s);
    else if(d>s && d>i)printf("%d\n",d);
    else if(i>s && i>d)printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX 2000000001

int S[MAX],H = 1;

int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}
void maxHeapify(int i){
  int l,r,largest,tmp;
  l = left(i);
  r = right(i);
  if(l <= H && S[l] > S[i]) largest = l;
  else largest = i;
  if(r <= H && S[r] > S[largest]) largest = r;
  if(largest != i){
    tmp = S[i];
    S[i] = S[largest];
    S[largest] = tmp;
    maxHeapify(largest);
  }
}


void heapIncreaseKey(int i,int key){
  int tmp;
  if(key < S[i]) return;
  S[i] = key;
  while(i > 1 && S[parent(i)] < S[i]){
    tmp = S[i];
    S[i] = S[parent(i)];
    S[parent(i)] = tmp;
    i = parent(i);
  }
}

void insert(int k){
  H++;
  S[H] = -1;
  heapIncreaseKey(H,k);
}

void extract(void){
  int max;
  max = S[1];
  S[1] = S[H];
  H--;
  maxHeapify(1);
  printf("%d\n",max);
}

int main()
{
  int i,n,k;
  char buf[10];
  while(1){
    scanf("%s",buf);
    if(buf[0] == 'i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(buf[0] == 'e' && buf[1] == 'x') extract();
    else if(buf[0] == 'e' && buf[1] == 'n') break;
  }
  return 0;
}



Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int h, w, a, b;
	cin >> h >> w >> a >> b;
	vector<vector<int>> g(h, vector<int>(w,0));
	for (int i = 0; i < b; i++) {
		for (int j = 0; j < a; j++) {
			g[i][j] = 1;
		}
	}
	for (int i = b; i < h; i++) {
		for (int j = a; j < w; j++) {
			g[i][j] = 1;
		}
	}
	rep(i,h) {
		rep(j,w) cout << g[i][j];
		cout << endl;
	}
}

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

int main() {
    int time;
    int hour = 0;
    int min = 0;
    int sec = 0;

    std::cin >> time;
    sec = time % 60;
    time = time - sec;

    if (time > 0) {
        min = (time % (60 * 60)) / 60;
        time = time - min * 60;
    }

    if (time > 0) {
        hour = (time % (60 * 60 * 24)) / (60 * 60);
    }

    printf("%d:%d:%d\n", hour, min, sec);

    return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m;
    cin>>n>>m;
    long long int a[n+5];
    for(int i=0;i<n;i++)
    cin>>a[i];
    long long int lo=1;
    long long int hi=1000000000;
    long long ans=0;
    while(lo<=hi)
    {
        long long int mid=(lo+hi)/2;
        long long count=0;
        for(int i=0;i<n;i++)
        count+=((a[i]-1)/mid);
        if(count<=m)
        {
            ans=mid;
            hi=mid-1;
        }
        else
        lo=mid+1;
    }
    sort(a,a+n);
    if(m==0)
    cout<<a[n-1];
    else
    cout<<ans;
}

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

int main() {

  int N, X; cin >> N >> X;
  int D = 0;
  int i = 0;
  while (i < N) {
    int L; cin >> L;
    D += L;
    if (D > X) {
      break;
    }
    i++;
  }
  cout << i + 1 << endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];

    vector <bool> used(n, false);
    vector <int> ans(n);

    for (int i = 0; i < n; i++) {
        int num = 1;
        int idx = -1;

        for (int j = 0; j < n; j++) {
            if (used[j]) continue;
            if (b[j] == num) idx = j;
            num++;
        }

        if (idx == -1) {
            cout << -1 << '\n';
            return 0;
        } else {
            ans[n-i-1] = b[idx];
            used[idx] = true;
        }
    }

    for (int x : ans) cout << x << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++) 
int f(int n, int k) {
    if(n==1) return 0;
    return (f(n-1,k)+k)%n;
}
int main() {
    int n,m,k;
    while(cin>>n>>k>>m) {
        if(n+m+k==0) return 0;
        int t = m-k+1+n;
        t%=n;
        cout<<(f(n,k)+t+n-1)%n+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 1468
namespace ABC124_B
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadInputAsInt();
            var hotels = ReadInputsAsInt().ToList();
            WriteLine(Solve(hotels));
        }

        public static int Solve(List<int> hotels)
        {
            return hotels.Where((height, index) => hotels.Where((h, i) => i < index).All(h => h <= height)).Count();
        }

        public static int ReadInputAsInt() => int.Parse(ReadLine());
        public static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));
    }
}

Measured memory_bytes: 13396
#define _crt_secure_no_warnings

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main()
{
	int a, b, c,sum;
	vector<int> data;
	while (1)
	{
		data.clear();
		cin >> a >> b >> c;
		if (a == 0)break;
		data.resize(a);
		for (size_t i = 0; i < a; i++)
		{
			cin >> data[i];
		}
		sum=accumulate(data.begin(), data.end(), 0);
		cout << (data[b - 1]?(int)(sum*(100-c) / (double)data[b - 1]):0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();

        long leftB = 0;
        long rightA = 0;
        long both = 0;

        long answer = 0;

        for (int i = 0; i < n; i++)
        {
            string s = sc.Next();
            s = s.Replace("AB", "1");
            answer += s.Where(c => c == '1').Count();

            if (s.StartsWith("B") && s.EndsWith("A"))
            {
                both++;
            }
            else if (s.StartsWith("B"))
            {
                leftB++;
            }
            else if (s.EndsWith("A"))
            {
                rightA++;
            }
        }

        if (rightA > 0 && leftB > 0)
        {
            answer += Math.Min(rightA, leftB) + both;
        }
        else if (rightA == 0 && leftB == 0)
        {
            answer += Math.Max(0, both - 1);
        }
        else
        {
            answer += both;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 30068
// Volume2-0216
import java.util.*;

public class Main {

	public static void main(String[] args) {

		//declare
		final int END = -1;
		      int w,price;
		
    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		w = sc.nextInt();
    		if(w==END){break;}
    		
    		//calculate
    		if(w <= 10){
    			price = 1150;
    		} else if(10 < w && w <= 20){
    			price = 1150+(w-10)*125;
    		} else if(20 < w && w <= 30){
    			price = 2400+(w-20)*140;
    		} else {
    			price = 3800+(w-30)*160;
    		}
    		//output
    		System.out.println(4280-price);
    	}
	}
}

Measured memory_bytes: 18544
import collections as cl

n = int(input())
a = [int(x) for x in input().split()]

plus = [x+1 for x in a]
minus = [x-1 for x in a]
mix = plus  + minus + a #インクリメントしたものデクリメントしたものそのままにしたものを1つの配列に格納
res = cl.Counter(mix) #各要素の個数を数え上げてその最大値となる最初の値を出力する
ans = max(res.values())

print(ans)

Measured memory_bytes: 30024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;


int main() {
 
  int64_t N,r=0,w=0,ans=INF,r2=0,w2=0,g=0,rrr=0;
  cin>>N;
  string a,b;
  cin>> a;
  bool rr=true;
  //vector<int64_t> A(N);
  for(int i=0; i<N; i++){
    if(a[i]=='W'){w++;rr=false;}
    if(rr)rrr++;
    // if(i<N/2 && a[i]=='R')g++;
    }
    r=N-w;
    ans=min(r-g,w);
    // cout<<r<<" "<<g<<" "<<w<<endl;
 for(int i=0; i<N; i++){
    if(a[i]=='W' && i<N/2)w2++;
    else if(i>=N/2 && a[i]=='R')r2++;
    }
    int64_t be=0,be2=0;
     for(int i=0; i<N-1; i++){
    if(a[i]=='W' && a[i+1]=='R')be++;
    if(a[i]=='R' && a[i+1]=='W' && i<N-1 && a[i+2]=='R')be2++;
    }
    int64_t w3=0;
         for(int i=0; i<r; i++){
    if(a[i]=='W'){w3++;}
    
    }
    // cout<<r2<<" "<<w2<<endl;
// ans=min(w2,min(r2,ans));
// ans=min(ans,max(be,r-be));
// ans=min(ans,max(r2,w2));
ans=min(ans,w3);


// b=a;
// int64_t p=0,ans2=ans;
//   for(int i=0; i<N; i++){
//     int64_t w3=0,r3=0,w4;
//     if(a[i]=='R')continue;
//     p++;
//     // b=a.substr(i+1,N);

//       for(int k=i+1; k<N; k++){
//     if(a[k]=='W')w3++;
//     }
//     r3=N-i-w3;
//     ans=min(r3+p,min(w3+p,ans));
//  for(int k=i+1; k<N/2; k++){
//     if(a[k]=='W')w4++;
//     }
// ans=min(w4+p,ans);
// if(p>=ans2)break;
//   }

  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << ans << endl;
}

Measured memory_bytes: 3660
#include <stdio.h>
#include <algorithm>
 
using namespace std;
 
int e;
 
int main()
{
    while (true)
    {
        scanf("%d", &e);
 
        if (e == 0) break;
 
        int ret = 999999999;
 
        for (int z = 0; z * z * z <= e; z++)
        {
            for (int y = 0; y * y + z * z * z <= e; y++)
            {
                ret = min(ret, e - y * y - z * z * z + y + z);
            }
        }
 
        printf("%d\n", ret);
    }
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll k;
    cin >> k;

    ll ans = 0;
    ll i;
    for(i=2; i*i<=k; i++) {
        ll n = k;
        while(n % i == 0) n /= i;
        if(n%i == 1) ans++;
    }

    ll r = i - 1;

    for(i=1; i*i<=(k-1); i++) {
        if((k-1) % i == 0) {
            ll a = (k-1) / i;
            if(a > r) {
                ans++;
            }
        }
    }

    ans++;

    cout << ans << endl;

    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);
        
        //int a = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int num[] = new int[3];
        String s = stdIn.next();
        char c[] = s.toCharArray();
        int sum = 700;
        //boolean flag = true;
        for(int i = 0; i < s.length(); i++){
            if(c[i] == 'o'){
                sum += 100;
            }
        }
        
        System.out.println(sum);
        
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int s = scan.nextInt();
		int l = s / 100;
		int r = s % 100;
		if (l >= 1 && l <= 12) {
			if (r >= 1 && r <= 12) {
				System.out.println("AMBIGUOUS");
			} else {
				System.out.println("MMYY");
			}
		} else {
			if (r >= 1 && r <= 12) {
				System.out.println("YYMM");
			} else {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 22740
/*
 * ITP1_1_D.c
 *
 *  Created on: 2017/05/11
 *      Author: sl2-user
 */
#include<stdio.h>

int main(void){

int W,H,x,y,r;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

	if((y-r)<0 || (y+r)>H || (x-r)<0 || (x+r)>W ){printf("No\n");}
	else {printf("Yes\n");}

return 0;
}

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

#define min(a,b) (a>b?b:a)

struct Edge {
  int to, cap, rev;
  Edge(){}
  Edge(int t, int c, int r) : to(t), cap(c), rev(r) {}
};
typedef vector<Edge> Graph;

#define N 400
#define INF 1000000007

Graph g[N];
bool used[N];

void add_edge(int from, int to, int cap) {
  g[from].push_back(Edge(to, cap, g[to].size()));
  g[to].push_back(Edge(from, 0, g[from].size()-1));
}

int dfs(int s, int t, int f) {
  if(s == t || f == 0) return f;
  used[s] = true;
  for(int i=0; i<g[s].size(); ++i) {
    Edge &e = g[s][i];
    if(e.cap>0 && !used[e.to]) {
      int d = dfs(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        g[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int ret = 0;
  while(true) {
    int f = dfs(s, t, INF);
    for(int i=0; i<N; ++i) used[i] = false;
    if(f == 0) break;
    ret += f;
  }
  return ret;
}

int main() {
  int n, m, l;
  while(cin >> n >> m >> l) {
    int mat[N][N];
    for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) mat[i][j] = INF;
    for(int i=0; i<n; ++i) mat[i][i] = 0;
    for(int i=0; i<m; ++i) {
      int a, b, d;
      cin >> a >> b >> d; --a; --b;
      mat[a][b] = mat[b][a] = d;
    }
    for(int i=0; i<=2*n+1; ++i) g[i].clear();
    for(int i=0; i<n; ++i) {
      int p;
      cin >> p;
      add_edge(0, i+1, p);
    }
    for(int i=0; i<n; ++i) {
      int k;
      cin >> k;
      add_edge(n+i+1, 2*n+1, k);
    }
    for(int k=0; k<n; ++k) {
      for(int i=0; i<n; ++i) {
        for(int j=0; j<n; ++j) {
          mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
        }
      }
    }
    for(int i=0; i<n; ++i) {
      for(int j=0; j<n; ++j) {
        if(mat[i][j] < l) {
          add_edge(i+1, n+j+1, INF);
        }
      }
    }
    cout << max_flow(0, 2*n+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 1680
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();

    let mut count = vec![0; n + 1];

    for i in 2..n + 1 {
        let mut m = i;
        for j in 2..n + 1 {
            while m % j == 0 {
                m /= j;
                count[j] += 1;
            }
        }
    }

    let mut ans = 1i64;

    for x in count {
        if x != 0 {
            ans = (ans * (x + 1)) % 1_000_000_007;
        }
    }
    println!("{}", ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

int32_t main(){

    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust\n";
    else cout<<"win\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 234567;
const long long lim = (1ll<<62) - 1;
long long add(long long a, long long b){
	a += b;
	if(a >= lim) a = lim;
	return a;
}
long long slow_mul(long long a, long long b){
	long long r = 0;
	for(; b; a = add(a, a), b >>= 1) if(b&1) r = add(r, a);
	return r;
}
long long x[maxn], val[maxn];
int main(){
	int n, X; cin >> n >> X;
	for(int i = 0; i < n; i++) cin >> x[i];
	for(int i = 1; i < n; i++) x[i] += x[i - 1];
	val[1] = 5;
	for(int i = 2; i <= n; i++) val[i] = 2 * i + 1;
	auto get = [&](int i, int j){
		long long ans = x[j];
		if(i - 1 >= 0) ans -= x[i - 1];
		return ans;
	};
	long long ans = lim + lim;
	for(int i = 1; i <= n; i++){
		long long now = 0;
		int pt = n - 1, bl = 0;
		for(int j = 1; pt >= 0; j++, pt -= i){
			long long here = get(pt - i + 1, pt);
			now = add(now, slow_mul(here, val[j]));
			bl++;
		}
		now = add(now, slow_mul(i, X));
		ans = min(ans, now);
	}
	cout << ans + slow_mul(n, X) << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
#define int long long
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


struct BinaryIndexedTree{
    int n;
    vector<ll>dat;
    BinaryIndexedTree(int n=0):n(n){
        dat.resize(n+1);
    }
    void add(int k,ll x){
        for(k++;k<=n;k+=k&-k)dat[k]+=x;
    }
    ll sum(int k){
        ll ret=0;
        for(k++;k;k-=k&-k)ret+=dat[k];
        return ret;
    }
};



int N;
ll A[111111];

ll S[111111];


bool check(ll x){
    int K=(N*(N+1)/2)/2;
    
    for(int i=0;i<N;i++){
        S[i+1]=S[i];
        if(A[i]<x)S[i+1]++;
        else S[i+1]--;
    }
    
    vector<ll>vs;
    rep(i,N+1)vs.push_back(S[i]);
    sort(all(vs));vs.erase(unique(all(vs)),vs.end());
    rep(i,N+1)S[i]=lower_bound(all(vs),S[i])-vs.begin();
    
    ll cnt=0;
    BinaryIndexedTree bit(N+114);
    
    rep(i,N){
        bit.add(S[i],1LL);
        cnt+=bit.sum(S[i+1]-1);
    }
    
    return cnt<=K;
}

signed main() {
    cin>>N;
    rep(i,N)cin>>A[i];
    
    int lb=0,ub=1001001001;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(check(mid))lb=mid;
        else ub=mid;
    }
    cout<<lb<<endl;
    return 0;
    
    return 0;
}









Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    vector<int> c(n);
    rep(i,n) cin >> c[i];
    int ans = 0;
    for(int i = 0; i <= n-3; i++){
        if(c[i] < c[i+1] && c[i+1] < c[i+2]) ans++;
        if(c[i] > c[i+1] && c[i+1] > c[i+2]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int x = n/15;
	cout << n*800-x*200 << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
listV = list(map(int, input().split()))
listV.sort()

sum = 0
index=0
while index < len(listV):
    if index == 0:
        sum = (listV[index]+listV[index+1])/2
        index+=2
    else:
        sum = (sum+listV[index])/2
        index+=1
print(sum)

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

int main(){
  int X,Y;
  cin >> X >> Y;
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      int A=i,B=j;
      if(A+B==X && A*2+B*4==Y){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3512
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int N,M,Q;
    cin >> N >> M >> Q;
    vector<int> L(M),R(M);
    rep(i,M){
        cin >> L[i] >> R[i];
    }
    vector<vector<int> > sum(N+1,vector<int>(N+1));
    for(int i=0;i<M;i++){
        sum[L[i]][R[i]]++;
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            sum[i][j] += sum[i-1][j];
            sum[i][j] += sum[i][j-1];
            sum[i][j] -= sum[i-1][j-1];
        }
    }

    rep(i,Q){
        int p,q;
        cin >> p >> q;
        int res = sum[q][q]+sum[p-1][p-1]-sum[p-1][q]-sum[q][p-1];
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

class cf {
public:
  int A;  //�U����
  int B;  //�����
  int pos;
  double r;  //�������U���́^�����
//  bool operator <(const cf& x) {return r < x.r; }
  void vset(int va, int vb) {
    A=va; B=vb;
    r = (double)va/vb;
  }
};

int H,N;
vector<cf> v1;

int minm(int, int);
int minmem[10001];

int main()
{
  int i;
  int A,B;
  cf ab;
  int ret=0;
  int maxA, maxB;
  int minB;

  cin >> H >> N;

  for(i=0; i<N; i++) {
    cin >> A >> B;
    if (A>H) A=H;
    ab.vset(A, B);
    ab.pos = i;
    v1.push_back(ab);
  }

  /*
  //�ő������H��0�ɂ��钼�O�܂ōU������
  sort(v1.begin(), v1.end(), [](const cf& x, const cf& y) {return x.r > y.r;});  //������������
  maxA = v1[0].A; maxB = v1[0].B;
  while (H>=maxA) {
    ret += H/maxA*maxB;
    H %= maxA;
printf("maxA=%d, maxB=%d, ret=%d, H=%d\n", maxA, maxB, ret, H);
    if (H==0) {
      printf("%d\n", ret);
      return 0;
    }
    
    for (i=0; i<N; i++) {
      if (v1[i].A>H) v1[i].vset(H, v1[i].B);
    }
    sort(v1.begin(), v1.end(), [](const cf& x, const cf& y) {return x.r > y.r;});  //������������
    maxA = v1[0].A; maxB = v1[0].B;
  }
    */

  printf("%d\n", minm(H, 0));
  return 0;
}

int minm(int h, int d) {
  int i;
  int minx=-1;
  int tm;
  int av;

  if (minmem[h]) return minmem[h];
  for (i=0; i<N; i++) {
    if (h<=v1[i].A) {
      if (v1[i].B<minx || minx < 0) {
        minx = v1[i].B;
      }
      continue;
    }
    tm = minm(h-v1[i].A, d+1)+v1[i].B;
    if (tm<minx || minx < 0) {
      minx = tm;
    }
  }
//printf("minm(%d, %d)=%d\n", h, d, minx);
  minmem[h] = minx;
  return minx;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            //var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            string[] A = new string[N];
            string[] B = new string[M];
            for(var i = 0; i < N; i++)
            {
                A[i] = Console.ReadLine();
            }
            for(var i = 0; i < M; i++)
            {
                B[i] = Console.ReadLine();
            }

            for(var i = 0; i < N - M + 1; i++)
            {
                for(var j = 0; j < N - M + 1; j++)
                {
                    bool ok = true;
                    for(var k = 0; k < M; k++)
                    {
                        for(var l = 0; l < M; l++)
                        {
                            if (B[k][l] != A[i + k][j + l])
                            {
                                ok = false;

                            }
                        }
                    }
                    if (ok)
                    {
                        Console.WriteLine("Yes");
                        return;
                    }
                    
                }
            }

            Console.WriteLine("No");


           
            

            //Console.Out.Flush();

        }
    }

    

    public class Calculation
    {

    }

    public class Graph
    {
       
    }
}




Measured memory_bytes: 13396
#include <stdio.h>

int main()
{
    int M1,M2,D1,D2;
    int day[]={31,28,31,30,31,30,31,31,30,31,30,31};
    int ans;

    ans=0;

    scanf("%d %d\n",&M1,&D1);
    scanf("%d %d\n",&M2,&D2);

    if(D1==day[M1-1]){
        ans=1;
    }

    printf("%d\n",ans);

    return 0;
}


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

int main()
{
  long long int N;
  cin >> N;
  int M = sqrt(N);
  int ans;
  for(int i = 1; i <= M; i++)
    if(N%i == 0) ans = max(log10(i)+1,log10(N/i)+1);
  cout << ans << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

#define MAX 100010
set<ii> ban;
int N,M,K;
vector<int> G[MAX], bG[MAX];
int par[MAX];

int find(int x) {
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

void solve() {

}

int main() {
  cin >> N >> M >> K;
  rep(i,N) par[i] = i;
  rep(i,M) {
    int s,t;
    cin >> s >> t;
    --s, --t;
    G[s].pb(t);
    G[t].pb(s);
    unite(s,t);
  }
  rep(i,K) {
    int s,t;
    cin >> s >> t;
    --s, --t;
    bG[s].pb(t);
    bG[t].pb(s);
  }

  map<int,int> mp;
  rep(i,N) ++mp[find(i)];
  rep(i,N) {
    if( i ) cout << " ";
    int maxi = mp[find(i)]-1;
    maxi -= (int)G[i].size();
    rep(j,(int)bG[i].size()) {
      int nex = bG[i][j];
      if( find(i) == find(nex) ) --maxi;
    }
    cout << maxi;
  } puts("");

  return 0;
}


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

typedef unsigned long long ull;
int main(void){
  ull c = 100000;
  int n; cin >> n;
  while(n--){
    c *= 1.05;
    if(c%1000 > 0){
      c = c - c%1000 + 1000;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define SQ(a) (a)*(a)you
#define f first
#define s second
#define int long long
#define PB push_back
#define MP make_pair
#define db long double
#define all(a) a.begin(), a.end()
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define mod 1000000007 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
      

    return (a.first<b.first); 
} 

int32_t main()
{
IOS


     
     
          int x,y;
          cin>>x>>y;
            if(x>0)
                x--;
          int ans1,ans2;
          if(x%4==0)
          {
            ans1=x;
          
          }
          else if(x%4==1)
          {
            ans1=1;

          }
          else if(x%4==2)
          {
            ans1=(x/4)*4+3;
          }
          else
          {
              ans1=0;
          }


          if(y%4==0)
          {
            ans2=y;
          
          }
          else if(y%4==1)
          {
            ans2=1;

          }
          else if(y%4==2)
          {
            ans2=(y/4)*4+3;
          }
          else
          {
              ans2=0;
          }
            cout<<(ans1^ans2);

    return 0;
    }
    
    
  

  

Measured memory_bytes: 256
import math
a,b,c,d=list(map(int ,input().split()))
l=[]
first_pro=a*c
l.append(first_pro)

second_pro=b*d
l.append(second_pro)

second_pro1=a*d
l.append(second_pro1)

second_pro2=b*c
l.append(second_pro2)
print(int(max(l)))



Measured memory_bytes: 9172
#include<iostream>
#include<vector>
#include<cstdio>
#include<iterator>
#include<string>
#include<algorithm>
using namespace std;
#define INF int(2e9)
typedef pair<int, int> P;
inline int in() {
	int temp;
	scanf("%d", &temp);
	return temp;
}
int main(){
	string s, ans;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == ',')
			cout << ' ';
		else
			cout << s[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int N;
ll dp[100001][3];
//dp[i][j] := i日目(1-idx)に行動jをした時の幸福度 今回は1-idxで実装してることに注意！
//j == 0なら行動A、j == 1なら行動B、j == 2なら行動C

ll A[100001], B[100001], C[100001];//三つの行動の日にちごとに得られる幸福度　今回は1-xで実装してることに注意！

ll memo(int a, int act) {

	if (dp[a][act] != -1) return dp[a][act];
	
	if (a == 1) {
		if (act == 0) return dp[a][act] = A[1];
		if (act == 1) return dp[a][act] = B[1];
		if (act == 2) return dp[a][act] = C[1];
	}
	else {
		ll best = 0;
		for (int i = 0; i < 3; i++) {
			
			if (i != act) {
				best = max(best, memo(a - 1, i));
			}
		}


		if (act == 0) return dp[a][act] = best + A[a];
		if (act == 1) return dp[a][act] = best + B[a];
		if (act == 2) return dp[a][act] = best + C[a];
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i] >> B[i] >> C[i];
	}

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j < 3; j++)dp[i][j] = -1;
	}

	memo(N, 0), memo(N, 1), memo(N, 2);

	//最終日の最大は、行動A~Cのうちのいずれかなので、その最大をとる
	ll ans = 0;
	for (int i = 0; i < 3; i++)ans = max(ans, dp[N][i]);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
int a[114514],b[114514],c[8];
int ans[114514][8];
signed main(){
	ic(n)
	rep(0,i,n)c[i]=i+1;
	rep(0,i,n)cin>>a[i];
	rep(0,i,n)cin>>b[i];
	int sum=0;
	do{
		rep(0,i,n){
			ans[sum][i]=c[i];
		}
		sum++;
	}while(next_permutation(c,c+n));
	int ans1=114500,ans2=114514;
	int kosuua=0,kosuub=0;
	rep(0,i,sum){
		rep(0,j,n){
			if(a[j]==ans[i][j]){
				kosuua++;
			}
			if(b[j]==ans[i][j]){
				kosuub++;
			}
		}
		if(kosuua==n)ans1=i;
		if(kosuub==n)ans2=i;
		kosuua=0;
		kosuub=0;
	}
	c(abs(ans1-ans2))
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;


struct UnionFind {
    vector< int > data;
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }    
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, m; cin >> n >> m;
    vector<P> p(m);
    UnionFind uf(n);
    rep (i, m) {
        cin >> p[i].first >> p[i].second;
        p[i].first --; p[i].second --;
        uf.unite(p[i].first, p[i].second);
    }
    int ans = 0;
    rep (i, n) {
        if (uf.find(i) == i)       chmax(ans, uf.size(i));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 5528
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

int main(){
    ll n,h;
    cin >> n >> h;
    P a[n],b[n];
    vector<P> vec;

    rep(i,0,n){
        cin >> a[i].fs >> b[i].fs;
        a[i].sc = i;
        b[i].sc = i;
    }

    sort(a,a+n,greater<P>());
    sort(b,b+n,greater<P>());

    ll cnt = 0;

    rep(i,0,n){
        if(a[0].fs <= b[i].fs){
            h -= b[i].fs;
            cnt++;
        }

        if(h <= 0){
            cout << cnt << endl;
            return 0;
        }
    }


    cnt += ceil((double)h/(double)a[0].fs);
    
    cout << cnt << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int tmp = n;
  int s = 0;
  while(tmp){
    s += tmp % 10;
    tmp /= 10;
  }
  if(n % s == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3612
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]

length = 0
for i in range(n) :
    for j in range(n):
        route = 10000000000
        for k in range(n):
            if k == i or k == j : continue
            route = min(route, a[i][k] + a[k][j] ) #< a[i][j]
            if route < a[i][j]:
                print(-1)
                exit() 
        if route > a[i][j] :
            length +=  a[i][j]
print(int(length/2))

Measured memory_bytes: 46044
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e9 + 10;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int M = 1e3 + 10;
const int N = 1e6 + 10;

struct S {
    int x, y, i;
} a[N];

bool cmp(S a, S b) {
    return a.x + a.y > b.x + b.y;
}

void solve() {
    int n;
    scanf("%d", &n);
    int x, y;
    ll sum1 = 0, sum2 = 0;
    fr(i, n) {
        scanf("%d %d", &x, &y);
        a[i].x = x;
        a[i].y = y;
        a[i].i = i;
    }
    sort(a, a + n, cmp);
    ll A = 0, B = 0;
    fr(i, n)
        if (i % 2 == 0)
            A += a[i].x;
        else
            B += a[i].y;
    cout << A - B;
}

int main() {
    //ios_base::sync_with_stdio(false);
    //freopen("a.in", "r", stdin);
    solve();
}


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

int main()
{
	int count[2]{};
	char c;
	while (true)
	{
		c = getchar();
		if (c == '\n') break;
		count[c - '0']++;
	}
	printf("%d\n", 2 * std::min(count[0], count[1]));

	return 0;
}

Measured memory_bytes: 256
// Problem : B - Multiplication 2
// Contest : AtCoder - AtCoder Beginner Contest 169
// URL : https://atcoder.jp/contests/abc169/tasks/abc169_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

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

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	ll mx = (ll)1e18;
	ll ans = 1;
	REP(i, n) {
		ll a;
		cin >> a;
		if (a == 0) {
			ans = 0;
			break;
		}
		if (ans > mx / a) {
			ans = -1;
		}
		if (ans != -1) {
			ans *= a;
		}
	}
	cout << ans;
	return 0;
}
 


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

int main(){

    ll n,x;
    cin >> n >> x;

    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }

    ll ans=0;
    rep(i,n-1){
        if(a[i]+a[i+1]>=x){
            ll t=(a[i]+a[i+1]-x);
            if(a[i+1]>=t){
                a[i+1]-=t;
            }else{
                a[i+1]=0;
                a[i]-=(t-a[i+1]);
            }
            ans+=t;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024