akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
template<class T>inline bool chmax(T& a, T b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T& a, T b){if(a > b){a = b; return 1;}return 0;}
const ll INF = 1LL<<60;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n; cin >> n;
    map<ll, ll> mp;
    REP(i, n){
        ll a; cin >> a;
        if(mp[a] == 0) mp[a]++;
        else mp[a]--;
    }
    ll res = 0;
    for(auto x : mp){
        if(x.second != 0) res++; 
    }
    cout << res << endl;
}

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

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

int main() {
  string s, t;
  cin >> s >> t;
  int len = t.size();
  int ans = 1e6 + 7;
  for(int i = 0; i + len <= s.size(); i++) {
  	string str = s.substr(i, len);
  	int cnt = 0;
	for(int i = 0; i < len; i++) {
		if(str[i] != t[i]) {
			cnt++;
		}
	}
	ans = min(ans, cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static int judge = 0;

	public static int breakcount = 0;

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		int n = Integer.parseInt(line1);

		Card[] cards = new Card[n];

		for (int i = 0; i < n; i++) {
			String line = sc.nextLine();
			cards[i] = new Card(line.substring(0, 1), Integer.parseInt(line
					.substring(2)), i);
		}

		quicksort(cards, 0, n - 1);

		for (int i = 0; i < n - 1; i++) {
			if (cards[i].num == cards[i + 1].num
					&& cards[i].ord > cards[i + 1].ord) {
				judge++;
				break;

			}
		}

		if (judge > 0) {
			System.out.println("Not stable");
		} else {
			System.out.println("Stable");
		}

		for (int i = 0; i < n; i++) {
			StringBuilder kari = new StringBuilder();
			kari.append(cards[i].str);
			kari.append(" ");
			kari.append(cards[i].num);
			System.out.println(kari);
		}
	}

	public static int partition(Card[] c, int p, int r) {
		int x = c[r].num;
		int i = p - 1;
		Card kari = new Card(null, 0, 0);
		for (int j = p; j < r; j++) {

			if (c[j].num <= x) {
				i++;
				kari = c[i];
				c[i] = c[j];
				c[j] = kari;

			}

		}

		kari = c[i + 1];
		c[i + 1] = c[r];
		c[r] = kari;

		return i + 1;
	}

	public static void quicksort(Card[] c, int p, int r) {
		if (p < r) {
			int q = partition(c, p, r);
			quicksort(c, p, q - 1);
			quicksort(c, q + 1, r);
		}
	}
}

class Card {

	String str;
	int num;
	int ord;

	public Card(String str, int num, int ord) {
		super();
		this.str = str;
		this.num = num;
		this.ord = ord;
	}
}

Measured memory_bytes: 158604
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x % y == 0:
        return y
    else:
        return gcd(y,x%y)

def lcm(m,n):
    return int(m * n /gcd(m,n))

d = gcd(N,M)
l = lcm(N,M)

s = [0 for i in range(0,d)]
t = [0 for i in range(0,d)]

a = int(l/M)
b = int(l/N)

for i in range(0,d):
    s[i] = S[i*a]
    t[i] = T[i*b]

if s == t:
    print(l)
else:
    print(-1)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
	int a[3];
	REP(i, 3){
		cin >> a[i];
	}
	std::sort(a, a+3);
	cout << a[0]+a[1]+a[2]*10 << '\n';
	
	return 0;
}


Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
s += ' '
ruiseki = []
i = 0
while i<n:
    if s[i]+s[i+1]=='AC':
        ruiseki.append('')
        ruiseki.append('AC')
        i= i+1
    else:
        ruiseki.append(s[i])
    i+=1
t = [0] * (n+1)
for i in range(n):
    if ruiseki[i] == 'AC':
        t[i+1] = t[i]+1
    else:
        t[i+1] = t[i]
for i in range(q):
    l,r = map(int,input().split())
    print(t[r]-t[l]) 

Measured memory_bytes: 12336
#include <iostream>

using namespace std;

int main() {
	int n, cards[2][10000], score[2];
	while (cin >> n, n) {
		for (int i = 0; i < n; ++i)
			cin >> cards[0][i] >> cards[1][i];
		
		score[0] = 0, score[1] = 0;
		for (int i = 0; i < n; ++i)
			if (cards[0][i] > cards[1][i]) score[0] += cards[0][i] + cards[1][i];
			else if (cards[0][i] < cards[1][i]) score[1] += cards[0][i] + cards[1][i];
			else score[0] += cards[0][i], score[1] += cards[1][i];

		cout << score[0] << " " << score[1] << endl;
	}
	return 0;
}

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

