akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
using namespace std;

void swap(int &i, int &j) {
    if (j < i) {
        int tmp = i;
        i = j;
        j = tmp;
    }
}

int main() {

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        swap(a, b);
        swap(a, c);
        swap(b, c);
        if (pow(c, 2) == (pow(a, 2) + pow(b, 2))) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

using P=complex<double>;

int main(){
    int n;
    while(cin>>n,n){
        int ans=1;
        vector<P> c(n);
        rep(i,n) { double p,q; cin>>p>>q; c[i]=P(p,q); }
        rep(i,n)range(j,i+1,n){
            P v=c[i]-c[j];
            double d=abs(v);
            if(d>2.0) continue;
            P med=(c[i]+c[j])/2.0;
            P nml=v/d*P(0,1)*sqrt(1-d*d/4);
            P r1=med+nml;
            P r2=med-nml;
            int s1=0,s2=0;
            rep(k,n){
                s1+=(abs(r1-c[k])<=1.0+1e-6);
                s2+=(abs(r2-c[k])<=1.0+1e-6);
            }
            ans=max(ans,max(s1,s2));
        }
        cout<<ans<<endl;
    }
	return 0;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    ll H,W; cin >> H >> W;
    ll dp[H][W]={};
    char c[H][W];
    rep(i,H){
        rep(j,W){
            cin >> c[i][j];
        }
    }
    rep(i,H){
        if(c[i][0]=='.')dp[i][0]=1;
        else break;
    }
    rep(i,W){
        if(c[0][i]=='.')dp[0][i]=1;
        else break;
    }
    for(int i=1;i<H;i++){
        for(int j=1;j<W;j++){
            if(c[i][j]=='#')dp[i][j]=0;
            else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout << dp[H-1][W-1] << endl;

}

/*



 */



Measured memory_bytes: 9088
import itertools
n,m = map(int, input().split())
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(lambda x:int(x)-1, input().split())
    g[a].append(b)
    g[b].append(a)
cnt = 0
if n == 2:
    if 1 in g[0]:
        print(1)
    else:
        print(0)
    exit()
for p in itertools.permutations(range(1,n)):
    if p[0] in g[0]:
        flag = True
        for i in range(n-2):
            if p[i+1] not in g[p[i]]:
                flag = False
                break
        if flag:
            cnt += 1
print(cnt)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <valarray>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <string>
#include <tuple>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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

int main()
{
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (int i = 0; i < m; ++i)
  {
    int x, y, z;
    cin >> x >> y >> z;
    x--, y--;
    uf.unite(x, y);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    if (uf.data[i] < 0)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    a_arr.sort(reverse=True)
    alice_card = a_arr[0::2]
    bob_card = a_arr[1::2]
    cnt = sum(alice_card) - sum(bob_card)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 38256
#include <stdio.h>
int main ()
{
	int N,Q,A[10000],B[100000];
	int cnt=0;
	scanf("%d",&N);
	for(int i = 0;i<N;i++)	{
		scanf("%d",&A[i]);
	}
	scanf("%d",&Q);
	for(int i=0;i<Q;i++)	{
		scanf("%d",&B[i]);
		for(int j=0;j<N;j++)
		{
			if(A[j]==B[i]){
			 cnt++;
			 break;
			 }
		}
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int n,k;
   cin >> n >> k; 
   cout << (n%k==0 ? 0 : 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int res = 0;
  for (int i = 0; i < n - 1; ++i) {
    res += s[i] == s[i + 1];
  }
  cout << min(res + 2 * k, n - 1) << '\n';
}

Measured memory_bytes: 512
N = int(input())
s = [int(input()) for x in range(N)]

mn = 100
sm = sum(s)

for i in s:
    if i % 10:
        mn = min(mn, i)

if sm % 10:
    print(sm)
elif mn == 100:
    print(0)
else:
    print(sm - mn)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define F first
#define S second
#define dq deque
#define vc vector
#define INF ((int)(1e9))
#define LINF ((ll)(1e18))
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define B cout << "BreakPoint" << endl;
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print(int _x){printf("%d ",_x);}
void print(ll _x){printf("%I64d ",_x);}
_tp<_tyn T>void print( T _a[] , int _s , int _t ){
	for( int i = _s ; i <= _t ; i++ )
		cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
struct InputReader{
    static const int bs = 1000000;
    char buf[bs];
    int p;
    il InputReader():p(bs) {}
    il void flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    il char c(){
        if(p >= bs) flush();
        return buf[p++];
    }
    il int operator() (){
        int ans = 0;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = c();
        }
        return ans;
    }
	ll readll(){
		ll ans = 0LL;
        char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = c();
        }
        return ans;
	}
}in;
il void read( int &x ){
	x = in();
}
il void read2( int &x, int &y ){
	x = in(); y = in();
}
il void read3( int &x1 , int &x2 , int &x3 ){
	x1 = in(); x2 = in(); x3 = in();
}
/*********************************************************************/
/*********************************************************************/
#define MAXN 100100
int n,m;
vc<int> e[MAXN];

int col[MAXN];
bool dfs( int pos , bool color ){
	if( col[pos] != -1 ){
		if( col[pos] == color ) return 1;
		return 0;
	}
	col[pos] = color;
	for( int i = 0 ; i < e[pos].size() ; i++ )
		if( !dfs( e[pos][i] , color^1 ) )
			return 0;
	return 1;
}

int main(){
	//fin( "C.in" );

	read2(n,m);
	for( int i = 1 ; i <= m ; i++ ){
		int a,b;
		read2(a,b);
		e[a].pb(b);
		e[b].pb(a);
	}

	msn(col,-1);

	ll ans;
	if( dfs( 1 , 0 ) ){
		int cnt[3]; ms(cnt);
		for( int i = 1 ; i <= n ; i++ )
			cnt[ col[i] ]++;
		cout << (ll)(cnt[0]) * (ll)(cnt[1]) - m << endl;
	}else{
		cout << (ll)(n) * (ll)(n-1) / 2LL - m << endl;
	}

	return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))   
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
typedef tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;  

inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mod = 1e9+7;
const int inf = 1e18;
const int maxn = 5e5+5;

void solve(){
	int n; cin>>n;
	int a[n], b[n];
	rep(i, 0, n) cin>>a[i]>>b[i];
	int ok = 0; 
	rep(i, 0, n-2){
		ok = (a[i] == b[i]) + (a[i+1] == b[i+1]) + (a[i+2] == b[i+2]);
		if(ok == 3){
			cout<<"Yes"; return;
		}
	}
	cout<<"No";
}

signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //io();
    //cout<<setprecision(16);
    int tc=1; //cin>>tc; 
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3644
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

n = ri()
if n==1:
    print('Hello World')
else:
    A=ri()
    B=ri()
    print(A+B)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	priority_queue<int> q;
	string s = {};
	string s1 = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	//ll x[300005] = {};
	ll y[300005] = {};
	ll z[302][302] = {};
	cin >> a;
	cin >> b;
	for (int i = 0; i < a; i++)
	{
		cin >> y[i];
	}
	sort(y, y + a);
	for (int i = 0; i < a-b; i++)
	{
		ans+=y[i];
	}
	
	
	cout << ans << endl;



	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n){
        cin >> a[i];
    }
    
    int q;
    cin >> q;
    int m[q];
    rep(i, q){
        cin >> m[i];
    }
 
    string res[q];
    rep(i, q){
        res[i] = "no";
    }
    
    rep(i, 1<<n){
        int sum = 0;
        rep(j, n) if(i>>j & 1) sum += a[j];
        rep(j, q) if(sum == m[j]) res[j] = "yes";
    }
    
    rep(i, q) cout << res[i] << endl;
    
    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
inline void chmin(int& a, int b) { a = min(a, b); }
 
const int INF = INT_MAX;
const int MAX_N  = 1000000;
const int BACKET = 500;
 
  
int main()
{
  int N, Q;
  int A[MAX_N];
  int small[MAX_N / BACKET + 1];
  fill_n(A, MAX_N, INF);
  fill_n(small, MAX_N / BACKET + 1, INF);
    
  scanf("%d %d", &N, &Q);
   
  while(Q--) {
    int t, a, b;
    scanf("%d %d %d", &t, &a, &b);
    if(t == 0) {
      int curr = a / BACKET;
      A[a] = b;
      small[curr] = INF;
      for(int i = 0; i < BACKET; i++) chmin(small[curr], A[curr * BACKET + i]);
    } else {
      int begin = (a + BACKET - 1) / BACKET;
      int end   = b / BACKET;
      int ret = INF;
      if(begin >= end) {
        for(int i = a; i <= b; i++) chmin(ret, A[i]);
      } else {
        for(int i = begin * BACKET - 1; i >= a; i--) chmin(ret, A[i]);
        for(int i = begin; i < end; i++) chmin(ret, small[i]);
        for(int i = end * BACKET; i <= b; i++) chmin(ret, A[i]); 
      }
      printf("%d\n", ret);
    }
  }
}

Measured memory_bytes: 5104
#include "stdio.h"

int main(int argc, char const *argv[])
{
    long int N, a, p, c = 0;
    scanf("%ld", &N);
    for (int i = 0; i < N; i++) {
        scanf("%ld", &a);
        i || (p = a);
        i && (p > a) && (c += p - a);
        p = a > p ? a : p;
    }
    printf("%ld\n", c);

    return 0;
}


Measured memory_bytes: 3232
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

int main(){
  ll n;cin>>n;
  ll ans=0;
  drep(i,pow(n,0.5),1){
    if(n%i==0){
      ll tmp=n/i;
     
      while(tmp>0){
        tmp/=10;
        ans++;
      }
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3996
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <iterator>
#include <map>
#include <unordered_map>
#define ll long long int
#define vi vector<long long int>
#define vvi vector<vi >
#define vpi vector<pair<ll,ll> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
using namespace std;
vvi g;
vi vis,a;
void dfs(ll i){
	vis[i]=1;
	for(auto j:g[i]){
		if(!vis[j]) dfs(j);
	}
	a.pb(i);
}
int main(){
	ll n,m,i,u,v;
	cin>>n>>m;
	g.resize(n+1);
	vis.resize(n+1,0);
	while(m--){
		cin>>u>>v;
		g[u].pb(v);
	}
	for(i=1;i<=n;i++){
		if(!vis[i]) dfs(i);
	}
	reverse(all(a));
//	print(a);
	vi d(n+1,0);
//	for(i=1;i<=n;i++){
//		cout<<i<<" - ";
//		for(auto j:g[i]) cout<<j<<" ";cout<<endl;
//	}
	for(i=0;i<n;i++){
		for(auto j:g[a[i]]) d[j]=max(d[j],d[a[i]]+1);
	}
//	print(d);
	ll s=0;
	for(i=1;i<=n;i++) s=max(s,d[i]);
	cout<<s<<endl;
}


Measured memory_bytes: 10228
N = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)

count = 0
if N % 2 == 0:
  for i in range(int(N/2)):
    count += 2 * a[i]
  count -= a[0]
else:
  for i in range(int((N+1)/2)):
    count += 2 * a[i]
  count -= a[0]
  count -= a[int((N-1)/2)]
    
print(count)

Measured memory_bytes: 31412
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int w = sc.nextInt();
    int[][] map = new int[h][w];
    int a = 0;
    int aNumber = 0;
    int n = sc.nextInt();
    for(int i = 0; i<h; i++){
      if(i%2 == 0){
        for(int j = 0; j<w; j++){
          if(a == 0){
            a = sc.nextInt();
            aNumber++;
          }
          map[i][j] = aNumber;
          a--;
        }
      }else{
        for(int j = w-1; j>=0; j--){
          if(a == 0){
            a = sc.nextInt();
            aNumber++;
          }
          map[i][j] = aNumber;
          a--;
        }
      }
    }
    for(int i = 0; i<h; i++){
      for(int j = 0; j<w; j++){
        if(j < w-1){
          System.out.print(map[i][j] + " ");
        }else{
          System.out.println(map[i][j]);
        }
      }
    }
  }
}


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


int main() {

    //freopen ("in.txt","r",stdin);
    //freopen ("out.txt","w",stdout);

	string s, t;
	cin >> s >> t;
	
	int ans = 0;
	
	for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            ans++;
        }
	}
	
	cout << ans << "\n";
    
	return 0;
}


Measured memory_bytes: 3908
package main

import "fmt"

func main() {
	var k, x int
	fmt.Scan(&k, &x)
	for i := x - k + 1; i <= x+k-1; i++ {
		fmt.Print(i)
		if i == x+k-1 {
			fmt.Println()
			return
		}
		fmt.Print(" ")
	}
}


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

using namespace std;

const int MAXN=1e5+1;

int x,y,a,b,c,p[MAXN],q[MAXN],r[MAXN],nowr;
long long ans=0;
priority_queue<int,vector<int>,greater<int> > ansp,ansq;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>x>>y>>a>>b>>c;
	for(int i=1; i<=a; ++i) cin>>p[i];
	for(int i=1; i<=b; ++i) cin>>q[i];
	for(int i=1; i<=c; ++i) cin>>r[i];
	sort(p+1,p+1+a);
	sort(q+1,q+1+b);
	sort(r+1,r+1+c);
	for(int i=a; i>=a-x+1 && i>=0; --i) ansp.push(p[i]);
	for(int i=b; i>=b-y+1 && i>=0; --i) ansq.push(q[i]);
	nowr=c;
	while(ansp.size()<x && nowr>0) ansp.push(r[nowr--]);
	while(ansq.size()<y && nowr>0) ansq.push(r[nowr--]);
	while(nowr>0) {
		if(ansp.top()>ansq.top()) {
			if(r[nowr]>ansq.top()) {
				ansq.pop();
				ansq.push(r[nowr]);
			}
		} else {
			if(r[nowr]>ansp.top()) {
				ansp.pop();
				ansp.push(r[nowr]);
			}
		}
		--nowr;
	}
	while(!ansp.empty()) {
		ans+=ansp.top();
		ansp.pop();
	}
	while(!ansq.empty()) {
		ans+=ansq.top();
		ansq.pop();
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int h, w;
  cin >> h >> w;
  vector<int> num(26, 0);
  rep(i, h) rep(j, w) {
    char t; cin >> t;
    num[t - 'a'] ++;
  }

  int g1, g2, g3;
  g1 = (h % 2) * (w % 2);
  g3 = (h / 2) * (w / 2) * 4;
  g2 = h * w - g1 - g3;
  g3 /= 4, g2 /= 2;

  rep(i, 26) {
    while (num[i] >= 4 && g3 >= 1) {
      g3 --;
      num[i] -= 4;
    }
  }

  rep(i, 26) {
    while (num[i] >= 2 && g2 >= 1) {
      g2 --;
      num[i] -= 2;
    }
  }

  rep(i, 26) {
    while (num[i] >= 1 && g1 >= 1) {
      g1 --;
      num[i] --;
    }
  }

  if (g1 + g2 + g3 > 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a;
    int counter = 0;
    int COUNTER = 0;
    cin >> a;
    vector<char> b;

    for(int i = 0; i < a; i++) {
        char A;
        cin >> A;
        b.push_back(A);
    }

    for(int i = 0; i < a; i++) {
        if(b[i] == 'R') {
            counter++;
        } else {
            COUNTER++;
        }
    }

    if(counter > COUNTER) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
from time import time

def main():
    N, K, Q = map(int,input().split())
    A = []
    for i in range(Q):
        A.append(int(input()))

    life = [0 for i in range(N)]

    for i in A:
        life[i-1] += 1

    for i in range(N):
        life[i] = K - Q + life[i]

    for i in life:
        if i > 0:
            print("Yes")
        else:
            print("No")

if __name__ == '__main__':
    start = time()
    main()
    # print(time() - start)



Measured memory_bytes: 11780
from collections import deque
from itertools import combinations
class Dinic:
    def __init__(self, N):
        self.N=N
        self.G=[[]for _ in range(N)]
    def add_edge(self,fr,to,cap):
        forward=[to,cap,None]
        forward[2]=backward=[fr,0,forward]
        self.G[fr].append(forward)
        self.G[to].append(backward)
    def add_multi_edge(self,v1,v2,cap1,cap2):
        edge1=[v2,cap1,None]
        edge1[2]=edge2=[v1,cap2,edge1]
        self.G[v1].append(edge1)
        self.G[v2].append(edge2)
    def bfs(self,s,t):
        self.level=level=[None]*self.N
        deq=deque([s])
        level[s]=0
        G=self.G
        while deq:
            v=deq.popleft()
            lv=level[v]+1
            for w,cap,_ in G[v]:
                if cap and level[w]is None:
                    level[w]=lv
                    deq.append(w)
        return level[t]is not None
    def dfs(self,v,t,f):
        if v==t:return f
        level=self.level
        for e in self.it[v]:
            w,cap,rev=e
            if cap and level[v]<level[w]:
                d=self.dfs(w,t,min(f,cap))
                if d:
                    e[1]-=d
                    rev[1]+=d
                    return d
        return 0
    def flow(self,s,t):
        flow=0
        INF=10**9+7
        G=self.G
        while self.bfs(s,t):
            *self.it,=map(iter,self.G)
            f=INF
            while f:
                f=self.dfs(s,t,INF)
                flow+=f
        return flow
INF=10**9+7
t,*a=open(0)
h,w=map(int,t.split())
d=Dinic(h+w+3)
add=d.add_multi_edge
for i,s in enumerate(a,1):
    for j,t in enumerate(s[:-1],h+1):
        if t!='.':
            if t=='S':
                add(0,i,INF,INF)
                add(0,j,INF,INF)
            elif t=='T':
                add(i,h+w+2,INF,INF)
                add(j,h+w+2,INF,INF)
            add(i,j,1,1)
a=d.flow(0,h+w+2)
print(-(a>=INF)or a)

Measured memory_bytes: 45932
# -*- coding: utf-8 -*-
import sys
abcd = input()
n = len(abcd)-1
for i in range(3**n):
    t = abcd[0]
    for j in range(n):
        if (i >> j & 1):
            t += '+'
        else:
            t += '-'
        t += abcd[j+1]
    if eval(t) == 7:
        t += '=7'
        print(t)
        sys.exit()

Measured memory_bytes: 3060
n = int(input())
score = [list(map(int, input().split())) for i in range(n)]

dp = [[0, 0, 0] for _ in range(n)]
dp[0] = score[0]

for day in range(1, n):
    for i in range(3):
        for j in range(3):
            if i != j:
                dp[day][i] = max(dp[day][i], dp[day-1][j] + score[day][i])

print(max(dp[-1]))

Measured memory_bytes: 47344
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  ll v_x = x2 - x1;
  ll v_y = y2 - y1;

  ll x3 = x2 - v_y;
  ll y3 = y2 + v_x;

  ll x4 = x3 - v_x;
  ll y4 = y3 - v_y;

  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

  return 0;
}

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

int main(){
  int N;
  cin >> N;
  map<string, int> D;
  rep(i, N){
    string s;
    cin >> s;
    if (D.count(s)) D[s]++;
    else D[s] = 0;
  }
  int max_value = 0;
  for (auto d : D) max_value = max(max_value, d.second);
  for (auto d : D){
    if (d.second == max_value) cout << d.first << endl;
  }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD_1 998244353
#define MOD_2 1000000007
#define MOD_3 1012924417


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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	vector<ll> MODs = {998244353, 1000000007, 1012924417};

	ll n;cin >> n;
	vector<ll> b(2*n);REP(i, n)cin >> b[i],b[n+i] = b[i];
	vector<ll> diff_b(2*n-1);REP(i, 2*n-1)diff_b[i] = b[i] ^ b[i+1];
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> diff_a(n-1);REP(i, n-1)diff_a[i] = a[i] ^ a[i+1];
/*
	SHOW1d(a, a.size());
	SHOW1d(diff_a, diff_a.size());
	SHOW1d(b, b.size());
	SHOW1d(diff_b, diff_b.size());
*/
	vector<ll> seica(3);
	vector<ll> sum(3, 1);
	REP(i, diff_a.size()){
		REP(j, 3){
			seica[j] *= INF;seica[j] += diff_a[i];seica[j] %= MODs[j];
			sum[j] = (sum[j] * INF) % MODs[j];
		}
	}

	//REP(i, 3)cout << seica[i] << endl;

	vector<P> ans;

	vector<ll> keymoon(3);
	REP(i, diff_b.size() - 1){
		//cout << i << endl;
		REP(j, 3){
			keymoon[j] *= INF;keymoon[j] += diff_b[i];keymoon[j] %= MODs[j];
		}
		if(i > n - 2){
			REP(j, 3){
				keymoon[j] = keymoon[j] + MODs[j] - diff_b[i-(n-1)] * sum[j] % MODs[j];
				keymoon[j] %= MODs[j];
			}
		}
		if(i >= n - 2){
			bool flag = true;
			REP(j, 3){
				//cout << keymoon[j] << endl;
				if(seica[j] != keymoon[j])flag = false;
			}
			if(flag)ans.EB(i - (n - 2), a[0] ^ b[i - (n - 2)]);
		}
	}

	REP(i, ans.size()){
		cout << ans[i].FI << " " << ans[i].SE << endl;
	}


	return 0;
}


Measured memory_bytes: 16108
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  string s="Sunny";
  string c="Cloudy";
  string r="Rainy";
  
  string w;
  cin >> w;
  
  if(w==s)
  {
    cout << c << endl;
  }
  if(w==c)
  {
    cout << r << endl;
  }
  if(w==r)
  {
    cout << s << endl;
  }
}

Measured memory_bytes: 256
s = str(input())
if ((s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2])):
    if(s[0] == s[1] == s[2]):
        print("No")
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.util.Random


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val l, r = sc.nextInt()
    (l, r)
  }

  def solve(l: Int, r: Int): Long = {
    val mod = 2019
    // 0~2018が必要条件
    val ml = l % mod
    val mr = r % mod
    // ml <= mr の場合: [ml, mr]の範囲
    // ml > mrの場合: [0, mr], [ml, 2018]

    if (mr < ml) return 0
    val dl = l / mod
    val dr = r / mod

    val range: IndexedSeq[Int] = ml to mr
    if (dl == dr) {
      (for (i <- range; j <- range; if i < j) yield {
        i * j % mod
      }).min
    } else {
      (for (i <- range; j <- range) yield {
        i * j % mod
      }).min
    }
  }

  def solve2(l: Int, r: Int): Long = {
    (for (i1 <- l until r; i2 <- l + 1 to r if i1 < i2) yield {
      i1 * i2 % 2019
    }).min
  }

  def solve3(l: Int, r: Int): Long = {
    val mod = 2019
    // 0~2018が必要条件
    val ml = l % mod
    val mr = r % mod
    // ml <= mr の場合: [ml, mr]の範囲
    // ml > mrの場合: [0, mr], [ml, 2018]

    val dl = l / mod
    val dr = r / mod
    if (dl < dr) return 0

    val range: IndexedSeq[Int] = ml to mr
    (for (i <- range; j <- range; if i < j) yield {
      i * j % mod
    }).min
  }

