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

int main(){
    long int a, b, c, d;
    cin >> a >> b >> c >> d;
    long int m = max(a*c, b*d);
    m = max(m, a*d);
    m = max(m, b*c);
    cout << m << endl;
    return 0;
}

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

int main(){
  int h,w;
  cin >>h >>w;
  char s[50][50];
  rep(i,h){
    rep(j,w) cin >>s[i][j];
  }
  const int dx[4] = {0,0,-1,1};
  const int dy[4] = {-1,1,0,0};
  bool can = true;
  rep(i,h){
    rep(j,w){
      bool can2 = false;
      if(s[i][j]=='.') continue;
      rep(d,4){
        const int ni = i+dy[d];
        const int nj = j+dx[d];
        if(ni<0 or h<=ni) continue;
        if(nj<0 or w<=nj) continue;
        if(s[ni][nj]=='#') can2=true;
      }
      if(!can2){
        can = false;
        break;
      }
    }
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  unordered_map<string,int> mp;
  for(int i=0;i<n;i++)
  {
    string a;
    cin>>a;
    mp[a]++;
  }
  cout<<"AC"<<" x "<<mp["AC"]<<endl;
  cout<<"WA"<<" x "<<mp["WA"]<<endl;
  cout<<"TLE"<<" x "<<mp["TLE"]<<endl;
  cout<<"RE"<<" x "<<mp["RE"]<<endl;
}

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

typedef long long ll;

const int Maxn = 100005;

int n;
ll c;
ll X[Maxn], V[Maxn];
ll dp[Maxn];

ll Get(int koef1, int koef2)
{
	ll val = 0;
	for (int i = n - 1; i >= 0; i--) {
		val += V[i];
		dp[i] = val - koef1 * (c - X[i]);
	}
	ll cur = 0;
	ll mx = 0;
	ll res = 0;
	for (int i = 0; i < n; i++) {
		res = max(res, dp[i] + mx);
		cur += V[i];
		mx = max(mx, cur - koef2 * X[i]);
	}
	res = max(res, mx);
	return res;
}

int main()
{
	scanf("%d %lld", &n, &c);
	for (int i = 0; i < n; i++)
		scanf("%lld %lld", &X[i], &V[i]);
	printf("%lld\n", max(Get(2, 1), Get(1, 2)));
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e15

using namespace std;

vll a;
vll dp;
vll osum;

ll dfs(int k)
{
    if (k<1) return 0;
    if (dp[k]!=-INF) return dp[k];
    else dp[k] = dfs(k-2)+a[k];
    if (k&1) chmax(dp[k], osum[k]);
    else chmax(dp[k], dfs(k-1));
    return dp[k];
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    a.resize(n);
    dp.resize(n,-INF);
    osum.resize(n);
    rep(i,n) cin>>a[i];
    rep(i,n)if(i%2==0) osum[i]+=a[i];
    rep(i,n-1) osum[i+1]+=osum[i];
    cout<<dfs(n-1)<<"\n";
    return 0;
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
using namespace std ;
const int mod=1e9 + 7;
int n,m;

ll panther(int row,int col,vector<string> inp,vector<vector<ll>> &dp)
{
    if(row<0) return 0;
    if(col<0) return 0;
    if(inp[row][col] == '#') return 0;
    if(row == 0 and col == 0) return 1;
    
    if(dp[row][col] == -1)
    {
        ll ans = 0;
        ans += panther(row-1,col,inp,dp);
        ans %= mod;
        ans += panther(row,col-1,inp,dp);
        ans %= mod;
        
        dp[row][col] = ans;
        return ans;
    }
    else return dp[row][col];
}

ll topdown(vector<string> inp,vector<vector<ll>> &dp)
{
    dp[0][0] = 1;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(inp[i][j] == '#') dp[i][j] = 0;
            else 
            {
                if(j-1>=0)
                {
                    dp[i][j] += dp[i][j-1];
                }
                if(i-1>=0)
                {
                    dp[i][j] += dp[i-1][j];    
                }
            }
            dp[i][j] %= mod;
        }
    }
    return dp[n-1][m-1];
}

int main()
{
    cin>>n>>m;
    
    vector<string> inp(n);
    for(int i=0;i<n;i++)
    {
        cin>>inp[i];
    }
    std::vector<vector<ll>> dp(n,vector<ll> (m)) ;
    cout<<topdown(inp,dp)<<endl;
}

Measured memory_bytes: 14384
/**
 *  Author1: low-equipped w_udixixi
 *  Author2: Sher丶lock
 *  Date :2019-08-20
 **/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<queue>
#include<map>
#define ll long long
#define pb push_back
#define rep(x,a,b) for (int x=a;x<=b;x++)
#define repp(x,a,b) for (int x=a;x<b;x++)
#define pi 3.14159265358979323846
#define mem(a,x) memset(a,x,sizeof a)
#define lson rt<<1,l,mid
#define rson rt<<1|1,mid+1,r
using namespace std;
const int maxn=2e5+7;
const int INF=1e9;
const ll INFF=1e18;
ll w[maxn];
ll val[maxn];
ll dp[maxn];

int main()
{
    ll n,vol;
    scanf("%lld%lld",&n,&vol);
    rep(i,1,n)
    {
        scanf("%lld%lld",&w[i],&val[i]);
        dp[i]=0;
    }
    rep(i,1,n)
    {
        for (int j=vol;j>=w[i];j--)
        {
            dp[j]=max(dp[j],dp[j-w[i]]+val[i]);
        }
    }
    cout<<dp[vol]<<endl;
}


Measured memory_bytes: 3072
/*
 * Matheus Oliveira
 * 12:20:10 02/04/2019
 * 122c.cpp
*/

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

#define EPS
#define INF
#define MAXN 100100
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, ini, fim) printf("%s: ", #x); for(int i = ini; i <= fim; i++) printf("%d%c", x[i], (i == fim) ? '\n' : ' ');
typedef long long ll;
typedef pair<int, int> pii;

int ans[MAXN];
char inp[MAXN];

int get(int idx) {
	if(idx < 0) return 0;
	return ans[idx];
}

int main() {
	int sz, q, l, r;

	scanf("%d %d", &sz, &q);
	getchar();

	scanf("%s", inp);

	for(int i = 1; i < sz; i++) {
		ans[i] += ans[i-1];
		if(inp[i] == 'C' and inp[i-1] == 'A') ans[i]++;
	}

	//debugarr(ans, 0, sz-1);

	for(int i = 0; i < q; i++) {
		scanf("%d %d", &l, &r);
		l--, r--;

		printf("%d\n", get(r) - get(l));
	}

	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a=0,b=0,a1=0,b1=0;
	for(int i=0;i<4;i++)
	{
		cin>>a;
		a1+=a;
	}
	for(int i=0;i<4;i++)
	{
		cin>>b;
		b1+=b;
	}
	cout<<max(a1,b1)<<endl;
	return 0;
}
//8:12.624クリア


Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, a[N];
long long res = -1ll * 1000000000 * 1000000000;
long long sum = 0;
long long x[N], y[N];
int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= 3 * n; i++) cin >> a[i];
    priority_queue <int, vector<int>, greater <int> > pq;
    for (int i = 1; i <= n; i++) {
        pq.push(a[i]);
        sum += a[i];
    }
    x[n] = sum;
    for (int i = n + 1; i <= 3 * n; i++) {
        if (a[i] > pq.top()) {
            sum -= pq.top();
            pq.pop();
            pq.push(a[i]);
            sum += a[i];
        }
        x[i] = sum;
    }
    priority_queue <int> pq2;
    sum = 0;
    for (int i = 3 * n; i >= 2 * n + 1; i--) {
        sum += a[i];
        pq2.push(a[i]);
    }
    y[2 * n + 1] = sum;
    for (int i = 2 * n; i; i--) {
        if (a[i] < pq2.top()) {
            sum -= pq2.top();
            pq2.pop();
            pq2.push(a[i]);
            sum += a[i];
        }
        y[i] = sum;
    }
    for (int i = n; i <= 2 * n; i++)
        res = max(res, x[i] - y[i + 1]);
    cout << res;
    return 0;
}


