akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x[2020];
cin>>n;
  for(int i=0;i<2*n;i++)
    scanf("%d",x+i);
    sort(x,x+2*n);
int ans=0;
  for(int i=0;i<2*n;i=i+2)
    ans+=x[i];
cout<<ans<<endl;
return 0;
}

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

#define ll long long
#define EPSION numeric_limits<double>::epsilon()
#define REP(i,n) for(int i=0; i<n; ++i)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

//ifstream f("input.in");
//ofstream g("output.out");

signed main(int argc, char **argv)
{
    IOS;

    int a[5];
    int li = 10, num = -1;
    int ans = 0;
    REP(i, 5)
    {
        cin>>a[i];
        if(a[i] % 10 < li && a[i] % 10 >=1)
        {
            num = i;
            li = a[i] % 10;
        }

    }

    REP(i, 5)
    {
        if(i == num)
        {
            ans += a[i];
        }
        else
        {
            if(a[i] % 10 != 0)
                a[i] += 10 - (a[i] % 10);
            ans+= a[i];
        }
    }

    cout<<ans;

    return 0;
}



Measured memory_bytes: 256
use proconio::input;

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

    println!(
        "{}",
        if a.iter().sum::<i32>() >= h {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<map>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){

    int n,m;
    cin>>n>>m;
   vector<pair<int,int>> s[n];
    int si=1;
    int ansm[m+1];
   rep(i,m){
        int p,m;
        cin>>p>>m;
        ansm[i+1]=p;
        s[p-1].push_back(make_pair(m,si));
        si++;
    }

     rep(i,n)   sort(s[i].begin(),s[i].end());
    
    int ans[m+1];
    rep(i,n){
        rep(j,s[i].size()){
            int h=s[i][j].second;
            ans[h]=j+1;
        }
    }
    /*for(int i=1;i<m+1;i++){
        cout<<ansm[i]<<ans[i]<<endl;
    }*/
    for(int i=1;i<m+1;i++){
        printf("%06d",ansm[i]);
        printf("%06d",ans[i]);
        cout<<endl;
    }
   
return 0;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

bool isSame(const string s, const char c)
{
    bool res = true;
    REP(i, s.size())
    {
        if (s[i] != c)
        {
            res = false;
            break;
        }
    }

    return res;
}

int main()
{
    string s;
    cin >> s;
    set<char> candC;
    REP(i, s.size())
    {
        candC.insert(s[i]);
    }

    ll ans = LONG_MAX;
    REPV(it, candC)
    {
        char c = *it;
        bool flag = true;
        if (isSame(s, c))
        {
            ans = 0;
            break;
        }

        string copyS(s);
        ll count = 0;
        while(copyS.size() > 0)
        {
            REP(i, copyS.size() - 1)
            {
                if (copyS[i] == c || copyS[i + 1] == c)
                {
                    copyS[i] = c;
                }
            }
            count++;
            copyS.pop_back();
            if (isSame(copyS, c))
            {
                ans = min(ans, count);
                break;
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5])
        cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
#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 X;
    cin >> X;
    for (int i = X; i <= 100003; ++i) {
        bool flag = true;
        for (int j = 2; j <= i / 2; ++j) {
            if (i % j == 0) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3548
/* monkukui 競技プログラミング用のテンプレート  (ここから) */
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using lnt = long long int;
using Graph = vector<vector<int>>;
using Wgraph = vector<vector<pair<int, long long int>>>;
constexpr long long int INF = 1001001001001001LL;
constexpr long long int MOD = 1000000007LL;
constexpr double PI = 3.1415926535897932;
constexpr long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
constexpr long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
inline void yes(){ cout << "yes" << endl; }
inline void Yes(){ cout << "Yes" << endl; }
inline void YES(){ cout << "YES" << endl; }
inline void no(){ cout << "no" << endl; }
inline void No(){ cout << "No" << endl; }
inline void NO(){ cout << "NO" << endl; }
inline void possible(){ cout << "possible" << endl; }
inline void Possible(){ cout << "Possible" << endl; }
inline void POSSIBLE(){ cout << "POSSIBLE" << endl; }
inline void impossible(){ cout << "impossible" << endl; }
inline void Impossible(){ cout << "Impossible" << endl; }
inline void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = 1; i <= (n); i++)
#define DREP(i,n) for(int i = (n)-1; i >= 0; i--)
#define SREP(i,s,t) for(int i = s; i < t; i++)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define PB push_back

/* monkukui 競技プログラミング用のテンプレート (ここまで)*/

int main(){
  int n; cin >> n;
  string s; cin >> s;
  for(int i = 0; i < s.size(); i++) {
    int id = s[i] - 'A';
    id = (id + n) % 26;
    cout << char(id + 'A');
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int amax = 0;
		int amin = 1000;
		
		
		for(int i = 0; i < N; i++){
			int j = sc.nextInt();
			if(amax < j) amax = j;
			if(amin > j) amin = j;			
		}
		
		System.out.println(amax - amin);
		

		
		
	}

}


Measured memory_bytes: 20948
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,m,i,j,k,x,y,z,Ans,sum,cnt;
LL a[N],b[N];
char c[N];

struct Data{
	LL x,y;
}d[N];

IL LL Abs(LL x){return (x<0)?-x:x;}
IL void Swap(LL &a,LL &b){a^=b^=a^=b;}
IL LL Min(LL a,LL b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MO:0,p=(p*p)%MO,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();
	for (i=1;i<=n;i++)	a[i]=read();
	for (i=1;i<=n;i++)	b[i]=(b[i-1]+a[i])%MO;
	for (i=1;i<n;i++){
		x=(b[n]-b[i]+MO)%MO;
		Ans=(Ans+(x*a[i])%MO)%MO;
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 6700
/* Oh, Lady Moon, shine down a little people magic if you will */

#include <iostream>

#include <vector>

#include <algorithm>

#include <map>

#define fastio ios_base::sync_with_stdio(0);cin.tie(0)

#define rep(i,a,b) for(int i=int(a); i<int(b); i++)

#define rip(i,a,b) for(int i=(int)a; i>=(int)b; i--)

#define pb push_back

#define mp make_pair

#define fst first

#define snd second

#define sz(x) int(x.size())

#define all(v) (v).begin(), (v).end()

#define trace(x) cerr << #x << ": " << x <<endl;



using namespace std;



typedef long long int lli;

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

typedef pair<int, ii> iii;



int main(){

    fastio;

	map<int, int> dp[105];
	ii O[105];
	int n, W;
	scanf("%d%d", &n, &W);
	int w, v;
	rep(i, 0, n){
		scanf("%d%d", &w, &v);
		O[i]={w,v};
	}
	dp[0][0]=0;
	rep(i, 0, n){
		for(auto const &x: dp[i]){
			if(!dp[i+1].count(x.fst)) dp[i+1][x.fst]= x.snd;
			else dp[i+1][x.fst]=min(dp[i+1][x.fst], x.snd);
			int nxtw =x.snd+O[i].fst;
			if(nxtw>W) continue; 
			int nxtv = x.fst+O[i].snd;
			if(!dp[i+1].count(nxtv)) dp[i+1][nxtv]=nxtw;
			else dp[i+1][nxtv]=min(dp[i+1][nxtv], nxtw);
		}
	}
	int ans = 0;
	for(auto const &x: dp[n]) ans=max(ans, x.fst);
	cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 128128
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i, N){
        cin >> A[i];
    }

    ll res = 0;
    int right = 0;
    int sum = 0;
    for (int left = 0; left < N; ++left) {
        while (right < N && (sum ^A[right]) == (sum + A[right])) {
            sum += A[right];
            ++right;
        }
        res += right - left;

        sum -= A[left];

    }

    cout << res << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;//数字を文字列に変換する方が早い

int main(void){
    int N;
    cin>>N;
    int ans=0;
    int keta=0;
    string str;
    for (int i=1;i<=N;i++){
        str = std::to_string(i);
        keta=str.length();
        if (keta%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

bool is_prime(ll n) {
    if (n <= 1) return false;
    for (ll i = 2; i*i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> ans;
    rep(i, 1, 55555) {
        if (is_prime(i) && i % 5 == 1) ans.pb(i);
        if (ans.size() == n) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, a[100], i, j, tmp=0, sum=0;
    scanf("%d\n", &n);
    for (i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    for (i=0; i<=n-2; i++)
    {
        for (j=i+1; j<=n-1; j++)
        {
            if (a[i] > a[j]) {
                tmp = a[j];
                a[j] = a[i];
                a[i] = tmp;
            }
        }
    }
    for (i=0; i<=n-2; i++)
    {
        sum += a[i+1] - a[i];
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007LL;
struct edge {
	int to, rev;
	ll cap;
	edge(int to, ll cap, int rev) :to(to), cap(cap), rev(rev) {}
};
vector<int> dist;
vector<int> itr;
void add_edge(vector<vector<edge>> &G, int from, int to, ll cap) {
	G[from].emplace_back(to, cap, (int)G[to].size());
	G[to].emplace_back(from, 0, (int)G[from].size() - 1);
}
void bfs(vector<vector<edge>> &G, int s) {
	dist.assign(G.size(), -1);
	queue<int> q;
	dist[s] = 0;
	q.push(s);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (auto &e : G[v]) {
			if (e.cap > 0 && dist[e.to] < 0) {
				dist[e.to] = dist[v] + 1;
				q.push(e.to);
			}
		}
	}
}
ll dfs(vector<vector<edge>> &G, int v, int t, ll f) {
	if (v == t) return f;
	for (int &i = itr[v]; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (e.cap > 0 && dist[v] < dist[e.to]) {
			ll d = dfs(G, e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
ll max_flow(vector<vector<edge>> &G, int s, int t) {
	int ret = 0;
	ll f = 0;
	while (bfs(G, s), dist[t] >= 0) {
		itr.assign(G.size(), 0);
		while ((f = dfs(G, s, t, 1 << 30)) > 0) ret += f;
	}
	return ret;
}
int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<edge>> G(H + W, vector<edge>());
	int s_h, s_w;
	int t_h, t_w;
	for (int i = 0; i < H; i++) {
		string line;
		cin >> line;
		for (int j = 0; j < W; j++) {
			if (line[j] == 'S') {
				s_h = i;
				s_w = j;
				add_edge(G, i, j + H, 1 << 30);
				add_edge(G, j + H, i, 1 << 30);
			}
			else if (line[j] == 'T') {
				t_h = i;
				t_w = j;
				add_edge(G, i, j + H, 1 << 30);
				add_edge(G, j + H, i, 1 << 30);
			}
			else if (line[j] == 'o') {
				add_edge(G, i, j + H, 1);
				add_edge(G, j + H, i, 1);
			}
		}
	}
	if (s_h == t_h || s_w == t_w) {
		cout << -1 << endl;
		return 0;
	}
	ll f = max_flow(G, s_h, t_h);
	cout << f << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);
const lli mod = (lli)(1e9 + 7);

lli n, m, x[N], y[N], an1, an2;

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> x[i];
	for(int i = 1; i <= m; i++)
		cin >> y[i];
	for(int i = 1; i <= n - 1; i++) {
		an1 += (n - i) * x[i] % mod - i * x[i + 1] % mod + mod + mod;
		an1 %= mod;
	}
	for(int i = 1; i <= m - 1; i++) {
		an2 += (m - i) * y[i] % mod - i * y[i + 1] % mod + mod + mod;
		an2 %= mod;
	}
	cout << an1 * an2 % mod;

}

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

int V, E, R, s, t, d;
const int Inf = 10000*100000+100;

int main(){
    cin >> V >> E >> R;
    vector<int> dist(V, Inf);
    vector<vector<int>> edges(V), cost(V);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> Q;
    pair<int,int> u, v;
    for(int i = 0; i < E; ++i){
        cin >> s >> t >> d;
        edges[s].push_back(t);
        cost[s].push_back(d);
    }
    dist[R] = 0;
    Q.push(make_pair(0,R));
    while(!Q.empty()){
        u = Q.top();
        Q.pop();
        for(int i = 0; i < edges[u.second].size(); ++i){
            if(dist[edges[u.second][i]] > dist[u.second] + cost[u.second][i]){
                dist[edges[u.second][i]] = dist[u.second] + cost[u.second][i];
                Q.push(make_pair(dist[edges[u.second][i]], edges[u.second][i]));
            }
        }
    }
    for(auto d: dist) d == Inf ? cout << "INF" << endl : cout << d << endl;
    return 0;
}


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

using namespace std;

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

    long long count1 = n/k;
    long long count2 = 0;
    if (k % 2 == 0) {
        for (int i=1; i<=n; i++) {
            if (i % k == (k/2)) {
                count2++;
            }
        }
    }

    long long ans = (count1 * count1 * count1) + (count2 * count2 * count2);
    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll>   pairl;
typedef vector<ll>     vl;
typedef vector<ll>     vll;
typedef vector<vector<ll> > vvl;
const   int            infi = numeric_limits<int>::max();
const   ll             infl = numeric_limits<ll>::max();
const   double         eps = 0;
const   int            ms  = 0;



int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);
    
    int N;
    cin >> N;
    vi A(N);
    vvi X(N), Y(N);
    rep(i, N){
        cin >> A[i];
        vi x(A[i]), y(A[i]);
        rep(j, A[i]){
            cin >> x[j] >> y[j];
        }
        X[i] = x;
        Y[i] = y;
    }

    int ans = 0;
    for(int i = 0; i < (1<<N); i++){
        //debug(i)
        int c = 0;
        vi B(N, -1);
        int f = 1;
        rep(j, N){
            int b = (((1<<j) & i) != 0);
            c+=b;
            //debug(b)
            if(B[j] != -1 && B[j] != b){
                f = 0;
                break;
            }

            B[j] = b;
            if(b == 0)continue;
            rep(k, A[j]){
                int x = X[j][k]-1;
                int y = Y[j][k];
                if(B[x] == -1){
                    B[x] = y;
                }
                else {
                    if(B[x] != y){
                        f = 0;
                        break;
                    }
                }
            }
            if(f == 0)break;
        }
        if(f == 0)c=0;
        ans = max(c, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N, T, A, X;
  cin >> N >> T >> A;
  int res = 0;
  int cc = 1 << 30;
  
  for (int i = 1; i <= N; i++) {
    cin >> X;
    int d = fabs((T*1000-X*6) - A*1000);
    if (cc > d) {
      cc = d;
      res = i;
    }
  }
  
  cout << res << endl;
  
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cmath>
#define PI 3.1415927
#include <vector>

using namespace std;

int main()
{
    int H,W;
    cin>>H>>W;
    char s[H][W];
    for(int i=0;i<H;i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            if(s[i][j]!='#')
                {
                    int c=0;
                    if(i>0&&j>0&&s[i-1][j-1]=='#')c++;
                    if(j>0&&s[i][j-1]=='#')c++;
                    if(i<H-1&&j>0&&s[i+1][j-1]=='#')c++;
                    if(i>0&&s[i-1][j]=='#')c++;
                    if(i<H-1&&s[i+1][j]=='#')c++;
                    if(i>0&&j<W-1&&s[i-1][j+1]=='#')c++;
                    if(j<W-1&&s[i][j+1]=='#')c++;
                    if(i<H-1&&j<W-1&&s[i+1][j+1]=='#')c++;
                    cout<<c;
                }
            else cout<<'#';
        }
        if(i<H-1)cout<<endl;
    }
}

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

using namespace std;
#define lint long long
#define P pair<int, lint>


int main() {
    int N, M;
    cin >> N >> M;
    
    int p[M], y[M];
    vector<vector<int>> lis;
    
    for(int i = 0; i < M; ++i){
        cin >> p[i] >> y[i];
        vector<int> tmp = {y[i], p[i], i};
        lis.push_back(tmp);
    }
    sort(lis.begin(), lis.end());
    
    
    map<int, int> cnt;
    vector<P> ans;
    for(int i = 0; i < M; ++i){
        cnt[lis[i][1]]++;
        lint tmp = (lint)lis[i][1] * 1E6 + cnt[lis[i][1]];
        
        ans.push_back(make_pair(lis[i][2], tmp));
    }
    
    sort(ans.begin(), ans.end());
    
    for(int i = 0; i < M; ++i){
        cout << setfill('0') << right << setw(12) << ans[i].second << endl;
    }
    
    
}

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

int main() {
  string S;
  cin >> S;
    
  if ( S.at(5) == '0' && ( S.at(6) == '4' || S.at(6) == '3' || S.at(6) == '2' || S.at(6) == '1' )) {
    cout << "Heisei" << endl;
  }
  else {
    cout << "TBD" << endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

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

int a, b, c, d, e, f;

int main() {
    cin >> a >> b >> c >> d >> e >> f;
    
    a *= 100;
    b *= 100;

    int bestwater = a; int bestsugar = 0;

    for (int A = 0; A <= f; A += a) {
        for (int B = 0; A+B <= f; B += b) {
            for (int C = 0; A+B+C <= f; C += c) {
                for (int D = 0; A+B+C+D <= f; D += d) {
                    int water = A+B;
                    int sugar = C+D;

                    if (A+B == 0 || A+B+C+D == 0) continue;

                    if (sugar * (e + 100)  <= e * (sugar + water)) {
                        if (sugar * (bestsugar + bestwater) > bestsugar * (sugar + water)) {
                            bestwater = water;
                            bestsugar = sugar;
                        }
                    }
                }
            }
        }
    }

    cout << bestsugar + bestwater << " " << bestsugar << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;


int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n, x;
  cin >> n >> x;
  ll res = n;
  ll a = x, b = n - x;
  while (a!=b && a>0) {
    res += 2 * ((b-1) / a)*a;
    b %= a;
    swap(a, b);
  }
  cout << res+b << endl;
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N,M; cin >> N >> M;
    map<ll, ll> A;
    rep(i,N){
        int Ai; cin >> Ai;
        Ai *= -1;
        if(Ai) A[Ai]++;
        else A[Ai] = 1;
    }
    rep(i,M){
        int B, C; cin >> B >> C;
        C *= -1;
        if(A[C]) A[C] += B;
        else A[C] = B;
    }
    ll sum = 0;
    for(auto p: A){
        auto key = p.first;
        auto val = p.second;
        if(N >= val){
            sum += (-1)*key*val;
            N -= val;
        }
        else{
            sum += (-1)*key*N;
            break;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 12800
A = [int(i) for i in input().split()]

p = max(A)
ans = 0
flag = 1
for i in range(3):
    A[i] = abs(A[i]-p)
    if A[i]%2 == 0:
        ans += A[i]/2
    else:
        ans += (A[i]+1)/2+flag
        if flag:
            flag = 0
        else:
            flag = 1
            ans -= 2
print(int(ans))


Measured memory_bytes: 3060
from sys import stdin


def main():
    S = stdin.readline().rstrip()
    odd = [x for i, x in enumerate(S) if (i + 1) % 2]
    even = [x for i, x in enumerate(S) if not (i + 1) % 2]
    if len([x for x in odd if x == 'L']) or len([x for x in even if x == 'R']):
        print('No')
    else:
        print('Yes')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
int l[1000006], r[1000006];
int main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i){
		scanf("%d %d", &l[i], &r[i]);
		r[i] = -r[i];
	}
	++ n;
	sort(l + 1, l + 1 + n);
	sort(r + 1, r + 1 + n);
	long long ans = 0, sl = 0, sr = 0;
	for (int i = 1; i <= n; ++ i){
		sl += l[n - i + 1];
		sr += r[n - i + 1];
		ans = max(ans, sl + sr);
	}
	cout << 2 * ans << endl;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(void){
  int a,b,c,d,x;
  scanf("%d",&a);
  b=a/500;
  b=b*1000;
  c=a%500;
  d=c/5;
  d=d*5;
  x=b+d;
  printf("%d\n",x);
    return 0;
}

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

signed main(){

  int d;
  vector<int> c(26);
  cin>>d;
  for(auto& ci:c)cin>>ci;
  vector<vector<int>> s(d,vector<int>(26));
  for(auto& si:s)for(auto& sij:si)cin>>sij;

  vector<int> t(d);
  for(auto& ti:t)cin>>ti,ti--;

  vector<int> last(26,0);

  vector<int> v(d);

  auto calc_satisfaction_level = [&](int d,int i){
    int res = s[d][i];
    for(int j=0;j<26;++j){
      if(i==j)continue;
      res -= c[j]*(d-last[j]+1);
    }
    return res;
  };

  for(int i=0;i<d;++i){
    int tmp = calc_satisfaction_level(i,t[i]);
    if(i>0)v[i]=v[i-1]+tmp;
    else v[i] = tmp;
    last[t[i]] = i+1;
  }

  int m;
  cin>>m;
  while(m--){
    int di,qi;
    cin>>di>>qi;
    di--;qi--;
    t[di] = qi;
    for(auto& li:last)li=0;
    for(auto& vi:v)vi=0;
    for(int i=0;i<d;++i){
      int tmp = calc_satisfaction_level(i,t[i]);
      if(i>0)v[i]=v[i-1]+tmp;
      else v[i] = tmp;
      last[t[i]] = i+1;
    }
    cout<< v.back() <<endl;
  }

}

Measured memory_bytes: 3624
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

ll init,take,lim,gain;

bool solve() {
	if(gain<take||init<take) return false;
	ll cur=init;
	if(cur<=lim) {
		if(cur<take) return false;
		ll delta=gain-take;
		if(delta==0) return true;
		cur+=(lim-cur+delta)/delta*delta;
		assert(cur>lim&&cur-delta<=lim);
	}
	assert(cur>lim);
	if(cur>lim) {
		ll delta=take;
		cur-=(cur-lim+delta-1)/delta*delta;
		assert(cur<=lim&&cur+delta>lim);
		if(cur<0) return false;
	}
	ll a=(lim-cur)%take;
	cur+=gain;
	assert(cur>lim);
	if(cur>lim) {
		ll delta=take;
		cur-=(cur-lim+delta-1)/delta*delta;
		assert(cur<=lim&&cur+delta>lim);
		if(cur<0) return false;
	}
	ll b=(lim-cur)%take;
	if(a==b) return true;
	ll d=(b-a+take)%take;
	// a+?*d mod take (except 0 impossible)
	ll g=gcd(d,take);
	//printf("a=%lld b=%lld d=%lld g=%lld take=%lld lim=%lld\n",a,b,d,g,take,lim);
	a+=(take-a-1)/g*g;
	return lim>=a;
}

void run() {
	scanf("%lld%lld%lld%lld",&init,&take,&lim,&gain);
	printf("%s\n",solve()?"Yes":"No");
}

int main() {
	int n; scanf("%d",&n); FORE(i,1,n) run();
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<pi> p(n);
	rep(i, n) cin >> p[i].fi >> p[i].se;
	rep(i, n - 2){
		if(p[i].fi == p[i].se && p[i + 1].fi == p[i + 1].se && p[i + 2].fi == p[i + 2].se){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 3648
#include <iostream>
#include <string.h>
using namespace std;
 
typedef long long ll;
char a[15];
ll v[100], cnt[5];
ll n, ans;
 
int main()
{
    ll i, j, k;
 
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> a;
        v[a[0]]++;
    }
 
    cnt[0]=v['M'];
    cnt[1]=v['A'];
    cnt[2]=v['R'];
    cnt[3]=v['C'];
    cnt[4]=v['H'];
 
    for(i=0; i<5; i++)
        for(j=i+1; j<5; j++)
            for(k=j+1; k<5; k++)
                ans+=cnt[i]*cnt[j]*cnt[k];
 
    cout << ans;
    return 0;
}

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

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    rep(i, n)
    {
        ans = min(ans * 2, ans + k);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}

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

int main(){
	ll n;
	ll ans = 0;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0; i<n; i++){
		cin>>v[i];
	}
	sort(v.begin(), v.end());
	int i,j,k;
	for(i=0;i< n-2; i++){
		j = i+1;
		for(;j<n-1;j++){
			k  = j + 1;
			while(k < n){
				if(v[i] + v[j] > v[k]){
					k++;
					ans++;
				}
				else{
					break;
				}
			}		
		}
	}

	cout<<ans;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(){
	
	int n, k; cin >> n >> k;
	set<int> s;
	for(int i = 0; i < k; ++i){
		int snu; cin >> snu;
		for(int j = 0; j < snu; ++j){
			int tmp; cin >> tmp;
			s.insert(tmp);
		}
	}
	cout << n-s.size() << "\n";
			
}

int main(){
	std::ios::sync_with_stdio(0); std::cin.tie(0);
	
	solve();
		
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>

using namespace std;
using ll = long long;

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

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

  int cnt = 0;
  vector<int> cd;
  for (int i = 1; i <= min(a, b); ++i) {
    if (a % i == 0 && b % i == 0) {
      cd.push_back(i);
      ++cnt;
    }
  }

  cout << cd[cd.size() - k] << '\n';
  return 0;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vl adj[200001];
vl value(200001,0);
vl vis(200001,0);

void dfs(int s, int prev)
{
	if(vis[s])
		return;
	vis[s]=1;
	value[s]=value[s]+value[prev];
	for(auto x : adj[s])
	{
		dfs(x,s);
	}
}
int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    ll n,m;cin>>n>>m;
    for(int i=0; i<n-1; ++i)
    {
    	ll a,b;cin>>a>>b;
    	adj[a].pb(b);
    	adj[b].pb(a);
    }
    while(m--)
    {
    	ll a,val;
    	cin>>a>>val;
    	value[a]+=val;
    }
    dfs(1,0);
    for(int i=1; i<200001; ++i)
    {
    	if(vis[i])
    		cout<<value[i]<<" ";

    }
}

Measured memory_bytes: 22784
#include <iostream>
using namespace std;
const int N = 101, K = 100100;
int dp[K], a[N], n, k;
int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 1; i <= n; i++)cin >> a[i];
	for (int i = 1; i <= k; i++)
		for (int j = 1; j <= n; j++) {
			if (i - a[j] >= 0) {
				if (dp[i - a[j]] == 0)
					dp[i] = 1;
			}
		}
	cout << (dp[k] ? "First" : "Second") << endl; 
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++){
       cin>>a[i];
    }
    long long ans=1e16;
    for(int i=1;i+k-1<=n;i++){
        int l=i,r=i+k-1;
        long long x=min(abs(a[l]),abs(a[r]));
        x+=(a[r]-a[l]);
        ans=min(ans,x);
    }
    cout<<ans << endl;;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        int L = scanner.nextInt();
        int R = scanner.nextInt();
        int d = scanner.nextInt();

        int Ans = 0;
        for (int i = L; i <= R; i++) {
            if (i % d == 0)
                Ans++;
        }

        System.out.println(Ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35648
//C
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long LL;
const int INF=0x3f3f3f3f;

int main(){
    LL n,m,tmp=1;
    cin>>n>>m;
    for(LL i=1;i<=m;i++) tmp*=2;
    cout<<(n-m)*100*tmp+m*1900*tmp<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define inf 1000000000

using namespace std;

struct edge{
	int to, cap, rev;
	edge(int a, int b, int c){
		to = a, cap = b, rev = c;
	}
};

int N, M, L;
int S, T;
int dist[105][105];
int p[1005], t[1005];
vector<edge> G[2005];
bool used[2005];

void WarshallFloyd()
{
	for(int k = 0; k < N; k++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
}

void add_edge(int u, int v)
{
	G[u].push_back( edge(v, 1, G[v].size() ) );
	G[v].push_back( edge(u, 0, G[u].size()-1 ) );
}

int dfs(int v, int c)
{
	if(v == T) return c;
	used[v] = true;
	
	int ret;
	for(int i = 0; i < (int)G[v].size(); i++){
		if(used[G[v][i].to] || G[v][i].cap == 0) continue;
		ret = dfs(G[v][i].to, min(c, G[v][i].cap));
		if(ret > 0){
			G[v][i].cap -= ret;
			G[G[v][i].to][G[v][i].rev].cap += ret;
			return ret;
		}
	}
	return 0;
}

int main(void)
{
	while(1){
		cin >> N >> M >> L;
		if(N == 0 && M == 0 && L == 0) break;
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				dist[i][j] = inf;
				if(i == j) dist[i][j] = 0;
			}
		}
		
		int u, v, d;
		for(int i = 0; i < M; i++){
			cin >> u >> v >> d;
			dist[u][v] = dist[v][u] = d;
		}
		
		WarshallFloyd();
		
		
		for(int i = 1; i <= L; i++){
			cin >> p[i] >> t[i];
		}
		
		S = 0, T = 2 * L + 1;
		for(int i = S; i <= T; i++) G[i].clear();
		for(int i = 1; i <= L; i++){
			add_edge(S, i);
			add_edge(L+i, T);
			for(int j = 1; j <= L; j++){
				if(i == j) continue;
				if(t[i] + dist[p[i]][p[j]] <= t[j]){
					add_edge(i, L+j);
				}
			}
		}
		
		int ret, flow = 0;
		while(1){
			for(int i = S; i <= T; i++) used[i] = false;
			ret = dfs(S, inf);
			if(ret == 0) break;
			flow += ret;
		}
		
		cout << L - flow << endl;	
	}
	
	return 0;
}

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

using namespace std;

using ll = long long;

int INF = 1e9 + 5;

template<typename T>
void max_self(T& a, T b)
{
    a = max(a,b);
}

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

    int N, W;
    scanf("%d%d", &N, &W);
    
    vector<ll> dp(W+1,0);
    
    int weight, value;
    
    for(int i=0; i<N; ++i)
    {
        scanf("%d%d", &weight, &value);
        
        for(int j=W-weight; j>=0; --j)
        {
            max_self(dp[j+weight],dp[j]+value);
        }
    }
    
    ll answer = 0;
    for(int j=0; j<=W; ++j)
    {
        max_self(answer,dp[j]);
    }

    cout << answer;
    
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  int n;
  while(cin >> n, n){
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    double ave = accumulate(a.begin(),a.end(),0);
    ave /= n;
    int ans = 0;
    REP(i,n){
      if(a[i]<=ave) ans++;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		char[] s = sc.next().toCharArray();
		int x = 0, y = 0;
		boolean N = false, S = false, W = false, E = false;
		for (int i = 0; i < s.length; i++) {
			if (s[i] == 'N') {
				N = true;
			} else if (s[i] == 'S') {
				S = true;
			} else if (s[i] == 'E') {
				E = true;
			} else if (s[i] == 'W') {
				W = true;
			}
		}
		System.out.println((N && S && E && W
				|| N & S & !E && !W
				|| !N & !S & E && W) ? "Yes" : "No");
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ABC = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Array.Sort(ABC);
            Console.WriteLine(ABC[2]*10+ABC[0]+ABC[1]);

        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


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

template <typename T>
struct BIT {
    int n;             // 要素数
    vector<T> bit[2];  // データの格納先
    BIT(int n_) { init(n_); }
    void init(int n_) {
        n = n_ + 1;
        for (int p = 0; p < 2; p++) bit[p].assign(n, 0);
    }
 
    void add_sub(int p, int i, T x) {
        for (int idx = i; idx < n; idx += (idx & -idx)) {
            bit[p][idx] += x;
        }
    }
    void add(int l, int r, T x) {  // [l,r) に加算
        add_sub(0, l, -x * (l - 1));
        add_sub(0, r, x * (r - 1));
        add_sub(1, l, x);
        add_sub(1, r, -x);
    }
 
    T sum_sub(int p, int i) {
        T s(0);
        for (int idx = i; idx > 0; idx -= (idx & -idx)) {
            s += bit[p][idx];
        }
        return s;
    }
    T sum(int i) { return sum_sub(0, i) + sum_sub(1, i) * i; }
};

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, K, ans=0, tmp=0;
vector<ll> A, B, C;
set<ll> as;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        a -= K;
        A.push_back(a);
    }
    vector<ll> S(N+1,0);
    as.insert(0);
    for(int i=0;i<N;i++) {
        S[i+1] = S[i] + A[i];
        as.insert(S[i+1]);
    }
    for(set<ll>::iterator itr=as.begin();itr!=as.end();itr++) {
        B.push_back(*itr);
    }
    for(int i=0;i<N+1;i++) {
        ll id = lower_bound(B.begin(), B.end(), S[i])-B.begin();
        C.push_back(id+1);
        //cout << " " << C.back();
    }
    //cout << endl;
    BIT<ll> bit(N+2);
    for(int i=1;i<N+2;i++) {
        ans += bit.sum(C[i-1])-bit.sum(0);
        //cout << ans << endl;
        bit.add(C[i-1], C[i-1]+1, 1);  
        /*      
        for(int j=1;j<N+2;j++) {
            cout << " " << bit.sum(j)-bit.sum(j-1);
        }
        cout << endl;
        */
    }
    /*
    cout << endl;
    bit.add(1, 3, 3);
    for(int i=1;i<N+2;i++) {
        cout << " " << bit.sum(i)-bit.sum(i-1);
    }
    cout << endl;
    bit.add(3, 5, 5);
    for(int i=1;i<N+2;i++) {
        cout << " " << bit.sum(i)-bit.sum(i-1);
    }
    cout << endl;
    bit.add(6, 10, 7);
    for(int i=1;i<N+2;i++) {
        cout << " " << bit.sum(i)-bit.sum(i-1);
    }
    cout << endl;
    for(int i=0;i<N+1;i++) {
        auto itr = ms.find(S[i]);
        if (itr != ms.end()) ms.erase(itr);
        ans += distance(ms.lower_bound(S[i]), ms.end());
        //cout << ans << endl;
    }
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22028
#include <iostream>
using namespace std;
typedef long long ll;

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

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

  ll H[N];
  REP(i, N) cin >> H[i];

  ll ans = 0;
  REP(h, N) {
    REP(i, h) {
      if (H[i] > H[h]) {
        ans -= 1;
        break;
      }
    }
    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256