def readRand () = {
  val l = 1000
  val r = Random.nextInt (4000) + l + 1
  (l, r)
}

  def test (): Unit = {
  val (l, r) = readRand ()
  println (l, r)
  println (solve (l, r) == solve2 (l, r) )
}


  def main (args: Array[String] ): Unit = {
  //test()
  val (l, r) = read ()
  println (solve3 (l, r) )
}
}

Measured memory_bytes: 106124
"""
変数Oは奇数、Eは偶数番目の文字列
各変数を結合して、、元の文字列を復元する。
"""


O, E = [input() for _ in range(2)]

rest_str = ''
for i in range(len(O)):
    try:
        rest_str += O[i]+E[i]
    except IndexError:
        rest_str += O[i]

print(rest_str)


Measured memory_bytes: 2940
x1,y1,x2,y2 = map(int,input().split())

"""
x3 = x2 - y2 + y1
y3 = y2 - x1 + x2
x4 = x3 - x2 + x1 = x2 - y2 + y1 - x2 + x1
y4 = y3 - y2 + y1 = y2 - x1 + x2 - y2 + y1
"""

x3 = x2 - y2 + y1
y3 = y2 - x1 + x2
x4 = x2 - y2 + y1 - x2 + x1
y4 = y2 - x1 + x2 - y2 + y1

