akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstring>
#include<utility>
#include<cmath>
#include<assert.h>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<complex>
#include<bitset>

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound

pii RS[100100];
int N, M;
int X[100100];
int Y[100100];

signed main() {
    cin >> N >> M;
    rep(i, M) {
        cin >> X[i] >> Y[i];
        X[i]--, Y[i]--;
    }
    rep(i, N)RS[i] = pii(0, 1);
    RS[0] = pii(1, 1);
    rep(i, M) {
        int x = X[i], y = Y[i];
        if (RS[x].first == 0) {
            RS[x].second--;
            RS[y].second++;
        } else if (RS[x].first == RS[x].second) {
            RS[x].first--;
            RS[x].second--;
            RS[y].first++;
            RS[y].second++;
        } else {
            RS[x].second--;
            RS[y].first++;
            RS[y].second++;
        }
    }
    int ans = 0;
    rep(i, N) {
        ans += (RS[i].first > 0);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

def solve():
    C = Counter(A)
    M = len(C)
    if M == 1 and 0 in C:
        return True
    elif M == 2:
        if 0 in C:
            b = 0
            for k, v in C.items():
                if k != 0:
                    b = v
            a = C[0]
            return (b == a * 2)
        else:
            return False
    elif M == 3:
        a, b, c = C.keys()
        if a ^ b == c or b ^ c == a or c ^ a == b:
            return (C[a] == C[b] == C[c])
        else:
            return False
    else:
        return False

if solve():
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14460
#include<stdio.h>

int main(){
  int a,b,c;
  int x;
  int count = 0;
  scanf("%d %d %d",&a,&b,&c);
  for(x=a; x <= b; x++){
    if(c % x == 0){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
    
}


Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt()%10;
		switch(N) {
		case 3:
			System.out.println("bon");
			return;
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			return;
		default:
			System.out.println("hon");
			return;
		}
	}

}


Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a,b) + min(c,d);
}


Measured memory_bytes: 256
n = int(input())
d = dict()
for _ in range(n):
    x = str(input())
    if x in d:
        d[x] += 1
        continue
    else:
        d[x] = 0

d_sort = sorted(d.items(), key=lambda d:d[1], reverse = True)
d_max = d_sort[0][1]

ans = []
for i in d_sort:
    if d_max == i[1]:
        ans.append(i[0])
    else:
        break

ans.sort()
for a in ans:
    print(a)


Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

int main(){
	int n;
	cin >> n;
	int hako[210];
	REP(i,n*2)cin >> hako[i];
	sort(hako,hako+n*2);
	int ret = 0;
	for(int i=0;i<n*2;i+=2){
		ret += hako[i];
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

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

	a := make(map[int]int)

	tmp := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		a[tmp]++
	}
	if len(a) <= k {
		fmt.Println(0)
		return
	}

	cnt := make([]int, len(a))
	for _, v := range a {
		cnt[idx] = v
		idx++
	}
	sort.Ints(cnt)

	for i := 0; i < len(a)-k; i++ {
		ans += cnt[i]
	}
	fmt.Println(ans)
}