Measured memory_bytes: 6520
n,m = map(int,input().split())
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

if n >= 2:
  a = cmb(n,2)
else:
  a = 0
if m >= 2:
  b = cmb(m,2)
else:
  b = 0
print(a+b)
  

Measured memory_bytes: 3700
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define popcnt(n) __builtin_popcount(n)
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;


const int NMAX=1000001;


signed main() {
    string s;
    cin >> s;
    
    ll l = (ll)s.size();
    
    if (s[l-1] == 's') {
        cout << s << "es";
    } else {
    cout << s << "s";
    }
    
 
    
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll a,b;
 cin>>a>>b;
 if(a>=b)
 {
     for(int i=1;i<=a;i++)
        cout<<b;
 }
 else
 {
     for(int i=1;i<=b;i++)
        cout<<a;
 }
return 0;
}




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

int main() {
  // your code here...
  int N;
  scanf("%d", &N);

  int D[N];

  for (int i = 0; i < N; i++) {
    scanf("%d", &D[i]);
  }

  int sum = 0, k;
  for (int i = 0; i < N; i++) {
    k = 0;
    for (int j = i; j < N; j++) {
      if (i == j) continue;
      k += D[j];
    }
    sum += D[i] * k;
  }

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, l;
    cin >> n >> l;
    vector<string> a(n);
    for (int i = 0; i < n; ++ i) {
        cin >> a[i];
    }
    auto cmp = [](string& x, string& y) {
        return x + y < y + x;
    };
    sort(a.begin(), a.end(), cmp);
    for (auto& str : a) cout << str;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }
        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var a = cin.ReadLongArray(N);
            var sum = a.Sum();
            var ans = long.MaxValue;
            var x = 0L;
            for(int i = 1; i <= N - 1; i++)
            {
                x += a[i - 1];
                var abs = Abs(2 * x - sum);
                if (abs < ans) ans = abs;
                if (ans == 0) break;
            }
            WriteLine(ans);
        }

        /*public long C(long n, long r)
        {
            if (r == 0 || r == n) return 1L;
            if (n < r) return 0L;
            long[,] Pascal = new long[n + 1, n + 1];
            Pascal[0, 0] = 1;
            for (long i = 1; i <= n; i++)
            {
                Pascal[i, 0] = 1;
                Pascal[i, i] = 1;
                for (long j = 1; j < n; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[n, r];
        }*/

        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: 33720
