akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vector<bool> done(8);
    int ans1 = 0, ans2 = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(a < 3200){
            done[a / 400] = true;
        }else{
            ++ans2;
        }
    }
    rep(i, 8){
        ans1 += done[i];
        ans2 += done[i];
    }
    ans1 = max(ans1, 1);
    printf("%d %d\n", ans1, ans2);
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	m1 := make(map[int]int)
	m2 := make(map[int]int)
	var v int
	for i := 0; i < n; i++ {
		fmt.Scan(&v)
		if i%2 == 0 {
			m1[v]++
		} else {
			m2[v]++
		}
	}

	vs1 := make([]Pair, 0)
	for v, c := range m1 {
		vs1 = append(vs1, Pair{v, c})
	}
	vs1 = append(vs1, Pair{0, 0})
	vs2 := make([]Pair, 0)
	for v, c := range m2 {
		vs2 = append(vs2, Pair{v, c})
	}
	vs2 = append(vs2, Pair{0, 0})

	sort.Sort(sort.Reverse(SortBy(vs1)))
	sort.Sort(sort.Reverse(SortBy(vs2)))

	v11 := vs1[0]
	v12 := vs1[1]
	v21 := vs2[0]
	v22 := vs2[1]

	if v11.number != v21.number {
		ans := (n/2 - v11.count) + (n/2 - v21.count)
		fmt.Println(ans)
		return
	}

	ans := min(
		(n/2-v11.count)+(n/2-v22.count),
		(n/2-v12.count)+(n/2-v21.count),
	)
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

type Pair struct {
	number, count int
}

type SortBy []Pair

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i].count < a[j].count
}


Measured memory_bytes: 12024
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];

            if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) 
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }
        }
    }
}

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

int main() {
  int N, K, M = 1e9+7;
  cin >> N >> K;
  vector<vector<int>> G(N);
  for (int a, b; cin >> a >> b;) {
    a--, b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }

  function<long(int, int)> dfs = [&](int pre, int v) -> long {
    long ret = 1;
    int k = (pre == -1) ? K : K - 1;
    for (auto next : G.at(v)) {
      if (next == pre) continue;
      ret *= --k;
      ret %= M;
      ret *= dfs(v, next);
      ret %= M;
    }
    return ret;
  };

  cout << dfs(-1, 0) * K % M << "\n";
}


Measured memory_bytes: 15528
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

vector<int> dy = { 0,0,1,-1 };
vector<int> dx = { 1,-1,0,0 };

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

int main() {
	string S, T; cin >> S >> T;
	V<int> SA(S.size()+1,0), SB(S.size()+1, 0), TA(T.size()+1, 0), TB(T.size()+1, 0);
	REP(i, S.size()) SA[i + 1] = SA[i] + (S[i] == 'A');
	REP(i, S.size()) SB[i + 1] = SB[i] + (S[i] == 'B');
	REP(i, T.size()) TA[i + 1] = TA[i] + (T[i] == 'A');
	REP(i, T.size()) TB[i + 1] = TB[i] + (T[i] == 'B');

	int Q,mini; cin >> Q;
	V<int> ans(Q);
	REP(i, Q) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		a--; c--;
		int sa = SA[b] - SA[a];
		int sb = SB[b] - SB[a];
		int ta = TA[d] - TA[c];
		int tb = TB[d] - TB[c];
		mini = min(sa, sb);
		sa -= mini;
		sb -= mini;
		mini = min(ta, tb);
		ta -= mini;
		tb -= mini;

		if (sa == 0) {
			sa = 2 * sb;
			sb = 0;
		}

		if (ta == 0) {
			ta = 2 * tb;
			tb = 0;
		}

		ans[i] = (abs(sa-ta)%3==0);
	}
	REP(i, Q) YN(ans[i]);

	
	return 0;
}



Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>


using namespace std;

int pow2(int n) {
    int ans = 1;
    while (n > 0) {
        if (n % 2) return ans;
        n /= 2;
        ans *= 2;
    }
    return 0;
}

