akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
typedef pair<int, int> P;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n;
  ll a, b;
  cin >> n >> a >> b;
  vecll h(n);
  for (auto &e : h) cin >> e;
  sort(all(h), greater<ll>());
  // for (auto &e : h) cout << e << endl;
  auto check = [&](ll x) -> bool {
    vecll copy(n);
    REP(i, n) { copy[i] = h[i] - b * x; }
    ll cnt = 0;
    REP(i, n) {
      if (copy[i] <= 0) {
        return true;
      }
      cnt += (copy[i] + (a - b - 1)) / (a - b);
      if (cnt > x) {
        return false;
      }
    }
    return true;
  };
  ll l = 0;
  ll r = 1e9 + 1;
  while (r - l > 1) {
    ll c = (l + r) / 2;
    if (check(c)) {
      r = c;
    } else {
      l = c;
    }
  }
  cout << r << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if((A+B)>(C+D)){
	cout << "Left" << endl;
  }
  else if((A+B)==(C+D)){
	cout << "Balanced" << endl;
  }
  else{
	cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <deque>

using namespace std;

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

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

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

	int diff_min = 2e9;
	deque<int> deq;
	for (auto h: hs) {
		if (deq.size() < k) {
			deq.push_back(h);
		} else {
			int diff = abs(deq.front() - deq.back());
			diff_min = min(diff, diff_min);

			deq.pop_front();
			deq.push_back(h);

			diff = abs(deq.front() - deq.back());
			diff_min = min(diff, diff_min);
		}
	}

	cout << diff_min << endl;
	return 0;
}


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

typedef pair<double,double> pd;
vector<pd>vec;
vector<long>used;

bool op(pd p1,pd p2){
    if(p1.first*p2.second-p2.first*p1.second>0)return 0;
    return 1;
}
bool com(pd p1,pd p2){
    return p1.first==p2.first?p1.second<p2.second:p1.first<p2.first;
}

pd minu(pd p1, pd p2){
    return make_pair(p1.first-p2.first, p1.second-p2.second);
}

int main(){
    int n;
    while(cin>>n,n){
        vec.clear();
        used.clear();
        for(int i=0;i<n;i++){
            double x,y;char c;
            cin>>x>>c>>y;
            vec.push_back(make_pair(x, y));
        }
        sort(vec.begin(),vec.end(),com);
        pd last=minu(vec[1],vec[0]), cur;
        used.push_back(0);
        used.push_back(1);
        for(int i=0;i<vec.size();i++){
            cur=vec[i];
            if(find(used.begin(),used.end(),i)!=used.end())
                continue;
            while(op(last,minu(cur,vec[used[used.size()-1]]))){
                used.pop_back();
                last=minu(vec[used[used.size()-1]],vec[used[used.size()-2]]);
            }
            last=minu(cur,vec[used[used.size()-1]]);
            used.push_back(i);
        }
        for(long i=vec.size()-1;i>=0;i--){
            cur=vec[i];
            if(find(used.begin(),used.end(),i)!=used.end()&&i!=0)
                continue;
            while(op(last,minu(cur,vec[used[used.size()-1]]))){
                used.pop_back();
                last=minu(vec[used[used.size()-1]],vec[used[used.size()-2]]);
            }
            if(i!=0){
                last=minu(cur,vec[used[used.size()-1]]);
                used.push_back(i);
            }
        }
        cout<<vec.size()-used.size()<<endl;
    }
}

Measured memory_bytes: 1264
#include <stdio.h>

int main(void)
{
	float x, high = 0.0, low = 10000;
	
	while(scanf("%f",&x) != EOF){
		if(x > high){
			high = x;
		}
		else if(x < low){
			low = x;
		}
	}
	printf("%f\n",high - low);
	return 0;
}

Measured memory_bytes: 640
i, j = map(int, input().split())

if i + 2019 < j:
    print(int(0))