int discending(const int* a, const int* b)
{
	return *b - *a;
}

int ascending(const int* a, const int* b)
{
	return *a - *b;
}

int main()
{
	std::vector<int> inputVector;
	int vectorSize;

	std::cin >> vectorSize;
	inputVector.resize(vectorSize);
	for (int i = 0; i < vectorSize; i++)
	{
		std::cin >> inputVector[i];
	}

	std::qsort(&inputVector[0], vectorSize, sizeof(int), (int(*)(const void*, const void*))ascending);

	long long sum = 0;
	for (int i = 0; i < vectorSize; i++)
	{
		sum += inputVector[i];
	}

	std::cout << inputVector[0] << " " << inputVector[vectorSize - 1] << " "  << sum << std::endl;
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
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++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int H, W, HN, WN;
int usedH[12], usedW[12];
int areH, areW;
pair<int, int> HP[6], WP[6];
char C[12][12];
string S[12], S2[12];
int OK;

void calc() {
	int NG = 0;
	
	rep(i, HN) rep(j, WN) {
		int a = HP[i].first;
		int b = HP[i].second;
		int c = WP[j].first;
		int d = WP[j].second;
		if (S[a][c] != S[b][d]) NG = 1;
		if (S[a][d] != S[b][c]) NG = 1;
	}

	if (H % 2) {
		rep(i, WN) {
			int c = WP[i].first;
			int d = WP[i].second;
			if (S[areH][c] != S[areH][d]) NG = 1;
		}
	}
	if (W % 2) {
		rep(i, HN) {
			int a = HP[i].first;
			int b = HP[i].second;
			if (S[a][areW] != S[b][areW]) NG = 1;
		}
	}
	if (NG == 0) OK = 1;
}

void SWP(int A) {
	if (A == -1) {
		rep(i, W) {
			areW = i;
			usedW[i] = 1;
			SWP(0);
			usedW[i] = 0;
		}
		return;
	}
	if (A == WN) {
		calc();
		return;
	}
	rep(i, W) if (usedW[i] == 0) {
		usedW[i] = 1;
		rep(j, W) {
			if (usedW[j] == 0) {
				usedW[j] = 1;
				WP[A] = mp(i, j);
				SWP(A + 1);
				usedW[j] = 0;
			}
		}
		usedW[i] = 0;
		return;
	}
}

void SHP(int A) {
	if (A == -1) {
		rep(i, H) {
			areH = i;
			usedH[i] = 1;
			SHP(0);
			usedH[i] = 0;
		}
		return;
	}
	if (A == HN) {
		if (W % 2) SWP(-1);
		else SWP(0);
		return;
	}
	rep(i, H) if (usedH[i] == 0) {
		usedH[i] = 1;
		rep(j, H) {
			if (usedH[j] == 0) {
				if (OK) return;
				if (S2[i] == S2[j]) {
					usedH[j] = 1;
					HP[A] = mp(i, j);
					SHP(A + 1);
					usedH[j] = 0;
				}
			}
		}
		usedH[i] = 0;
		return;
	}
}

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


	cin >> H >> W;
	HN = H / 2;
	WN = W / 2;
	rep(i, H) rep(j, W) {
		cin >> C[i][j];
		S[i] += C[i][j];
	}
	rep(i, H) {
		sort(C[i], C[i] + W);
		rep(j, W) S2[i] += C[i][j];
	}

	if (H % 2) SHP(-1);
	else SHP(0);

	if (OK) co("YES");
	else co("NO");

	Would you please return 0;
}

Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;
 