int main() {
    int n;
    cin >> n;
    if (n < 3 || pow2(n) == n) {
        cout << "No" << '\n';
        return 0;
    }
    cout << "Yes" << '\n';
    cout << 1+n << ' ' << 2+n << '\n';
    for (int i=1; i<=(n-1)/2; i++) {
        cout << 1     << ' ' << 2*i << '\n';
        cout << 2*i   << ' ' << 2*i+1 << '\n';
        cout << 1     << ' ' << 2*i+1+n << '\n';
        cout << 2*i+n << ' ' << 2*i+1+n << '\n';
    }
    if (n % 2 == 0) {
        cout << pow2(n) * 2 - 2 << ' ' << n << '\n';
        cout << 2*n-1 << ' ' << 2*n << '\n';
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;
void f(){
  string in;
  cin >> in;
  bool start = false;
  int ans = 0;
  int i;
  
  for(i = 0; i < 3; i++){
  	if(in[i] == 'R')
      break;
  }
  if(i == 3)
    cout << 0 << endl;
  if(i == 2)
    cout << 1 << endl;
  if(i == 1){
    if(in[2] == 'R')
      cout << 2 << endl;
    else 
      cout << 1 << endl;
  }
  if(i == 0){
    if(in[1] == 'R' && in[2] == 'R')
      cout << 3 << endl;
  	else if(in[1] == 'R')
      cout << 2 << endl;
  	else
      cout << 1 << endl;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 f();
 return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;
const ll Mod=1e9+7;


vector<ll> inv,fact,invfact;
void Mod_build(int n=201010){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%Mod;
		if(i>0)inv[i+1]=Mod-inv[Mod%(i+1)]*(Mod/(i+1))%Mod;
		invfact[i+1]=invfact[i]*inv[i+1]%Mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%Mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%Mod)*invfact[k]%Mod;
}
ll powMod(ll n,ll k){
	k%=Mod-1;
	if(k<0)k+=Mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%Mod;
		n=n*n%Mod;
		k>>=1;
	}
	return ret;
}

int main(){
  int i,j;
  int n;
  cin>>n;
  ll sum=0;
  VI c(n);
  for(i=0;i<n;i++){
    cin>>c[i];
  }
  sort(c.begin(),c.end());

  Mod_build();
  ll tw[202020];
  tw[0]=1;
  for(i=1;i<202020;i++){
    tw[i]=tw[i-1]*2%mod;
  }

  for(i=0;i<n;i++){
    ll r=c[i]*tw[i]%mod;
    if(i!=n-1) {
      r=r*tw[n-1-i-1];
      r%=mod;
      r=r*(n-1-i+2)%mod;
    }
    sum+=r;
    sum%=mod;
  }

  sum=sum*tw[n]%mod;

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


Measured memory_bytes: 7296
#include <iostream>
#include <fstream>
#include <queue>
#include <vector>
//#define LOCAL
using namespace std;
typedef long long ll;
const int mx=1e3+10;
priority_queue<ll, vector<ll>, less<ll> >pq[mx];

int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n, q;
cin>>n>>q;
for(ll i=1;i<=q;i++){
    ll t, sub, value;
    cin>>t;
    switch(t){
        case 0: cin>>sub>>value;
                pq[sub].push(value);
                break;
        case 1: cin>>sub;
                if(!pq[sub].empty())
                    cout<<pq[sub].top()<<endl;
                break;
        case 2: cin>>sub;
                if(!pq[sub].empty())
                    pq[sub].pop();
                break;
    }


}





#ifdef LOCAL
fin.close();
#endif // LOCAL
}




Measured memory_bytes: 5144
#include <bits/stdc++.h>          
using namespace std;               
 
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    int A = 0;
    int k = 0;
    for(int i = 0; i < N; i++){
        A++;
        if(a.at(k) == 2) {
            break;
        }
        k = a.at(k) - 1;
    }
    if(A < N){
        cout << A << endl;
    }
    else{
        cout << -1 << endl;
    }
}



Measured memory_bytes: 3724
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

string S;
ll sum = 0;

signed main(){
    cin >> S;
    rep(i, S.size()){
        sum += S[i]-'0';
    }
    if(sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3704
# atcoder : python3 (3.4.3)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7

# main
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

Ans = [0]*N
for a,b in AB:
    Ans[a-1] += 1
    Ans[b-1] += 1

for ans in Ans:
    print(ans)

Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500 * i + 100 * j + 50 * k == X:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define READ() freopen("in.txt","r",stdin)
#define WRITE() freopen("out.txt","w",stdout)
#define  pb(x)  push_back(x)
#define mem(arr,val) memset(arr,val,sizeof(arr));
typedef long long ll;
const int mx=30005;
vector<int>G[mx],cost[mx];
struct data{
    bool ev;
    int val;
};

bool cmp(data a,data b)
{
    if(a.val<b.val)
    {
        return true;
    }
    if(a.val==b.val)
    {
        return a.ev;

    }
    return false;
}
const int sz=10000000;
bool arr[sz+5];
ll prime[sz-100000];
int ind=0;
void Seive()
{
    arr[0]=true;
    arr[1]=true;
    arr[2]=false;
    prime[ind++]=2;
    for(int i=4;i<sz;i+=2)
    {
        arr[i]=true;
    }
    ll m=sqrt(sz);
    for(int i=3;i<=m;i+=2)
    {
        if(arr[i]==false)
        {
            for(int j=i*i;j<=sz;j+=i<<1)
            {
                arr[j]=true;
            }
        }
    }
    for(int i=3;i<sz;i+=2)
    {
        if(!arr[i])
        {
            prime[ind++]=i;
        }
    }
}

int main()
{
//    READ();
    Seive();
    //cout<<ind<<endl;
    int n;
    cin>>n;
    printf("%lld",prime[0]);
    int sum=2;
    int r=1;
    int i=1;
    while(r<n)
    {
        if(prime[i]%5==1){
        printf(" %lld",prime[i]);
        r++;
        }
        i++;

    }
    cout<<endl;

    return 0;
}


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

int main(void) {
    int a, b, c, x = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            x++;
        }
    }
    cout << x <<endl;
    
    return 0;
   }

Measured memory_bytes: 1160
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main()
{
    char a[102][102]={0};
    int m,n;
    cin>>m>>n;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
        cin>>a[i][j];
    for(int i=0;i<=m+1;i++)
    {
        for(int j=0;j<=n+1;j++)
        if(a[i][j])putchar(a[i][j]);
        else putchar('#');
        if(i<m+1)putchar('\n');
    }
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

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

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	int a;
	string s;

	cin >> a;
	cin >> s;

	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++)
    cin>>L[i];
  sort(L.begin(),L.end());
  int sum = accumulate(L.begin(),L.end(),0);
  sum -= L.back() * 2;
  if(sum > 0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
n, d = map(int, input().split())
x = []

for i in range(n):
    xi = [int(s) for s in input().split()]
    x.append(xi)

count = 0
for i in range(0, n - 1):
    for j in range(i + 1, n):
        distance = 0
        for k in range(d):
            distance += (x[i][k] - x[j][k]) ** 2
        norm = math.sqrt(distance)
        if norm.is_integer():
            count += 1
print(count)


Measured memory_bytes: 9116
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i=0; i<n; i++) arr[i] = sc.nextInt();

        int res = arr[0];

        for (int i=1; i<n; i++) {
            res = gcd(res, arr[i]);
        }

        System.out.println(res);
    }

    int gcd(int m, int n) {
        if (m < n) {
            int tmp = n;
            n = m;
            m = tmp;
        }
        if (n == 0) return m;
        if (n == 1) return 1;
        return gcd(n, m%n);
    }

}