else:
    min_ = 2019
    for a in range(i,j+1):
        for b in range(a+1,j+1):
            min_ = min(min_, ((a%2019)*(b%2019))%2019)
    print(min_)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

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

    int sum = 0;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;

        sum += min(2*x, 2*(K-x));
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
z[999],p[168];
int s(n){
  int i=0,s=0;
  for(;i<168;i++){
    if(!(n%p[i])){
      for(;!(n%p[i]);n/=p[i]);
      if(n==1)return p[i]-s;
      s+=p[i];
    }
  }
  return n-s;
}
main(i,j){
  for(z[0]=z[1]=1;i<999;i++)
    if(!z[i])
      for(j=2*i;j<999;j+=i)
        z[j]=1;
  for(i=j=0;j<999;j++)
    if(!z[j])
      p[i++]=j;
  for(;scanf("%d%d",&i,&j),i;)
    printf("%c\n",'a'+(s(i)<s(j)));
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
int map[10][10], n, m;
int _min(int x, int y) { return x < y ? x : y; }
int main() {
	int i, j, k;
	scanf("%d%d", &n, &m);
	for(i = 0; i < 10; i++) for(j = 0; j < 10; j++) scanf("%d", &map[i][j]);
	for(k = 0; k < 10; k++){
		for(i = 0; i < 10; i++){
			for(j = 0; j < 10; j++) map[i][j] = _min(map[i][k]+map[k][j], map[i][j]);
		}
	}
	int ans = 0;
	for(i = 1; i <= n; i++){
		for(j = 1; j <= m; j++){
			int x;
			scanf("%d", &x);
			if(x != -1) ans += map[x][1];
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {

	long long n;
	cin >> n;

	vector<long long> a(n, (long long)(0));

	long long oddsum = 0;
	long long evensum = 0;
	for (long long i = 0; i < n; i++) {
		cin >> a[i];
		if (i % 2 == 0) {
			evensum += a[i];
		}
		else {
			oddsum += a[i];
		}
	}

	long long x1 = 0;
	x1 = (evensum - oddsum) / 2;

	cout << x1*2 << " ";

	for (long long i = 0; i < n-1; i++) {
		cout << (a[i] - x1)*2 << " ";
		x1 = a[i] - x1;
	}
}

Measured memory_bytes: 2048
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
  double r;
  double I,L;
  scanf("%lf", &r);
  I = r * r * M_PI;
  L = r * 2 * M_PI;

  printf("%.6lf %.6lf\n",I,L);

}

Measured memory_bytes: 2660
#include <iostream>

using namespace std;
int main(){
    int i,num[3],a=0,b=0;

    cin >> num[0]>>num[1]>>num[2];

    for(i=0;i<3;i++){
        if(num[i] == 5){
            a++;
        }
        else if(num[i] == 7){
            b++;
        }
    }
    if((a==2)&&(b==1)){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
from math import sqrt

n = int(input())
for i in range(1, n + 1):
    if i <= 5:
        print(0)
        continue
    cnt = 0
    ub = int(-1 + sqrt(i - 2))
    for y in range(1, ub + 1):
        for z in range(1, ub + 1):
            tmp = 4 * i - 3 * y * y - 3 * z * z - 2 * y * z
            if tmp < 0:
                continue
            s = int(sqrt(tmp))
            if s * s != tmp:
                continue
            if (s - y - z) % 2 != 0:
                continue
            if s > y + z:
                cnt += 1
    print(cnt)


Measured memory_bytes: 68976
N = int(input())
pos = [0,0]
time = 0
for _ in range(N):
    t,x,y = [int(i) for i in input().split()]
    d = abs(pos[0] - x) + abs(pos[1] - y)
    if d > t - time:
        print("No")
        break
    elif (t - time - d)%2 != 0:
        print("No")
        break
    pos = [x,y]
    time = t
else:
    print("Yes")

Measured memory_bytes: 9192
#include<stdio.h>
#define MAX 500000
int queue[MAX];
int head=0,tail=0;
void push(int,int);
int randomAccess(int);
void pop(int);
int main(void)
{
  int i,q,x1,x2,x3;
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&x1);
      switch(x1)
        {
        case 0:
          scanf("%d%d",&x2,&x3);
          push(x2,x3);
          break;
        case 1:
          scanf("%d",&x2);
          printf("%d\n",randomAccess(x2));
          break;
        case 2:
          scanf("%d",&x2);
          pop(x2);
          break;
        }
    }
  return 0;
}

void push(int d,int x)
{
  switch(d)
    {
    case 0:
      head=(head-1+MAX)%MAX;
      queue[head]=x;
      break;
    case 1:
      queue[tail]=x;
      tail=(tail+1)%MAX;
    }
}
int randomAccess(int p)
{
  return queue[(p+head)%MAX];
}
void pop(int p)
{
  switch(p)
    {
    case 0:
      head=(head+1)%MAX;
      break;
    case 1:
      tail=(tail-1+MAX)%MAX;
      break;
    }
}


Measured memory_bytes: 3320
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b;
string x;
int32_t main(){
CODE_START;
cin>>x;
for(ll i=0;i<x.size();i++)
    cout<<'x';
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *prev, *next;
};

Node *nil; //番兵

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

//keyを持つ最初のノードのポインタを返す
Node* listSearch(int key) {
  Node *current = nil->next;
  while ( current != nil && current->key != key ) {
    current = current->next;
  }
  return current;
}

void deleteNode(Node *node) {
  if ( node == nil ) return; //nodeが番兵の時は何もしない
  node->prev->next = node->next;
  node->next->prev = node->prev;
  free(node); //メモリを解放
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

//リストの要素を表示
void print_list() {
  int count = 0;
  Node *current = nil->next;

  while ( 1 ) {
    if (current == nil ) {
      break;
    }
    if (count++ > 0) printf(" ");
    printf("%d", current->key);
    current = current->next;
  }
  printf("\n");
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  scanf("%d", &n); //
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) { insert(key); }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) { deleteFirst(); }
        else if ( com[6] == 'L' ) { deleteLast(); }
      } else {
        deleteKey(key);
      }
    }
  }

  print_list();

  return 0;
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