print(x3,y3,x4,y4)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 1000000007;
map <ll, int> dp;
int DP(ll n) {
    if (n < 0) return 0;
    if (n == 0) return 1;
    if (dp.count(n)) return dp[n];
    int res = 0;
    if (n & 1) res = (DP(n / 2) * 2 % mod + DP(n / 2 - 1)) % mod;
    else res = (DP(n / 2) + DP(n / 2 - 1) * 2 % mod) % mod;
    return dp[n] = res;
}
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    // set <pair <ll, ll> > st;
    // for (int a = 0; a <= n; ++ a) for (int b = 0; a + b <= n; ++ b) st.emplace(a + b, a ^ b);
    // cout << st.size() << endl;
    cout << DP(n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long int
#define ff first
#define ss second
#define S size()
#define mod (ll)(1e9+7)
#define mset(a,k) memset(a,k,sizeof(a));
#define fr(i, x, y) for ( ll i = x; i < y;i++)
#define dr(i, x, y) for ( ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define pqueue priority_queue<ll>
#define mapcl map<char,ll>
#define mapll map<ll,ll>
#define mapsl map<string,ll>
#define vi vector<ll>
#define vs vector<string>
#define psi pair<string,ll>
#define pii pair<ll,ll>
#define piii pair<ll,pii>
#define vii vector<pii>
using namespace std;
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
//----------------------------------------FUNCTIONS---------------------------------------------------
ll gcd(ll x, ll y )						{if (y == 0) return x; return gcd(y, x % y);}
ll lcm(ll a, ll b)						{return (a * b) / gcd(a, b);}
ll logx(ll base, ll num)				{int cnt = 0; while (num != 1) {num /= base; ++cnt;} return cnt;}
vi vin(ll n)							{vi a(n); fr(i, 0, n) cin >> a[i]; return a;}
void vout(vi a)							{for (int i = 0; i < (ll)a.S; i++) { cout << a[i] << " "; } cout << endl;}
void in(ll *a, ll n)        			{for (ll i = 0; i < n; i++)cin >> a[i];}
void in1(ll *a, ll n)        			{for (ll i = 1; i <= n; i++)cin >> a[i];}
void out1(ll *a, ll n)					{fr(i, 1, n + 1) {cout << a[i] << " ";} cout << '\n';}
void out(ll *a, ll n)					{fr(i, 0, n) {cout << a[i] << " ";} cout << endl;}
//----------------------------------------START--------------------------------------------------------

bool isprime(ll n)
{
	// Corner cases
	if (n <= 1)  return false;
	if (n <= 3)  return true;

	// This is checked so that we can skip
	// middle five numbers in below loop
	if (n % 2 == 0 || n % 3 == 0) return false;

	for (ll i = 5; i * i <= n; i = i + 6)
		if (n % i == 0 || n % (i + 2) == 0)
			return false;

	return true;
}
const ll maxN = (ll)(1 * 1e5 + 5 );
int main()
{
#ifndef ONLINE_JUDGE
	freopen ("inp4.txt", "r", stdin);
	freopen ("out4.txt", "w", stdout);
#endif
	fast();
	ll t = 1;
	//cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll a[n];
		in1(a, n);
		ll ans = 0;
		fr(i, 1, n + 1)
		{
			if (i & 1 && a[i] & 1)ans++;
		}
		cout << ans << '\n';
	}

}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ha 1000000007
using namespace std;

