akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        int N = Integer.parseInt(scanner.nextLine());
        String S = scanner.nextLine();
        char[] array = S.toCharArray();

        int current = 0;
        for (int i = 1; i < N; ++i) {
            if (array[i] == 'E') {
                ++current;
            }
        }

        int min = current;
        for (int i = 1; i < N; ++i) {
            //current += line[i];
            if (array[i] == 'E') {
                --current;
            }
            if (array[i-1] == 'W') {
                ++current;
            }
            if (min > current) {
                min = current;
            }
        }

        System.out.println(min);
    }
}

Measured memory_bytes: 32796
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Repi(i, a, b) for(int i = int(a); i < (int)(b); i++)
#define Repl(i, list) for(int i : list)
#define Sort(v) sort(v.begin(), v.end())
#define Rev(v) reverse(v.begin(), v.end())
#define Argmin(v) { int imin = 0; Rep(i, v.size()){ v.at(i) < v.at(imin) ? imin = i : ; } }
#define ll long long
template<typename _T> void Out(_T x) { cout << x << endl; }
template<typename _T> void PrintVec(vector<_T> vec) { Rep(i, vec.size()) { cout << vec.at(i) << " "; } cout << endl; }

int min_dist(int a, int b)
{
    return min(abs(a-b), abs(b-a));
}

int main()
{
    // input
    int K; // length of a circle
    int N; // number of houses
    cin >> K >> N;
    vector<int> A(N+1);
    Rep(i, N){
        cin >> A.at(i);
    }
    A.at(N) = K + A.at(0);
    // output
    int l = 0;
    Rep(i, N){
        l = max(A.at(i+1) - A.at(i), l);
    }
    Out(K-l);
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void dfs(Graph& g,ll v,ll p, ll t,Array& dp, Array& ans,Array& a){
    auto it=lower_bound(dp.begin(),dp.begin()+t,a[v]);
    bool flag=false;
    P change={-1,-1};
    if(it-dp.begin()==t){
        change={t,dp[t]};
        dp[t] = a[v];
        t++;
        
    }else{
        
        if(*it>a[v]){
            change={it-dp.begin(),*it};
            *it=a[v];
        }
    }

    ans[v]=t;

    for(auto e:g[v]){
        if(e.to==p) continue;
        dfs(g,e.to,v,t,dp,ans,a);
    }

    if(change.first!=-1){
        dp[change.first]=change.second;
    }
}

void solve(){
    ll n;
    cin>>n;
    Array a(n);
    REP(i,n)cin>>a[i];
    Graph g(n);
    REP(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        add_edge(g,a,b,1,true,1);
    }

    Array ans(n,0);
    Array dp(n+1,INF);
    dp[0]=a[0];
    dfs(g,0,-1,1,dp,ans,a);
    for(auto i:ans)cout<<i<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 45056
let split_nums str =
  Str.split (Str.regexp " ") str
  |> List.map int_of_string

let odd_indexed xs =
  let os, es = List.fold_left (fun (l,r) x -> x :: r, l) ([], []) xs
  in es

let sum_list = List.fold_left (+) 0
       
let answer xs =
  List.sort (-) xs
  |> odd_indexed
  |> sum_list

let () =
  let _ = read_int () in
  read_line ()
  |> split_nums
  |> answer
  |> Printf.printf "%d\n";


Measured memory_bytes: 512
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n = int(rl())
	S = 0
	A = list(rli())
	for x in A:
		S ^= x
	ans = []
	for i in range(n):
		ans.append(S ^ A[i])
	print(" ".join(str(x) for x in ans))
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 121452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(ll) (n);i++)
int main(void){
    ll p=0,b[10010],n,m,c,a[1000][1000],co=0;
    cin >> n >> m >> c;
    rep(i,m)
    {
        cin >> b[i];
    }
    rep(i,n)
    {
        rep(j,m)
        {
            cin >> a[i][j];
        }
    }
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            p+=a[i][j]*b[j];
        }
        if(p+c>0)
        {
            co++;
        }
        p=0;
    }
    cout << co << endl;
    return 0;

}