Measured memory_bytes: 14996
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve() {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a=n/10;
		int b=n%10;
		if(a==9 || b==9)System.out.println("Yes");
		else System.out.println("No");
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long

ll n,k,a;

vector<double> logs;

bool can(ll mid) {
    ll res = 0;
    for(auto a : logs) {
        if(a<=mid) continue;
        res += ceil(a/mid)-1;
    }
    return res <= k;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll low=1, high = 0;
    cin >> n >> k;
    for(int i=0;i<n;i++) {
        cin >> a; logs.push_back(a);
        high = max(high ,a);
    }
    while(low<high) {
        ll mid = (low+high) >> 1;
        if(can(mid)) high = mid;
        else low = mid+1;
    }
    cout << low;
}


Measured memory_bytes: 5320
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll dp[55][55][5000];

signed main(){
	//cout << fixed << setprecision(10);
	string s; cin>>s;
	int n=s.size();
	ll ans=0,cnt=0;
	rep(i,0,n){
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')cnt++;
		else{
			chmax(ans,cnt);
			cnt=0;
		}
	}
	chmax(ans,cnt);
	cout<<ans<<endl;
	 
	return 0;
}

Measured memory_bytes: 3628
import math

def disp(p,x,y,n):
    if p==0:
        max=0
        for i in range(n):
            if max<abs(x[i]-y[i]):
                max=abs(x[i]-y[i])
        return max
    else:
        sum=0
        for i in range(n):
            sum+=(abs(x[i]-y[i]))**p
        return (sum**(1/p))
    
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
for p in range(1,4):
    print(disp(p,x,y,n))
print(disp(0,x,y,n))


Measured memory_bytes: 5700
import sys
n = int(input())
# 2, 4, 8, 16, 32, 64 | 128

# if n % 2 == 1:
#     print(0)
#     sys.exit()

if n == 1:
    print(1)


if 2 <= n and n < 4:
    print(2)
elif 4 <= n and n < 8:
    print(4)
elif 8 <= n and n < 16:
    print(8)
elif 16 <= n and n < 32:
    print(16)
elif 32 <= n and n < 64:
    print(32)
elif 64 <= n and n <= 100:
    print(64)


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

int main(){

  int a, b, c, cnt=0;

  cin>>a>>b>>c;

  if(a!=b) cnt++;
  if(b!=c) cnt++;
  if(c!=a) cnt++;

  if(cnt) cout<<cnt<<endl;
  else cout<<1<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>
#include <sys/time.h>
#include <fstream>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define REP(i,n)  FOR(i,0,n)
#define each(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define deb(x) cerr << #x << " = " << (x) << " , ";
#define debl cerr << " (L" << __LINE__ << ")"<< endl;
#define sz(s) (int)((s).size())


#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(x,y) make_pair((x),(y))

double pi=3.14159265358979323846;

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

template<typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& z){
	os << "[ ";
	REP(i,z.size())os << z[i] << ", " ;
	return ( os << "]" << endl);
}

template<typename T> std::ostream& operator<<(std::ostream& os, const set<T>& z){
	os << "set( ";
	EACH(p,z)os << (*p) << ", " ;
	return ( os << ")" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const map<T,U>& z){
	os << "{ ";
	EACH(p,z)os << (p->first) << ": " << (p->second) << ", " ;
	return ( os << "}" << endl);
}

template<typename T,typename U> std::ostream& operator<<(std::ostream& os, const pair<T,U>& z){
	return ( os << "(" << z.first << ", " << z.second << ",)" );
}

double get_time(){
	struct timeval tv;
	gettimeofday(&tv, NULL);
	return tv.tv_sec + tv.tv_usec*1e-6;
}

typedef unsigned int uint32_t;
struct RND{
	uint32_t x;
	uint32_t y;
	uint32_t z;
	uint32_t w;
	RND(){
		x=123456789;
		y=362436069;
		z=521288629;
		w=88675123;
	}
	void init(int seed){
		x=123456789;
		y=362436069;
		z=521288629;
		w=seed+100;
		REP(i,10)get();
	}
	uint32_t get(){
		uint32_t t;
		t=x^(x<<11);
		x=y;y=z;z=w;
		w=(w^(w>>19))^(t^(t>>8));
		return w;
	}
};
RND rnd;

void _main(istream &inp){
    vi cnt(4);
    rep(i,3){
        int a,b;
        inp >> a >> b;
        cnt[a-1]++;
        cnt[b-1]++;
    }
    debug(cnt);
    cout << ( cnt[0]<=2 && cnt[1]<=2 && cnt[2]<=2 && cnt[3]<=2 ? "YES" : "NO" ) << endl;

}

int main(){
	if(0){
		ifstream ifs("test.txt");
		_main(ifs);
	}
	else{
		_main(cin);
	}
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

struct node {
	int id;
	int cost;
	node(int i, int c){
		this->id = i;
		this->cost = c;
	}
	bool operator<(node c) const {
		return this->cost > c.cost;
	}
};

int main() {
	int n;
	scanf("%d", &n);
	
	int c[n];
	int w[n][n];
	for(int i = 0; i < n; i++){
		int u, k;
		scanf("%d %d", &u, &k);
		
		c[u] = u ? INT_MAX : 0;
		for(int j = 0; j < n; j++){
			w[u][j] = -1;
		}
		while(k--){
			int v, c;
			scanf("%d %d", &v, &c);
			w[u][v] = c;
		}
	}
	
	priority_queue<node> q;
	q.push(*new node(0, 0));
	while(q.size()){
		int i = q.top().id;
		int ca = q.top().cost;
		q.pop();
		
		for(int j = 0; j < n; j++){
			if(w[i][j] != -1 && c[j] > w[i][j] + ca){
				c[j] = w[i][j] + ca;
				q.push(*new node(j, c[j]));
			}
		}
	}
	
	for(int i = 0; i < n; i++){
		printf("%d %d\n", i, c[i]);
	}
}

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

int main() {
    int H, W;
    while(1){
    	cin >> H >> W;
    	if(H==0 && W==0) break;
    	for(int i=0;i<H;i++){
    		for(int j=0;j<W;j++){
    			cout << "#";
    		}
    		cout << endl;
    	}
    	cout << endl;
    }
    return 0;
}

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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine();

            if (N.Contains("9"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
            

            
        }
    }
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<ll> h(n);
  rep(i,n)cin>>h[i];
  vector<int> a(m);
  vector<int> b(m);
  vector<bool> tall(n,true);
  rep(i,m)cin>>a[i]>>b[i];
  rep(i,m){
    if(h[a[i]-1]>h[b[i]-1]){
      tall[b[i]-1]=false;
    }else if(h[a[i]-1]<h[b[i]-1]){
      tall[a[i]-1]=false;
    }
    else{
      tall[b[i]-1]=false;
      tall[a[i]-1]=false;
    }
  }
  int cnt=0;
  rep(i,n){
    if(tall[i]==true){
      cnt++;
    }
  }
  cout<<cnt;
  return 0;
}


Measured memory_bytes: 4808
#include <vector>
#include <iostream>
#include <map> 
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    vector<char> code;
    for(int i = 0;i < s.size(); i++){
        switch(s[i]){
            case '0':
                code.push_back('0');
                break;
            case '1':
                code.push_back('1');
                break;
            case 'B':
                if(code.size() > 0)
                    code.pop_back();
                break;
        }
    }
    
    // -> std::string
    std::string stdString(code.begin(), code.end());
    
    cout << stdString << endl;
}


Measured memory_bytes: 256
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readString() -> String {
    return readLine()!
}

func readLines(times: Int) -> [String] {
    var array = [String]()
    for _ in 0..<times {
        array.append(readLine()!)
    }
    return array
}

func readSeparatedStrings() -> [String] {
    return readLine()!.split(separator: " ").map({String($0)})
}

func readStringToStrings() -> [String] {
    return readLine()!.map({String($0)})
}

func readSeparatedInts() -> [Int] {
    return readLine()!.split(separator: " ").map({Int($0)!})
}
func readSeparatedDouble() -> [Double] {
    return readLine()!.split(separator: " ").map({Double($0)!/100000})
}


let numbers = readSeparatedInts()
let L = numbers[0]
let R = numbers[1]
let d = numbers[2]

var count = 0
for n in L...R {
    if n % d == 0 {
        count += 1
    }
}
print(count)


Measured memory_bytes: 13600
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#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 REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    ll N,T;
    cin>>N>>T;
    vector<pair<ll,ll>> AB(N);
    REP(i,N) cin>>AB[i].first>>AB[i].second;
    sort(AB.begin(),AB.end());
    vector<vector<ll>> dp(3010,vector<ll>(6010,0));
    REP(i,N){
        REP(j,6010){
            if(j-AB[i].first>=0&&j-AB[i].first<T) dp[i+1][j]=max(dp[i][j-AB[i].first]+AB[i].second,dp[i][j]);
            else dp[i+1][j]=dp[i][j];
        }
    }
    ll ans=0;
    REP(j,6010){
        ans=max(ans,dp[N][j]);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 141824
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 998244353;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

struct Combination {
    vector<ll> fac, finv, inv;

    Combination(ll maxN) {
        maxN += 100; // for safety
        fac.resize(maxN + 1);
        finv.resize(maxN + 1);
        inv.resize(maxN + 1);
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for (ll i = 2; i <= maxN; ++i) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    ll operator()(ll n, ll k) {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};


int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    Combination nCk(n);
    ll ret = 0;
    for (ll i = 0; i <= n; ++i) {
        ll red = i * a;
        if ((k - red) >= 0 && (k - red) % b == 0) {
            ll ib = (k - red) / b;
            ret = (ret + nCk(n, ib) * nCk(n, i)) % MOD;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 7296
#include<algorithm>
using namespace std;
#define MAX 200

class Doll{
    public:
    int h, r;
    Doll(){}
    Doll( int h, int r ): h(h), r(r){}

    bool operator < ( const Doll &d ) const {
	if ( r == d.r ) return h < d.h;
	else return r < d.r;
    }
};

Doll dolls[MAX+1];
int size;

int lis(){
    int T[MAX+1];
    T[0] = 0;
    dolls[0] = Doll( 0, 0 );
    for ( int i = 1; i <= size; i++ ){
	int maxi = 0;
	for ( int j = 0; j <= i - 1; j++ ){
	    if ( T[j] > T[maxi] && 
		 dolls[j].h < dolls[i].h && dolls[j].r < dolls[i].r ){
		maxi = j;
	    }
	}
	T[i] = T[maxi] + 1;
    }

    int maxv = 0;
    for ( int i = 1; i <= size; i++ ) maxv = max( maxv, T[i] );

    return maxv;
}

bool input(){
    int n, m, h, r;
    cin >> n;
    if ( n == 0 ) return false;

    dolls[0] = Doll(0, 0);

    for ( int i = 1; i <= n; i++ ){
	cin >> h >> r;
	dolls[i] = Doll( h, r );
    }
    cin >> m; size = n + m;
    for ( int i = n + 1; i <= size; i++ ){
	cin >> h >> r;
	dolls[i] = Doll( h, r );
    }
    return true;
}

int main(){
    while(input()){
	sort( dolls, dolls + size + 1);
	cout << lis() << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import math
n=int(input())
a=0
b=0

n_rt=math.sqrt(n)
if float.is_integer(n_rt)==True:
    print(2*int(n_rt-1))
else:
    for i in range(int(n_rt//1)):
        tmp=n%(n_rt//1-i)
        if tmp==0:
            y=int(n/(n_rt//1-i))
            print(int((n_rt//1-i)+y-2))
            break

Measured memory_bytes: 3188
#include<iostream>

int main()
{
    int H,W;
    
    while(1){    
        
        std::cin>>H>>W;
        
        if(H==0 && W==0){
            break;
        }else{
            for (int i=1; i<=H;i++){
                for (int j=1; j<=W;j++){
                    std::cout<<'#';
                }
            std::cout<<std::endl;
            }
        }
        std::cout<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int main()
{
	int n,m,o;
	scanf("%d%d%d",&n,&m,&o);
	int mina=0x3f3f3f3f;
	int minb=0x3f3f3f3f;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		mina=min(mina,a[i]);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
		minb=min(minb,b[i]);
	}
	int ans=mina+minb;
	for(int i=1;i<=o;i++)
	{
		int x,y,k;
		scanf("%d%d%d",&x,&y,&k);
		ans=min(ans,a[x]+b[y]-k);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#define  REP(i, s, e) for(register int i = s; i <= e ;i++)
#define DREP(i, s, e) for(register int i = s; i >= e ;i--)

#define DEBUG fprintf(stderr, "Passing [%s] in LINE %d\n", __FUNCTION__, __LINE__)
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

#include <bits/stdc++.h>

using namespace std;

template <typename T> T read()
{
	T ans(0), p(1);
	char c = getchar();
	while (!isdigit(c))
	{
		if (c == '-') p = -1;
		c = getchar();
	}
	while (isdigit(c))
	{
		ans = ans * 10 + c - 48;
		c = getchar();
	}
	return ans * p;
}

int m, n, k;

int main()
{
	long long a, b;
	cin >> a >> b;
	cout << (long long)abs(a - 2) * (long long)abs(b - 2);


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, D;
        cin >> N >> D;
        ll ans = 0;
        rep(i, 0, N) {
                ll x, y;
                cin >> x >> y;
                if (x*x + y*y <= D*D) ++ans;
        }
        cout << ans << endl;
}


Measured memory_bytes: 3616
import sys
s=list(input())

if len(s)%2!=0:
    print("No")
    sys.exit()
f=True
for i in range(len(s)//2):
    l=i*2
    if s[l]!="h" or s[l+1]!="i":
        f=False
if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>

using namespace std;

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

  int y,m,d;
  y = stoi(str.substr(0,4));
  m = stoi(str.substr(5,2));
  d = stoi(str.substr(8,2));

  string out;

  if (y < 2019)
    out = "Heisei";
  else if (y > 2019)
    out = "TBD";
  else if (m < 5)
    out = "Heisei";
  else
    out = "TBD";
  
  cout << out << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long int arr[100001];
long int dp[100001];
int k;
long int solve(long int i){
	if(i<=0)
	return INT_MAX-10001;
	if(dp[i]!=INT_MAX-10001)
	return dp[i];
	for(int j=1;j<=k;j++){
		if(i-j>=1)
		dp[i]=min(dp[i],solve(i-j)+abs(arr[i]-arr[i-j]));
	}
	return dp[i];
}
int main(){
	long int n;
	cin>>n;
	cin>>k;
	for(long int i=1;i<=n;i++)
	cin>>arr[i];
	for(long int i=0;i<=n;i++)
	dp[i]=INT_MAX-10001;
	dp[1]=0;
	long int ans=solve(n);
	cout<<dp[n];
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define FORU(a, b, c) for (int a = b; a < c; ++a)
#define FORD(a, b, c) for (int a = b; a > c; --a)
#define ld long double
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    ld p[n+1];
    FORU(i, 1, n+1)
        cin >> p[i];
    ld dp[n+1][n+1];
    dp[0][0] = 1;
    FORU(i, 1, n+1)
        dp[0][i] = 0;
    FORU(i, 1, n+1)
        dp[i][0] = (1-p[i])*dp[i-1][0];
    FORU(i, 1, n+1)
        FORU(j, 1, n+1)
            dp[i][j] = dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
    ld ans = 0;
    FORU(i, (n+1)/2, n+1)
        ans += dp[n][i];
    cout << setprecision(10) << ans;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int D = nextInt();


  vector< vector<int> > X;
  REP(i, N) {
    vector<int> x;
    REP(j, D) {
      x.push_back(nextInt());
    }
    X.push_back(x);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      auto x = X[i];
      auto y = X[j];
      int s = 0;
      REP(k, D) {
        s += (x[k] - y[k]) * (x[k] - y[k]);
      }
      int r = (int)(sqrt(s + 0.5));
      if (r * r == s) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(500000)

N, Q = map(int, input().split())
G = [set() for _ in range(N)]
cnt = [0]*N
visited = [0]*N

def dfs(start_node):
    for i in G[start_node]:
        if visited[i]==0:
            visited[i]=1
            cnt[i] += cnt[start_node]
            dfs(i)

for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

for i in range(Q):
    node, x = map(int, input().split())
    node -= 1
    cnt[node] += x

visited[0]=1
#dfs(0)
st = [0]
while st:
    v = st.pop()
    for u in G[v]:
        if visited[u]: continue
        visited[u] = 1
        cnt[u] += cnt[v]
        st.append(u)    

print(*cnt)


Measured memory_bytes: 80516
import java.util.Scanner;

class Main {
    static final Scanner IN = new Scanner(System.in);
    static final String S = IN.next();
    public static void main(String... args) {
        puts(S.matches("A[a-z]+C[a-z]+") ? "AC" : "WA");
    }
    static <T> void puts(T arg) { System.out.println(arg);}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    ll ans = 0, val = 0;
    for (int i = 0; i < n; ++i) {
        val = max<ll>(val, v[i]);
        ans += val-v[i];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 4040
import itertools
import math
n = int(input())
point = [list(map(int, input().split())) for _ in range(n)]

dist = [[math.sqrt((point[i][0] - point[j][0])**2 + (point[i][1] - point[j][1])**2) for j in range(n) ] for i in range(n)]
ans = 0
l = [i for i in range(n)]
for v in itertools.permutations(l):
  ans += sum([dist[v[i]][v[i+1]] for i in range(n-1)])
print(ans / math.factorial(n))    


Measured memory_bytes: 3064
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    i64 n, m, d;
    read(n, m, d);

    cout << fixed << setprecision(12);
    if (d == 0) {
        print((m - 1) / double(n));
    } else {
        print((m - 1) * 2 * (n - d) / double(n * n));
    }

    return 0;
}


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

using namespace std;


#define ff				first
#define ss				second
#define int				long long
#define pb				push_back
#define mp				make_pair
#define pii				pair<int,int>
#define vi				vector<int>
#define mii 			map<int,int>
#define	pqb				priority_queue<int>
#define pqs				priority_queue<int,vi,greater<int> >
#define setbits(x)		__builtin_popcountll(x)
#define zrobits(x)		__builtin_ctzll(x)
#define mod				1000000007
#define inf 			1e18
#define ps(x,y)			fixed<<setprecision(y)<<x
#define mk(arr,n,type)	type *arr = new type[n]
#define w(x)			int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl			'\n'

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


bool isPrime(int n)
{
	if (n <= 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0 || n % 3 == 0)
		return false;
	for (int i = 5; i * i <= n; i += 6)
	{
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	}
	return true;
}

vector<int> Sieve(int n)
{
	bool prime[n + 1];
	memset(prime, true, sizeof(prime));
	for (int i = 2; i * i <= n; i++)
	{
		if (prime[i])
		{
			for (int j = i * i; j <= n; j += i)
			{
				prime[j] = false;
			}
		}
	}
	vector<int> primes;

	for (int i = 2; i <= n; i++)
	{
		if (prime[i])
			primes.pb(i);
	}
	return primes;
}
map<int, int> primeFactors(int  n)
{
	mii factors;
	while (n % 2 == 0)
	{
		n /= 2;
		factors[2]++;

	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		// int count = 0;
		while (n % i == 0)
		{
			factors[i]++;
			n /= i;
		}
	}
	if (n > 2)
		factors[n]++;
	return factors;
}


// Graph------------------------------------------------------------------------

int32_t main()
{
	FIO;
	// c_p_c();
// --------------------------------------------------
// Never GIVE UP !!!!
	int n, k;
	cin >> n >> k;
	mk(arr, n, int);
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	sort(arr, arr + n, greater<int>());
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (i >= k)
		{
			ans += arr[i];
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 5112
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{   
    long long N, x;
    cin >> N >> x;
    long long a[N];
    for(int i=0; i<N; ++i) cin >> a[i];

    long long count = 0;
    // 2つ組みで検証
    long long dis = 0;
    for(int i=0; i<N-1; ++i){
        dis = a[i] + a[i+1] - x;
        if(dis > 0){
            if(a[i+1] >= dis){
                a[i+1] -= dis;
            }
            else{
                // a[i] -= (dis-a[i+1]);
                a[i+1] = 0;
            }
            count += dis;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int r;
  cin >> r;

  if(r < 1200){
    cout << "ABC\n";
  }else if(r < 2800){
    cout << "ARC\n";
  }else{
    cout << "AGC\n";
  }
  return 0;
}



Measured memory_bytes: 256
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

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

typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef long double           ldb;
const   ll   N = 2e5+5;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         nel            printf("\n");
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"YES"<<"\n";
#define         no             cout<<"NO"<<"\n";
#define         pb             push_back
#define         pii            pair< ll , ll >
#define         ppi            pair< pii , ll >
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int fact(int n)
{
   if(n==0)
      return(1);

   return(n*fact(n-1));
}
int prm(ll n)
{
    ll j=0;
    while (n % 2 == 0)
    {
        j++;
        n = n/2;
    }


    for (ll i = 3; i*i <= n ; i = i + 2)
    {
        while (n % i == 0)
        {
           j++;
            n = n/i;
        }
    }

    if (n > 2)
        j++;

    return j;
}

int main(){Faysal

    ll ans,cnt,sum,mx,mn,chk;

    ll n,q,a,b,x,y,i,j,k;

    cin>>n;
    cnt=1;ans=0;
    while(n>0)
    {
        n/=2;
        ans+=cnt;
        cnt*=2;
    }

    cout<<ans<<endl;

    return 0;

}


Measured memory_bytes: 256
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)
#define     int 	    long long
#define 	pb 	        push_back
#define 	mp 	        make_pair
#define 	pi 	        2*acos(0.0)
#define     scan(i)     scanf("%lld",&i)
#define     scann(i,j)  scanf("%lld%lld",&i,&j)
#define     print(i)    printf("%lld\n",i)
#define     printt(i,j) printf("%lld %lld\n",i,j)
#define     loop(i,n) 	for(int i = 0 ; i <n ; i++)
#define 	vect 	    vector<int>
#define 	vec_it 	    vector<int>::iterator vi
#define     sorta(v)    sort(v.begin(),v.end())
#define     sortd(v)    sort(v.begin(),v.end(),greater<>())
#define 	mapp 	    map<int,int>
#define 	pairr 	    pair<int,int>
#define 	sett	    set<int>
#define 	set_it 	    set<int>::iterator si
#define     map_it      map<int,int> :: iterator mi
#define 	yes 	    cout<<"Yes"<<endl
#define 	no 	        cout<<"No"<<endl
#define 	ff 	        first
#define 	ss 	        second
#define     mx          INT_MAX
#define     lmx         LLONG_MAX
#define     mn          INT_MIN
#define     lmn         LLONG_MIN
#define     GCD         __gcd(a,b)
#define     LCM         (a/GCD)*b
template <typename T> T gcd(T a,T b){return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}
int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }

void solve()
{
  //  freopen ("(input).txt" , "r",  stdin) ;
  //  string st,stt ;
  //  int low=0,high=0;
  //  int l,r;
  //  FAST;
    int n,k,t,b,c,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;
    cin>>n  ; vect v ,a  ; sett s ; set_it ; mapp m ; pairr p; map_it;
    loop(i,n)
    {
        cin>>x;
        if((i+1)%2==1&&x%2==1)
            cnt++;
    }
    cout<<cnt;

}

main()
{
    int t;
  //  cin>>t;
  //  while(t--)
        solve();
}


Measured memory_bytes: 3620
#include<stdio.h>
#define MAX 100
int main()
{
  int i,j,count=0;
  int array[MAX];
  int x,min=0,tmp=0;
 
  scanf("%d",&x);
  for(i=0;i<x;i++)
    {
      scanf("%d",&array[i]);
    }
  for(i=0;i<x;i++)
    { 
      min = i;
      for(j=i;j<x;j++)
	{
	  if(array[j] <array[min])
	    {
	      min = j;
	    }
	}
      if(i!=min)
	{
	  count++;
	  tmp = array[i];
	  array[i] = array[min];
	  array[min] = tmp;
	}
    }
  for(i=0;i<x;i++)
    {
      printf("%d",array[i]);
      if(i != x-1)
	{
	  printf(" ");
	}
      else printf("\n");
    }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d >> s;
  a--; b--; c--; d--;

  bool f;
  // a < c < b < d or a < b < c < d
  if (c < d) {
    f = 1;
    rep(i, d-b) {
      if (s[b+i] == '#' && s[b+i+1] == '#') {
        f = 0;
      }
    }
    rep(i, c-a) {
      if (s[a+i] == '#' && s[a+i+1] == '#') {
        f = 0;
      }
    }
  // a < b < d < c
  } else {
    f = 0;
    for (ll i = b; i <= d; i++) {
      if (s[i-1] == '.' && s[i] == '.' && s[i+1] == '.') {
        f = 1;
      }
    }
  }

  if (f) {
    puts("Yes");
  } else {
    puts("No");
  }
}



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

int main() {
  int N, sum = 0, num = 1;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  while (true) {
    num = a.at(num - 1);
    sum++;
    if (sum > N) {
      sum = -1;
      break;
    }else if (num == 2) {
      break;
    }
  }
  cout <<endl << sum;    
}

Measured memory_bytes: 768
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
#define sz(x) (int)x.size()
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/
const int N=2e5+5;
ll n,q;
vector<ll> g[N];
int visited[N];

ll v[N];
void solve()
{
	string s,t;
	cin>>s>>t;
	int l1=s.size();
	int l2=t.size();
	vector<ll> v[26];
	ll i,j;
	rep(i,0,l1){
		v[s[i]-'a'].pb(i);	
	}
	rep(i,0,l2){
		if(v[t[i]-'a'].size()==0){
			cout<<-1;
			return ;
		}	
	}
	ll ans=0,pre=-1;
	ll cnt=0;
	rep(i,0,l2){
		ll k=t[i]-'a';
		ll pos=upper_bound(all(v[k]),pre)-v[k].begin();
		if(pos==v[k].size()) cnt++,pre=v[k][0];
		else pre=v[k][pos];
	}
	ans=cnt*l1+pre+1;
	cout<<ans<<" ";
}

 
int main() 
{
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 6728
# coding: utf-8

A, B, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = 1000000
for i in range(m):
    x, y, c = map(int, input().split())
    if ans > a[x - 1] + b[y - 1] - c:
        ans = a[x - 1] + b[y - 1] - c

if ans > min(a) + min(b):
    ans = min(a) + min(b)

print(ans)

Measured memory_bytes: 18488
n, m = [int(x) for x in input().split()]
lst = [0]*(n+1)
a = 0
b = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if s == 'AC' and lst[p] is not None:
    a += 1
    b += lst[p]
    lst[p] = None
  elif s == 'WA' and lst[p] is not None:
    lst[p] += 1
print(a,b)

Measured memory_bytes: 3828
#include <iostream>
#include <map>
using namespace std;
int main()
{
    while(1)
    {
        int n,p,d1,d2;
        map<int,int> pat;
        cin>>n;if(!n)return 0;
        for(int i=0;i<n;++i){
            cin>>p>>d1>>d2;
            pat.insert(make_pair(d1+d2,p));
        }
        map<int,int>::iterator it=pat.end();
        it--;
        cout<<(*it).second<<" "<<(*it).first<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String t = sc.nextLine();
		int ans = 0;
		for(int i = 0; i<3; i++) {
			if(s.charAt(i) == t.charAt(i)) ans++;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_set>

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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;
}
template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}

struct Item{
    Item(ll A, ll B) : A(A), B(B){};
    ll A;
    ll B;
    bool operator<(const Item& another) const {
        return A < another.A;
    }
};
int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> h(N);
    rep(i,N){
        cin>>h[i];
    }

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

    ll answer = std::numeric_limits<long long>::max();

    for(int i=0; i<N-K+1; i++) {
        answer = min(h[i + K-1] - h[i], answer);
    }

    cout<<answer<<endl;

}



Measured memory_bytes: 1024
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

//累乗(aのk乗)
ll matpow(ll a,int k){
    ll dp=1,mt=a;
    while(k>0){
        if(k & 1)dp=(dp*mt)%mod;
        mt=(mt*mt)%mod;
        k/=2;
    }
    return dp;
}

int main(){
    int N; cin>>N;
    ll ans = (matpow(10, N) + matpow(8, N) - 2 * matpow(9, N) + 2 * mod) % mod; 
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
    		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int[] value = new int[n];
		int i=0;
		for (;i<value.length; i++){
			value[i] = sc.nextInt();
			if ((value[i]%2==0 && value[i]%3!=0) && (value[i]%2==0 && value[i]%5!=0)){
				break;
			}	//「偶数であるが、3でも5でも割り切れないもの」が出てきた時点でアウト、ループを抜ける
		}
		if (i==n){
			System.out.println("APPROVED");
		} else {
			System.out.println("DENIED");
		}	//全て条件を満たすときだけ上記ループを完遂するはず
		
    	}
  
}

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


    int main(){
        int d, n;
        cin >> d >> n;
            if (d == 0&&n<100)cout << n << endl;
            else if (d == 0 && n == 100)cout << 101 << endl;
            else if (d == 1&&n<100)cout << 100 * n << endl;
            else if (d == 1 && n == 100)cout << 100 * 101 << endl;
            else if (d == 2&&n<100)cout << 10000 * n << endl;
            else if (d == 2 && n == 100)cout << 10000 * 101 << endl;
        
        return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<set<int>> link(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      x--;
      link[i].insert(x);
    } 
  }
  vector<int> light(M);
  for (int &e : light) cin >> e;
  
  int pat = 0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<10> sw(tmp);
    vector<int> on_off(M,0);
    for (int i = 0; i < N; i++) {
      if (sw.test(i)) {
        for (int j = 0; j < M; j++) {
          if (link[j].count(i)) on_off[j] += 1;
        }
      }
    }
    
    bool b = true;
    for (int j = 0; j < M; j++) {
      if (on_off[j]%2 != light[j]) b = false;
    }
    if (b) pat += 1;
  }
    cout << pat << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1000), 1000000)
}

func rcvStr() string {
	sc.Scan()
	return sc.Text()
}

func rcvLongStr() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	_ = rcvStr()
	s := rcvLongStr()

	m := make(map[rune]int, 26)
	for _, ss := range s {
		m[ss]++
	}

	var ans = 1
	for _, mm := range m {
		ans = ans * (mm + 1) % 1000000007
	}
	ans--
	fmt.Println(ans)
}


Measured memory_bytes: 1024