Measured memory_bytes: 51584
// ================
// Himanshu Lal
// MNIT Jaipur
// ================
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define TEZ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define INF 1e18
#define vi vector<pair<ll,ll>>
#define ff first
#define ss second
#define mp map<ll,ll>
#define test ll tp; cin>>tp; while(tp--)
#define srt(v) sort(v.begin(),v.end())
double pi=acos(-1);
void OJ(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    #endif
}
int main(){
    TEZ;
    char c;
    cin>>c;
    if(c>='A' and c<='Z'){
        cout<<"A";
    }else{
        cout<<"a";
    }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,m;int a[85][85],c[85][85];bitset<13000> bi[85][85];
int lif=6500;
bool ok(int x){return 0<=x&&x<=12800;}
int main()
{
    scanf("%d%d",&n,&m);
    rep(i,1,n) rep(j,1,m) scanf("%d",&a[i][j]);
    rep(i,1,n) rep(j,1,m){
        int num;scanf("%d",&num);
        c[i][j]=a[i][j]-num;
    }
    bi[1][1][c[1][1]+lif]=bi[1][1][-c[1][1]+lif]=1;
    rep(i,1,n) rep(j,1,m){
        if(i==1&&j==1) continue;
        rep(k,0,12800){
            int nxt1=k+c[i][j],nxt2=k-c[i][j];
            if(ok(nxt1)) {
                if(i>1&&bi[i-1][j][nxt1]) bi[i][j][k]=1;
                if(j>1&&bi[i][j-1][nxt1]) bi[i][j][k]=1;
            }
            if(ok(nxt2)) {
                if(i>1&&bi[i-1][j][nxt2]) bi[i][j][k]=1;
                if(j>1&&bi[i][j-1][nxt2]) bi[i][j][k]=1;
            }
        }
    }
    int ans=233;
    rep(i,-80,80) if(bi[n][m][i+lif]) ans=min(ans,abs(i));
    printf("%d\n",ans);
    return 0;
}

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n;
	cin >> n;
	cout << (1000 - n%1000)%1000 << '\n';

	return 0;
}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int h, w;
char matrix[12][12];
bool able[12][12];
void get(queue<int> &q){
    if (q.size() <= 1){
        cout << "YES" << endl;
        exit(0);
    }
    int ld = q.size();
    int el = q.front();
    q.pop();
    for (int i=0; i < q.size(); i++){
        int V = q.front();
        q.pop();
        if (able[V][el]) get(q);
        q.push(V);
    }
    if (ld % 2) get(q);
    q.push(el);
}
void solve(queue<int> &q, vector<pair<int, int> > &v){
    if (q.size() > 1){
        int ld = q.size();
        int el = q.front();
        q.pop();
        for (int i=0; i < q.size(); i++){
            int V = q.front();
            q.pop();
            v.push_back(make_pair(el, V));
            solve(q, v);
            v.pop_back();
            q.push(V);
        }
        if (ld % 2){
            v.push_back(make_pair(el, el));
            solve(q, v);
            v.pop_back();
        }
        q.push(el);
        for (int i=0; i < q.size()-1; i++){
            int V = q.front();
            q.pop();
            q.push(V);
        }
        return;
    }
    for (int i=0; i < w; i++){
        for (int j=0; j < w; j++){
            able[i][j] = true;
            for (int s=0; s < v.size(); s++){
                int a = v[s].first, b = v[s].second;
                if (matrix[a][i] != matrix[b][j]) able[i][j] = false;
                if (matrix[b][i] != matrix[a][j]) able[i][j] = false;
            }
            if (q.size() > 0){
                int e = q.front();
                if (matrix[e][i] != matrix[e][j]) able[i][j] = false;
            }
        }
    }
    queue<int> nq;
    for (int i=0; i < w; i++) nq.push(i);
    get(nq);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    for (int i=0; i < h; i++) for (int j=0; j < w; j++) cin >> matrix[i][j];
    queue<int> v;
    vector<pair<int, int> > q;
    for (int i=0; i < h; i++) v.push(i);
    solve(v, q);
    cout << "NO" << endl;
    return 0;
}

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

