akhauriyash/Code-Regression huggingface dataset:
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
map<char,int> 
count_same_elements(const vector<char>& v){map<char,int>cmap; for_each(v.begin(),v.end(),[&cmap](int x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T,class U>
void msg_with_compare(T A,T B,U A_greater_B,U A_eq_B,U A_less_B){
    if(A==B){cout<<A_eq_B<<"\n";}else if(A>B){cout<<A_greater_B<<"\n";}else{cout<<A_less_B<<"\n";}}
template<class B,class T>
void msg_with_boolean(B A,T true_msg,T false_msg){cout<< ( A? true_msg:false_msg);}
template<class B,class T>
void msg_with_boolean(B A1,B A2,T both_true_msg,T true_false_msg,T false_true_msg,T both_false_msg){
    if(A1){if(A2){cout<<both_true_msg;}else{cout<<true_false_msg;}
    }else{if(A2){cout<<false_true_msg;}else{cout<<both_false_msg;}}
}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}

ll a,b,k;
void input(){
    cin>>a>>b>>k;
}
void src(){
    if(k<=(b-a)/2){
        rep(i,k){
            cout<<a+i<<"\n";
        }
        rep(i,k){
            cout<<b-k+i+1<<"\n";
        }
    }else{
        rep(i,b-a+1){
            cout<<a+i<<"\n";
        }
    }
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

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

int main() {
  int n,m; cin>>n>>m;  
  vector<pair<long long,long long>>AB;
  vector<pair<long long,long long>>CD;
  for(int i=0;i<n;i++){
    long long a,b; cin>>a>>b;
    AB.push_back(make_pair(a,b));
  }
  for(int i=0;i<m;i++){
    long long c,d; cin>>c>>d;
    CD.push_back(make_pair(c,d));
  }
  
  for(int i=0;i<n;i++){
    vector<pair<long long,int>>ans;
    for(int j=0;j<m;j++){
      long long X=abs(AB[i].first-CD[j].first);
      long long Y=abs(AB[i].second-CD[j].second);
      ans.push_back(make_pair(X+Y,j));
    }
    sort(ans.begin(),ans.end());
    cout<<ans[0].second+1<<endl;
  }
}

    
  


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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 2e5 + 5;
int arr[MAX], ans[MAX];
int n;

int main() {
	scanf("%d", &n);

	vector<ii> v;
	fori(i, 1, n + 1) {
		scanf("%d", arr + i);
		v.emplace_back(arr[i], i);
	}

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

	fori(i, 0, n) {
		if(i < n / 2) {
			ans[v[i].second] = v[n / 2].first;
		}
		else {
			ans[v[i].second] = v[n / 2 - 1].first;
		}
	}

	fori(i, 1, n + 1) {
		printf("%d\n", ans[i]);
	}

	return 0;
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
 
const long long mod = 1000000007LL;

int main(void) 
{
 
    long long N,M;
    cin >> N >> M;

    long long M2 = M/2;

    if (N >= M2) 
    {
        cout << M2 << endl;
    }
    else
    {
        cout << (N+M2)/2 << endl;
    }

    return 0;
}


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

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

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  rep(i,n) cin >> p.at(i);

  int count = 0;
  rep(i,n){
    if(p.at(i)!=i+1) count++;
  }

  if(count==0||count==2)cout << "YES";
  else cout << "NO";
}

Measured memory_bytes: 256
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))


a = list(map(int, input().split()))
ans = 0
for i in range(2):
    ans+=max(4-a[i],0)*100000
if(sum(a)==2):
    ans+=400000
    
print(ans)

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

int main()
{
    long long N, A, B, C, D, E;

    std::cin >> N >> A >> B >> C >> D >> E;
    long long ans = 0;

    long long min = std::min({ A,B,C,D,E });

    N = ((N - 1) / min);
    ans = 5 + N;

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	a, b, c, d = map(int, input().split(" "))
	i = 0
	while a > 0 or c > 0:
		if i%2 == 0:
			c -= b
		else:
			a -= d
		i += 1
	print("YNeos"[i%2::2])



if __name__ == "__main__":
	solve()

Measured memory_bytes: 9392
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    w,h,n = map(int, input().split())
    X = []
    Y = []
    A = []
    for i in range(n):
        x,y,a = map(int, input().split())
        X.append(x)
        Y.append(y)
        A.append(a)

    plots = [[0,0], [w,0], [w,h], [0,h]]
    for i in range(n):
        if A[i] == 1:
            plots[0][0] = max(plots[0][0], X[i])
            plots[3][0] = max(plots[3][0], X[i])
        elif A[i] == 2:
            plots[1][0] = min(plots[1][0], X[i])
            plots[2][0] = min(plots[2][0], X[i])
        elif A[i] == 3:
            plots[0][1] = max(plots[0][1], Y[i])
            plots[1][1] = max(plots[1][1], Y[i])
        else:
            plots[2][1] = min(plots[2][1], Y[i])
            plots[3][1] = min(plots[3][1], Y[i])
    width = plots[1][0] - plots[0][0]
    height = plots[2][1] - plots[1][1]
    if width <= 0 or height <= 0:
        print(0)
        return
    print(width * height)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66232
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
const int INF = INT_MAX - 5;
char mt[30][30];
int vis[30][30];
int dx[4] = {-1, 0, 0, 1};
int dy[4] = {0, -1, 1, 0};
int main() {
    int h,w;
    cin>>h>>w;
    for(int i = 0; i < h; ++i) {
        for(int k = 0; k < w; ++k) {
            cin>>mt[i][k];
        }
    }
    int ans = 0;
    for(int i = 0; i < h; ++i) {
        for(int k = 0; k < w; ++k) {
            for(int j = 0; j < h; ++j) {
                for(int l = 0; l < w; ++l) {
                    vis[j][l] = INF;
                }
            }
            if(mt[i][k] == '#') continue;
            queue<ii> q;
            q.emplace(i, k);
            vis[i][k] = 0;
            while(!q.empty()) {
                auto f = q.front();
                q.pop();
                int d = vis[f.first][f.second];
                // cout<<f.first<<" "<<f.second<<endl;
                for(int j = 0; j < 4; ++j) {
                    int px = dx[j] + f.first;
                    int py = dy[j] + f.second;
                    if(px >= 0 and px < h and py >= 0 and py < w) {
                        // cout<<px<<" - "<<py<<" "<<h<<" "<<w<<endl;
                        if(mt[px][py] == '.') {
                            if(d + 1 < vis[px][py]) {
                                vis[px][py] = d + 1;
                                q.emplace(px, py);
                            }
                        }
                    }
                }   
            }
            int mx = 0;
            for(int j = 0; j < h; ++j) {
                for(int l = 0; l < w; ++l) {
                    // cout<<vis[j][l]<<" ";
                    if(mt[j][l] == '.' and vis[j][l] != INF) {
                        mx = max(mx, vis[j][l]);
                    }
                } // cout<<endl;
            } // cout<<endl;
            ans = max(ans, mx);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#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>
#include <climits>

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

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


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    ll ans = 0;

    if (2 * C > A + B) {
        ans = A * X + B * Y;
    } else {
        ll Z = min(X, Y);
        ans += 2 * Z * C;
        X -= Z;
        Y -= Z;

        if (X == 0) {
            if (B <= 2 * C) {
                ans += B * Y;
            } else {
                ans += Y * C * 2;
            }
        } else{
            if (A <= 2 * C){
                ans += A * X;
            }else{
                ans += X * C * 2;
            }
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t; cin >> s >> t;

	bool ok = false;
	int n = s.size(), m = t.size();

	int idx = 1;
	for (int i = 0; i < m; ++i) {
		if (idx >= n) {
			ok = true;
			break;
		}
		if (t[i] == s[idx]) {
			idx += 2;
		}
	}

	idx = 0;
	for (int i = 0; i < m; ++i) {
		if (idx >= n) {
			ok = true;
			break;
		}
		if (t[i] == s[idx]) {
			idx += 2;
		}
	}
	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	int c;  cin >> c;
	return 0;

}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in insert
#define mp make_pair
#define F first
#define pb push_back
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
ll exp(ll x,ll y,ll p){ ll res=1; while(y) {if(y%2) res=(res*x%p)%p; x=(x*x)%p; y/=2; } return res;}
ll exp(ll x,ll y){ ll res=1; while(y) {if(y%2) res=(res*x); x=(x*x); y/=2; } return res;}

int main(){
    ll n; cin>>n;
    ll a[n];
    map<ll,ll> mp;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    ll sum=0;
    for(auto i=mp.begin();i!=mp.end();i++){
        ll x=i->second;
        sum+= (x)*(x-1)/2;
        
    }
    for(ll i=0;i<n;i++){
        cout<<sum-mp[a[i]]+1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 11008
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    string s;
    cin >> s;

    bool a = false, b = false, c = false;
    REP(i, 3) {
        if (s[i] == 'a')
            a = true;
        if (s[i] == 'b')
            b = true;
        if (s[i] == 'c')
            c = true;
    }

    if (a && b && c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, ans=1;
  string s;
  cin >> n >> s;
  rep(i,n-1) {
    if(s.at(i) != s.at(i+1))
      ans++;
  }
  cout << ans;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 100

int main(){
  long a[N][N], b[N][N], c[N][N];
  int n, m ,l, sum, i, j, k;
  
  scanf("%d%d%d",&n,&m,&l);

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

  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      scanf("%ld",&b[i][j]);
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      for(k=0;k<l;k++){
	c[i][k]+=a[i][j]*b[j][k];
      }
    }
  }


  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      if(j==l-1) {
	printf("%ld\n",c[i][j]);
	break;
      }
      printf("%ld ",c[i][j]);
    }
  }

  
  return 0;
}



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

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define debug(x) cerr << (#x) << "is "<< x << "\n"

using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	array<int,3> a;
	cin >> a[0] >> a[1] >> a[2];
	sort(all(a));
	cout << a[0]+a[1] << "\n";
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

# N = int(readline())
# D = [int(d) for d in readline().split()]

import itertools

N, *D = map(int, read().split())
# Dcum = itertools.accumulate(D)

S = sum(D)
T = sum([x * x for x in D])

ans = (S * S - T) // 2
print(ans)

# ans = 0
# for i in range(N):
#     for j in range(N):
#         if j <= i:
#             continue
#         ans += D[i] * D[j]
#
# print(ans)


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

using namespace std;

int main()
{
    int a,b,m;
    scanf("%d%d%d",&a,&b,&m);
    vector<int> one(a+1,0);
    vector<int> two(b+1,0);
    int c=1000000;
    int d=1000000;
    for(int i=1;i<=a;i++)
    {
        scanf("%d",&one[i]);
        c=min(c,one[i]);
    }
    for(int i=1;i<=b;i++)
    {
        scanf("%d",&two[i]);
        d=min(d,two[i]);
    }
    int res=c+d;
    while(m--)
    {
        int x,y,c;
        scanf("%d%d%d",&x,&y,&c);
        res=min(res,one[x]+two[y]-c);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	int n,m,i,num=0,num2=0;
  	cin>>n>>m;

  	if(n==0 || n==1)num=0;
  	if(n==2)num=1;

  	if(m==0 || m==1)num2=0;
  	if(m==2)num2=1;

  	if(n>2){
      for(i=1;i<n;i++)num+=i;
    }
 	if(m>2){
      for(i=1;i<m;i++)num2+=i;
    }
  	cout<<num+num2;
  	return 0;
}


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

using namespace std;

int main(){
    int n;
    stack <int> inp;

    while(std::cin >> n){
        if(n != 0){
            inp.push(n);
        } else {
            std::cout << inp.top() << std::endl;
            inp.pop();
        }
    }
}

Measured memory_bytes: 1200
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val s = readInputLine().toCharArray()
    
    var now = 0
    var max = 0
    
    for (c in s) {
        if (c == 'D') {
            now--
        } else {
            now++
            if (now > max) {
                max = now
            }
        }
    }

    println(max)
}
 
fun readInputLine(): String {
    return readLine()!!
}

Measured memory_bytes: 29856
import java.util.Scanner;
import java.util.Arrays;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    long [] a = new long[n];
    for (int i = 0; i < n; i++){
      a[i] = scan.nextLong();
      if (a[i] == 0){
        System.out.println(0);
        return;
      }
    }
    
    Arrays.sort(a);
    
    long ans = 1;

    for (int i = n-1; i >= 0; i--){
      if (a[i] > 1000000000000000000L/ans){
        System.out.println(-1);
        return;
      }else{
        ans *= a[i];
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 61440
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <math.h>

using namespace std;
//std::cout << std::fixed << std::setprecision(10);

int
main()
{
  double a, b, x,y;
  double ans;

  cin >> a >> b >> x;

  if(a*a*b/2>=x){
    y = 2 * x / a / b;
    //cout << y << endl;
    ans = 180/M_PI * atan(b / y);
    //cout << atan(b / y) << endl;
    cout << std::setprecision(10) << ans << endl;
  }
  else{
    y = (2 * x / a / a);
    //cout << y << endl;
    ans = 180/M_PI*atan((2*b /a)- (y / a));
    cout << std::setprecision(10) << ans << endl;
  }
}

Measured memory_bytes: 256
/*

 ________      
|\   ____\         _____              _          ___   ___   
\ \  \___|_ ___  _|_   _|__ _   _ ___| |_   _   / _  V  _ \ 
 \ \_____  V _ \/ __; |/ _ \ | | / __; | | | | | |_| | |_| |
  \|____|\  \ _/| | | | |_|  |_| \__ \ | |_| | |  _  |  _  |
    ____\_\  \_||_|_| |\___/\__,_|___/_|\__, |0|_| |_|_| |_|
   |\_________\   |_____|               {___/                
   \|_________|                

*/

#include <bits/stdc++.h>
using namespace std;
#define sz(x) (ll)(x).size()
#define trav(x) for(auto& it: x)
#define all(x) x.begin(), x.end()
#define stp fixed<<setprecision(20)
#define tc ll tt; cin>>tt; while(tt--)
#define For(i, st, en) for(ll i=st; i<en; i++)
#define rFor(i, st, en) for(ll i=st; i>=en; i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define printv(x) For(i, 0, sz(x)){cout<<x[i]<<" ";} cout<<endl;  
#define print2v(x) For(i, 0, sz(x)){For(j, 0, sz(x[i])){cout<<x[i][j]<<" ";} cout<<endl;}
#define scan2v(x,n,m) For(i, 0, n){vi tp(m,0);For(j, 0, m){cin>>tp[j];}x.pb(tp);}
#define scanv(x,n) For(i, 0, n){cin>>tttt; x.pb(tttt);}
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
#define po pop_back
#define mp make_pair
#define ss substr
typedef deque<int> di;
typedef vector<int> vi; 
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef map <int, int> mii;
typedef priority_queue <int> pq;
#define endl '\n'   
#define MAXN 300005
#define MOD 1000000007  
#define INF 1000000000000000007
#define bitc __builtin_popcountll

int begtime = clock(); ll tttt;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>

#define end_routine() cout << "\n\nTime elapsed: " << (double)(clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n";

void splitx(string s, char c, vector<string> &v){
    int i=0, j;
    while(i<sz(s)){
        j=i; string temp;
        while(j<sz(s) && s[j]!=c){temp+=s[j]; j++;}
        v.pb(temp); i=j+1; }}
struct TreeNode { int val; TreeNode *left; TreeNode *right; 
		TreeNode(int x) : val(x), left(NULL), right(NULL) {} };


signed main()
{   
		int n;cin>>n;
		n%=1000;
		if(n==0)
			cout << n;
		else
			cout << 1000-n;
	
	
   return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t x,y;
  cin>>x>>y;
  if(y>x){
    cout<<min(y-x,1+abs(abs(y)-abs(x)));
    return 0;
  }
  if(x>=0&&y<=0){
    cout<<1+abs(abs(x)-abs(y));
    return 0;
  }
  cout<<2+abs(abs(x)-abs(y));
}

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

int main() {
 UL N;scanf("%u",&N);
 int A[1000]; rep(i,N) scanf("%d",&A[i]);
 UL Q;scanf("%u",&Q);
 rep(q,Q){
  UL s,t; int k; scanf("%u%u%d",&s,&t,&k);
  UL ans=0;
  for(UL i=s; i<t; i++) if(A[i]==k) ans++;
  printf("%d\n",ans);
 }
 return 0;
}




Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int r,g,b,a;
    cin>>r>>g>>b;
    a=r*100+g*10+b;
    if (a%4==0) cout<<"YES";
    else cout<<"NO";
    return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n;
vi arr;
void in(){
    cin >> n;
    rep(i,0,n) arr.push_back(input());
}

void solve(){

    int ans = 1;
    int mx = arr[0];
    rep(i,1,n){
        ans += arr[i] >= mx;
        chmax(mx, arr[i]);
    }

    print(ans);


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 256
import sys
import math

N = int(input())
C = []
S = []
F = []

for i in range(N - 1):
    c, s, f = [int(x) for x in input().split()]
    C.append(c)
    S.append(s)
    F.append(f)


def f(idx, t):
    depT = -1
    if t <= S[idx]:
        depT = S[idx]
    else:
        depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx])
    return depT + C[idx]


for i in range(N - 1):
    t = 0
    for j in range(i, N - 1):
        t = f(j, t)
    print(t)

print(0)


Measured memory_bytes: 3188
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){

  long i, j;
  long xmin = 1000000000;
  long xmax = 0;
  long ans = 1;
  long N, X;
  long x[100001];

  scanf("%ld%ld", &N, &X);
  for(i = 0; i < N; i++){
    scanf("%ld", &x[i]);
  }

  for(i = 0; i < N; i++){
    x[i] = abs(x[i] - X);
  }

  for(i = 0; i < N; i++){
    xmin = min(xmin, x[i]);
  }

  for(i = 0; i < N; i++){
    xmax = max(xmax, x[i]);
  }

  xmin = min(xmax-xmin, xmin);

  if(N == 1){
    ans = x[0];
    goto Ans;
  }

  if(xmin == 1) goto Ans;

  for(j = 2; j <= xmin; j++){
    for(i = 0; i < N; i++){
      if(x[i] % j != 0) goto NextJ;
    }
    ans = j;
    NextJ: ;
  }


  Ans: ;

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

  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  string s;
  cin >> s;
  int ans=0;
  int n=s.length();
  for(int i=0; i<(n+1)/2; i++){
    if(s[i]!=s[n-1-i]){
      ans++;
    }
  }
  cout << ans << endl;

	return 0;
}

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

from collections import deque
sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

H, W = na()
g = [ns() for _ in range(H)]
d = [[-1] * W for _ in range(H)]
ct = 0
for i in range(H):
    ct += g[i].count('#')
d[0][0] = 1
que = deque()
que.append((0, 0))
while que:
    y, x = que.popleft()
    if y == H - 1 and x == W - 1:
        break
    for dy, dx in [(-1, 0), (1, 0), (0, -1), (0, 1)]:
        ny = y + dy
        nx = x + dx
        if 0 <= ny < H and 0 <= nx < W and g[ny][nx] != '#' and d[ny][nx] == -1:
            d[ny][nx] = d[y][x] + 1
            que.append((ny, nx))
if d[H-1][W-1] == -1:
    print(-1)
else:
    print(H * W - ct - d[H-1][W-1])

Measured memory_bytes: 6820
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

#define pb(x) push_back(x)
#define deb(x) cerr <<#x<<" = "<<x<<"\n"
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////



/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n;cin >> n ;
	int a[n];
	ll sum = 0;
	map<ll,ll> m;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum += a[i];
		m[a[i]]++;

	}
	int q;cin >> q;
	while(q--){
		int b,c;cin >> b >> c;
		int times = m[b];
		m[c] += times;
		m[b]=0;
		sum += (c-b)*times;
		cout << sum <<"\n";
	}

}


int main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		freopen("error.txt", "w", stderr);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
	/* #ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
    #endif  */
}

Measured memory_bytes: 9800
import java.util.Scanner;

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

		String keyItem = S.substring(K-1,K);

		System.out.println(maskIgnoreKeyWord(S,keyItem));
	}

	private static String maskIgnoreKeyWord(String input,String key) {
		String result = "";

		for(int i = 0; i < input.length() ;i++) {
			String tmp = input.substring(i, i+1);
			if(key.equals(tmp)) {
				result += tmp;
			}else {
				result +="*";
			}
		}
		return result;
	}
}

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

using namespace std;
const int N = 200010;

struct edge {
    int to, next, w;
} e[N * 10];

int head[N], ecnt = 1, dep[N], cur[N];

inline void adde(int from, int to, int w) {
    e[++ecnt] = (edge){to, head[from], w}, head[from] = ecnt;
    e[++ecnt] = (edge){from, head[to], 0}, head[to] = ecnt;
}

inline bool BFS(int s, int t) {
    memset(dep, -1, sizeof(dep)), dep[s] = 0; queue<int> q; q.push(s);
    while (!q.empty()) {
        int u = q.front(); q.pop();
        for (int i = head[u]; i; i = e[i].next)
            if (e[i].w && dep[e[i].to] == -1) {
                dep[e[i].to] = dep[u] + 1, q.push(e[i].to);
                if (e[i].to == t) return true;
            }
    }
    return false;
}

int DFS(int u, int f, int t) {
    if (u == t || !f) return f; int res = 0;
    for (int &i = cur[u], tmp; i; i = e[i].next)
        if (e[i].w && dep[e[i].to] == dep[u] + 1 && (tmp = DFS(e[i].to, min(f, e[i].w), t))) {
            res += tmp, f -= tmp, e[i].w -= tmp, e[i ^ 1].w += tmp;
            if (!f) break;
        }
    return res;
}

inline int Dinic(int s, int t) {
    int res = 0;
    while (BFS(s, t)) memcpy(cur, head, sizeof(head)), res += DFS(s, 1e9, t);
    return res;
}

int fa[N], fa1[N];

int find(int x) {
    return x == fa[x] ? x : fa[x] = find(fa[x]);
}

int find1(int x) {
    return x == fa1[x] ? x : fa1[x] = find1(fa1[x]);
}

int A[N], B[N];

int main() {
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++) fa[i] = i, fa1[i] = i;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &A[i]), A[i]++;
        int x = find(i), y = find(A[i]);
        if (x != y) fa[x] = y;
    }
    for (int i = 1; i <= n; i++) {
        scanf("%d", &B[i]), B[i]++;
        int x = find1(i), y = find1(B[i]);
        if (x != y) fa1[x] = y;
    }
    int s = 2 * n + 1, t = s + 1, ct = 0;
    for (int i = 1; i <= n; i++) {
        if (A[i] == i && B[i] == i) { ct++; continue; }
        if (A[i] == i) adde(s, n + find1(i), 1);
        else if (B[i] == i) adde(find(i), t, 1);
        else {
            adde(find(i), n + find1(i), 1);
            if (A[i] == B[i]) adde(n + find1(i), find(i), 1);
        }
    }
    printf("%d\n", n - Dinic(s, t) - ct);
}