int n,m;
struct Inteval{int l,x,next;} e[310];
int h[310],sum=0;
int f[310][310][310];

inline void Add(int &x,const int &y){x=(x+y>=ha)?(x+y-ha):(x+y);}

void add_inteval(int l,int r,int x)
{
	e[++sum].l=l;
	e[sum].x=x;
	e[sum].next=h[r];
	h[r]=sum;
}

int main()
{
	int l,r,x;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&x);
		add_inteval(l,r,x);
	}
	f[1][0][0]=1;
	for(int t=h[1];t;t=e[t].next)
		for(int j=0;j<=1;j++)
			for(int k=0;k<=1;k++)
			{
				int cnt=1;
				cnt+=(j>=e[t].l);
				cnt+=(k>=e[t].l);
				if(cnt!=e[t].x) f[1][j][k]=0;
			}
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<i;j++)
			for(int k=0;k<i;k++)
			{
				if(j||k)
				{
					Add(f[i+1][i][k],f[i][j][k]);
					Add(f[i+1][j][i],f[i][j][k]);
				}
				else Add(f[i+1][i][0],f[i][j][k]);
				Add(f[i+1][j][k],f[i][j][k]);
			}
		for(int t=h[i+1];t;t=e[t].next)
		{
			for(int j=0;j<=i;j++)
				for(int k=0;k<=i;k++)
				{
					int cnt=1;
					cnt+=(j>=e[t].l);
					cnt+=(k>=e[t].l);
					if(cnt!=e[t].x) f[i+1][j][k]=0;
				}
		}
	}
	int ans=3ll*f[n][0][0]%ha;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(i||j) Add(ans,6ll*f[n][i][j]%ha);
	printf("%d\n",ans);
	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[222222];