Measured memory_bytes: 3680
import collections
c=collections.Counter()
n=input()
for a in map(int, raw_input().split()):
	c[a]+=1
l=[a for a, num in c.items() if num>=2]+[a for a, num in c.items() if num>=4]
if len(l)<2:
	print 0
else:
	m=max(l)
	l.remove(m)
	print m*max(l)

Measured memory_bytes: 56684
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    ll n,m;
    cin >> n >> m;
    ll nx[n],ny[n],mx[m],my[m];
    REP(i,0,n) cin >> nx[i] >> ny[i];
    REP(i,0,m) cin >> mx[i] >> my[i];
    ll ans[60]={};

    //処理
    REP(i,0,n){
        ll md = LLONG_MAX;
        REP(j,0,m){
            ll tmp=abs(nx[i]-mx[j])+abs(ny[i]-my[j]);
            if(tmp<md){
                md=tmp;
                ans[i]=j+1;
            }
        }
    }
    
    //出力
    REP(i,0,n) cout << ans[i] << ENT;
    return 0;
}

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


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


void solve() {
  int A,B;
  cin >> A >> B;
  if (A<B) {
    std::cout << 0 << '\n';
  } else {
    std::cout << 10 << '\n';
  }
}

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


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        List<String> input = readInput();
        int N = Integer.valueOf(input.get(0).split(" ")[0]);
        memo = new long[N + 1];
        Arrays.fill(memo, -1);
        memo[0] = 1;
        input.stream().skip(1).map(Integer::valueOf).forEach(x -> {
            memo[x] = 0;
        });
        System.out.println(rec(N));
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static long[] memo;

    private static long rec(int n) {
        if (n < 0) {
            return 0;
        }
        if (memo[n] >= 0) {
            return memo[n];
        }
        memo[n] = (rec(n - 1) + rec(n - 2)) % 1_000_000_007;
        return memo[n];
    }

}


Measured memory_bytes: 100460
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    long long W, H, X, Y; cin >> W >> H >> X >> Y;
    cout << (W*H)/2.0 << ' ';
    cout << (W == 2*X && H == 2*Y) << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 256
