akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pi acos(-1)
using namespace std;

double a,b,x;

int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b>>x;
    if(x*2>=a*a*b){
        double a1=(x/a*2/a)-b;
        double ans=atan((b-a1)/a)*180/pi;
        cout<<fixed<<setprecision(10)<<ans<<endl;
    } else {
        double a1=(x/a*2/b);
        double ans=atan(b/a1)*180/pi;
        cout<<fixed<<setprecision(10)<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int cnt[30];
char str[1000];
signed main()
{
    int N;
    scanf("%s", str + 1);
    N = strlen(str + 1);
    for (ri i = 1; i <= N; ++i) {
        int tmp = str[i] - 'a' + 1;
        cnt[tmp]++;
    }
    int flag = true;
    for (ri i = 1; i <= 26; ++i) {
        if (cnt[i] % 2 == 1) {
            flag = false;
            break;
        }
    }
    puts(flag ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
int main(void)
{
	int n,w[300002]={0},e[300002]={0},min=INT_MAX,i;
	char s[300001];
	scanf("%d %s", &n, s);
	for(i=0; i<n; i++)
	{
		if(s[i]=='W')
		w[i+1]=1;
		else
		e[i+1]=1;
		w[i+1]+=w[i];
		e[i+1]+=e[i];
	}
	for(i=1; i<=n; i++)
	{
		if(min>w[i-1]+e[n]-e[i])
		min=w[i-1]+e[n]-e[i];
	}
	printf("%d\n", min);
	
	return 0;
}

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

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

int main()
{
  int a[3][3] = {};
  for (int i = 0; i < 3; ++i)
  {
    for (int j = 0; j < 3; ++j)
    {
      cin >> a[i][j];
    }
  }
  bool c[3][3] = {};
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    int b;
    cin >> b;
    for (int j = 0; j < 3; ++j)
    {
      for (int k = 0; k < 3; ++k)
      {
        if (a[j][k] == b)
          c[j][k] = true;
      }
    }
  }
  if (c[0][0] && c[1][1] && c[2][2])
  {
    cout << "Yes" << endl;
    return 0;
  }
  if (c[2][0] && c[1][1] && c[0][2])
  {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 0; i < 3; ++i)
  {
    if (c[0][i] && c[1][i] && c[2][i])
    {
      cout << "Yes" << endl;
      return 0;
    }
    if (c[i][0] && c[i][1] && c[i][2])
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

int main() {
  
  string a,b,c;
  cin >> a >> b >> c;
  
  char t = a[0];
  a.erase(a.begin(),a.begin()+1);
  
  while ( true ){
    if ( t == 'a' ){
      if( a.size() == 0 ){
        cout << 'A' << endl;
        return 0;
      }else{
        t = a[0];
        a.erase(a.begin(),a.begin()+1);
      }
    }else if ( t == 'b' ){
      if( b.size() == 0 ){
        cout << 'B' << endl;
        return 0;
      }else{
        t = b[0];
        b.erase(b.begin(),b.begin()+1);
      }
    }else if ( t == 'c' ){
      if( c.size() == 0 ){
        cout << 'C' << endl;
        return 0;
      }else{
        t = c[0];
        c.erase(c.begin(),c.begin()+1);      
      }
    }
  }
    
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;

    static int h, w;
    static int[][] C = new int[10][10];
    static int[][] A;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        h = in.nextInt();
        w = in.nextInt();
        A = new int[h][w];

        for(int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++) C[i][j] = in.nextInt();

        for(int i = 0; i < h; i++)
            for (int j = 0; j < w; j++) A[i][j] = in.nextInt();

        long dist[][] = new long[10][10];
        for(int i = 0; i < 10; i++) {
            Arrays.fill(dist[i], inf);
            for (int j = 0; j < 10; j++) dist[i][j] = C[i][j];
        }

        for(int k = 0; k < 10; k++) {
            for(int i = 0; i < 10; i++) {
                for(int j = 0; j < 10; j++) {
                    if(i == j) continue;
                    dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }

        long cost = 0;
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(A[i][j] == -1) continue;
                cost += dist[A[i][j]][1];
            }
        }

        print(cost);
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }
}

Measured memory_bytes: 49892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k,cnt=0,n;
    cin>>a>>b>>k;
    int m=max(a,b);
    for(int i=m;i>=1;i--)
    {
        if(a%i==0&&b%i==0)
            cnt++;
        if(cnt==k)
        {
            n=i;
            break;
        }
    }
    cout<<n;
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

ll ans = 0;
bool dfs(int depth,int x){
  if(depth > ans || (x << (ans - depth)) < n || x <= 0)return false;
  d[depth] = x;
  if(x == n || (x << (ans - depth)) == n)return true;
  lep(i,0,depth){
    if(dfs(depth + 1,x + d[i]) || dfs(depth + 1,x-d[i]))return true;
  }
  return false;
}

int main(){
  while(cin >> n,n){
    ans = 0;
    while(1){
      if(dfs(0,1)){
        print(ans);
        break;
      }
      ans++;
    }
  }
  return 0;
}


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

int main()
{
  int N, l, r, p = 0;
  cin >> N;
  
  for(int i=0;i<N;i++)
  {
    cin >> l >> r;
    p += r - l + 1;
  }
  
  cout << p << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int a,b;
    int producted;
    // スペース区切りの整数の入力
    scanf("%d %d", &a , &b);
    producted = (a * b) % 2;
    if(producted == 0){
        printf("Even");
    }else{
        printf("Odd");
    }  

    return 0;
}

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

int main(){
	int N, K;
	map<int, int> cnt;
	cin >> N >> K;
	for(int i=0; i<N; i++){
		int a;
		cin >> a;
		cnt[a]++;
	}

	vector<int> c;
	for(auto p: cnt){
		c.push_back(p.second);
	}
	sort(c.begin(), c.end());

	int ans = 0;
	for(int i=0; i<max(0, (int)c.size()-K); i++){
		ans += c[i];
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 10748
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i<n; i++) {
            x[i] = sc.nextInt();
            y[i] = x[i];
        }
        Arrays.sort(y);
        int median = y[(n+1)/2-1];
        int median2 = y[(n+1)/2];
        //System.out.println((n+1)/2+" "+median+" "+median2);
        for(int i = 0; i<n; i++) {
            if(x[i]<=median) System.out.println(median2);
            else System.out.println(median);
        }

    }
}

Measured memory_bytes: 93732
from itertools import combinations
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
n,m = map(int,input().split())
abc = [list(map(int,input().split())) for i in range(m)]
abc = [[abc[i][0]-1,abc[i][1]-1,abc[i][2]] for i in range(m)]
graph = [[] for i in range(n+1)]
for a,b,c in abc:
  graph[a].append((b,c))
  graph[b].append((a,c))
v1,v2,edge = zip(*abc)
csr = csr_matrix((edge,(v1,v2)),shape = (n,n))
dist = floyd_warshall(csr, directed = False)
ans = 0
for i,j in combinations(range(n),2):
  fs1,fs2 = zip(*graph[i])
  if j in fs1:
    x = fs1.index(j)
    if fs2[x] > dist[i][j]:
      ans += 1
print(ans)

Measured memory_bytes: 18492
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <iterator>

using namespace std;

//std::set<int> powOf2;
int powOf2[32];


void init()
{
//	powOf2.clear();
//	powOf2.insert(1);

	powOf2[0] = 1;
	int base = 1;
	for (int i = 1 ; i <= 31 ; i++)
	{
		base = base * 2;
//		powOf2.insert(base);
		powOf2[i] = base;
	}
}

std::map<int, int> numMap;

int n;
int a[200010];

int main()
{
	init();
	
	scanf("%d", &n);
	
	for (int i = 0 ; i < n ; i++)
	{
		scanf("%d", &(a[i]));		
		if (numMap.find(a[i]) == numMap.end())
			numMap[a[i]] = 1;
		else
			numMap[a[i]] = numMap[a[i]] + 1;
	}
	
	int total = 0;
	std::map<int, int>::iterator iNumMap;
	int iPowerPos = 30;
	for (int i = iPowerPos ; i >= 0 ; i--)
	{
		for (iNumMap = numMap.begin() ; 
		     iNumMap != numMap.end() ;
			 iNumMap++)
		{
			int base = iNumMap->first;
			int count = iNumMap->second;
			int left = powOf2[i] - base;
			
			while (iNumMap->second > 0)
			{
				if (base == left)
				{
					if (numMap[left] >= 2)
					{
						iNumMap->second = iNumMap->second - 2;
						total++;
					}
					else
						break;
				}
				else
				{
					if ((numMap.find(left) != numMap.end()) 
						&& numMap[left] > 0)
					{
						iNumMap->second--;	//无论怎样都要减1 						
						numMap[left] = numMap[left] - 1;
						total++;
					}
					else
						break;
				}
				
			}
		}		
	}	
	
	printf("%d\n", total);
	
	return 0;
}

Measured memory_bytes: 10368
import sys
# import collections
# import math
# import string
import bisect

def main():
    n, *parts = (int(x) for x in sys.stdin.read().split())
    uppers, middles, lowers = (parts[n*i:n*(i+1)] for i in range(3))
    uppers.sort()
    lowers.sort()

    count = 0
    for j in middles:
        i = bisect.bisect_left(uppers, j)
        k = len(lowers) - bisect.bisect_right(lowers, j)
        count += i * k
        
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 36340
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::HashMap;

fn main() {
    let _n = get!(usize);
    let aa = get!(String).split_whitespace().map(|a| a.parse::<usize>().unwrap()).collect::<Vec<_>>();

    let mut map = HashMap::new();
    for a in aa.into_iter() {
        let v = map.entry(a).or_insert(0);
        *v += 1;
    }

    let mut r = 0;
    for (k, v) in map {
        if v < k {
            r += v;
        } else {
            r += v - k;
        }
    }
    println!("{}", r);
}

Measured memory_bytes: 7056
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,s=0;;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<k;i++)
	s+=a[i];
	cout<<s;
}

Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