int main(){
  ll x; cin >> x;
  ll ans = (x/500)*1000;
  x%=500;
  ans += (x/5)*5;
  cout << ans << endl;
}

Measured memory_bytes: 3596
fn main(){
    let v:Vec<_> = getline().trim().split(' ').map(|e| e.parse::<i64>().unwrap()).collect();
    let vx = v[0] - v[2];
    let vy = v[1] - v[3];
    println!("{} {} {} {}", v[2] + vy, v[3] - vx, v[0] + vy, v[1] - vx);
}

fn getline() -> String{
    let mut __ret=String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}


Measured memory_bytes: 4476
import std.algorithm;
import std.conv;
import std.datetime;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main() {
  int lec, loz;

  foreach (string line; stdin.lines) {
    int a, b, c;
    line.formattedRead("%d,%d,%d", &a, &b, &c);

    if (pow(a, 2) + pow(b, 2) == pow(c, 2)) {
      lec++;
    } else if (a == b) {
      loz++;
    }
  }

  writeln(lec, "\n", loz);
}

Measured memory_bytes: 1192
//   //  /////       ///      
//  //   //  //     // //     
// //    //   //   //   //    
////     //   //  //     //   
// //    //   //  /////////    
//  //   //  //   //     //    
//   //  /////    //     //    

#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define iter(it,a,b) for(a::iterator it=b.begin(); it!=b.end();++it)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;
typedef vector<bool> vbool;
typedef priority_queue<p32> pq32;
typedef priority_queue<p32, vector<p32>, greater<p32> > pq32l;

#pragma GCC optimize ("-O2")
const ll LIM = 2e5+5;
const ll MOD = 1e9+7;
const ll inf = 1e16;



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

	int n;
	cin >> n;

	ll a[n];
	forn(i,n) cin >> a[i];

	ll dp[n][n];
	ll cost[n][n];

	forn(i,n){
		forn(j,n-i){
			if(i==0){
				dp[j][j] = a[j];
				cost[j][j] = 0;
			}
			else{
				ll x = dp[j][j] + dp[j+1][j+i];
				ll c = cost[j][j] + cost[j+1][j+i] + x;
				forn(t,i){
					c = min(c, cost[j][j+t] + cost[j+t+1][j+i] + x);
				}
				dp[j][j+i] = x;
				cost[j][j+i] = c;
			}
		}
	}

	cout << setprecision(20) << cost[0][n-1]; 

}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
long long ww[103],cost[103],dp[101][100001];
int n,W;
long long func(long long i, long long w)
{
    long long r1,r2;
    if(i==n+1) return 0;

    if(dp[i][w]!=-1) return dp[i][w];

    if(w+ww[i]<=W)
    {

        r1=cost[i]+func(i+1,w+ww[i]);
    }

    else r1=0;

    r2=func(i+1,w);

    return dp[i][w]= max(r1,r2);
}
int main()
{
    cin>>n>>W;
    for(int i=0;i<101;i++){
        for(int j=0;j<100001;j++){
            dp[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++) cin>>ww[i]>>cost[i];

    cout<<func(0,0)<<endl;
}


Measured memory_bytes: 79104
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a;

int main(){
  cin >> a;
  cout << ((a+1)/2)*(a/2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long N;
	cin >> N;
	vector<long>A(N);
	for (long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long ans = 1, num = A.at(0);
	for (long i = 1; i < N; i++) {
		if (A.at(i) < num) {
			ans++;
			num = A.at(i);
		}
	}
	cout << ans << endl;
}


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

int main()
{
    ll n,i,j,cnt=1,k,w,a,b,h,m;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
    cin>>n>>m;
    if(m==n)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
	    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<int>vs(N);
		for (int i = 0; i < N; ++i) {
			cin >> vs[i];
		}
		int time = 0;
		while (1) {
			map<int, int>mp;
			for (int i = 0; i < N; ++i) {
				mp[vs[i]]++;
			}
			vector<int>nexvs(N);
			for (int i = 0; i < N; ++i) {
				nexvs[i] = mp[vs[i]];
			}
			if (vs == nexvs)break;
			vs = nexvs;
			time++;
		}
		cout << time << endl;
		for (int i = 0; i < N; ++i) {
			cout << vs[i];
			if (i != N - 1)cout << " ";
			else cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}

int main() {
	int a, b;
	top = 0;
	char s[100];

	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());

	return 0;
}


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

using namespace std;

#define MAX_N 100
#define MAX_V 2000
#define INF 1e9

int V,match[MAX_V];
vector<int> G[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    int u = G[v][i],w = match[u];
    if(w < 0 || (!used[w] && dfs(w))){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v = 0 ; v < V ; v++){
    if(match[v] < 0){
      memset(used,false,sizeof(used));
      if(dfs(v)){ res++; }
    }
  }
  return res;
}

void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
  }
}

int main(){
  int N,M,L,a,b,c;
  while(cin >> N >> M >> L, N){
    int d[MAX_N][MAX_N];
    for(int i = 0 ; i < N ; i++){
      for(int j = 0 ; j < N ; j++){
        d[i][j] = (i != j ? INF : 0);  
      }
    }
    for(int i = 0 ; i < M ; i++){
      cin >> a >> b >> c;
      d[a][b] = d[b][a] = c;
    }

    int p[L],t[L];
    for(int i = 0 ; i < L ; i++){
      cin >> p[i] >> t[i];
    }
    for(int i = 0 ; i < L ; i++){
      for(int j = L-1 ; j > 0 ; j--){
        if(t[j] < t[j-1]){
          swap(t[j],t[j-1]);
          swap(p[j],p[j-1]);
        }
      }
    }
    for(int k = 0 ; k < N ; k++){
      for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < N ; j++){
          d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
        }
      }
    }
    init(); V = L;
    for(int i = 0 ; i < L ; i++){
      for(int j = i+1 ; j < L ; j++){
        if(d[p[i]][p[j]] <= t[j]-t[i]){
          add_edge(i,j+L);
        }
      }
    }
    cout << L-bipartite_matching() << endl;
  }
  return 0;
}