int main(void){
    int i,a,b,c,t,k=0;
    
    cin >> a >> b >> c;
    for(i=a; i<=b; i++){
        t = c / i;
//        cout << t << endl;
        if(c == ( i * t)){ k++; }
    }
    
    cout << k << endl;
    
    
    return 0;
    
}


Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main()
{
	char str;
	int alpha[26];
	int i;
	
	for(i=0;i<26;i++)alpha[i]=0;
	
	
	while(scanf("%c",&str)!=EOF)
	{
			if(isalpha(str))
			{
				if(isupper(str))
				{
					alpha[str-'A']++;
				}
				else
				{
					alpha[str-'a']++;
				}
			}
	}
	
	for(i=0;i<26;i++)
	{
		printf("%c : %d\n",'a'+i,alpha[i]);
	}
	
	
	return 0;
}

Measured memory_bytes: 544
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <cmath>
const int MaxN = 100000;
using namespace std;
char s[MaxN + 5];
int main() 
{
	while(~scanf("%s", s + 1)) {
		int len = strlen(s + 1);
		int res = len;
		for (int i = 2; i <= len; i++) {
			if(s[i] != s[i -1]) res = min(res, max(i - 1, len - i + 1));
		}
		printf("%d\n", res);
	}
	return 0;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int, input().split())
list=list(map(int, input().split()))
l_b=[]
d=0
for i in range(N):
  d=A-(T-list[i]*0.006)
  if d<0:
    d=-d
  l_b.append(d)
print(l_b.index(min(l_b))+1)