int S[222222];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N){
        S[i+1]=S[i]+A[i];
    }

    int a=0,b=2;

    int latte=LLONG_MAX;
    for(int i=2;i<N-1;i++){
        while(S[a+1]<S[i]-S[a+1])a++;
        while(S[b+1]-S[i]<S[N]-S[b+1])b++;
        rep(j,2)rep(k,2){
            vint uku;
            uku.pb(S[a+j]);
            uku.pb(S[i]-S[a+j]);
            uku.pb(S[b+k]-S[i]);
            uku.pb(S[N]-S[b+k]);
            sort(all(uku));
            chmin(latte,uku[3]-uku[0]);
        }
    }
    cout<<latte<<endl;
    return 0;
}


Measured memory_bytes: 3328
using System;
 
namespace _0048
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
              string uef = Console.ReadLine();
                
                if (uef == null) { break; }
                string r = "";
                float a = float.Parse(uef);
                if (a <= 48) {r="light fly"; }
                else if (a <= 51) { r = "fly"; }
                else if (a <= 54) {r="bantam"; }
                else if (a <= 57) { r = "feather"; }
                else if (a <= 60) { r = "light"; }
                else if (a <= 64) { r = "light welter"; }
                else if (a <= 69) { r = "welter"; }
                else if (a <= 75) { r = "light middle"; }
                else if (a <= 81) { r = "middle"; }
                else if (a <= 91) { r = "light heavy"; ; }
                else { r = "heavy"; }
                Console.WriteLine(r);
            }
        }
    }
}