Measured memory_bytes: 8132
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int a[N];
int main()
{
	int n,k,m,x,y,z;
	scanf("%d%d",&n,&m);
	if(n-m>m){cout<<0<<endl;return 0;}
	cout<<n-m;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from functools import lru_cache

n, k = map(int, read().split())


@lru_cache()
def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt


print(check(n, k))


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll> Pll;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,X;cin>>N>>X;
  vector<tuple<ll,ll,ll,ll> > tmp(N);
  for(ll i=0;i<N;i++){
    ll b,l,u;
    cin>>b>>l>>u;
    tmp[i]=make_tuple(u*(X-b)+l*b,b,l,u);
  }
  sort(tmp.begin(),tmp.end());
  ll low=-1,high=X*N;
  while(high-low>1){
    ll mid=(high+low)/2;
    ll q = mid/X;
    ll r = mid-q*X;
    ll sum1=0,sum2=0;
    bool isok=false;
    for(ll i=0;i<N;i++){
      ll a,b,l,u;
      tie(a,b,l,u)=tmp[i];
      if(i<N-q){
        sum1 -= l*b;
      }else{
        sum1 += u*(X-b);
      }
      if(i<N-(q+1)){
        sum2 -= l*b;
      }else{
        sum2 += u*(X-b);
      }
    }
    for(ll i=0;i<N;i++){
      ll a,b,l,u;
      tie(a,b,l,u)=tmp[i];
      ll sum;
      if(i<N-q){
        sum = sum1;
        sum += l*b;
      }else{
        sum = sum2;
        sum -= u*(X-b);
      }
      if(r>=b){
        sum += u*(r-b);
      }else{
        sum += l*(r-b);
      }
      isok |= sum>=0;
    }
    if(isok){
      high=mid;
    }else{
      low=mid;
    }
  }
  cout<<high<<endl;
  return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <map>
#include <vector>
#include <cstring>

using namespace std;

using ll = long long;
constexpr ll MAX = 514;
constexpr ll UNVISITED = (1 << 25);

struct Edge {
    ll to, cost;
    Edge() {}
    Edge(ll to, ll cost) :
        to{to}, cost{cost} {}
};

vector<Edge> G[MAX];
ll dist[MAX];

bool dfs(ll v, ll p, ll d)
{
    if (dist[v] != UNVISITED) {
        return (dist[v] != d);
    }
    
    dist[v] = d;
    for (const auto& g : G[v]) {
        if (g.to == p) continue;
        if (dfs(g.to, v, d + g.cost)) {
            return true;
        }
    }
    return false;
}

bool run()
{
    ll N;
    cin >> N;
    if (N == 0) {
        return false;
    }

    for (ll i = 0; i < MAX; i++) {
        G[i].clear();
    }
    
    ll n = 0;
    map<string, ll> s2i;
    
    string t, u, v;
    for (ll i = 0; i < N; i++) {
        cin >> u >> u;

        if (s2i.count(u) == 0) {
            s2i[u] = n++;
        }
        
        cin >> t >> t >> v;
        t = t.substr(3);

        if (s2i.count(v) == 0) {
            s2i[v] = n++;
        }
        
        ll num = stoi(t);        
        G[s2i[v]].emplace_back(s2i[u], -num);
        G[s2i[u]].emplace_back(s2i[v], num);
    }
   
    bool ok = 1;
    for (ll i = 0; i < n; i++) {
        fill(dist, dist + MAX, UNVISITED);
        if (dfs(i, -1, 0)) {
            ok = 0;
            break;
        }
    }
    cout << (ok ? "Yes" : "No") << endl;
    return true;
}

int main()
{
    while (run())
        ;
    return 0;
}

Measured memory_bytes: 3048
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int nMax=3*1e5+10;
const int Mod=1e9+7;
int jc[3*nMax],_jc[3*nMax],bin[3*nMax];
int power(int a,int b)
{
	if(b==0)
		return 1;
	int c=power(a,b>>1);
	c=(long long)c*c%Mod;
	if(b%2)
		c=(long long)c*a%Mod;
	return c;
}
void work()
{
	jc[0]=1;
	for(int i=1;i<3*nMax;i++)
		jc[i]=(long long)jc[i-1]*i%Mod;
	_jc[3*nMax-1]=power(jc[3*nMax-1],Mod-2);
	for(int i=3*nMax-2;i>=0;i--)
		_jc[i]=(long long)_jc[i+1]*(i+1)%Mod;
	bin[0]=1;
	for(int i=1;i<3*nMax;i++)
		bin[i]=(bin[i-1]<<1)%Mod;
}
int _c(int a,int b)
{
	if(b==0)
		return 1;
	int ans=jc[b];
	ans=(long long)ans*_jc[b-a]%Mod;
	ans=(long long)ans*_jc[a]%Mod;
	return ans;
}
int n,m,k,ans;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	work();
	if(m>k)
		swap(m,k);
	for(int i=0;i<=m;i++)
		ans=(ans+((long long)bin[i]*_c(i,i+n-1)%Mod*power(3,n+m+k-i-n))%Mod)%Mod;
	int last=bin[m];
	for(int i=m+1;i<=m+k;i++)
	{
		last=(last<<1)%Mod;
		last-=_c(m,i-1);
		if(i-k>0)
			last-=_c(i-k-1,i-1);
		last=(last%Mod+Mod)%Mod;
		ans=(ans+(long long)last*_c(i,i+n-1)%Mod*power(3,n+m+k-i-n)%Mod)%Mod;
	}
	printf("%d\n",ans);
	return 0;
}

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