using namespace std;
using ll = long long;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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

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

//////////////////////////////////////////////////


int main() {
    char a; cin >> a;
    cout << char(a+1) << endl;
    return 0;
}

Measured memory_bytes: 256
import math
def main():
    a, b, x = map(float, input().split())

    # 底面三角形の高さ
    h = 2*x/(a*b)

    if h > a:
        res = a*a*b-x
        j = res*2/(a*a)
        rad = math.degrees(math.atan2(j,a))
    else:
        rad = math.degrees(math.atan2(b,h))
    #max_cos = (2*x)/(b*h*a)
    #rad = math.asin(max_cos)

    print(rad)

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main(){
    int n;
    while(cin >> n &&n!=0){
        vector<vector<pair<ll,int> > > g(n);
        vector<int> p(n);
        vector<ll>d(n);
        for(int i=1;i<n;i++){
            cin >> p[i];
            p[i]--;
        }
        ll ans=0;
        for(int i=1;i<n;i++){
            cin >> d[i];
            ans+=d[i];
        }
        ans *=3;
        for(int i=1;i<n;i++){
            g[i].PB(MP(d[i],p[i]));
            g[p[i]].PB(MP(d[i],i));
        }
        ll s = 0;
        vector<bool>flag(n);
        for(int i=0;i<n;i++){
            if(g[i].size()==1){
                s += g[i][0].first;
                flag[i] = 1;
            }
        }
        priority_queue<pair<ll,int>,vector<pair<ll,int> >,greater<pair<ll,int> >  >pq;
        for(int i=0;i<n;i++){
            if(g[i].size()!=1){
                pq.push(MP((ll)0,i));
                flag[i] = 1;
                break;
            }
        }
        int l=-1;
        while(!pq.empty()){
            auto a = pq.top();
            l = a.second;
            pq.pop();
            for(auto x:g[l]){
                if(!flag[x.second]){
                    flag[x.second] = 1;
                    pq.push(MP(a.first+x.first,x.second));
                }
            }
        }
        rep(i,n)if(g[i].size()!=1)flag[i]=0;
        if(l!=-1)pq.push(MP((ll)0,l)),flag[l]=1;
        ll r = 0;
        while(!pq.empty()){
            auto a = pq.top();
            r = a.first;
            pq.pop();
            for(auto x:g[a.second]){
                if(!flag[x.second]){
                    flag[x.second] = 1;
                    pq.push(MP(a.first+x.first,x.second));
                }
            }
        }
        ans -= 2*s+r;
        cout <<ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
 
int main(){ 
  int n, m;
  cin >> n >> m;
  vector<int> ac(n,0), wa(n,0);
  ll res0 = 0, res1 = 0;
  for (int i = 0; i < m; i++) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (!ac[p]&& s == "WA") wa[p]++;
    else if (s == "AC" && !ac[p]) ac[p] = 1;  
  }
  for (int i = 0; i < n; i++) {
    if (ac[i] == 0) continue;
    res0 += ac[i];
    res1 += wa[i];
  }
  cout << res0 << " " << res1 << endl;
  return 0;
} 

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;

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

    int N, T;
    cin >> N >> T;
    vector<long long> t(N);
    for(int i=0; i<N; i++) cin >> t[i];

    long long cur = 0;
    long long ans = 0;
    for(int i=0; i<N; i++){
        cur = max(cur, t[i]);
        ans += max(0LL, t[i] + T - cur);
        cur = t[i] + T;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
D = int(input().strip())

c = list(map(int, input().strip().split()))
s = [list(map(int, input().split())) for _ in range(D)]

score=0
last=[0]*26 # contents: 1 ind
for d in range(1,D+1): # 1 ind
    contest=int(input().strip())
    score+=s[d-1][contest-1]
    last[contest-1]=d
    for i in range(26): # 0ind
        score-=c[i]*(d-last[i])
    print(score)

Measured memory_bytes: 9388
#include <iostream> 
 
using namespace std ; 
 
int main(){
	int a, b;
	cin>>a>>b;
	if(a%3==0){
    	cout<<"Possible";
    }else{
    	if(b%3==0){
        	cout<<"Possible";
        }else{
        	if((a+b)%3==0){
            	cout<<"Possible";
            }else{
            	cout<<"Impossible";
            }
        }
    }
  	return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define INF 1e9

using namespace std;

int N;

int main(void)
{
    cin >> N;
    // vector<unsigned long long> A;
    vector<unsigned long long> A(N, 0ULL);
    rep(i, N)
    {
        cin >> A[i];
        // A.push_back(1000000000ULL);
    }

    unsigned long long sum = 0ULL;
    unsigned long long max = accumulate(A.begin(), A.end(), 0ULL);
    unsigned long long mod = (unsigned long long)pow(10, 9) + 7ULL;

    for (int i = 0; i < N - 1; i++)
    {
        max -= A[i];
        sum += (A[i] % mod) * (max % mod);
        sum %= mod;
    }

    cout << sum << endl;
}

Measured memory_bytes: 4840
import java.io.InputStream;
import java.util.Scanner;

/**
 * @author kanbe
 *
 */
public class Main {
    
    public static void main(String[] args) {
        
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int j = scanner.nextInt();
        
        if (i < 10) {
            j = ((100 * (10 - i)) + j);
        } 
        System.out.println(j);
        
    }

}


Measured memory_bytes: 21844
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int a = sc.nextInt();
		String s;
		if(n%500 <= a)s = "Yes";
		else s = "No";
		System.out.println(s);
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
    int n,flag=0;
    cin>>n;
    string s;
    cin>>s;
    if(n%2==1)
        cout<<"No"<<endl;
    else
    {
        int k=n/2;
        for(int i=0;i<k;i++)
        {
            if(s[i]!=s[i+k])
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}


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

//#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
/* }}} */

signed main() 
{
    int n;
    cin >> n;
    int x[100001],y[100001],t[100001];
    t[0]=x[0]=y[0]=0;
    rep(i,n)
    {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    
    bool judge=true;
    rep(i,n)
    {
        int dt=t[i+1]-t[i];
        int dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
        if(dist>dt) judge=false;
        if(dist%2!=dt%2) judge=false;
    }
    judge?print("Yes"):print("No");

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int ans=0;
  for(int i=0;i<N;i++){
    ans += vec.at(i)*pow(-1,i);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		int n = Integer.parseInt(input);
		String input2 = sc.nextLine();
		String[] data = input2.split(" ");
		int Min = Integer.parseInt(data[0]);
		int Max = Min;
		long Sum = Min;
		int value = 0;
		boolean judge = true;

		if ((n == data.length) && (n >= 0 && n <= 10000)) {

			out: for (int i = 1; i < data.length; i++) {
				value = Integer.parseInt(data[i]);
				if (value < -1000000 || value > 1000000) {
					judge = false;
					break out;
				}
				if (Max < value) {
					Max = value;
				}
				if (Min > value) {
					Min = value;
				}
				Sum += value;
			}

			if (judge == true) {
				System.out.println(Min + " " + Max + " " + Sum);
			}

		}

	}
}



Measured memory_bytes: 31896
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
	int N;
	ll a[300001],L[300001],R[300001],ans=-1152921504606846976;
	priority_queue<int, vector<int>, greater<int> > le;
	priority_queue <ll> ri;
int main(){
	cin>>N;
	reg(i,1,N){
		cin>>a[i];
		L[N]+=a[i];
		le.push(a[i]);
	}
	reg(i,N+1,N*2){
		cin>>a[i];
	}
	reg(i,N*2+1,N*3){
		cin>>a[i];
		R[2*N+1]+=a[i];
		ri.push(a[i]);
	}
	reg(k,N+1,2*N){
		if(le.top()<a[k]){
			L[k]=L[k-1]+a[k]-le.top();
			le.push(a[k]);
			le.pop();
		}else{
			L[k]=L[k-1];
		}
	}
	ireg(k,N+1,2*N){
		if(ri.top()>a[k]){
			R[k]=R[k+1]+a[k]-ri.top();
			ri.push(a[k]);
			ri.pop();
		}else{
			R[k]=R[k+1];
		}
	}
	reg(k,N,2*N){
		if(ans<L[k]-R[k+1])ans=L[k]-R[k+1];
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 7412
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/












template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int H, W, A, B;
string C[1010];
int vis[1010][1010]; ll dis[1010][1010];
min_priority_queue<pair<ll, int>> que;
enum { UP = 0, UP_RIGHT, RIGHT, DOWN_RIGHT, DOWN, DOWN_LEFT, LEFT, UP_LEFT };
int dx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dy[8] = { -1,-1,0,1,1,1,0,-1 };
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> H >> W >> A >> B;
    rep(y, 0, H) cin >> C[y];

    rep(y, 0, H) rep(x, 0, W) dis[y][x] = infl;

    int sx, sy;
    rep(y, 0, H) rep(x, 0, W) if (C[y][x] == 's') {
        sx = x;
        sy = y;
    }

    dis[sy][sx] = 0;
    que.push({ 0, sy * 1010 + sx });

    while (!que.empty()) {
        auto q = que.top(); que.pop();

        ll c = q.first;
        int x = q.second % 1010;
        int y = q.second / 1010;

        if (C[y][x] == 'g') {
            cout << dis[y][x] << endl;
            return;
        }

        if (vis[y][x]) continue;
        vis[y][x] = 1;

        rep(i, 0, 8) if ((i & 1) == 0) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (xx < 0 or W <= xx or yy < 0 or H <= yy) continue;
            if (C[yy][xx] == '#') continue;
            if (chmin(dis[yy][xx], c + A)) que.push({ dis[yy][xx], yy * 1010 + xx });
        }

        int ok = 1;
        if (C[y][x] == '*') ok = 0;
        rep(i, 0, 8) {
            int xx = x + dx[i];
            int yy = y + dy[i];
            if (xx < 0 or W <= xx or yy < 0 or H <= yy) continue;
            if (C[yy][xx] == '*') ok = 0;
        }

        if (ok) {
            rep(i, 0, 8) {
                int xx = x + dx[i];
                int yy = y + dy[i];
                if (xx < 0 or W <= xx or yy < 0 or H <= yy) continue;
                int d = abs(x - xx) + abs(y - yy);
                if (chmin(dis[yy][xx], c + B + A * d)) que.push({ dis[yy][xx], yy * 1010 + xx });
            }
        }
    }

    cout << "INF" << endl;
}


Measured memory_bytes: 16028
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int map[2000][2000];

int main(void) {
    int q;
    scanf("%d",&q);
    for(int i=0; i<q; i++) {
        memset(map, 0, sizeof(map));
        char x[2000], y[2000];
        scanf("%s%s",x,y);
        int xl=strlen(x),yl=strlen(y);

        for(int m=0; m<xl; m++)
            map[m][0] = 0;
        for(int n=0; n<yl; n++)
            map[0][n] = 0;
        for(int m=1; m<=xl; m++)
            for(int n=1; n<=yl; n++) {
                if(x[m-1] == y[n-1])
                    map[m][n] = max(max(map[m-1][n-1]+1, map[m-1][n]), map[m][n-1]);
                else
                    map[m][n] = max(max(map[m-1][n-1]+0, map[m-1][n]), map[m][n-1]);
            }
        printf("%d\n", map[xl][yl]);
    }
    return 0;
}

Measured memory_bytes: 16664
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	for (int i = 0; i < 60; i++) {
		long long int odd = 0,even = 0;
		for (auto j : v) {
			if ((j >> i) & 1)odd++;
			else even++;
		}
		K = 1LL << i;
		K %= MOD;
		K *= (odd*even) % MOD;
		M += K;
		M %= MOD;
	}
	cout << M << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define int long long
#define F first
#define S second
#define endl "\n"
using namespace std;

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

int n,m;
int a[nax], b[nax];
vector<int>adj[nax];

/*
 * 	   ************************ If you gave me a chance *******************************
 * 	   ************************ I'll take it            *******************************
 * 	   ************************	It's a shot in the dark *******************************
 * 	   ************************	But I will make it:D    *******************************
 */
int dp[nax]; // here dp is the wining probablity.

signed main(){
    fast;

    cin>>n>>m;
    
    dp[0] = 0; // dp[0] when stone is zero the first player will not be able to make move hence lose - 0.
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=m;i++){
        for(int j=0;j<n;j++){
            if(i>=a[j]){
                if(dp[i-a[j]] == 0){
                    dp[i] = 1;
                }
            }
        }
    }

    if(dp[m]){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }


    return 0;
}



Measured memory_bytes: 11408
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include <vector>

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

using namespace std;

int a[40] = { 0 }, b[40] = { 0 }, c[40] = { 0 }, N;
int dp1[40][401][401] = { 0 };


int main() {
	int Ma, Mb;
	cin >> N >> Ma >> Mb;
	REP(i, N) {
		cin >> a[i] >> b[i] >> c[i];
	}


	REP(j, 401) {
		REP(k, 401) {
			dp1[0][j][k] = 4001;
		}
	}
	
	REP(i, N) {
		REP(j, 401) {
			REP(k, 401) {
				if (i > 0) {
					if (j - a[i] >= 0 && k - b[i] >= 0) {
						dp1[i][j][k] = min(dp1[i - 1][j][k], dp1[i - 1][j - a[i]][k - b[i]] + c[i]);
					}
					else {
						dp1[i][j][k] = dp1[i - 1][j][k];
					}
				}
				else {
					if (j - a[i] == 0 && k - b[i] == 0) {
						dp1[i][j][k] = c[i];
					}
					else if (j == 0 && k == 0) {
						dp1[i][j][k] = 0;
					}
				}
			}
		}
	}

	

	int ans = 4001;
	int x = Ma, y = Mb;
	while (x < 401 && y < 401) {
		ans = min(ans, dp1[N - 1][x][y]);
		x += Ma;
		y += Mb;
	}

	if (ans == 4001) {
		cout << -1 << endl;
		return 0;
	}
	cout << ans << endl;

	return 0;
}


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


int main() {
  int n_ball,n_color;
  cin >> n_ball >> n_color;
  long long answer = n_color;
  for(int i = 0 ; i < n_ball-1 ; ++i) answer *= n_color-1;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
// AOJ 0557
#include<iostream>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef long long int number;

const int NMAX = 108;

int N, sequence[NMAX];
number kind[21];

number solve() {
  kind[sequence[0]] = 1;

  for (int i = 1; i < N - 1; i++) {
    number nkind[21];
    int s = sequence[i];

    REP(i, 21) {
      nkind[i] = 0;
    }

    for (int n = s; n < 21; n++) {
      nkind[n] = kind[n - s];
    }

    for (int n = 20 - s; n >= 0; n--) {
      nkind[n] += kind[n + s];
    }

    REP(i, 21) {
      kind[i] = nkind[i];
    }
  }

  return kind[sequence[N-1]];
}

int main() {
  cin >> N;
  REP(i, N) {
    cin >> sequence[i];
  }

  cout << solve() << endl;
}

Measured memory_bytes: 1156
h,w=gets.split.map(&:to_i)
s=h.times.map{gets.chomp}

h.times do |i|
  w.times do |j|
    next if s[i][j]=="#"

    count=0
    count+=1 if i-1>=0 && j-1>=0 && s[i-1][j-1]=="#"
    count+=1 if i-1>=0 && s[i-1][j]=="#"
    count+=1 if i-1>=0 && j+1<w && s[i-1][j+1]=="#"
    count+=1 if j-1>=0 && s[i][j-1]=="#"
    count+=1 if j+1<w && s[i][j+1]=="#"
    count+=1 if i+1<h && j-1>=0 && s[i+1][j-1]=="#"
    count+=1 if i+1<h && s[i+1][j]=="#"
    count+=1 if i+1<h && j+1<w && s[i+1][j+1]=="#"
    s[i][j]=count.to_s
  end
end
puts s


Measured memory_bytes: 14308
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, w, h;
	cin >> n >> w >> h;
	vi v(w + 1, 0), u(h + 1, 0);
	REP(i, n) {
		int x, y, W;
		cin >> x >> y >> W;
		v[max(0, x - W)]++; v[min(w, x + W)]--;
		u[max(0, y - W)]++; u[min(h , y + W)]--;
	}
	REP(i, w )v[i + 1] += v[i];
	REP(i, h )u[i + 1] += u[i];
	int c = *min_element(v.begin(),v.end()-1), d = *min_element(u.begin(),u.end()-1);
	if (c == 0 && d == 0)cout << "No" << endl;
	else cout << "Yes" << endl;
	

	return 0;
}

Measured memory_bytes: 3616
N=int(input())
S=input()

def match_num(A, B):
    m=[]
    for a in A:
        if a in B and a not in m:
            m.append(a)
    return m

match_nums=[]
for n in range(1, N):
    #print("{}\t{}".format(S[:n], S[n:]))
    #print(n)
    if n <= N//2:
        #print(S[:n])
        #print(match_num(S[:n], S[n:]))
        match_nums.append(len(match_num(S[:n], S[n:])))
        
    else:
        #print(S[n:])
        #print(match_num(S[:n], S[n:]))
        match_nums.append(len(match_num(S[n:], S[:n])))
print(max(match_nums))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<Z A,Z...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  long double a,b;
  cin >> a >> b;
  pr((ll)(a*b));
}

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


Measured memory_bytes: 3748
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())

n,m,k = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
cd = [list(map(int,input().split())) for i in range(k)]
num = [0]*(n+1)
g = [[] for i in range(n+1)]
uf = UnionFind(n+1)
for a,b in ab:
  g[a].append(b)
  g[b].append(a)
  uf.union(a,b)
for c,d in cd:
  if uf.same(c,d) == True:
    g[c].append(d)
    g[d].append(c)
for i in range(1,n+1):
  print(uf.size(i)-len(g[i])-1,end=" ")

Measured memory_bytes: 127192
#include <stdio.h>
int main(void)
{
  int a,b,c,d,sec;
  scanf("%d %d %d %d", &a, &b,&c,&d);
  if(b<=c||d<=a){
    sec = 0;
  } else {
    sec = (b<d?b:d)-(a<c?c:a);
  }
  printf("%d\n", sec);
  return 0;
}


Measured memory_bytes: 128
<?php

$n = (int)trim(fgets(STDIN));
$a_array = explode(' ', trim(fgets(STDIN)));

// sort($a_array);
$uniq_array = [];
$even = 0;
$count=0;

for ($i=0; $i < $n; $i++) { 
	$tmp = (int)$a_array[$i];
	if (empty($uniq_array[$tmp])) {
		$uniq_array[$tmp]=1;
	}else{
		$uniq_array[$tmp]+=1;
	}
}
foreach ($uniq_array as $key => $value) {
	if ($value %2===1) {
		++$count;
	}else{
		++$even;
	}
}
if ($even % 2 === 0) {
	$count += $even;
}else{
	$count += $even - 1;
}
echo $count;

Measured memory_bytes: 18932
#include <iostream>
#include <fstream>
#include <stack>
#include <cmath>
#include <string>
#include <algorithm>
#include <stack>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
#define pb push_back
#define ld long double
const ll N = 100005;
const int inf = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, k, c, ans = 0;
    cin >> n;
    k = 100;
    while (k < n) {
        k+= k/100;
        ans++;
    }
    cout << ans << '\n';
    return 0;
}


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

int main(){
    vector <string> s;
    int n, l;
    cin >> n >> l;
    for(int i = 0; i < n; i++){
        string t;
        cin >> t;
        s.push_back(t);
    }
    sort(s.begin(), s.end());
    for(auto x : s)
        cout << x;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<math.h>
int main()
{
    int x,a,b,c,d;
    scanf("%d%d%d",&x,&a,&b);
    c=abs(x-a);
    d=abs(x-b);
    if(c>d)
        printf("B");
    else {printf("A");}
    return 0;



}


Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
int main(void)
{
	int n,y,t,b[50],r,i,j,max99,max,parad;
	float kyo,g[50];
	while(1){
		max99=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		scanf("%d",&y);
		for(i=0;i<n;i++){
			scanf("%d%d%d",&b[i],&r,&t);
			if(t==1){
				g[i]=100*(1+y*r*0.01);
			}
			else{
				kyo=1+r*0.01;
				g[i]=pow(kyo,y);
				g[i]=100*g[i];
				}
		}
		for(i=0;i<n;i++){
			if(g[i]>max99){
				max99=g[i];
				max=b[i];
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 692
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};

int main(){
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

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

const ll INF = 1LL << 59;
int N, K;
ll V[55];

void solve() {
    cin >> N >> K;
    REP(i, N) cin >> V[i];
    
    ll ans = 0;
    vector<int> hoge;
    REP2(l, -1, N) REP2(r, l+1, N+1) {
        hoge.clear();
        int lcnt = l + 1;
        int rcnt = N - r;
        int rest = K - lcnt - rcnt;
        if (rest < 0) continue;
        REP(i, l+1) hoge.push_back(V[i]);
        REP2(i, r, N) hoge.push_back(V[i]);
        sort(hoge.begin(), hoge.end());
        ll tmp = 0;
        for (auto a: hoge) {
            if (a < 0 && rest > 0) {
                rest -= 1;
                continue;
            } else {
                tmp += a;
            }
        }
        ans = max(ans, tmp);
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const long long INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    ll ans=0;
    for (ll i=0;i<1000;i++){
        if (a%2 or b%2 or c%2){
            cout << ans << endl;
            return 0;
        }
        ll x=b/2+c/2;
        ll y=a/2+c/2;
        ll z=b/2+a/2;
        a=x;
        b=y;
        c=z;
        ans++;
    }
    cout << -1 << endl;
    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);
  for (int i = 0; i < m; i++){
    cin >> s.at(i) >> c.at(i);
  }
  int ans = -1;
  
  if (n == 1){
    for (int i = 0; i < 10;i++){
      string x = to_string(i);
      bool z = true;
      for (int j = 0; j < m; j++){
        if (x.at(s.at(j) - 1) != c.at(j)){
          z = false;
        }
      }
      if (z){
        ans = i;
        break;
      }
    }
  }
  
  if (n == 2){
    for (int i = 10; i < 100;i++){
      string x = to_string(i);
      bool z = true;
      for (int j = 0; j < m; j++){
        if (x.at(s.at(j) - 1) != c.at(j)){
          z = false;
        }
      }
      if (z){
        ans = i;
        break;
      }
    }
  }
  
  if (n == 3){
    for (int i = 100; i < 1000;i++){
      string x = to_string(i);
      bool z = true;
      for (int j = 0; j < m; j++){
        if (x.at(s.at(j) - 1) != c.at(j)){
          z = false;
        }
      }
      if (z){
        ans = i;
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3696
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#define N 10
using namespace std;

int judge(int ans){
    if (ans==0) return 1;
    else return 0;
}

int main() {
    int n,m;
    int count=0;
    int data[N][N];
    cin>>n>>m;
    int num[m];
    for (int i=0; i<m; i++){
        cin>>num[i];
        for (int j=0; j<num[i]; j++){
            cin>>data[i][j];
        }
    }
    int p[m];
    for (int i=0; i<m; i++) cin>>p[i];
    //cout<<data[1][0]<<endl;
    
    for (int bit = 0; bit < (1<<n); ++bit){
        bool t=true;
        vector<int> S;
        S.push_back(9); //S[0]を入れておく
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) { 
                S.push_back(1);
            }
            else S.push_back(0);
        }
        //for (int i=0; i<=n; i++) cout<<S[i];
        //cout<<endl;
        for (int i=0; i<m; i++){
            int ans=0;
            for (int j=0; j<num[i]; j++){
                if (S[data[i][j]]==1) ans=judge(ans);
            }
            if (ans!=p[i]) t=false;
        }
        if (t) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N, M;
  scanf("%d", &N);
  scanf("%d", &M);
  std::vector<int> to(M+5);
  std::vector<int> order(M+5);
  int P, Y;
  std::vector<std::map<int, int> > mp(N+5);
  for (int i=0; i<M; i++){
    scanf("%d", &P);
    scanf("%d", &Y);
    P--;
    to[i]=P;
    mp[P].insert(std::make_pair(Y,i));
  }
  for (int i=0; i<N; i++){
    //printf("i=%d\n", i);
    int counter = 0;
    for (auto entry : mp[i]){
      order[entry.second]=counter;
      //printf("order[%d]=%d\n", entry.second, counter);
      counter++;
    }
    /*    for (int j=0; j<mp[i].size(); j++){
      order[mp[i][j].second]=j;
      }*/
  }
  for (int i=0; i<M; i++){
    printf("%06d%06d\n",to[i]+1,order[i]+1);
  }
  return 0;
}


Measured memory_bytes: 9344
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

string str, ans;
char c[100];

int main(void) {
  cin>>str;
  for(int i=0;i<8;i++) str.pop_back();
  cout<<str<<endl;
  return 0;
}


Measured memory_bytes: 256