Measured memory_bytes: 9040
def main():
    from itertools import accumulate

    n, k = map(int, input().split())
    *p, = ((float(x) + 1) / 2 for x in input().split())

    acc = (0,) + tuple(accumulate(p))

    ret = 0
    for i in range(k, n + 1):
        ret = max(ret, acc[i] - acc[i - k])
    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 23616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#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 <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int N, M, L;
const int MAX_V = 2100;
int V;
VI biG[MAX_V];
VI origG[MAX_V];
int match[MAX_V];
bool used[MAX_V];


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

bool dfs(int v){
  used[v] = true;
  for(int i=0;i<biG[v].size();++i){
	int u = biG[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;
}

int findMinPathcover(int n){
  REP(i,MAX_V) biG[i].clear();
  V = 2*n;
  REP(i,n) REP(j,SZ(origG[i])){
	add_edge(i, n+origG[i][j]);
  }
  int res = bipartite_matching();
  return n - res;
}


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

  while(cin>>N>>M>>L,N){
	REP(i,MAX_V) origG[i].clear();
	vector<vector<LL>> dist(N, vector<LL>(N, 1e+15));
	REP(i,N) dist[i][i] = 0;
	REP(i,M){
	  int u, v, d;
	  cin >> u >> v >> d;
	  dist[u][v] = dist[v][u] = d;
	}

	REP(k,N) REP(i,N) REP(j,N)
	  dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

	vector<LL> p(L), t(L);
	REP(i,L) cin >> p[i] >> t[i];
	REP(i,L) REP(j,L)
	  if(i != j && t[i] + dist[p[i]][p[j]] <= t[j])
		origG[i].PB(j);
	cout << findMinPathcover(L) << endl;
  }
  
  return 0;
}

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

const long long mod = 998244353;


int main() {
    int n, s;
    cin >> n >> s;
    long long ans = 0;
    vector<int> arr(n);
    for(int &x : arr) cin >> x;
    vector<long long> dp(s + 1, 0);
    for(int i = 0; i < n; i++) {
        dp[0] = (dp[0] + 1) % mod;
        vector<long long> tmp(begin(dp), end(dp));
        for(int j = s; j >= arr[i]; j--) {
            tmp[j] = (tmp[j] + dp[j - arr[i]]) % mod;
        }   
        dp = tmp;
        ans = (ans + tmp[s]) % mod;
    }
    
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import sys

A = [[0] for _ in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
B = []
for i in range(N):
    B.append(int(input()))

row = A
column = [[] for _ in range(3)]
for i in range(3):
    column[i] = [A[0][i], A[1][i], A[2][i]]
cross = [[A[0][0], A[1][1], A[2][2]], [A[2][0], A[1][1], A[0][2]]]

for i in range(3):
    if set(row[i]) <= set(B) or set(column[i]) <= set(B):
        print('Yes')
        sys.exit()

for i in range(2):
    if set(cross[i]) <= set(B):
        print('Yes')
        sys.exit()
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,m;
 cin>>n>>m;
 if(m==0 && n>1){
     cout<<"1";
     for(int y=1;y<n;y++){
         cout<<"0";
     }
 }
 else if (n==1 && m==0){
     cout<<"0";
 }
 else{char c[n];
 for(int j=0;j<n;j++){
     c[j]='!';
 }
 int a[m][2],flag =0;
 for(int i=0;i<m;i++){
     scanf("%d %d",&a[i][0],&a[i][1]);
 }
 /*for(int i=0;i<m;i++){
     printf("%d %d ",a[i][0],a[i][1]);
 }*/
 
 for(int p = 0;p<m;p++){
     if(((c[a[p][0]-1])=='!')||((c[a[p][0]-1])=='0'+a[p][1]))c[a[p][0]-1]='0'+a[p][1];
     else if(c[a[p][0]-1]!='0'+a[p][1]) {
         flag = 1;
         break;
     }
 }
 if(c[0]=='0' && n>1)flag = 1;
 else if(c[0]=='!' && n>1)c[0]='1';
 
 if(flag)cout<<"-1"<<endl;
 else{
     for(int x = 0;x<n;x++){
         if(c[x]=='!')cout<<"0";
         else cout<<c[x];
     }
 }}
 
 
}


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

using namespace std;

typedef long long ll;

const int N = 1e5+10;
const int mod = 1e9+7;

vector<int> g[N];

ll w[N], b[N];

void dfs(int v, int p) {
	//bool f = 1;
	w[v] = b[v] = 1;
	for(auto i: g[v]) {
		if(i==p) continue;
		else {
			dfs(i, v);
			w[v] *= (w[i]+b[i]);
			b[v] *= w[i];
			w[v] %= mod;
			b[v] %= mod;
			//f = 0;
		}
	}

	// if(f) {
	// 	w[v] = b[v] = 1;
	// }
	
	w[v] %= mod;
	b[v] %= mod;
}

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

	for(int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;

		g[x].push_back(y);
		g[y].push_back(x);
	}

	dfs(1, -1);
	// int sum = 0;
	// for(int i = 1; i <= n; i++) {
	// 	cout << i << "=i " << w[i] << " " << b[i] << endl;
	// 	sum += (w[i]+b[i]);
	// }
	// cout << sum << endl;
	cout << (w[1]+b[1])%mod;
}

Measured memory_bytes: 17540
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int n;
string s, t;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> s >> t;
    n = s.size();
    int rez = 0;
    for(int i=0;i<n;i++)rez += (s[i] != t[i]);
    cout << rez << endl;
    return 0;
}


Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
 