#define int long long

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)

int modpow(int x, int y, int z) { int a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }

const int M = 998244353;
int a[310];
int d[90310];
int e[90310];

signed main() {
  int n;
  scanf("%lld", &n);
  int sum = 0;
  d[0] = 1;
  REP(i, n) {
    scanf("%lld", a + i);
    RREP(t, sum + 1) {
      (d[t + a[i]] += d[t]) %= M;
      (d[t] *= 2) %= M;
    }
    sum += a[i];
  }
  int ans = modpow(3, n, M);
  FOR(t, (sum + 1) / 2, sum + 1) {
    ans = (ans - d[t] * 3) % M;
  }
  if ((sum & 1) == 0) {
    int u = 0;
    e[0] = 1;
    REP(i, n) {
      RREP(t, min(sum / 2, u + 1)) {
        (e[t + a[i]] += e[t]) %= M;
      }
      u += a[i];
    }
    ans = (ans + e[sum / 2] * 3) % M;
  }
  ans = (ans + M) % M;
  printf("%lld", ans);
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename T, typename Can> T bsearch(T L, T R, Can&& can, bool left_feasible = true) {
    static_assert(is_convertible<decltype(can), function<bool(T)>>::value, "can must be bool(T)");
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = L + (R - L) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    string s;
    cin >> n >> k >> s;
    vector<int> flip(s.size(), s[0] == '0');
    for(int i = 1; i < s.size(); i++) {
        flip[i] = s[i] != s[i - 1] and s[i] == '0';
    }
    partial_sum(flip.begin(), flip.end(), flip.begin());
    int ans = 0;
    for(int L = 0; L < s.size(); L++) {
        int R = bsearch<int>(L, s.size(), [&](int R) {
            return (s[L] == '0' and L and s[L] == s[L-1]) + flip[R] - (L ? flip[L - 1] : 0) <= k;
        });
        ans = max(ans, R - L + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n;
char s[4005];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>s[i];
	int ans=0;
	int r=0,g=0,b=0;
	for(int i=1;i<=n;i++)
		if(s[i]=='R')
			r++;
		else if(s[i]=='G')
			g++;
		else
			b++;
	ans=r*g*b;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			int x=i,y=i+j,z=i+2*j;
			if(x<=n&&y<=n&&z<=n&&s[x]!=s[y]&&s[y]!=s[z]&&s[x]!=s[z])
				ans--;
		}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int N;
  int d[110];

  cin >> N;
  for(int i=0;i<N;i++){
    cin >>d[i];
  }

  int num[110] = {0};
  for(int i=0;i<N;i++){
    num[d[i]]++;
  }
  int res=0;
  for(int i=1;i<=100;i++){
    if(num[i]){
      res++;
    }
  }
  cout << res << endl;
}
		


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,p,i,cnt=0,cnt1=0;
	cin>>n>>m;
	int ara[n];
	memset(ara,0,sizeof(ara));
	string s,s1="AC";
	for(i=0;i<m;i++){
		cin>>p>>s;
		if(ara[p-1]!=-1){
			if(s==s1){
				cnt1+=ara[p-1];
				cnt++;
				ara[p-1]=-1;
			}
			else{
				ara[p-1]++;
			}
		}
	}
	cout<<cnt<<" "<<cnt1<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    string s;cin >> s;
    ll dp[s.size()+1][2];
    dp[0][0]=0;dp[0][1]=1;
    rep(i,s.size()){
        ll d=s[i]-'0';
        dp[i+1][0]=min(dp[i][0]+d,dp[i][1]+(10-d));
        dp[i+1][1]=min(dp[i][0]+d+1,dp[i][1]+(10-d-1));
    }
    cout << dp[s.size()][0] <<endl;
}

Measured memory_bytes: 20064
#include<stdio.h>
int main(void){
  int n;
  int m[200000]={0};
  int a[200000];
  
  scanf("%d",&n);
  for(int i=0;i<n-1;i++){
    scanf("%d",&a[i]);
    m[a[i]-1]++;
  }
  for(int j=0;j<n;j++){
    printf("%d\n",m[j]);
  }
  return 0;
}

Measured memory_bytes: 3248
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
using mpint = mp::cpp_int; // 多倍長整数（任意精度）

/*
 * 定数
 */
const long double PI = (acos(-1));
const long double EPS = 1e-10;
const long long INF = 1e18;

/*
 * データ変換 
 */
/* char -> int */
int ctoi(char c) { return (int)(c - '0'); }

/*
 * 数学的な計算
 */
/* 階乗 */
int factorial(int n){ int ret = 1; for(int i = 1; i < n + 1; ++i) { ret = ret * i; } return ret; }

/* 最大公約数 */
template <typename T>T gcd(T x, T y){ return x % y == 0 ? y : gcd(y, x % y); }

/* 最小公倍数 */
template <typename T>T lcm(T a, T b) { return a * b / gcd(a, b); }

/* n個の整数の最小公倍数 */
template <typename T>T lcm_n(vector<T> &numbers) { T l; l = numbers[0]; for(int i = 1; i < numbers.size(); ++i) { l = lcm(l, numbers[i]); } return l; }

/*
 * DP向け
 */
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; }