int main() {
  int k, n;
  cin >> n >> k;
  int l[51];
  REP(i, n) { cin >> l[i]; }
 
  sort(l, l + n);
 
  int ans = 0;
  int count = 0;
  REP(i, k) { ans += l[n - 1 - i]; }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
	int a, b;
	double N = 0, E = 0;
	double theta = 0;

	while(1){
		scanf("%d,%d", &a, &b);

		N += a * cos(theta);
		E += a * sin(theta);

		theta += b * (2 * M_PI / 360);

		if(a == 0 && b == 0) break;
	}

	printf("%d\n%d\n", (int)E, (int)N);
	return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if(n < 105) cout << 0 << endl;
  else if(n == 105) cout << 1 << endl;
  else {
    int count=1;
    for(int i=107;i<=n;i += 2) {
      int c=0;
      for(int j=1;j<=i;j++) {
        if(i%j==0) {
          c++;
        }
      }
      if(c==8) {
        count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll num[10]={0,2,5,5,4,5,6,3,7,6};
vector<ll> sum(10001,-100000);

int main(void){

  ll n,m;
  cin>>n>>m;
  vector<ll> a(m);

  rep(i,m){
    cin>>a[i];
  }

  ll _min=8;

  sort(all(a),greater<int>());

  rep(i,a.size()){

    if( _min > num[a[i]] ) {
      _min=num[a[i]];
    }

  }

  sum[_min]=1;
  sum[0]=0;

  //cout << _min << endl;

  for(ll i=_min+1;i<n+1;i++){

    ll _max=0;
    rep(j,a.size()){
      if(i-num[a[j]]<0) continue;
      _max = max(_max,sum[i - num[a[j]] ]+1);

    }
    //cout << _max << endl;
    sum[i]=_max;

  }
  //cout << sum[n] << endl;
  ll rest=n;
  while(rest>0){
    rep(i,a.size()){
      if( rest-num[a[i]]>=0 && sum[rest - num[a[i]]] + 1 == sum[rest] ){
        rest=rest - num[a[i]];
        //cout << "rest:" << rest << endl;
        //cout << a[i] << endl;
        cout << a[i] ;
        break;
      }
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
int n,k,a[220000];
int main() {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	for (int i=k;i<n;++i) 
		if (a[i-k+1]>=a[i+1]) printf("No\n"); else printf("Yes\n");
	
	return 0;
} 

Measured memory_bytes: 2432
import math

s = input().split()
n=int(s[0])
x = int(math.log(n, 10))
count=0
for i in range(x):
        if i%2==0:
                count=count+9*10**i
if x % 2 == 0:
                count = count+n-10**x+1

print(count)


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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 1e5 + 10;
const int M = (int) 2018 * 2018;
const int K = (int) 500 + 10;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

map<string, int> m;

void add(int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
}

int mult(int x, int y) {
	return 1ll * x * y % mod;
}

int solve(string s) {
	if (s.empty())
		return 1;
	if (m.count(s)) 
		return m[s];
	int ans = 0;
	if (s[0] == '1') {
		add(ans, mult(2, solve(s.substr(1))));
	} else {
		add(ans, solve(s.substr(1)));
	}
	for (int len = 1; len <= sz(s); len++) {
		int cur = len;
		string st = s.substr(0, len);
		for (int k = 2; k * len <= sz(s); k++) {
			for (int i = 0; i < len; i++) {
				if (s[cur + i] == '0') 
					st[i] = '0'; 
			}
			cur += len;
			add(ans, mult(solve(st), solve(s.substr(cur))));
		}
	}
	return m[s] = ans;
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	string s;
	cin >> s;
	cout << solve(s);
	return 0;
}

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

int main(){
  int a[3][3];
  int c[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      scanf("%d",&a[i][j]);
      c[i][j]=0;
    }
  }
  int n;
  scanf("%d", &n);
  int b[n];
  for(int k=0;k<n;k++){
    scanf("%d",&b[k]);
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(b[k]==a[i][j]){
          c[i][j]++;
        }
      }
    }
    for(int i=0;i<3;i++){
      int sum=0;
      for(int j=0;j<3;j++){
        sum+=c[i][j];
      }
      if(sum==3){
        cout<<"Yes"<<endl;
        return 0;
      }  
    }
    for(int j=0;j<3;j++){
      int sum=0;
      for(int i=0;i<3;i++){
        sum+=c[i][j];
      }
      if(sum==3){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    int sum1=0;
    int sum2=0;
    for(int i=0;i<3;i++){
      sum1+=c[i][i];
      sum2+=c[i][2-i];
    }
    if(sum1==3 || sum2==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 205
using namespace std;

typedef long long ll;
ll n, m, r, s, mn = 1e18, a[15], d[N][N], num[N];
bool v[15];
void f(int p) {
	int i;
	if (p == r) {
		s = 0;
		for (i = 1; i < r; i++) {
			s += d[num[i - 1]][num[i]];
		}
		mn = min(mn, s);
		return;
	}
	for (i = 0; i < r; i++) {
		if (v[i]) continue;
		num[p] = a[i];
		v[i] = true;
		f(p + 1);
		v[i] = false;
	}
}

int main()
{
	ll i, j, k, t1, t2, t3;
	cin >> n >> m >> r;
	for (i = 0; i <= n; i++) for (j = 0; j <= n; j++) d[i][j] = 1e9;
	for (i = 0; i <= n; i++) d[i][i] = 0;
	for (i = 0; i < r; i++) scanf("%lld", &a[i]);
	for (i = 0; i < m; i++) scanf("%lld %lld %lld", &t1, &t2, &t3), d[t1][t2] = d[t2][t1] = t3;
	for (k = 1; k <= n; k++) {
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	f(0);
//	do {
//		s = 0;
//		for (i = 1; i < r; i++) {
//			s += d[a[i - 1]][a[i]];
//		}
//		mn = min(mn, s);
//	} while (next_permutation(a, a + r));
    cout << mn << 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 a, b, c;
	cin >> a >> b >> c;
	string ans;

	if (a == b && b == c && c == a)
	{
		ans = "No";
	} else if (a != b && b != c && c != a)
	{
		ans = "No";
	} else {
		ans = "Yes";
	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int A[101][101] = {};
	int B[101] = {};
	
	for(int i=0;i<a;i++)
	for(int j=0;j<b;j++){
		
	cin >> A[i][j];
	A[i][b] += A[i][j];
	
	}
	for(int i=0;i<=b;i++)
	for(int j=0;j<=a;j++)	
	B[i] += A [j][i];
	
	for(int i=0;i<a;i++){
	for(int j=0;j<b;j++)
	cout << A[i][j] << " ";
	
	cout << A[i][b];
	cout << "\n";
	}
	 
	for(int i=0;i<b;i++)
	cout << B[i] << " ";
	
	cout << B[b] << "\n";
}
	return 0;
}


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

int main() {
	int row, col;
	cin >> row >> col;
	char arr[row][col];
	for( int i = 0; i < row; i++){
	    for (int j = 0; j < col; j++){
	        cin >> arr[i][j];
	    }
	}
	int path[row][col];
	int i, j = 0;
	while(arr[i][0] != '#' && i < row){
	    path[i][0] = 1;
	    i++;
	}
	while(i < row){
	    path[i][0] = 0;
	    i++;
	}
	while(arr[0][j] != '#' && j < col){
	    path[0][j] = 1;
	    j++;
	}
	while(j < col){
	    path[0][j] = 0;
	    j++;
	}
	for ( i = 1; i < row; i++){
	    for (j = 1; j < col; j++){
	        if(arr[i][j] == '#'){
	            path[i][j] = 0;
	        }
	        else{
	            path[i][j] = (path[i-1][j] + path[i][j-1])% 1000000007;
	        }
	    }
	}
	cout<<path[row-1][col-1];
}


Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
using namespace std;
#define fo(i,a,b) for(i=a;i<=b;i++)
#define ll long long
struct op{
	int go,ne,use;
	ll va;
};
const int N=1005;
int i,j,n,s,t,fa,fb,fc,fd,x,y,z,so,zja;
ll ans,ch;
int h[N*4],fr[N*4],dl[N*100],mp[N*4],f[N*4];
bool bz[N*4];
op lk[N*300];
int read()
{
	int x=0;char s=getchar();
	while ((s<'0')||(s>'9')) s=getchar();
	while ((s>='0')&&(s<='9')) x=x*10+(s-'0'),s=getchar();
	return x;
}
int min(int x,int y)
{
	if (x<y) return x;
	return y;
}
void ad(int x,int y,int us,int va)
{
	so++;lk[so].go=y;lk[so].ne=h[x];
	h[x]=so;lk[so].use=us;lk[so].va=va;
	so++;lk[so].go=x;lk[so].ne=h[y];
	h[y]=so;lk[so].use=0;lk[so].va=0-va;
}
bool bfs(int x)
{
	fo(i,1,fd) f[i]=-2000000000,fr[i]=0;
	mp[x]=10000;
	f[x]=0;int l,r,i;l=r=1;dl[l]=x;
	while (l<=r)
	{
		i=h[dl[l]];
		while (i)
		{
			if ((lk[i].use)&&(f[dl[l]]+lk[i].va>f[lk[i].go]))
			{
				f[lk[i].go]=lk[i].va+f[dl[l]];fr[lk[i].go]=i;
				mp[lk[i].go]=min(mp[dl[l]],lk[i].use);
				if (!bz[lk[i].go]){bz[lk[i].go]=true;r++;dl[r]=lk[i].go;}
			}
			i=lk[i].ne;
		}
		bz[dl[l]]=false;
		l++;
	}
	if (fr[t]) return true;
	return false;
}
int main()
{
	n=read();so=1;
	s=n*2+1;t=s+1;fa=t+1;fb=fa+1;fc=fb+1;fd=fc+1;
	fo(i,1,n)
	{
		x=read();y=read();z=read();
		ad(s,i,z,0);
		ad(i,fa,z,x+y);
		ad(i,fb,z,x-y);
		ad(i,fc,z,y-x);
		ad(i,fd,z,-x-y);
	}
	fo(i,n+1,n*2)
	{
		x=read();y=read();z=read();
		ad(i,t,z,0);
		ad(fa,i,z,-x-y);
		ad(fb,i,z,y-x);
		ad(fc,i,z,x-y);
		ad(fd,i,z,x+y);
	}
	while (bfs(s))
	{
		i=t;ch=mp[t];ans+=ch*f[t];
		while (i!=s)
		{
			lk[fr[i]].use-=mp[t];
			zja=fr[i]^1;
			lk[zja].use+=mp[t];
			i=lk[zja].go;
		}
	}
	printf("%lld\n",ans);
}


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

#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
inline int in() { int x; cin >> x; return x; }

void solve() {
  int n = in();
  int ans = 0;
  FOR(i,0,n) {
    int a = in();
    if (a == ans+1) ans++;
  }
  if (ans==0) cout << -1 << endl;
  else cout << n - ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    // read in integer 
    ll n, m = 0;
    ll tot = 0;
    cin >> n >> m;
    vector<int> a(n, 0);
    REP(i, n) {
        cin >> a[i];
        tot += a[i];
    }

    sort(ALL(a));
    reverse(ALL(a));

    if (a[m-1] < tot * (1.0/(4*m))){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())

memo = dict()

def luca(n):
  if n == 0:
    return 2
  elif n == 1:
    return 1
  if n in memo:
    return memo[n]
  tmp = luca(n-1) + luca(n-2)
  memo[n] = tmp
  
  return tmp

print(luca(N))

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

long long f( long long n, long long x ){
    
    return (n/x)+1;
}

int main() {
    
    long long a, b, x; cin >> a >> b >> x;
    
    if( a ) cout << f( b, x ) - f( a-1, x ) << '\n';
    else cout << f(b, x) << '\n';
    
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
# print(a)

a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[n - 1 - i]


def check(x):
    # M回の握手の幸福度の最小値をx以上にできるか
    # つまり、M回の任意の握手の幸福度をx以上にできるか
    cnt = 0
    for ai in a:
        idx = bisect_left(a, x - ai)
        cnt += n - idx
    return cnt >= m


lb = 1  # True
ub = 2 * 10**5 + 5  # False
while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        lb = mid
    else:
        ub = mid

# print(lb)

ans = 0
cnt = 0
for ai in a:
    idx = bisect_left(a, lb - ai)
    ans += ai * (n - idx) + a_cs[n - idx]
    cnt += n - idx
ans -= lb * (cnt - m)
print(ans)


Measured memory_bytes: 14428
n = int(input())
h = list(map(int, input().split()))

dp = [float("inf")]*(n)
dp[0] = 0

for i in range(n):
    if i+2 < n:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2] - h[i]))
    if i + 1 < n:
        dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1] - h[i]))

print(dp[-1])

Measured memory_bytes: 52208
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int t[220000];
//b-a = t[a]+t[b] // t[a]+a = b-t[b]

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	map<int,int> m1;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>t[i];
		m1[i-t[i]]++;
	}
	LL s=0;
	for(i=0;i<n;i++){
		s+=m1[i+t[i]];
	}
	cout<<s<<endl;
}

Measured memory_bytes: 21272
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	long long int n, d;

	cin >> d >> n;

	if (n != 100) {
		if (d == 0) {
			cout << n << endl;
		}
		if (d == 1) {
			cout << n * 100 << endl;
		}
		if (d == 2) {
			cout << n * 10000 << endl;
		}
	}
	else {
		if (d == 0) {
			cout << n+1 << endl;
		}
		if (d == 1) {
			cout << (n+1) * 100 << endl;
		}
		if (d == 2) {
			cout << (n+1) * 10000 << endl;
		}
	}

	

	return 0;
}

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

int main() {
  int N;
  cin >> N ;
  if (N<1200) {
    cout << "ABC" << endl;
  }
  else if (N>=1200 && N<2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}


Measured memory_bytes: 256
a=[]
gets.split(" ").each{|f| a<<f.to_i}
if (((a[0]-a[1]).abs <= a[3]) && ((a[1]-a[2]).abs <= a[3])) || ((a[0]-a[2]).abs <= a[3]) then
   print "Yes"
else
  print "No"
end

Measured memory_bytes: 1788
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        a:i64,b:i64
    }
    let ans = if a > b * 2 { a - b * 2 } else { 0 };
    println!("{}", ans);
}


Measured memory_bytes: 4352
/*
 *  Author : Jun_SH
 *  Solution for ABC 140 C
 */
#include<bits/stdc++.h>
#define int long long
#define sd(a) scanf("%lld",&a)
using namespace std;
const int inf=0x3f3f3f3f;
int b[105];
main(){
    int n;
    cin>>n;
    for(int i=1;i<n;++i)cin>>b[i];
    int sum=b[1];
    b[n]=inf;
    for(int i=1;i<n;++i)
        sum+=min(b[i],b[i+1]);
    cout<<sum<<endl;
}


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

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

// mod add
const int MOD = 1000000007;
void add(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

// 0: dammy, 1: 'A', 2: 'G', 3: 'C', 4: 'T'
// "AGC, GAC, ACG", "A*GC", "AG*C" を含まない (012, 102, 021 を禁止)
long long solve(int N) {
    auto dp = make_vec<long long>(N+1, 5, 5, 5); // dp[i文字][3文字前][2文字前][1文字前]
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; ++n) {
        for (int i = 0; i < 5; ++i) {
            for (int j = 0; j < 5; ++j) {
                 for (int k = 0; k < 5; ++k) {
                     for (int l = 1; l < 5; ++l) {
                         if (i == 1 && j == 2 && l == 3) continue;
                         if (i == 1 && k == 2 && l == 3) continue;
                         if (j == 1 && k == 2 && l == 3) continue;
                         if (j == 2 && k == 1 && l == 3) continue;
                         if (j == 1 && k == 3 && l == 2) continue;
                         add(dp[n+1][j][k][l], dp[n][i][j][k]);
                     }
                }
            }
        }
    }
    long long res = 0;
    for (int i = 1; i < 5; ++i)
        for (int j = 1; j < 5; ++j)
            for (int k = 1; k < 5; ++k)
                add(res, dp[N][i][j][k]);
    return res;
}

int main() {
    int N;
    while (cin >> N) cout << solve(N) << endl;
}


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

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

int main(){
  int n;
  cin>>n;
  int a[n];
  map<int,int>m;
  for(int i=1;i<n;i++){
    cin>>a[i];
    m[a[i]]++;
  }
  for(int i=1;i<n+1;i++)
    cout<<m[i]<<endl;


  return 0;
}


Measured memory_bytes: 13788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;

		for (int i = a; i <= b ; i++) {
			if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10) {
				ans++;
			}
		}

		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 22868
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const long long INF = 1LL << 60;
ll MOD = 1e9+7;

int main() {

    int N; cin>>N;
    int A,B; cin>>A>>B;

    int sum=0;

    for (int i = 1; i <= N; ++i) {
        int tmp=i;
        int digitwa=0;
        while (tmp>0){
            digitwa += tmp % 10;
            tmp /= 10;
        }
        if(A <= digitwa && digitwa <= B) sum+=i;
    }

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

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int m, d;
  scan(m, d);
  int cnt = 0;
  FOR (i, 1, m+1) {
    FOR (j, 10, d+1) {
      int d1 = j % 10;
      int d10 = j / 10;
      if (d1 >= 2 && d10 >= 2 && i == d1 * d10) {
        cnt += 1;
      }
    }
  }
  print(cnt);

  return 0;
}


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

int main() {
  
  int A = 0, B = 0, T = 0;
  
  cin >> A >> B >> T;
  
  int time = T+0.5;
  
  if(time<A) {
    
    cout << "0" << endl;
    
  } else {
    
    int num = time/A;
    int cookie = num*B;
    
    cout << cookie << endl;
    
  }
  
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

string s;
int dp[12][8][2];
int n;

int solve(int i, int m, int k) {

    if (i == n) return m == 7;
    if (dp[i][m][k] != -1) return dp[i][m][k];

    int tmp = 0;

    if (k == 1) {
        for (int j=0; j<3; j++) {
            tmp += solve(i+1, m|(1<<j), k);
        }
        if (m == 0) {
            tmp += solve(i+1, m, k);
        }
    }
    else {
        for (char c = '0'; c <= s[i]; c++) {
            if (c == '7') {
                tmp += solve(i+1, m|1, c!=s[i]);
            }
            else if (c == '5') {
                tmp += solve(i+1, m|2, c!=s[i]);
            }
            else if (c == '3') {
                tmp += solve(i+1, m|4, c!=s[i]);
            }
            else if (c == '0' && i == 0) {
                tmp += solve(i+1, m, c!=s[i]);
            }
        }

    }

    //if (tmp == 1) cout<<i<<" "<<m<<" "<<k<<endl;

    dp[i][m][k] = tmp;

    return tmp;

}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    cin>>s;
    n = s.length();

    for (int i=0; i<n; i++) for (int j=0; j<8; j++) for (int k=0; k<2; k++) dp[i][j][k] = -1;

    cout<<solve(0, 0, 0);

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

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

    int L = -1, R = N + 1, l, r;
    for (int i = 0; i < M; i++) {
        cin >> l >> r;
        L = max(l, L);
        R = min(r, R);
    }
    cout << max(0, R - L + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int second;		//Value S.
	int h, m, s;	//ansers.

	scanf("%d", &second);

	h = second / 3600;
	m = second % 3600 / 60;
	s = second % 3600 % 60;

	printf("%d:%d:%d\n", h, m, s);
	return (0);
}



Measured memory_bytes: 2076
#include <iostream>
using namespace std;
int main()
{
	int x,a,b,c;//a 10 b 2 c 1
	int ans=0;
	int k;
	cin>>a>>b>>c>>x;
	x/=50;
	for(int i=0;i<=a;i++)
	{
		for(int j=0;j<=b;j++)
		{
			k=x-10*i-2*j;
			if(k>=0 && k<=c)
			{
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n1,n2,dp[3200][3200];
char s[3105],t[3015];
string ty;
int main(){
	scanf("%s",s+1);
	scanf("%s",t+1);
	n1=strlen(s+1);
	n2=strlen(t+1);
	for(int i=1;i<=n1;i++){
		for(int j=1;j<=n2;j++){
			int tt=max(dp[i-1][j],dp[i][j-1]);
			if(s[i]==t[j]) { tt=max(tt,dp[i-1][j-1]+1) ;}
			dp[i][j]=tt;
		}
	}
	int x=n1,y=n2;
	//int cev=dp[n1][n2];
	while(x>0 && y>0){
		if(s[x]==t[y]){
			ty=ty+s[x];
			x--;
			y--;
		}
		else if(dp[x-1][y]>dp[x][y-1]){
			x--;
		}
		else y--;
	}
	reverse(ty.begin(),ty.end());
	cout<<ty<<endl;
	return 0;
}
 

Measured memory_bytes: 39168
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC159A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = RInt;
            var M = RInt;

            int ans = N * (N - 1) / 2 + M * (M - 1) / 2;
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
a = []

for i in range(3):
    b = list(map(int, input().split()))
    a.append(b)
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

ans = [[0,0,0], [0,0,0], [0,0,0]]
for num_b in range(n):
    for i in range(3):
        for j in range(3):
            if b[num_b] == a[i][j]:
                ans[i][j] = 1

for i in range(3):
    if ans[i][0] == 1 and ans[i][1] == 1 and ans[i][2] == 1:
        print('Yes')
        exit()
    if ans[0][i] == 1 and ans[1][i] == 1 and ans[2][i] == 1:
        print('Yes')
        exit()
    if ans[0][0] == 1 and ans[1][1] == 1 and ans[2][2] == 1:
        print("Yes")
        exit()
    if ans[2][0] == 1 and ans[1][1] == 1 and ans[0][2] == 1:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;


int main(){
    int n,ans=0,i=0;
    cin>>n;
    vector<int> a(n,0);
    for(int i=0; i<n; i++)cin>>a[i];
    sort(a.begin(),a.end());

    while(1){
        if(a[i]==a[i+1]){
            i+=2;
        }else{
            ans++;
            i++;
        }
        if(i==n-1){
            ans++;
            break;
        }
        if(i>n-1)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
  string S;
  cin >> S;
  int cnt = 0;
  int cntmax = 0;
  rep(i, 3){
    if(S.at(i) == 'R')
      cnt++;
    else
      cnt = 0;
    cntmax = max(cnt, cntmax);
  }
  cout << cntmax << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++) s[i]='x';
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     int                long long
#define     ll                 long long
#define     start              int t;cin>>t;while(t--)
#define     f(n)               for(ll i=0;i<n;i++)
#define     fk(i,k,n)          for(ll i=k;i<=n;i++)
#define     al(s)              s.begin(),s.end()
#define     mp                 make_pair
#define     isvowel(a)         (a=='a' or a=='e' or a=='o' or a=='i' or a=='u')
#define     pb                 push_back
#define     ln                 cout<<"\n"
#define     sum(v)             accumulate(v.begin(), v.end(), 0ll)
#define     db1(x)           cout<<(#x)<<" is "<<x<<endl
#define     db2(x,y)           cout<<(#x)<<" is "<<x<<endl<<(#y)<<" is "<<y<<endl
#define     MOD                1000000007
#define     mii                map<int,int>
#define     vi                 vector<int>
#define     vii                vector<pair<int, int> >

const int N=2e5+20;
void print(vector<int> v, int n){f(n){cout<<v[i]<<" ";}}

void run()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(0);
   /* #ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #endif    */
}

int32_t main()
{
    run();
    
    string s;
    cin>>s;
    int x=count(al(s),'A');
    int y=count(al(s),'B');

    if(x and y)
        cout<<"Yes";
    else
        cout<<"No";
    ln;
}

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


using ll = long long int;
using namespace std;





int main()
{
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
	int n, p, i, j;
	string s;
	cin >> n >> p >> s;
	
	if (p == 2)
	{
		ll ans = 0;
		for(i = 0; i < n; ++i)
		{
			if ((s[i] - '0') % 2 == 0)
			{
				ans += (i + 1);
			}
		}
		cout << ans;
		return 0;
	}
	
	if (p == 5)
	{
		ll ans = 0;
		for(i = 0; i < n; ++i)
		{
			if ((s[i] - '0') % 5 == 0) 
			{
				ans += (i + 1);
			}
		}
		cout << ans;
		return 0;
	}
	
	vector<int> M(p);
	
	M[0] = 1;
	int sum = 0;
	int power = 1;
	ll ans = 0;
	for(i = n - 1; i >= 0; --i)
	{
		sum += ((s[i] - '0') * power) % p;
		sum %= p;
		ans += M[sum];
		M[sum]++;
		power *= 10;
		power %= p;
	}
	
	cout << ans;
	
	
	return 0;
}

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

int w, h;
int dp[101][101][4];

int solve(int y, int x, int index) { 
  // 0：まっすぐ下から　1：まっすぐ左から　2：曲がって下から　3：曲がって左から
  if( y == h-1 && x == w-1 ) return 1;
  if( y >= h || x >= w ) return 0;
  if( dp[y][x][index] ) return dp[y][x][index];
  if( index == 0 ) {
    return dp[y][x][index] = (solve(y+1, x, 0) + solve(y, x+1, 3)) % 100000;
  }
  if( index == 1 ) {
    return dp[y][x][index] = (solve(y, x+1, 1) + solve(y+1, x, 2)) % 100000;
  }
  if( index == 2 ) {
    return dp[y][x][index] = solve(y+1, x, 0) % 100000;
  }
  if( index == 3 ) {
    return dp[y][x][index] = solve(y, x+1, 1) % 100000;
  }
}
 
int main() {

  while( cin >> w >> h, w+h ) {
    for(int i=0; i<101; i++) {
      for(int j=0; j<101; j++) {
	for(int k=0; k<4; k++) {
	  dp[i][j][k] = 0;
	}
      }
    }

    cout << (solve(1, 0, 0) + solve(0, 1, 1)) % 100000 << endl; 
  }
}

Measured memory_bytes: 1328
while 1:
    n, m = map(int, input().split())
    if n == m == 0:
        break
    B = [int(input(), 2) for i in range(n)]
    C = {0: 0}
    for b in B:
        D = dict(C)
        for k in C:
            D[k ^ b] = max(D.get(k ^ b, 0), C[k] + 1)
        C = D
    print(C[0])

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

typedef long long ll;

ll N, M;
vector<vector<ll>> vec;
map<ll,ll> mapping;

int main(){
    cin >> N >> M;
    vec = vector<vector<ll>>(N,vector<ll>{});
    for(ll i = 0; i < M; i++){
        ll A, B;
        cin >> A >> B;
        A--, B--;
        vec[A].push_back(B);
        vec[B].push_back(A);
    }
    
    for(ll i = 0; i < N; i++){
        mapping[i] = -1;
    }
    
    queue<ll> sign;
    sign.push(0);
    while(!sign.empty()){
        ll temp = sign.front();
        sign.pop();
        for(int i = 0; i < (ll)vec[temp].size(); i++){
            if(mapping[vec[temp][i]] == -1){
                mapping[vec[temp][i]] = temp;
                sign.push(vec[temp][i]);
            }
        }
    }
    
    string res = "";
    for(int i = 1; i < N; i++){
        if(mapping[i] == -1){
            cout << "No" << endl;
            return 0;
        }
        res += to_string( mapping[i] + 1) + "\n";
    }
    cout << "Yes" << endl;
    cout << res;
    return 0;
}

Measured memory_bytes: 19212
#include <bits/stdc++.h>
using namespace std;
int main()
{
char s[30];
scanf("%s",s);
 int a;
 a=strlen(s);
 char ss[30];
 int sum;sum=0;
 for(int i=0;i<=a;i++)
    if(s[i]=='0')ss[sum++]='0';
    else if(s[i]=='1')ss[sum++]='1';
    else if(s[i]=='B'){if(sum)sum--;}
    for(int i=0;i<sum;i++)
        cout<<ss[i];
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

ans=0

for i in range(N):

    d=0
    a=list(map(int,input().split()))

    for j in range(M):
        
        d += B[j]*a[j]

    if d > -C:

        ans += 1
        
print(ans)


Measured memory_bytes: 3060