Measured memory_bytes: 15960
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(any{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	for(int i=0; i<N; i++) cin >> P[i];

	int m = P[0];
	int ans = 0;
	for(int i=0; i<N; i++){
		if(m >= P[i]) ans++;
		m = min(m, P[i]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int A[2000001];
char B[100];
int hs=0;

int parent(int x){
  return (x/2);
}

int left(int x){
  return 2*x;
}

int right(int x){
  return 2*x+1;
}

void maxHeapify(int i){
  int l,r,tmp;
  int largest;
  l = left(i);
  r = right(i);
  if(l <= hs && A[l] > A[i]){
    largest = l;
  } else {
    largest = i;
  }
  if(r <= hs && A[r] > A[largest]){
    largest = r;
  }
  if(largest !=i){
    tmp = A[i];
    A[i]=A[largest];
    A[largest]= tmp;
    maxHeapify(largest);
  }
  
}

void heapIncreaseKey(int,int);

void maxHeapInsert(int key){
  hs = hs+1;
  A[hs]=-1;
  heapIncreaseKey(hs,key);
}

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

int heapExtractMax(){
  int max;
  if(hs<1){
    return -1;
  }
  max = A[1];
  A[1]=A[hs];
  hs = hs -1;
  maxHeapify(1);
  return max;
}

int main(){
  int i;
  while(1){
    scanf("%s",B);
    if(B[0]=='i'){
      scanf("%d",&i);
      maxHeapInsert(i);
    } else if(B[2]=='d'){
      break;
    } else {
      printf("%d\n",heapExtractMax());
    } 
  }
  return 0;
}

Measured memory_bytes: 4692
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);
		int m = 2019;
		int l = sc.nextInt();
		int r = sc.nextInt();
		
		int lm = l % m;
		int rm = r % m;
		int ld = l / m;
		int rd = r / m;		
		int minl = Integer.MAX_VALUE;
		
		boolean isLap = rd -ld > 0;
		if( lm == 0 || rm==0 || isLap ) {
			minl = 0;
		}else {
			for( int i=lm ; i< rm ; i++ ) {
				for( int j=lm+1 ; j<= rm ; j++ ) {
					int tmp=(i*j)%m;
					if(  minl > tmp ) {
						minl = tmp;
					}
				}
			}
		}
		
		System.out.println(minl);
	}
}


Measured memory_bytes: 35812
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int x, a, b;
	int n,m;
	while(~scanf("%d",&x))
	{
		scanf("%d",&a);
		scanf("%d",&b);
		n = x - a;
		m = n % b;
		printf("%d\n",m);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const ll INF = numeric_limits<ll>::max();
int main()
{
    int n; cin >> n;
    VI l(n); rep(i, n) cin >> l[i];
    sort(ALL(l));
    int c = 0;
    rep(i, n){
        FOR(j, i+1, n) {
            FOR(k, j+1, n){
                if (l[i] + l[j] > l[k] && l[i] < l[j] && l[j] < l[k]) ++c;
            }
        }
    }
    cout << c << endl;
    return 0;
}

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

using namespace std;
int main() {
  unsigned long long n;
  cin >> n;
  string s;

  do {
    n--;
    int b = n % 26;
    char a = b + 'a';
    n /= 26;
    s.push_back(a);
  } while (n > 0);
  reverse(s.begin(), s.end());
  cout << s;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int N;
  cin >> N;
  if (N%2==0) {
    cout << (N-2)/2 << endl;
  }
  else {
    cout << (N-1)/2 << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
    ll s[100001];
int main(){
    ll n;
    cin>>n;
    vector<ll> v;
    rep(i,n){
        ll x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.rbegin(),v.rend());
    ll a=0;ll b=0;
    for(int i=1;i<n;i++){
        if(a==0&&b==0&&v[i]==v[i-1]){
            a=v[i];
            i++;
        }else if(b==0&&v[i]==v[i-1]){
            b=v[i];break;
        }
    }
    if(a==0||b==0){
        cout<<0<<endl;
    }else{
        cout<<a*b<<endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <set>
#include <algorithm>
using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)n;(i)++)
#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)

int N, d[20][20], dp[1<<18];

int rec(int S) {
  int res = 1<<28, i, j, mini;
  if (dp[S] >= 0) return dp[S];
  if (S == (1<<N)-1) return dp[S] = 0;
  rep(i,N) if (!((1<<i)&S)) {
    mini = d[i][0];
    rep(j,N) if ((1<<j)&S) mini = min(mini, d[i][j+1]);
    res = min(res, mini + rec(S|(1<<i)));
  }
  return dp[S] = res;
}

int main() {
  int i, j;
  while (scanf("%d",&N), N) {
    memset(dp, -1, sizeof dp);
    rep(i,N) rep(j,N+1) scanf("%d", &d[i][j]);
    printf("%d\n", rec(0));
  }
  return 0;
}

Measured memory_bytes: 1900
#include <cassert>
#include <iostream>
#include <functional>
#include <iomanip>
#include <set>
#include <unordered_map>
#include <queue>
#include <vector>
#include <deque>
#include <algorithm>
#include  <cstring>
#include <string>
#include <cmath> 
using namespace std;
typedef long long LL;
const int MAX = 110000;
const LL base = 1e9 + 7;


struct Node {
	int x, y, w;
};
int n, m;

vector<int> gr1[MAX], gr2[MAX];
int de[MAX];
int path[MAX];
void solve() {

	int result = 0;

	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		gr1[x].push_back(y);
	//	gr2[y].push_back(x);
		de[y] ++;
	}

	vector<int> pool;
	for (int i = 1; i <= n; ++i) {
		if (de[i] == 0) pool.push_back(i);
	}
	int nowt = 0;
	while (nowt<pool.size() ) {
		int now = pool[nowt++];
		result = max(result, path[now]);
		for (auto x : gr1[now]) {
			de[x]--;
			if (de[x] == 0) pool.push_back(x);
			path[x] = max(path[x], path[now] + 1);
		}
	}


	cout << result << endl;

}

int main() {
	const int inId = 0;
	const int outId = 0;
	if (inId>0) {
		cerr << "redirect stdin to input " << inId << endl;
		string s = "input";
		s += to_string(inId);
		s += ".txt";
		auto r = freopen(s.c_str(), "r", stdin);	
		if (r == nullptr) {
			cerr<< "invalid input file "<< s;
		}
	}
	if (outId>0) {
		cerr << "redirect stdout to stdout " << outId << endl;
		string s = "stdout";
		s += to_string(outId);
		s += ".txt";
		auto r = freopen(s.c_str(), "w", stdout);
		if (r == nullptr) {
			cerr<< "invalid output file "<< s;
		}		
	}
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // close sync between cout and printf
	cout.precision(10);
	solve();
}
 

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

using namespace std;
const int maxn=2e5+5;
typedef long long ll;
int a[maxn];
int main()
{

    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=a[i]*a[j];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//2020.1.27
//s1270188 xxxmk2
//alds1_12b

#include<stdio.h>
#include<limits.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

//global
int data[N][N], num;

//function
void cnt(void){
  int color[N], d[N], p[N];
  int min, i, j, u;

  //reset
  for(i=0;i<num;i++){
    color[i]=WHITE;
    d[i]=INT_MAX;
    p[i]=-1;
  }
  d[0]=0;

  
  while(1){
    min=INT_MAX;
    
    for(i=0;i<num;i++){
      if(color[i]!=BLACK && d[i]<min){
	min=d[i];
	u=i;
      }
    }
    
    if(min==INT_MAX) break;

    color[u]=BLACK;

    for(j=0;j<num;j++){
      if(color[j]!=BLACK && data[u][j]!=INT_MAX ){
	if(d[u]+data[u][j]<d[j]){
	  d[j]=d[u]+data[u][j];
	  p[j]=u;
	  color[j]=GRAY;
	}
      }
    }
    
  }

  for(i=0;i<num;i++) printf("%d %d\n",i,d[i]);  

}



int main(){
  int i, j, a, b, c, d;

  //input
  scanf("%d",&num);
  for(i=0;i<num;i++){//reset
    for(j=0;j<num;j++) data[i][j]=INT_MAX;
  }
  
  for(i=0;i<num;i++){
    scanf("%d %d",&a,&b);
    for(j=0;j<b;j++) {
      scanf("%d %d",&c,&d);
      data[a][c]=d;
    }
  }
  
  //output
  cnt();
  
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

// (行き先,容量,逆辺)
struct edge{ int to,cap,rev; };

const int MAX_V = 222; // TODO:initialize
const int F_INF = 123456789; // TODO:initialize
vector<edge> G[MAX_V];
int level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

void add_edge(int from, int to, int cap){
    G[from].pb({to,cap,(int)G[to].size()});
    G[to].pb({from,cap,(int)G[from].size()-1});
}

void dinic_bfs(int s){
    memset(level,-1,sizeof(level));
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        rep(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap>0 && level[e.to]<0){
                level[e.to] = level[v]+1;
                que.push(e.to);
            }
        }
    }
}

// 増加パスをdfsで探す
int dinic_dfs(int v, int t, int f){
    if(v==t) return f;
    for(int &i=iter[v]; i<(int)G[v].size(); ++i){
        edge &e=G[v][i];
        if(e.cap>0 && level[v]<level[e.to]){
            int d = dinic_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;
}

// sからtへの最大流
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        dinic_bfs(s);
        if(level[t]<0) return flow;
        memset(iter,0,sizeof(iter));
        int f;
        while((f=dinic_dfs(s,t,F_INF))>0) flow+=f;
    }
}

const int M = 191919;

int main()
{
    int h,w;
    cin >>h >>w;
    vector<string> s(h);
    rep(i,h) cin >>s[i];

    int S = h+w, T = S+1;
    rep(i,h)rep(j,w)
    {
        if(s[i][j]=='o') add_edge(i,h+j,1);
        else if(s[i][j]=='S')
        {
            add_edge(S,i,M);
            add_edge(S,h+j,M);
        }
        else if(s[i][j]=='T')
        {
            add_edge(T,i,M);
            add_edge(T,h+j,M);
        }
    }

    int ans = max_flow(S,T);
    if(ans>=M) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int a[4][4];
    REP(i, 3) {
        REP(j, 3) {
            cin >> a[i][j];
        }
    }
    REP(i, 3) {
        int row_min = 1000;
        REP(j, 3) {
            row_min = min(row_min, a[i][j]);
        }
        REP(j, 3) {
            a[i][j] -= row_min;
        }
    }
    REP(j, 3) {
        if ((a[0][j] != a[1][j]) || (a[0][j] != a[2][j])) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n>>k;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	sort(ar+1,ar+n+1,greater<ll>());

	ll an=0;
	for(i=k+1;i<=n;i++){
		an+=ar[i];
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int i,j;
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(i*j==n){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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

#define pb(a) push_back(a)
#define INF 1145141919810
#define mod 1000000007

typedef long long ll;

const int dsize = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[dsize],fac[dsize];

template <class T = int> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<dsize;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<dsize;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

int main() {
	int n=in(),h=in();
	int a[n],b[n];
	int ans=0;
	for (int i=0;i<n;i++) {
		a[i]=in(),b[i]=in();
	}
	sort(a,a+n,greater<int>());
	sort(b,b+n,greater<int>());
	int x=a[0];
	for (int i=0;i<n;i++) {
		if (b[i]>x&&h>0) {
			h-=b[i];ans++;
		}
	}
	if(h>0){
	if(h%x)ans++;
	ans+=h/x;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll q,h,s,d;
ll n;
int main(){
	scanf("%lld %lld %lld %lld",&q,&h,&s,&d);
	scanf("%lld",&n);
	ll t1=min(4*q,min(2*h,s));
	if(d>=(2*t1))printf("%lld\n",(n*t1));
	else printf("%lld\n",(n/2)*d+(n%2)*t1);
}

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

typedef long long ll;

int n;
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> s;
    int res = 0;
    for (int i = 0; i + 2 < n; ++i) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ++res;
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
int solve()
{
	int n,i,a,A=0,AS=1,B=0,BS=1,C=0;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",&a),A?A==a?++AS:B?B==a?++BS:C=1:B=a:A=a;
	if(C)return 0*puts("No");
	if(A<B)A^=B^=A^=B,AS^=BS^=AS^=BS;
	if(B)
	{
		if(B!=A-1)return 0*puts("No");
		if(BS>=A)return 0*puts("No");
		puts(2*(A-BS)>n-BS?"No":"Yes");
	}
	else puts(2*A>n&&A!=n-1?"No":"Yes");
}
int main()
{
	int T=1;
	for(;T--;)solve();
}

Measured memory_bytes: 128
#include<stdio.h>
#include <stdlib.h>

main()
{
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    if(W>=(x+r)&&H>=(y+r)&&x>=r&&y>=r)
    printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 2088