/*
 * グラフ
 */
class Graph {
   public:
    vector<vector<int>> G;
    vector<int> Trans;
    vector<int> inDeg;
    int numV;
 
    Graph(int numV) {
        this->numV = numV;
        inDeg.assign(numV, 0);
        Trans.assign(numV, 0);
        G.assign(numV, vector<int>());
    }
 
    int topologicalSort(int v, vector<int> &dp) {
        if (dp[v] != -1) {
            return dp[v];
        }
 
        int res = 0;
 
        for (auto to : G[v]) {
            chmax(res, topologicalSort(to, dp) + 1);
        }
 
        return dp[v] = res;
    }
};

#define layer_name(n) l ## n

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

  // vector<vector<vector<bool>>> is_searched(N, vector<vector<bool>>(N, vector<bool>(1, false)));
  // vector<vector<vector<bool>>> parent(N, vector<vector<bool>>(N, vector<bool>(1, false)));

  // int depth = 0;
  // int alphabet = 0;


  // while(1){
  //   // 文字出力後、探索リストが全部trueなら親に戻る

  //   // まだ探索してないなら
  //   if(!is_searched[depth][alphabet])

  //   // N文字目がN番目のアルファベットなら終了する
  // }

  // 1こ前の層
  vector<string> l1(1, "a");
  vector<string> m1(1, "a");

  // ここは、"aa", "ab"がくる
  vector<string> l2(1, "a");
  vector<string> m2(1, "a");



  for(int i = 1; i < N; ++i){
    // l1にl2を格納する
    l1.resize(l2.size());
    m1.resize(m2.size());

    for(int l_index = 0; l_index < l2.size(); ++l_index){
      l1[l_index] = l2[l_index];
      m1[l_index] = m2[l_index];
    }
    l2.resize(0);
    m2.resize(0);
    // 新しいレイヤーの数を計算する
    // 前の層を全部見る
    for(int l1_index = 0; l1_index < l1.size(); ++l1_index){
      // 前の層のある値の最大文字からその層に伸びる数を計算する
      int d = m1[l1_index][0] - 'a';

      for(int j = 0; j < d+2; ++j){
        char tmp = 'a' + j;
        string c{tmp};
        l2.push_back(l1[l1_index] + c);

        if(m1[l1_index][0] < c[0]){
          m2.push_back(c);
        }else{
          m2.push_back(m1[l1_index]);
        }
      }
    }
  }

  for(auto v : l2){
    cout << v << endl;
  }


  return 0;
}


Measured memory_bytes: 16872
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n,m; cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m; i++){
        int a; cin >> a;
        sum += a;
    }
    int ans = (n-sum >= 0) ? n-sum : -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
class UnionFind():
    n=1
    par=[0]
    rnk=[0]
    def __init__(self,size):
        self.n=size
        self.par=[i for i in range(self.n)]
        self.rnk=[0 for i in range(self.n)]
    def find(self,vertex1):
        if self.par[vertex1]==vertex1:
            return vertex1
        else:
            self.par[vertex1]=self.find(self.par[vertex1])
            return self.par[vertex1]
    def unite(self,vertex1,vertex2):
        vertex1=self.find(vertex1)
        vertex2=self.find(vertex2)
        if vertex1==vertex2:
            return
        if (self.rnk[vertex1]<self.rnk[vertex2]):
            self.par[vertex1]=vertex2
        else:
            self.par[vertex2]=vertex1
            if(self.rnk[vertex1]==self.rnk[vertex2]):
                self.rnk[vertex1]+=1
    def same(self,vetrex1,vertex2):
        return self.find(vetrex1)==self.find(vertex2)