Measured memory_bytes: 3064
/*input
2
P Y
*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long long int arr[112345],dp[1123456]={0};
long long int pow(long long int a, long long int b, long long int mod){
	if(b==1)return a;
	if(b==0)return 1;
	long long int ret = pow(a, b/2 ,mod);
	ret = ret * ret;
	ret %= mod;
	if(b&1){
		ret=ret*a;
		ret %= mod; 
	}
	return ret;
}

int main() {
	int n,m,ans;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="Y"){
			cout<<"Four\n";
			return 0;
		}
	}
	cout<<"Three\n";

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int x,y;
  cin >> x >> y;
  if(((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12))||((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

main :-
    get_number(N),
    X is N div 3,
    writeln(X).


Measured memory_bytes: 7992
def bubble_sort(A):
    cnt = 0
    for i in range(len(A) - 1):
        for j in reversed(range(i+1, len(A))):
            if A[j] < A[j - 1]:
                cnt += 1
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
    return cnt

cnt = 0
amount = int(input())
nl = list(map(int, input().split()))

cnt = bubble_sort(nl)

for i in range(amount - 1):
    print(nl[i], end=" ")
print(nl[amount - 1])
print(cnt)

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

using namespace std;

int main(void){
    int N;
    cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++){
        double x;
        string s;
        cin >> x >> s;
        if(s == "JPY"){
            ans += x;
        }else{
            ans += x * 380000.0;
        }
    }

    cout << ans;
}

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

def Warshall_Floyd():
    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])

Warshall_Floyd()

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += c[A[i][j]][1]
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define mod 1000000007
#define inf 1e18
#define PI 3.14159265358979323846264338327950L
#define w(x) int x; cin>>x; while(x--)
using namespace std;
bool sieve[2000006];
void sieve_make() 
{
	memset(sieve,true,sizeof(sieve));
	sieve[0]=sieve[1]=false;
	for(int i=2;i*i<2000006;i++)
	{
		if(sieve[i])
		{
			for(int j=i*i;j<2000006;j+=i)
				sieve[j]=false;
		}
	}
}

int max(int a,int b)
{
	if(a>b)
		return a;
	return b;
}
int min(int a,int b)
{
	if(a<b)
		return a;
	return b;
}
int modexp(int a,int b,int c)
{
	if(a==0) return 0;
	if(b==0) return 1;

	int ans;
	if(b%2==0)
	{
		int small=modexp(a,b/2,c);
		ans=(small*small)%c;
	}
	else
	{
		int small=modexp(a,b-1,c);
		ans=(a%c);
		ans=(small*ans)%c;
	}
	return (ans+c)%c;
}
bool sign(int x)
{
	if(x>0)
		return true;
	return false;
}
int kadane(int* a,int n)
{
	int loc=a[0],glo=a[0];
	for(int i=1;i<n;i++)
	{
		loc=max(a[i],loc+a[i]);
		glo=max(glo,loc);
	}
	return glo;
}

int dp[100005];
int dfs(vector<int>* adj,int sv,bool col,bool* vis,int n)
{
	if(sv==n-1)
		return 1;
	
	int ans=0;
	for(auto i:adj[sv])
	{
		if(!vis[i])
		{
			vis[i]=1;
			if(col)
				ans+=dfs(adj,i,!col,vis,n);
			else
				ans+=dfs(adj,i,!col,vis,n)+dfs(adj,i,col,vis,n);
			vis[i]=0;
		}
	}
	return ans;
}

int32_t main()
{
	ios::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
	
	
	
	
	int n;
	cin>>n;
	
	int ans=0;
	for(int i=1;i<n;i++)
	{
		ans+=(n-1)/i;
	}
	cout<<ans<<endl;
	
}



Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n, k int

	fmt.Sscan(getNextLine(scanner), &n, &k)
	xxx := getIntList(scanner)
	min := math.MaxInt32
	for i := len(xxx) - 1; i >= k-1; i-- {
		left := i - k + 1
		between := xxx[i] - xxx[left]
		if between+absint(xxx[i]) < min {
			min = between + absint(xxx[i])
		}
		if between+absint(xxx[left]) < min {
			min = between + absint(xxx[left])
		}

	}
	fmt.Println(min)
}
func absint(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 14080
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

ll fir(ll x){
    while(x>=10)
        x/=10;
    return x;
}

ll len(ll x){
    ll t = 0;
    while(x>0){
        t++;
        x/=10;
    }
    return t;
}

ll dig(ll x){
    ll t = 0;
    while(x>0){
        t+=x%10;
        x/=10;
    }
    return t;
}

int main(){
    fastIO;
    ll n;
    cin >> n;
    cout << max(9*(len(n)-1)+fir(n)-1,dig(n));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int a,i,d[101];
    d[0]=1;
    while (scanf("%d",&a)!=EOF)
    {
        int b=0;
        for(i=0;i<=a;i++)
        {
            d[i]=pow(2,i);
            if(d[i]>a)
            {
                b=d[i-1];
                break;
            }
        }
        printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Long A = sc.nextLong();
		Long B = sc.nextLong();
		long i =1;
		
		while(true){
			long a = A*i;
			if(a%B == 0){
				System.out.println(a);
				return;
			}
			i++;
		}
	}
}

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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    vector<int> lis(5, 0);
    REP(i, 0, 5){
        cin >> lis[i];
        if(lis[i] == 0){
            cout << i+1 << endl;
        }
    }
}

Measured memory_bytes: 3596
#include<stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define N 100
#define IN (1<<21)
#define O 0
#define I 1

void dijkstra(void);

int n,A[N][N];

int main(){
  int i,j,s,u,v,c,k;
  scanf("%d",&n);
  for(i=O;i<n;i++){
    for(j=O;j<n;j++){
      A[i][j]=IN;
    }
  }
  for(i=O;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=O;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v]=c;
    }
  }
  dijkstra();
  return 0;
}
void dijkstra(){
  int i,u,v,m,a=O,d[N],color[N];

  for(i=O;i<n;i++){
    d[i]=IN;
    color[i]=WHITE;
  }
  d[O]=O;
  color[O]=GRAY;
  while(I){
    m=IN;
    u=-I;
    for(i=O;i<n;i++){
      if(m>d[i] && color[i]!=BLACK){
        u=i;
        m=d[i];
      }
    }
    if(u==-I){
      break;
    }
    color[u]=BLACK;
    for(v=O;v<n;v++){
      if(color[v]!=BLACK && A[u][v]!=IN){
        if(d[v]>d[u]+A[u][v]){
          d[v]=d[u]+A[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
  for(i=O;i<n;i++){
    printf("%d %d\n",i,(d[i]== IN?-I:d[i]));
  }
}




Measured memory_bytes: 2088
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete
 
affine a b c
  | isAsciiLower c = chr $ mod (a * (ord c - ord 'a') + b) 26 + ord 'a'
  | otherwise = c
 
unaffine a b c
  | isAsciiLower c = head [x | x <- ['a'..'z'], affine a b x == c]
  | otherwise = c
 
   
findAffine s = fromJust $ find (getAny . foldMap Any . (isInfixOf <$> ["that", "this"] <*>) . pure)  [flip map s $ unaffine a b | a <- [1..25], b <- [0..25], mod a 2 /= 0, mod a 13 /= 0]
 
main = do
    getInt >>= flip replicateM getLine >>= mapM_ (putStrLn . findAffine)

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

int main()
{
  map< int, char, greater<int> > m;
  int s1, s2;
  int i;
  while (cin>>s1>>s2, s1||s2) {
    m.clear();
    m[s1+s2] = 'A';
    for (i = 1; i < 5; i++) {
      cin>>s1>>s2;
      m[s1+s2] = 'A'+i;
    }
    cout<<(*m.begin()).second<<" "<<(*m.begin()).first<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,p,cnt=0;
    cin >> n >> p;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a%2==0)cnt++;
    }
    if(cnt==n&&p==1)cout << 0;
    else if(cnt==n&&p==0)cout << ((long long)1<<n);
    else cout << ((long long)1<<n-1);
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll A, B, C;
    cin >> A >> B >> C;
    set<ll> s;
    s.insert(A);
    s.insert(B);
    s.insert(C);
    if (s.size() == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A <= B){
    cout << "0" << endl;
  }
  else{
    cout << A - B << endl;
  }
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/21/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int H,W; cin>>H>>W;
  vector<string> grid(H); for (auto& s : grid) cin>>s;
  vector<vector<int>> dist(H, vector<int>(W, 0));

  dist[0][0] = 0;
  for (int j = 1; j < W; j++) {
    dist[0][j] = (grid[0][j] == grid[0][j-1]) ? dist[0][j-1] : dist[0][j-1]+1;
  }
  for (int i = 1; i < H; i++) {
    dist[i][0] = grid[i-1][0] == grid[i][0] ? dist[i-1][0] : dist[i-1][0]+1;
    for (int j = 1; j < W; j++) {
      auto d = grid[i-1][j] == grid[i][j] ? dist[i-1][j] : dist[i-1][j]+1;
      auto r = grid[i][j-1] == grid[i][j] ? dist[i][j-1] : dist[i][j-1]+1;
      dist[i][j] = min(d, r);
    }
  }
  auto ans = (dist[H-1][W-1]+1)/2;
  if (grid[0][0] == '#' and grid[H-1][W-1] == '#')
    ans++;
  cout << ans << endl;

  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int H, W, K; cin >> H >> W >> K;
  vector<string> a(H); REP(i, H) cin >> a[i];
  vector<vector<int>> ans(H, vector<int>(W));
  REP(i, H) { // ansの初期化
    REP(k, W) {
      ans[i][k] = 0;
    }
  }
  // 横方向の走査
  int p = 1; bool flag = false;
  REP(i, H) {
    flag = false;
    REP(k, W) { // いちごがあるか？
      if(a[i][k] == '#') flag = true;
    }
    if(flag)  {
      REP(k, W) ans[i][k] = p;
    }
    if(!flag && i == H - 1) p--;
    if(flag && i != H - 1) p++;
  }
  // 縦方向の走査
  bool flag2 = false;
  REP(i, H) {
    flag = false; flag2 = false;
    REP(k, W) {
      if(a[i][k] == '#' && flag == false) {
        flag = true;
      } else if(a[i][k] == '#' && flag == true) {
        flag2 = true; p++;
      }
      if(flag2) ans[i][k] = p;
    }
  }
  // 空白行の帳尻合わせ
  for(int i = H - 1; i >= 0; --i) {
    flag = false;
    REP(k, W) {
      if(a[i][k] == '#') flag = true;
    }
    if(!flag) {
      REP(k, W) {
        if(i != H - 1) ans[i][k] = ans[i + 1][k];
      }
    }
  }
  REP(i, H) {
    flag = false;
    REP(k, W) {
      if(a[i][k] == '#') flag = true;
    }
    if(!flag) {
      REP(k, W) {
        if(i != 0) ans[i][k] = ans[i - 1][k];
        else ans[i][k] = ans[i + 1][k];
      }
    }
  }
  REP(i, H) {
    REP(k, W) {
      cout << ans[i][k] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 4120
N,M=map(int, input().split())
A=list(map(int, input().split()))
BC=[list(map(int, input().split())) for _ in range(M)]
BC=sorted(BC, key=lambda x: -1*x[1])
A=sorted(A)

ans = []
for bc in BC:
	num = bc[0]
	val = bc[1]
	for _ in range(num):
		ans.append(val)
		if(len(ans) > len(A)):
			break
out = 0
for idx in range(N):
	tmp = A[idx]
	if(idx < len(ans)):
		tmp = max(tmp, ans[idx])
	out += tmp
print(out)


Measured memory_bytes: 93080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;
ll res;
vector<ll>v, s;

int main() {
	cin >> N;
	int x;
	cin >> x;
	v.push_back(x);
	for (int i = 1; i < N; i++) {
		char c;
		cin >> c >> x;
		if (c == '+') {
			v.back() += x;
		}
		else {
			v.push_back(x);
			v.push_back(0);
		}
	}
	s = v;
	for (int i = v.size() - 2; i >= 0; i--) {
		s[i] += s[i + 1];
	}
	res = -llmax;
	ll t = 0;
	for (int i = 0; i < v.size(); i++) {
		if (i & 1) {
			if (i + 2 < v.size()) {
				res = max(res, t - v[i] - v[i + 1] + s[i + 2]);
			}
			t -= v[i];
		}
		else {
			t += v[i];
		}
	}
	cout << max(res, t) << endl;
}

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

using ll = long long;

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

    if (n % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    n /= 2;

    ll num2 = 0;
    for (ll i = 2; i <= n; i *= 2) {
        num2 += n / i;
        if (i > n / 2) break;
    }
    ll num5 = 0;
    for (ll i = 5; i <= n; i *= 5) {
        num5 += n / i;
        if (i > n / 5) break;
    }
    cout << min(num2, num5) << endl;

    return 0;
}

Measured memory_bytes: 256
main :: IO()
main = do
    str <- getLine
    print $ getsolve str
    
getsolve :: String -> Int
getsolve str
    | str == "SUN"			= 7
    | str == "MON"			= 6
    | str == "TUE"			= 5
    | str == "WED"			= 4
    | str == "THU"			= 3
    | str == "FRI"			= 2
    | str == "SAT"			= 1
    | otherwise				= 0

Measured memory_bytes: 380
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<vector<Int> >A(N);
  for(Int i=0;i<N;i++){
    Int m;
    cin>>m;
    A[i].resize(N, -1);
    for(Int j=0;j<m;j++){
      Int x, y;
      cin>>x>>y;
      A[i][x-1] = y;
    }
  }

  auto check=[&](Int x){
    for(Int i=0;i<N;i++){
      for(Int j=0;j<N;j++){
        if(A[i][j] == -1) continue;
        if((x>>i&1) == 1){
          if(A[i][j] == 1 && (x>>j&1) == 0) return 0;
          if(A[i][j] == 0 && (x>>j&1) == 1) return 0;
        }
        else{
          //if(A[i][j] == 0 && (x>>j&1) == 0) return 0;
          //if(A[i][j] == 1 && (x>>j&1) == 1) return 0;

        }
      }
    }
    return 1;
  };

  Int ans = 0;
  for(Int i=0;i<(1<<N);i++){
    if(check(i)) ans = max(ans, (Int)__builtin_popcount(i));
  }

  cout<<ans<<endl;

  return 0;
}


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

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

	for(int i=0;i<n;i++){
		int x,y,w,h;
		cin >> x >> y >> w >> h;
		int cat;
		int catcount = 0;
		cin >> cat;
		for(int j=0;j<cat;j++){
			int catx,caty;
			cin >> catx >> caty;

			if(x <= catx && x+w >= catx && y <= caty && y+h >= caty){
				catcount++;
			}
		}

		cout << catcount << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
 
int main() {
    //Recieve the inputs
    int D, T, S;
    cin >> D >> T >> S;
 
    //Calculate the duration of Takahashi's journey
    double time = (double)D / S;
 
    //Output depending on the inequality between T and time
    if (T >= time) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
# define pi 3.141592
int b,c;
inline double f(double x){
	double v=(x*x+b*x+c)/sin(x);
	return v;
}
ll power(ll a,ll x){
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;
        }
        a=a*a;
        x=x/2;
    }
    return r;
}
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	int a[3][3];
    	rep(i,3)rep(j,3)cin>>a[i][j];
    	int n;cin>>n;
    	int flag[3][3];
    	memset(flag,0,sizeof(flag));
    	rep(i,n){
    		int x;cin>>x;
    		rep(j,3){
    			rep(k,3){
    				if(a[j][k]==x){
    					flag[j][k]=1;
    				}
    			}
    		}
    	}
    	string ans="No";
    	rep(i,3){
    		int cnt=0;
    		rep(j,3){
    			cnt+=flag[i][j];
    		}
    		if(cnt==3)ans="Yes";
    	}
    	rep(i,3){
    		int cnt=0;
    		rep(j,3){
    			cnt+=flag[j][i];
    		}
    		if(cnt==3)ans="Yes";
    	}
    	if(flag[0][0]+flag[1][1]+flag[2][2]==3)ans="Yes";
    	if(flag[0][2]+flag[1][1]+flag[2][0]==3)ans="Yes";
    	cout<<ans;
    } 	
    return 0;   
}	

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int C; string result = ("null");

            if ((A * B) % 2 == 0)
            {
                result = ("No");
            }
            else
            {
                result = ("Yes");
            }


            

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long ll;
#define pi 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  double a,b,h,m;
  cin >> a>>b>>h>>m;
  double kakuc = abs(h*30+m*0.5-m*6);
  if(kakuc>=180) kakuc = 360 - kakuc;
  double ans;
  ans = a*a+b*b-2*a*b*cos(kakuc/180*pi);
  ans = pow(ans,0.5);
  cout << fixed << setprecision(20)<< ans << endl;
}

Measured memory_bytes: 4276
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
 
mv_array = [set() for _ in range(n)]
score_mv_array = [[] for _ in range(n)]
score_array = [0]*n
 
def get_sum(array):
    score_array = [0]
    for i, a in enumerate(array):
        score_array.append(score_array[i]+a)
    return max(score_array)
 
def get_max(array, q, mod):
    if q == 0:
        m_score = get_sum(array[:mod])
    else:
        m_score = get_sum(array+array[:mod])
        m_score = sum(array)*(q-1) + m_score
    return m_score
 
 
for i in range(n):
    score = 0
    max_score = c[i]
    pos = i
    for j in range(k):
        pos = p[pos]-1
        if pos in mv_array[i]:
            len_mv = len(score_mv_array[i])
            q, mod = divmod(k-j, len_mv)
            score += get_max(score_mv_array[i], q, mod)
            max_score = max(score, max_score)
            break
        score += c[pos]
        mv_array[i].add(pos)
        score_mv_array[i].append(c[pos])
        max_score = max(score, max_score)
    score_array[i] = max_score
 
print(max(score_array))

Measured memory_bytes: 883620
#include <stdio.h> 

int main() 

{
long int a,b,i,m,n=0;
scanf("%ld %ld",&a,&b); 

for(i=1;i<=b;i++) 
{
scanf("%ld",&m);
n=n+m; 
}
if(n>=a)
{
printf("Yes\n");
}
else
printf("No\n"); 
return 0; 
}   

Measured memory_bytes: 1624