#include<stdio.h>
int main() {
    int X;
    scanf("%d", &X);
    if (400 <= X && X <= 599) {
        printf("8");
    }
    else if (600 <= X && X <= 799) {
        printf("7");
    }
    else if (800 <= X && X <= 999) {
        printf("6");
    }
    else if (1000 <= X && X <= 1199) {
        printf("5");
    }
    else if (1200 <= X && X <= 1399) {
        printf("4");
    }
    else if (1400 <= X && X <= 1599) {
        printf("3");
    }
    else if (1600 <= X && X <= 1799) {
        printf("2");
    }
    else if (1800 <= X && X <= 1999) {
        printf("1");
    }


    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 057 D / Link: http://abc057.contest.atcoder.jp/tasks/abc057_d  ----- */

const int nCk_MAX = 100;
long long  comb[nCk_MAX + 1][nCk_MAX + 1];
void calcomb() {
	int  i, j;
	for (i = 0; i <= nCk_MAX; i++) {
		for (j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				comb[i][j] = 1;
			else
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	calcomb();
	LL N, A, B; cin >> N >> A >> B;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	map<LL, LL>cnt;
	FOR(i, 0, N) {
		cnt[a[i]]++;
	}
	LL ans = 0;
	double ansv = 0;
	LL mx = *max_element(ALL(a));
	// maxがA個以上ある場合
	if (cnt[mx] >= A) {
		FOR(i, A, B + 1) {
			ans += comb[cnt[mx]][i];
		}
		ansv = mx;
	}
	else {
		// maxがA個以上ないので,なんとかする場合->A個のみ
		LL sum = 1; LL selectable_val = 0;
		RSORT(a);
		ansv = a.front();

		FOR(i, 1, N) {
			if (sum + 1 <= A) {
				ansv += a[i];
				selectable_val = a[i];
			}
			else if (a[i - 1] == a[i]) {
				selectable_val = a[i];
			}
			else if (sum > A) {
				break;
			}
			sum++;

		}
		map<LL, LL>cnt2;
		FOR(i, 0, A) {
			cnt2[a[i]]++;
		}
		ans = comb[cnt[selectable_val]][cnt2[selectable_val]];
		ansv /= A;

	}




	cout << fixed << setprecision(10) << ansv << endl;
	cout << (ans) << "\n";

	return 0;
}


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

int zeta(int a,int b){
  if(a>=b) return a-b;
  else return b-a;
}

int main(){
  string t;cin>>t;
  int len=t.size();
  
  for(int i=0;i<len;i++){
    if(t.at(i)=='?'){
      t.at(i)='D';
    }
  }
  cout<<t<<endl;
  return 0;
}








Measured memory_bytes: 3756
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
int main(){
    CIN(A);CIN(B);
    int ans = 0;
    FOR(a,A,B+1){
        string s= to_string(a);
        bool result = true;
        REP(a,s.size()/2){
            if(s.at(a)!=s.at(s.size()-1-a)){
                result = false;
                break;
            }
        }
        if(result)ans++;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class P{
    static void Main(){
         int n = int.Parse(Console.ReadLine());
         int[] a = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
        Array.Sort(a);
        Console.WriteLine(Math.Abs(a[0] - a[n-1]));
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h> 
using namespace std; 
  
 
bool isPrime(int n)  
{  
     
    if (n <= 1)  return false;  
    if (n <= 3)  return true;  
    
     
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (int i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
}  
  

int nextPrime(int N) 
{ 
  
  
    if (N <= 1) 
        return 2; 
  
    int prime = N-1; 
    bool found = false; 
  
   
    while (!found) { 
         prime++;
  
        if (isPrime(prime)) 
            found = true; 
            
            
    } 
  
    return prime; 
} 
 int main() 
{ 
  int n;
   cin>>n;
   int t=nextPrime(n);
   cout<<t<<endl;
} 


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String[] s = S.split("/");
        int year = Integer.parseInt(s[0]);
        int month = Integer.parseInt(s[1]);
        int day = Integer.parseInt(s[2]);
        if (month>4) {
            System.out.println("TBD");
        } else {
            System.out.println("Heisei");
        }
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    ll n;
    cin >> n;
    ll norma[n];
    ll p[n];
    for (ll i = 0; i < n;i++){
        cin >> p[i];
        norma[i] = i + 1;
    }
    ll cnt = 0;
    for (ll i = 0; i < n; i++) {
        if (p[i] != norma[i]) cnt++;
    }
    if (cnt == 0 || cnt == 2) cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


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

ll b[100000],w[100000];
vector<int> e[100000];

void dfs(int v,int p){
    b[v]=w[v]=1;
    for(int u:e[v]){
        if(u!=p){
            dfs(u,v);
            b[v]=b[v]*w[u]%MOD;
            w[v]=w[v]*(b[u]+w[u])%MOD;
        }
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        --x,--y;
        e[x].push_back(y);
        e[y].push_back(x);
    }
    dfs(0,-1);
    cout<<(b[0]+w[0])%MOD<<endl;
}


Measured memory_bytes: 14208
#include "bits/stdc++.h"
using namespace std;int N;int main(){cin>>N;vector<long long>v(N);for(auto&i:v)cin>>i;auto D=[&](auto&&d,int l,int r,int x,int y)->long long{if(l+1==r)return 0;long long e=LLONG_MAX;for(int i=l+1;i<r;i++){e=min(e,((d(d,l,i,x,x+y))+(d(d,i,r,x+y,y))+v[i]*(x+y)));}return e;};cout<<D(D,0,N-1,1,1)+v[0]+v[N-1]<<endl;}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

namespace BasicMath {
    // 最大公約数を求める(ユークリッドの互除法) 
    // O(log max(a, b)) time, O(1) space
    static UInt GreatestCommonDivisor(UInt a, UInt b);
    // 最小公倍数を求める 
    // O(log max(a, b)) time, O(1) space
    static UInt LeastCommonMultiple(UInt a, UInt b);

    UInt GreatestCommonDivisor(UInt a, UInt b) {
        if (b == 0) {
            return a;
        } else {
            if (a < b) {
                std::swap(a, b);
            }
            return GreatestCommonDivisor(b, a % b);
        }
    }
    UInt LeastCommonMultiple(UInt a, UInt b) {
        Int gcd = GreatestCommonDivisor(a, b);
        return a / gcd * b;
    }
#define GCD GreatestCommonDivisor
#define LCM LeastCommonMultiple
}
using namespace BasicMath;

int main(void) {
    Int a, b;
    cin >> a >> b;
    cout << LCM(a, b) << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <limits.h>
#include <assert.h>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define db double
#define ldb long double
#define MOD 1000000007
#define Fi first
#define Se second
#define INF INT_MAX
#define NINF INT_MIN
#define L_INF LLONG_MAX
#define L_NINF LLONG_MIN
#define gc getchar
#define sz(x) (int)(x).size()
#define pii pair<int,int>
#define pll pair<ll,ll>

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

void scani(int &x)
{
    register int c = gc();x = 0;int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

int main()
{
    fsscan();
    ll n;
    cin>>n;
    ll i=0,sumi=0,val=0;
    while(n>0)
    {
    	i++;
    	sumi+=n%10;
    	val=n%10;
    	n/=10;
    }
    cout<<max(sumi,9*(i-1)+val-1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int N;
  cin>>N;
  string S;
 
    cin>>S;
  
  int sum=0;
  int count=0;
  int i=0;
  int j=1;
 char c;
  while(count<N){
    c=S[i];
    for(int j=i+1;j<N;j++){
      if(c==S[j]){
        sum++;
        i++;
      }
      else break;
    }
    i++;
    count++;
  }
  cout<<N-sum<<endl;
 return 0; 
}

Measured memory_bytes: 512
H,W=map(int,input().split())
c=[]
for i in range(10):
  c.append(list(map(int,input().split())))

for k in range(10):
  for i in range(10):
    for j in range(10):
      c[i][j]=min(c[i][j],c[i][k]+c[k][j])
#print(c)

ans=0
for i in range(H):
  A=list(map(int,input().split()))
  for j in A:
    if j>=0:
      ans+=c[j][1]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int n, m, x, a[100], front = 0, behind = 0, i;
    scanf("%d %d %d", &n, &m, &x);
    for (int i = 0; i < m; i++) {
        scanf("%d", &a[i]);
    }

    for (i = 0; i < m; i++) {
        if (a[i] < x) {
            front++;
        } else {
            break;
        }
    }

    behind = m - i;

    if (front > behind) {
        printf("%d\n", behind);
    } else {
        printf("%d\n", front);
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a;
	cin>>a;
	ll n=0;
	vector<bool> c(26,false);
	ll cnt=0;
	vector<ll> dp((ll)a.size());
	for(ll i=(ll)a.size()-1; i>=0; i--) {
		dp[i]=n;
		if(!c[a[i]-'a']) {
			cnt++;
			c[a[i]-'a']=true;
		}
		if(cnt==26) {
			cnt=0;
			for(ll j=0; j<26; j++) c[j]=false;
			n++;
		}
	}
	string ret="";
	for(ll i=0; i<26; i++) {
		if(!c[i]) {
			ret+=(char)('a'+i);
			break;
		}
	}
	ll idx=0;
	while((ll)ret.size()<n+1) {
		while(idx<(ll)a.size()&&a[idx]!=ret[(ll)ret.size()-1]) idx++;
		if(idx==(ll)a.size()) break;
		while((n+1)-(ll)ret.size()>dp[idx]+1) ret+='a';
		vector<bool> d(26,false);
		ll nidx=idx+1;
		while(nidx<(ll)a.size()&&dp[nidx]==dp[idx]) {
			d[a[nidx]-'a']=true;
			nidx++;
		}
		for(ll i=0; i<26; i++) {
			if(!d[i]) {
				ret+=(char)('a'+i);
				break;
			}
		}
		idx=nidx;
	}
	while((ll)ret.size()<n+1) ret+='a';
	cout<<ret<<endl;
}


Measured memory_bytes: 2196
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	map<char, char>c;
	c.insert(map<char, char>::value_type('T', 'a'));
	c.insert(map<char, char>::value_type('L', 'i'));
	c.insert(map<char, char>::value_type('U', 'u'));
	c.insert(map<char, char>::value_type('R', 'e'));
	c.insert(map<char, char>::value_type('D', 'o'));
	char b[9] = { 'w','k','s','t','n','h','m','y','r' };
	string s;
	while (cin >> s) {
		string h;
		string d = "";
		for (int z = 0; z < s.length(); z += 2) {
			h = s.substr(z, 2);
			int e = (int)h[0] - '0';
			if (e == 0 && h[1] == 'U')
				d += "nn";
			else {
				if (e != 1&&e!=0) {
					d += b[e - 1];
				}
				if (e == 0) d += 'w';
				d += c[h[1]];
			}
		}
		cout << d << endl;
	}
}

Measured memory_bytes: 3172
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N,M,X,Y; cin>>N>>M>>X>>Y;
    int x[N+1],y[M+1];
    x[0] = X;
    y[0] = Y;
    REP(i,N) cin>>x[i+1];
    REP(i,M) cin>>y[i+1];
    sort(x,x+N+1);
    sort(y,y+M+1);
    if (x[N]<y[0]) {
        cout<<"No War"<<endl;
    } else {
        cout<<"War"<<endl;
    }
}


Measured memory_bytes: 256
N = int(input())
c1 = 0
c2 = 0
c3 = 0
ans = 0
for _ in range(N):
    s = input()
    for i in range(len(s) - 1):
        if s[i:i + 2] == 'AB':
            ans += 1
    if s[0] == 'B' and s[-1] == 'A':
        c3 += 1
    elif s[0] == 'B':
        c2 += 1
    elif s[-1] == 'A':
        c1 += 1


if c3 == 0:
    ans += min(c1, c2)
elif c1 == c2 == 0:
    ans += c3 - 1
elif c1 == 0 or c2 == 0:
    ans += c3
else:
    ans += min(c1 - 1, c2 - 1) + c3 + 1
print(ans)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,s;
signed main(){
    cin>>n>>k>>s;
    rep(i,k)cout<<s<<(i==n-1?"\n":" ");
    for(int i=k;i<n;i++){
        if(s==1000000000)cout<<1<<(i==n-1?"\n":" ");
        else cout<<1000000000<<(i==n-1?"\n":" ");
    }
    return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int N = read(), M = read();

  vi X;
  REP(i, M) { X.push_back(read()); }
  sort(X.begin(), X.end());

  vi sub_X;
  FOR(i, 1, M) { sub_X.push_back(X[i] - X[i - 1]); }
  sort(sub_X.begin(), sub_X.end(), greater<int>());

  int ans = 0;
  FOR(i, N - 1, M - 1) { ans += sub_X[i]; }
  print(ans);

  return 0;
}


Measured memory_bytes: 2548
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const double pi=acos(-1);
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint calc(long long N, long long K) {
    mint res = 1;
    for (long long n = 0; n < K; ++n) {
        res *= (N - n);
        res /= (n + 1);
    }
    return res;
}
int main() {
//cout << fixed << setprecision(12);
string s; cin>>s;
string t="",u="";
ll n=s.size();
ll ca=0;
ll q=0;
for(ll i=0; i<(1 << n-1); i++){
bitset<9> b(i);
//cout << b << endl;
q=0;
rep(k,n-1){
if(b.test(k)==1){
while(q<=k){
t+=s.at(q);
q++;}
ll a = stoll(t);
ca+=a;
t="";}
}
while(q<=n-1){
t+=s.at(q);
q++;}
ll a = stoll(t);
ca+=a;
t="";}
cout << ca << endl;}


Measured memory_bytes: 3560
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::{min, max};
use itertools::Itertools;
use std::ops::{Add, AddAssign};
use num_integer::Integer;
use std::collections::VecDeque;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn read_tuple3<T: FromStr, S: FromStr, R: FromStr>() -> (T, S, R) {
    let a = read();
    let b = read();
    let c = read();
    (a, b, c)
}

fn lower_bound<T: Copy, F>(v: &Vec<T>, f: F) -> Option<usize> where
    F: Fn(T) -> bool
{
    let mut left = 0;
    let mut right = v.len() - 1;
    if !f(v[left]) {
        return None;
    }
    if f(v[right]) {
        return Some(right);
    }
    loop {
        if right - left == 1 {
            return Some(left);
        }
        let mid = (left + right) / 2;
        if f(v[mid]) {
            left = mid;
        } else {
            right = mid;
        }
    }
}

fn main() {
    let n: u64 = read();
    let a_list:Vec<u64> = (0..n).map(|_|read()).collect();
    let mut vq = VecDeque::with_capacity(n as usize);
    let mut push_front = true;
    for a in a_list {
        if push_front {
            vq.push_front(a);
        } else {
            vq.push_back(a);
        }
        push_front = !push_front;
    }
    let ans = if push_front {
        let a:Vec<String> = vq.iter().rev().map(|a|a.to_string()).collect();
        a.join(" ")
    } else {
        let a:Vec<String> = vq.iter().map(|a|a.to_string()).collect();
        a.join(" ")
    };
    println!("{}", ans);

}



Measured memory_bytes: 16340
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, 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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;

    vector<ll> money(n);
    money[0] = 1000;

    repr(i, 1, n) {
        ll maxi = 0;
        rep(j, i) {
            ll cnt = money[j] / a[j];
            chmax(maxi, cnt * a[i] + (money[j] - cnt * a[j]));
            chmax(maxi, money[j]);
        }
        money[i] = maxi;
    }
    cout << money[n - 1] << endl;
    //print(money);
}

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

using namespace std;

int main() {
    double x;
    cin >> x;

    for (int a=0;a<1000;a++) {
        for (int b=-1000;b<1000;b++) {
            if (pow(a,5)-pow(b,5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4224
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[][] d = new int[N + 1][N + 1];

        for(int i=0; i<=N; i++){
            for(int j=0; j<=N; j++){
                if(i==j){
                    d[i][j] = 0;
                }
                else{
                    d[i][j] = Integer.MAX_VALUE / 2;
                }
            }
        }

        for(int i=0; i<M; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            d[a[i]][b[i]] = 1;
            d[b[i]][a[i]] = 1;
        }
        int ans = 0;
        for(int i=0; i<M; i++){
            d[a[i]][b[i]] = Integer.MAX_VALUE / 2;
            for(int j=1; j<=N; j++){
                for(int k=1; k<=N; k++){
                    for(int l=1; l<=N; l++){
                        if(d[k][l]>d[k][j] + d[j][l]){
                            d[k][l] = d[k][j] + d[j][l];
                        }
                    }
                }
            }
            loop :for(int j=1; j<=N; j++){
                for(int k=1; k<=N; k++){
                    if(d[j][k]>=100){
                        ans++;
                        break loop;
                    }
                }
            }
            for(int j=1; j<=N; j++){
                for(int k=1; k<=N; k++){
                    if(j==k){
                        d[j][k] = 0;
                    }
                    else{
                        d[j][k] = Integer.MAX_VALUE / 2;
                    }
                }
            }
            for(int j=0; j<M; j++){
                d[a[j]][b[j]] = 1;
                d[b[j]][a[j]] = 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24552
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
ll countDivisibles(ll A, ll B, ll M) 
{ 
    // Add 1 explicitly as A is divisible by M 
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 
int main(){
	IOS;
	cout.precision(30) ;
	int n , m; cin >> n >> m ;
	vector<vector<int>> states(m , vector<int>(n , 0)) ;
	for(int i = 0 ; i < m ; i++){
		int k ; cin >> k ; int x ;
		for(int j = 0 ; j < k ; j++){
			cin >> x ;x-- ;
			states[i][x] = 1 ;
		}
	}
	vi p(m) ; for(int i = 0  ; i < m ; i++) cin >> p[i] ;
	int ans = 0 ;
	for(int i = 0 ; i < (1 << n) ; i++){
		vector<int> cur(n , 0) ;
		for(int j = 0 ; j < n ; j++){
			if(i & (1 << j)) cur[j] = 1 ;
		}
		bool b = true ;
		for(int j = 0 ; j < m ; j++){
			int p1 = 0 ;
			for(int k = 0 ; k < n ; k++){
				if(states[j][k] && cur[k]) p1++ ;
			}
			if(p1 % 2 != p[j]) b = false ;
		}
		if(b) ans++ ;
	}
	cout << ans << endl ;
	return 0;
}


Measured memory_bytes: 256
n,m,k=map(int,input().split())

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

U=UnionFind(n)
friend=[0]*n
block=[0]*n
for _ in range(m):
    a,b=map(int,input().split())
    U.union(a-1,b-1)
    friend[a-1]+=1
    friend[b-1]+=1
ans=[0]*n
for i in range(n):
    ans[i]=U.size(i)-friend[i]-1
for _ in range(k):
    c,d=map(int,input().split())
    if U.same(c-1,d-1):
        ans[c-1]-=1
        ans[d-1]-=1
print(*ans)

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;


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


int Gcd(int x,int y)              //最大公約数
{
  int large = max(x,y);
  int small = min(x,y);

  while(small!=0){
      int amari =large%small;

      large = small;

      small = amari;  
  }
  return large;
}

const int MOD = 1000000007;




//メイン関数--------------------------------------------



int main(){

int n,ct=0;
cin>>n;

for(int i=0;i<n;i++){
    int x,y;
    cin>>x>>y;
    if(x==y){
        ct++;
    }
    else{
        ct=0;
    }
    if(ct==3){
       break;
    }

}
if(ct==3){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}



}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define pii pair<ll, ll> 
#define pb push_back
#define debug(x) cerr<< #x << " is " <<x<<endl;
#define debug2(x) cerr<<#x<< " is\n"; for (auto &i:x) {cout<<i<<' '; } cout<<endl;
#define f first
#define s second
using namespace std;



int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, k; cin>>n>>k;
    vector<int> dp(k,0);
    vector<int> a(n);
    for (int i=0; i<n; i++) cin>>a[i];
    for (int i=1; i<=k; i++){
    	for (int x: a){
    		if (i-x>=0) dp[i]|=dp[i-x]^1;
    	}
    }
    if (dp[k]==1) cout<<"First\n";
    else cout<<"Second\n";
}

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

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ll> point;
#define F first
#define S second

ll cross(point a, point b) { return imag(conj(a) * b); }

int qua(point x)
{
	if (x.real() > 0 && x.imag() >= 0) return 0;
	if (x.real() <= 0 && x.imag() > 0) return 1;
	if (x.real() < 0 && x.imag() <= 0) return 2;
	return 3;
}

int main()
{
	#ifdef TurnRed
		//freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	cin >> n;
	vector<point> v(n);
	for (int i = 0, x, y; i < n; ++i)
	{
		cin >> x >> y;
		v[i] = { x, y };
	}

	ll ans = 0;
//	if (n <= 20)
//	{
//		for (int i = 1; i < 1<<n; ++i)
//		{
//			point p = { 0, 0 };
//			for (int j = 0; j < n; ++j)
//				if (i >> j & 1)
//					p += v[j];
//			ans = max(ans, norm(p));
//		}
//	}
//	else
	{
		sort(v.begin(), v.end(), [](const point &x, const point &y)
		{
			int qx = qua(x);
			int qy = qua(y);
			if (qx != qy) return qx < qy;
			if (cross(x, y) == 0) return norm(x) < norm(y);
			return cross(x, y) > 0;
		});

		for (int i = 0; i < n; ++i)
		{
			point p = { 0, 0 };
			for (int j = i, k = n; k--; j = (j+1) % n)
			{
				p += v[j];
				ans = max(ans, norm(p));
			}
		}
	}
	ld ans2 = sqrtl(ans);
//	ld l = 0, r = ans;
//	for (int it = 500; it--; )
//	{
//		ld m = (l + r) / 2.0;
//		if (m * m < ans)
//			l = m;
//		else
//			r = m;
//	}
//	ans2 = r;
	cout << setprecision(20) << fixed << ans2/*sqrtl(ans)*/ << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static final String STATIONS;

    static {
        String first = "abcdefghijklmnopqrstuvwxyz";
        String latter = first.toUpperCase();
        String stations = first.concat(latter);
        STATIONS = stations.concat(stations);
    }

    public static void main(String[] args) {
        try(Scanner scn = new Scanner(System.in)) {
            int n = 0;
            while((n = scn.nextInt()) > 0) {
                int[] keys = new int[n];
                for(int i = 0; i < n; i++) {
                    keys[i] = scn.nextInt();
                }

                StringBuilder sb = new StringBuilder();
                char[] list = scn.next().toCharArray();
                for(int i = 0; i < list.length; i++) {
                    sb.append(STATIONS.charAt(STATIONS.lastIndexOf(list[i]) - keys[i % n]));
                }
                System.out.println(sb);
            }
        }
    }
}

Measured memory_bytes: 33600
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	static int cnt,sum,m;
	static int a[];
	static char id[];
	static ArrayList<Integer>AL;
	public static void main(String[] arg)
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();//digit
			String str=in.next();
			AL=new ArrayList<Integer>();
			id=new char[str.length()];
			for(int i=str.length()-1;i>=0;i--)
				id[str.length()-i-1]=str.charAt(i);
			m=in.nextInt();
			a=new int[m];
			for(int i=0;i<m;i++)
				a[i]=in.nextInt();
			cnt=0;
			sum=0;
			for(int i=0;i<n;i++)
			{
				int num=0;
				if(Character.isDigit(id[i]))
				{
					num=id[i]-'0';
					if(i%2==1)
						num*=2;
					if(num>=10)
						num=num%10+num/10;
				}
				else
				{
					if(i%2==1)
						AL.add(1);
					else
						AL.add(0);
				}
				sum+=num;
			}
			//debug(id);
			dfs(0,sum);
			System.out.println(cnt);
		}
	}

	static void dfs(int index,int sum)
	{
		if(index==AL.size())
		{
			if(sum%10==0)
				cnt++;
		}
		else
		{
			for(int i=0;i<a.length;i++)
			{
				int num=a[i];
				if(AL.get(index)==1)
					num*=2;
				if(num>=10)
					num=num%10+num/10;
				dfs(index+1,sum+num);
			}
		}

	}

	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int m=sz(s);
	ll sm = 0;
	rep(i, m){
		int z = s[i] - '0';
		sm += z;
	}
	puts(sm%9==0? "Yes":"No");
	return 0;
}



Measured memory_bytes: 3756