N,M=map(int,input().split())
A=[0 for i in range(M)]
B=[0 for i in range(M)]
for i in range(M):
    A[i],B[i]=map(int,input().split())
    A[i]-=1;B[i]-=1
G=UnionFind(N)
D=dict()
for i in range(N):
    D[i]=1
ans=[(N*(N-1))//2]
for i in range(M)[::-1]:
    #print([G.find(i) for i in range(N)],A[i],B[i],D,ans[-1])
    a=G.find(A[i])
    b=G.find(B[i])
    G.unite(A[i],B[i])
    x=G.find(A[i])
    if a!=b:
        ans.append(ans[-1]-D[a]*D[b])
        if x==a:
            D[a],D[b]=D[a]+D[b],0
        else:
            D[a],D[b]=0,D[a]+D[b]
    else:
        ans.append(ans[-1])
for line in ans[:-1][::-1]:
    print(line)

Measured memory_bytes: 115872
#include<bits/stdc++.h>
using namespace std;
int main() 
{
    long long int n,m,k;
    cin>>n>>m>>k;
    long long int a[n];
    long long int b[m];
    for(long long int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(long long int i=0;i<m;i++)
    {
        cin>>b[i];
    }
    long long int pa[n],pb[m];
    pa[0]=a[0];
    pb[0]=b[0];
    for(long long int i=1;i<n;i++)
    {
        pa[i]=pa[i-1]+a[i];
    }
    for(long long int i=1;i<m;i++)
    {
        pb[i]=pb[i-1]+b[i];
    }
    long long int ans=0;
    
    auto ub1=upper_bound(pa,pa+n,k);
    long long int temp=ub1-pa;
    ans=max(ans,temp);

    auto ub2=upper_bound(pb,pb+m,k);
    temp=ub2-pb;
    ans=max(ans,temp);

    for(long long int i=0;i<n;i++)
    {
        if(k>=pa[i])
        {
            auto ub=upper_bound(pb,pb+m,k-pa[i]);
            long long int x=ub-pb;
            ans=max(ans,i+1+x);
        }
        else
        {
            break;
        }
    }
    for(long long int i=0;i<m;i++)
    {
        if(k>=pb[i])
        {
            auto ub=upper_bound(pa,pa+n,k-pb[i]);
            long long int x=ub-pa;
            ans=max(ans,i+1+x);
        }
        else
        {
            break;
        }
    }
    cout<<ans;
    

           
return 0;
}


Measured memory_bytes: 9768
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int[] HW = ReadIntArray();
    int[] hw = ReadIntArray();
    int a = hw[0] * HW[1] + hw[1] * HW[0];
    int b = a - hw[0]*hw[1];
    int res = HW[0] * HW[1] - b;
    Console.WriteLine(res);
  }

  private static string ReadStr() { return Console.ReadLine(); }
  private static int ReadInt() { return int.Parse(Console.ReadLine()); }
  private static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  private static long ReadLong() { return long.Parse(Console.ReadLine()); }
  private static char ReadChar() { return Console.ReadLine()[0]; }
  private static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  private static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  private static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  private static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  private static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  private static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13268
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = 0;
    String s = sc.next();
    for (int i = 0;i<4;i++) {
      if ((s.charAt(i))=='+') a++;
      else a--;
    }
    System.out.println(a);
  }
}


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