#include <iostream>
using namespace std;
int main(){
	int N,D,X,A[110]={},sunadatyan=0;
	cin>>N>>D>>X;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	for(int ii=0;ii<N;ii++){
		for(int i=0;i<D;i=i+A[ii]){
			sunadatyan++;
		}
	}
	cout<<sunadatyan+X<<endl;
}

Measured memory_bytes: 256
#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>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

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

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    string a,b;
    cin >> a >> b;
    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0])cout << "YES" << endl;
    else cout << "NO" << endl;
    
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()



int main(){
  ll N,M,t=0,ans=0;
  cin >> N >> M;
  vector<P> A(M);
  rep(i,M) cin >> A.at(i).first >> A.at(i).second;
  sort(all(A));
  rep(i,M){
    ll m=A.at(i).second;
    while(t<M&&A.at(t).first<m){
      m=min(m,A.at(t).second);
      t++;
    }
    ans++;
    i=t-1;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 4820
n = int(input())
s = "abcdefghij"

class Node:
    def __init__(self, string, index):
        self.children = []
        self.string = string
        self.index = index

    def get_children(self):
        parent = self.string
        for i, c in enumerate(s[:self.index+1], 1):
            self.children.append(Node(parent+c, max(i, self.index)))
        return self.children

root = Node("a", 1)
children = [root]
for _ in range(n-1):
    parents, children = children, []
    for parent in parents:
        children.extend(parent.get_children())
for child in children:
    print(child.string)

Measured memory_bytes: 49088
#include <iostream>
#include <vector>
#include <cstdlib>  // abs() for 整数値
#include <cmath> // abs() for 小数値

using namespace std;

int main(){
    int N;

    cin >> N ;

    vector <int> t(N + 1);
    vector <int> x(N + 1);
    vector <int> y(N + 1);

    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for(int i = 1; i < N + 1; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }
    
    int count = 0;

    while(count < N){

        int x_move = x[count + 1] - x[count];
        int y_move = y[count + 1] - y[count];
        int move = std::abs(x_move) + std::abs(y_move);

        int passtime = t[count + 1] - t[count];

        int move_dig = move % 2;
        int passtime_dig = passtime % 2;

        if (passtime < move || move_dig != passtime_dig){
            break;
        } else{
            count = count + 1;
        }
    }
    
    if (count == N){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int q; cin >> q;
    for (int i = 0; i < q; i++) {
        string s, t; cin >> s >> t;
        int n = s.size(), m = t.size();
        int dp[n+1][m+1] = {};
        for (int i= 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s[i] == t[j]) {
                    dp[i+1][j+1] = dp[i][j] + 1;
                } else {
                    dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
                }
            }
        }
        cout << dp[n][m] << endl;
    }
}


Measured memory_bytes: 7004
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;


signed main() {
int ans=0,N,tmp;
cin >> N;
vector<int> A(N+1,0);
for(int i=1;i<=N+1;i++){
    for(int j=1;j<=N+1;j++){
        tmp=i*j;
        A[tmp]+=1;
        if(tmp>N){
            break;
        }
    }
    
}
REP(i,N+1){
    if(A[i]==8&&i%2==1){
        ans+=1;
    
    }
}
answer(ans);
return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int i,j,k;
    int N,a[200001],count = 0;
    bool check[200001] = {false};
    
    scanf("%d",&N);
    for(i = 0;i < N - 1;i++){
        scanf("%d\n",&a[i]);
    }
    scanf("%d",&a[i]);
    
    for(i = N-1;i >= 0;i--){
        count = 0;
        for(j = i;j < N;j += (i+1)){
            if(check[j] == true){
                count++;
            }
        }
        if(a[i] == 1){
            if(count % 2 == 0){
                check[i] = true;
            }
        }else{
            if(count % 2 == 1){
                check[i] = true;
            }
        }
    }
    
    count = 0;
    for(i = 0;i < N;i++){
        if(check[i] == true){
            count++;
        }
    }
    printf("%d\n",count);
    for(i = 0;i < N;i++){
        if(check[i] == true){
            printf("%d ",i+1);
        }
    }
    printf("\n");
    
    return 0;
}



Measured memory_bytes: 1920
#include <stdio.h>
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
#define repm(i,l,r) for((i)=(l);(i)>=(r);(i)--)
int t[500][500];
int main(){
  int N,M,Q,i,j,p,q,l,r;
  scanf("%d%d%d",&N,&M,&Q);
  rep(i,0,M){
    scanf("%d%d",&l,&r);
    t[l-1][r-1]++;
  }
  for(i=N;i--;)rep(j,0,N-1)t[i][j+1]+=t[i][j];
  for(i=N-1;i--;)rep(j,0,N)t[i][j]+=t[i+1][j];
  rep(i,0,Q){
    scanf("%d%d",&p,&q);
    printf("%d\n",t[p-1][q-1]);
  }
}

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

int main(){
  int N;
  cin>>N;
  for(int i=1; i<=9; i++){
    if(N%i==0&&N/i<=9){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean[][] trumps = new boolean[4][13];
		int g = sc.nextInt();
		String character;
		int number;
		int trumpsIndex = 0;
		for (int i = 0; i < g; i++) {
			character = sc.next();
			number = sc.nextInt() - 1;
			switch (character) {
			case "S":
				trumpsIndex = 0;
				break;
			case "H":
				trumpsIndex = 1;
				break;
			case "C":
				trumpsIndex = 2;
				break;
			case "D":
				trumpsIndex = 3;
				break;
			}
			trumps[trumpsIndex][number] = true;
		}
		character = "";
		for (int i = 0; i < trumps.length; i++) {
			for (int j = 0; j < trumps[i].length; j++) {
				if (trumps[i][j] == false) {
					switch (i) {
					case 0:
						character = "S";
						break;
					case 1:
						character = "H";
						break;
					case 2:
						character = "C";
						break;
					case 3:
						character = "D";
						break;
					}
					System.out.println(character + " " + (j + 1));
				}
			}
		}
		sc.close();
	}
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
using namespace std;
#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++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << "\n"; }
#define YN(f) cout << (f ? "YES" : "NO") << "\n"
#define Yn(f) cout << (f ? "Yes" : "No") << "\n"
#define yn(f) cout << (f ? "yes" : "no") << "\n"
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using ti3 = tuple<int, int, int>;
using tl3 = tuple<ll, ll, ll>;

int main() {
	int N; cin >> N;
	vector<ll> A(N + 1); rep2(i, 1, N + 1) cin >> A.at(i); // 1-ind
	vl L(N + 2, 0), R(N + 2, 0);
	rep2(i, 1, N + 1) L[i] = __gcd(L[i - 1], A[i]);
	rep3(i, N, 0) R[i] = __gcd(R[i + 1], A[i]);
	dbv(A); dbv(L); dbv(R);
	ll ans = 0;
	rep2(i, 1, N + 1) ans = max(ans, __gcd(L[i - 1], R[i + 1]));
	cout << ans << endl;	
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[101];
int cnt[101];
int main()
{
	int n,ma=0,mi=214748;
	scanf("%d",&n);
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		ma=max(ma,a[i]);
	}
	for(int i=1;i<=ma+1;i++)
	{
		if(cnt[max(i-1,ma+1-i)])
			cnt[max(i-1,ma+1-i)]--;
		else
		{
			printf("Impossible");
			return 0;
		}
		mi=min(mi,max(i-1,ma+1-i)+1);
	}
	for(int i=1;i<mi;i++)
		if(cnt[i])
		{
			printf("Impossible");
			return 0;
		}
	printf("Possible");
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
a = [int(i) for i in readline().split()]

from functools import reduce
from operator import xor

NMAX = 62
omask = reduce(xor,a)
emask = (1<<NMAX)-1
emask ^= omask

for i in range(n):
    a[i] &= emask

k = 0
for i in range(NMAX,-1,-1):
    for j in range(k,n):
        if a[j] & (1<<i):
            if j != k: a[j], a[k] = a[k], a[j]
            for l in range(n):
                if l != k and a[l] & (1<<i): a[l] ^= a[k]
            k += 1
            break


print(omask + 2*reduce(xor,a))










Measured memory_bytes: 71456
mod reader {
    use std;

    macro_rules! read_line((  ) => {
                           {
                           let mut input = String :: new (  ) ; std :: io ::
                           stdin (  ) . read_line ( & mut input ) . unwrap (
                           ) ; input } } ;);

    pub fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
        read_line!().split_whitespace().map(|e|
                                                e.parse().ok().unwrap()).collect()
    }

	pub fn read_str() -> String { read_line!().trim().to_owned() }
}
use reader::*;

#[macro_use]
mod misc {
    #[macro_export]
    macro_rules! bind_from_vec((
                               $ ( $ variable : ident ) , + = $ vector : expr
                               ) => {
                               let mut v = $ vector . clone (  ) . into_iter (
                                ) ; $ (
                               let $ variable = v . next (  ) . unwrap (  ) ;
                               ) + } ;);
}

use std::collections::HashMap;

fn main() {
    bind_from_vec!(n , k = read_to_vec :: < usize > (  ));
    let s = read_str();
    let mut uprights: HashMap<i32, i32> = HashMap::new();
    let mut start: i32 = 0;

    uprights.insert(-1, 1);
    for (i, c) in s.chars().enumerate() {
        match c {
            '0' => {
                if start == (i as i32) { uprights.insert(start, 0); }
                *uprights.get_mut(&start).unwrap() += 1;
            }
            '1' => { start = (i as i32) + 1; }
            _ => { }
        }
    }
    uprights.insert(n as i32, 1);

    if uprights.len() - 2 <= k { println!("{}" , n); return; }

    let mut uprights: Vec<_> = uprights.iter().collect();

    uprights.sort_by_key(|tuple| tuple.0);

    println!("{}" , ( 1 .. ( uprights . len (  ) - k ) ) . fold (
             0 , | acc , i | std :: cmp :: max (
             acc , uprights [ i + k ] . 0 - (
             uprights [ i - 1 ] . 0 + uprights [ i - 1 ] . 1 ) ) ));
}


Measured memory_bytes: 8444
#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 all(a) a.begin(),a.end()
#define INF (int)(1e9)

int main(){
    int n,m; cin>>n>>m;
    vi ball(n,1),exist(n,0); exist[0]=1; 
    rep(i,m){
        int p,q; cin>>p>>q; p--; q--;
        ball[p]--; ball[q]++;
        if(exist[p]==1){
            if(ball[p]==0) exist[p]=0;
            exist[q]=1;
        }
    }
    cout<<accumulate(all(exist),0)<<endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int a, b;
	cin>>a>>b;
	if(abs(a-b)&1){
		cout<<"IMPOSSIBLE"<<'\n';
	}
	else{
		cout<<(a+b)/2<<'\n';
	}
	return 0;
}


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

int main() {
	int n,max,d;
	cin>>n;
	vector<int>vec(n);
	vector<int>vic(n);
	vector<int>vuc(n);
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		vec.at(i)=a;
	}
	for(int i=0;i<n;i++){
		int b;
		cin>>b;
		vic.at(i)=b;
	}
	for(int i=0;i<n;i++){
	int sum=0;	
		for(int j=0;j<n;j++){
			
			if(i>=j){
				sum+=vec.at(j);
			}
			else{
				sum+=vic.at(j-1);
			}
			
			
		}
	vuc.at(i)=sum;	
	}
	max=vuc.at(0);
	for(int i=0;i<n-1;i++){
		if(max<vuc.at(i+1)){
		max=vuc.at(i+1);	
		}
	}
	cout<<max+vic.at(n-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		long num = 1000000007;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int n = Integer.parseInt(bf.readLine());
 		long sum =0;
 		long sumsq = 0;
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		for(int j =0;j<n;j++){
 			int k = Integer.parseInt(st.nextToken());
 			sum+=(long)(k);
 			sumsq+=(long)((long)(k)*(long)(k));
 			sumsq%=num;
 			sum%=num;
 		}
 		
 		long ans = sum*sum;
 		ans%=num;
 		ans-=sumsq;
 		ans = (ans%num+num)%num;
 		if (ans%2 == 1)
 			ans+=num;
 		ans/=2;
 		
 		out.println(ans);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;

vector<double> solve(int n , vi t , vi v){
	int tot = 0;
	vi fr(n);
	rep(i , n){
		tot += t[i];
		fr[i] = tot;
	}
	vector<double> res(tot + 1);
	int k = 0;
	++tot;
	rep(i , tot){
		if(i > fr[k])++k;
		if(i == 0){
			res[0] = 0;
		}else{
			res[i] = min(1.0 * v[k] , res[i - 1] + 1);
		}
	}
	return res;
}

double f(int t1 , int t2 , double spd1 , double spd2 , double lim){
	if(abs(lim - spd1) < 1e-9)return spd1;
	if(spd2 > spd1)return spd1;
	if(spd2 < spd1)return spd1;
	double l = t1;
	double r = t2;
	rep(i , 200){
		double mid = (r + l) / 2;
		double cs1 = min(lim , spd1 + (mid - 1.0 * t1));
		double cs2 = min(lim , spd2 + (1.0 * t2 - mid));
		if(cs1 - 1e-7 <= cs2){
			l = mid;
		}else{
			r = mid;
		}
	}
	double spdl = min(lim , spd1 + (l - 1.0 * t1));
	double spdr = min(lim , spd2 + (1.0 * t2 - l));
//	cout << t1 << " " << spd1 << " " << lim << nl;
	return abs(l - 1.0 * t1) * (spdl + spd1) / 2.0 + abs(1.0 * t2 - r) * (spdr + spd2) / 2.0;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(15); 
	cout.setf(ios::fixed);

	int n;
	cin >> n;
	
	vi t(n);
	vi v(n);
	int tot = 0;
	vi fr(n);
	rep(i , n){
		cin >> t[i];
		tot += t[i];
		fr[i] = tot;
	}
	rep(i , n){
		cin >> v[i];
	}
	
	
	auto frw = solve(n , t , v);
	reverse(all(t));
	reverse(all(v));
	auto bck = solve(n , t , v);
	reverse(all(bck));
	reverse(all(v));
	
	vector<double> spd(tot + 1);
	double ans = 0;
	rep(i , tot + 1){
		spd[i] = min(frw[i] , bck[i]);
	//	cout << i << " " << spd[i] << nl;
	}
	
	int k = 0;
	rep(i , tot){
		if(i >= fr[k])++k;
		ans += f(i , i + 1, spd[i] , spd[i + 1] , v[k]);
	}
	cout << ans;
	
	

	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <set>
#include <queue>
typedef long long ll;
const int N=100005;
ll n,a,b;
using namespace std;

int main()
{
	#ifdef Kay
		freopen ("code.in","r",stdin);
		freopen ("code.out","w",stdout);
	#endif
	cin>>n>>a>>b;
	if (n==1 && (a!=b)){cout<<0;return 0;}
	if (a>b){cout<<0;return 0;}
	
	ll s1=a*(n-1)+b,s2=b*(n-1)+a;
	cout<<s2-s1+1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h,w;
    cin>>h>>w;
    ll d[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            if(i==j){
                d[i][j]=0;
            }
            else{
                d[i][j]=inf;
            }

        }
    }
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            int k;
            cin>>k;
            if(d[i][j]>k){
                d[i][j]=k;
            }
        }
    }
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(d[i][j]>d[i][k]+d[k][j]){
                    d[i][j]=d[i][k]+d[k][j];
                }
            }
        }
    }

    ll ans=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int k;
            cin>>k;
            if(k==-1)   continue;
                ans+=d[k][1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set> 
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 262145
#define INF (int)2e9 
#define pi acos(-1)
#define mxbit 30
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
int n,m,S,T;

struct edge{
    int x,y,nxt;
    int mxf;
    int flow;
    edge(){}
    edge(int xx,int yy,int nn,int ff){
        x=xx,y=yy,nxt=nn;
        mxf=ff;
        flow=0;
    }
}e[100009];
int head[10009],ecnt=1;

void addedge(int x,int y,int flow){
    ecnt++;
    e[ecnt]=edge(x,y,head[x],flow);
    head[x]=ecnt;
    return;
}

void ae(int x,int y,int fl){
    addedge(x,y,fl);
    addedge(y,x,0);
    return;
}

int dep[10009];
queue <int> q;

bool bfs(void){
    while (!q.empty()){
        q.pop();
    }
    memset(dep,-1,sizeof(dep));
    dep[S]=1;
    q.push(S);
    while (!q.empty()){
        int u=q.front();
        q.pop();
        for (int i=head[u];i;i=e[i].nxt){
            int v=e[i].y;
            if (dep[v]==-1 && e[i].mxf-e[i].flow>0){
                dep[v]=dep[u]+1;
                q.push(v);
            }
        }
    }
    if (dep[T]==-1){
        return 0;
    }
    return 1;
}

int dfs(int u,int flow){
    if (flow==0){
        return 0;
    }
    if (u==T){
        return flow;
    }
    int ans=0;
    for (int i=head[u];i;i=e[i].nxt){
        int v=e[i].y,now;
        if (dep[v]==dep[u]+1){
            now=dfs(v,min(flow,e[i].mxf-e[i].flow));
            if (now){
                e[i].flow+=now;
                e[i^1].flow-=now;
                flow-=now;
                ans+=now;
            }
        }
    }
    return ans;
}

int dinic(void){
    int ans=0;
    while (bfs()){
        ans+=dfs(S,INF);
    }
    if (ans>=INF){
        ans=-1;
    }
    return ans;
}

int main(){
    rd(n) rd(m)
    char ch;
    S=0,T=n+m+1;
    int sx,sy,tx,ty;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=m;j++){
            ch=getchar();
            while (ch!='.' && ch!='o' && ch!='T' && ch!='S'){
                ch=getchar();
            }
            if (ch=='o'){
                ae(i,j+n,1);
                ae(j+n,i,1);
            }
            else if (ch=='S'){
                ae(S,i,INF);
                ae(S,j+n,INF);
                sx=i,sy=j;
            }
            else if (ch=='T'){
                ae(i,T,INF);
                ae(j+n,T,INF);
                tx=i,ty=j;
            }
        }
    }
    if (sx==tx || sy==ty){
        puts("-1");
        return 0;
    }
    int ans=dinic();
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iomanip>