namespace AOZ
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
 
        public void Solve(ConsoleInput cin)
        {
            while (true)
            {
                var n = cin.ReadInt;
                var k = cin.ReadInt;
 
                if (n == 0 && k == 0)
                    break;
 
                int[] a = new int[n];
                for (int i = 0; i < n; i++) a[i] = cin.ReadInt;
 
                int[] sum = new int[n + 1];
                //int[] sum3 = new int[n - 2];
                int maxSum = int.MinValue;
                for (int i = 0; i < n; i++)
                {
                    sum[i + 1] = sum[i] + a[i];
                    if (k - 1 <= i)
                        maxSum = Math.Max(maxSum, sum[i + 1] - sum[i + 1 - k]);
                        //sum3[i - k] = sum[i + 1] - sum[i + 1 - k];
                }
                Console.WriteLine(maxSum);
            }
        }
    }
 
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

int main(int argc, char const *argv[])
{
	int m,nmi,nma;
	while(cin>>m>>nmi>>nma,m)
	{
		--nmi,--nma;
		int p[m];
		for (int i = 0; i < m; ++i) cin>>p[i];
		int ans=-1,gap=-1;
		for (int i = nmi; i <= nma; ++i)
		{
			if(p[i]-p[i+1]>=gap) ans=i,gap=p[i]-p[i+1];
		}
		cout<<ans+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 3020