int ispal(string s, int i ,int j)
{
    while(i<=j)
    {
        if(s[i]!=s[j])
        return 0;
        i++;
        j--;
    }
    return 1;
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
	string s;
	cin>>s;
	int n = s.length();
	int a_lim = (n-1)/2;
	int a_st = (n+3)/2;
	if(ispal(s, 0,n-1) and ispal(s, 0, a_lim-1) and ispal(s, a_st-1, n-1))
	cout<<"Yes\n";
	else
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int h,w;
    cin >>h >> w;
    lint ans = 0;
    vector<vector<int>> cost(10,vector<int>(10,INF));
    REP(i,10){
        REP(j,10){
            cin >> cost[i][j];
        }
    }
    REP(i,10){
        REP(j,10){
            REP(k,10){
                cost[j][k] = min(cost[j][k] , cost[j][i] + cost[i][k]);
            }
        }
    }

    REP(i,h){
        REP(j,w){
            int a;
            cin >> a;
            if(a != -1){
                ans += cost[a][1];
            }
        }
    }
    println(ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
#include<vector>
#include<set>

using namespace std;

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int>a(m), b(m);
	for (int i = 0; i < m; i++)cin >> a[i] >> b[i];
	vector<int>ans(n);
	for (int i = 0; i < m; i++) {
		if (a[i] != NULL && b[i] != NULL) {
			ans[a[i] - 1]++;
			ans[b[i] - 1]++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
using namespace std;
#define REP(i,n) for(int i=0;i<signed(n);i++)
const ll MOD = 1000000007;
const ll INF = 9e9;
ll N,M,ans=INF;
ll A[300010],S[301000];

int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        S[i]+=A[i];
        S[i+1]=S[i];
    }
    //a:右半分の区切り i:真ん中 b:左半分
    //s:右の和 t:左の和
    ll a=0,b=2,s,t;
    REP(i,N-1){
        if(i==b)b++;
        s=(S[i]-S[a])-S[a];
        t=(S[N-1]-S[b])-(S[b]-S[i]);
        bool f=true;
        if(i==0)continue;
        while(f){
            f=false;
            if(a+1==i)continue;
            if(abs(s)>abs(s-A[a+1]*2)){
                s-=A[a+1]*2;
                a++;f=true;
            }
        }
        f=true;
        while(f){
            f=false;
            if(b+1==N-1)continue;
            if(abs(t)>abs(t-A[b+1]*2)){
                t-=A[b+1]*2;
                b++;f=true;
            }
        }
        ans=min( ans,( max({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]})
        -min({S[a],S[i]-S[a],S[b]-S[i],S[N-1]-S[b]}) ) );
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3840
import sys
from functools import reduce
from math import sqrt

while True:
    n = int(sys.stdin.readline())
    if n == 0:
        break
    s = [int(i) for i in sys.stdin.readline().split()]
    m = sum(s) / n
    print(sqrt(sum(map(lambda x: (x - m) ** 2, s)) / n))

Measured memory_bytes: 6840
#include <stdio.h>

int main (void)
{
    char X;
    scanf("%c", &X);
    switch (X) {
        case 'A':
            printf("T");
            break;
        case 'T':
            printf("A");
            break;
        case 'C':
            printf("G");
            break;
        case 'G':
            printf("C");
            break;
        default:
            break;
    }

    return 0;
}

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

int main(){
  vector<int> days = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  vector<string> week = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  while(true){
    int m, d; cin >> m >> d;
    if(m == 0 && d == 0) break;

    int ans = d;
    for(int i=0; i<m-1; i++) ans += days[i];
    
    cout << week[(ans + 2) % 7] << endl;
  }
}
  
  


Measured memory_bytes: 3168
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            var n = int.Parse(line.Trim());
            var f = new bool[n + 1];
            generatePrime(f);
            Console.WriteLine(f.Where(x =>x == false).Count());
        }
    }
    public static void generatePrime(bool[] f)
    {
        var pL = f.Length;                                           // prime :  false
        f[0] = true; f[1] = true;
        for (int i = 2; i < pL; i++)
            if (!f[i])
                for (int j = i + i; j < pL; j += i)
                     f[j] = true;
    }
}



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

int main(){
	ll N;
	cin >> N;
	cout << (N*(N-1))/2;
}



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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  int ans;
  
  vector<int> a(A), b(B);
  REP(i,A)
    cin >> a.at(i);
  REP(i, B)
    cin >> b.at(i);
  
  ans = *min_element(a.begin(), a.end()) + *min_element(b.begin(), b.end());
  
  REP(i, M) {
    int x, y, c;
    cin >> x >> y >> c;
    
    ans = min(ans, a.at(x - 1) + b.at(y - 1) - c);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {

	ll N, A, B, C, D, X, H, W;
	char S[1000], T[1000];
	scanf("%lld", &N);


	ll ans = 0;

	ll near = sqrt(N);

	for (ll i = near; i < 10000000; i--) {
		if (N%i == 0) {
			ll pear = N / i;
			printf("%lld", i + pear -2);
			break;
		}
	}


}



Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        int[,] path = new int[m,2];
        List<int>[] pa = new List<int>[n];
        for(int i=0; i<n; i++){
          	pa[i] = new List<int>();
        }
        for(int i=0; i<m; i++){
            string[] input2 = Console.ReadLine().Split(' ');
            path[i,0] = int.Parse(input2[0]);
            path[i,1] = int.Parse(input2[1]);
            pa[path[i,0]-1].Add(path[i,1]);
            pa[path[i,1]-1].Add(path[i,0]);
        }

        int[] dist = new int[n];
        int[] prev = new int[n];

        var que = new Queue<int>();
        que.Enqueue(1);
        while(que.Count > 0){
            int current = que.Peek();
            que.Dequeue();

            foreach (int item in pa[current-1])
            {
                if(dist[item-1] == 0) {
                    que.Enqueue(item);
                    dist[item-1] = dist[current-1] + 1;
                    prev[item-1] = current;
                }
            }
        }
        for(int i=1; i<n; i++){
            if(prev[i] == 0) {
              Console.WriteLine("No");
              return;
            }
        }
        Console.WriteLine("Yes");
        for(int i=1; i<n; i++){
            Console.WriteLine(prev[i]);
        }
	}   
}


Measured memory_bytes: 36740