using namespace std;
#define INF 1e9
#define MAX 105
#define MOD 1000000007
#define Q queue
#define PQ priority_queue
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define FOR( i, L, U ) for(int i=(int)L ; i<(int)U ; i++ )
#define FORD( i, U, L ) for(int i=(int)U ; i>=(int)L ; i-- )
#define wa cout<<"Wa"<<endl
#define READ(filename)  freopen(filename, "r", stdin);
#define WRITE(filename)  freopen(filename, "w", stdout);

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef map<int , vector<int> > mvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

void base(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
}


	int n,m;
	char arr[MAX][MAX];
int main(){
//	base();
	cin>>n>>m;
	FOR(i,1,n+1){
		FOR(j,1,m+1){
			cin>>arr[i][j];
		}
	}
	
	FOR(i,0,n+2){
		FOR(j,0,m+2){
			if (i==0 || j==0 || i==n+1 || j==m+1) cout<<"#";
			else cout<<arr[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int top,S[1000];
 
void push(int x);
int pop();
 
int main(){
  int a,b;
  top=0;
  char s[100];
 
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else
      push(atoi(s));
  }
 
printf("%d\n",pop());
 
return 0;
}
 
void push(x){
  S[++top]=x;
}
 
int pop(){
 
  top--;
 
  return S[top+1];
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n, m; cin >> n >> m;
    // priority_queue<int, vector<int>, greater<int>> a;
    priority_queue<P> a;
    ll ans = 0;
    rep(i, n){
        int x; cin>>x;
        a.push(make_pair(x, 1));
    }

    rep(i, m){
        int b, c; cin>>b>>c;
        a.push(make_pair(c,b));
    }
    rep(i, n) {
        auto au = a.top();
        a.pop();
        ans += au.first;
        if(au.second > 1) {
            --au.second;
            a.push(au);
        }
    }
    cout << ans << endl;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i=0; i<h; i++){
        cin >> a[i];
    }
    vector<vector<int>> ans(h, vector<int>(w, -1));
    for(int i=0; i<h; i++){
        int curr = -1;
        for(int j=0; j<w; j++){
            if(a[i][j] == 'c'){
                curr = 0;
            }
            ans[i][j] = curr;
            if(curr != -1){
                curr++;
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w-1; j++){
            cout << ans[i][j] << " ";
        }
        cout << ans[i][w-1] << endl;
    }
    return 0;
}



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

int main() {
  int Alice = 0, Bob = 0;
  int N;
  int diff;

  cin >> N;
  int a[N];

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

    for(int j = 0; j < i; j++){
      if(a[i] > a[j]){
        int temp = a[j];
        a[j] = a[i];
        a[i] = temp;
      }
    }
  }

  for(int i = 0; i < N; i++){
    if(i % 2){
      Alice += a[i];
    }
    else{
      Bob += a[i];
    }
  }

  diff = (Alice > Bob) ? Alice - Bob : Bob - Alice;

  cout << diff << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  int a,b,c;
  cin>>a>>b>>c;
  int ans=a*b/2;
  
  cout(ans);
 
  return 0;
}

Measured memory_bytes: 125568