akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

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

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	A := sc.nextIntSlice(N)
	ok := true
	for i := 0; i < N; i++ {
		if A[i]%2 == 0 {
			if A[i]%3 != 0 && A[i]%5 != 0 {
				ok = false
			}
		}
	}
	if ok {
		fmt.Fprintln(wtr, "APPROVED")
	} else {
		fmt.Fprintln(wtr, "DENIED")
	}
}


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

int main() {
  int N, A, p1, p2;
  cin >> N >> A ;

  p1 = N / 500;
  p2 = N - p1 * 500;
  
  if (p2 > A) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3636
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => int.Parse(Console.ReadLine()))
			.Select(a => new int[a].Select(i => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray())
			.ToArray();

		var p2 = new int[n + 1];
		p2[0] = 1;
		for (int i = 1; i <= n; i++) p2[i] = 2 * p2[i - 1];

		var M = 0;
		for (int f = 0; f < p2[n]; f++) M = Math.Max(M, Assert(f, ps, p2));
		Console.WriteLine(M);
	}

	static int Assert(int f, int[][][] ps, int[] p2)
	{
		var c = 0;
		for (int i = 0; i < ps.Length; i++)
		{
			if ((f & p2[i]) == 0) continue;
			c++;
			foreach (var xy in ps[i])
				if (((f & p2[xy[0] - 1]) > 0 ? 1 : 0) != xy[1]) return 0;
		}
		return c;
	}
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> b(n);
	rep(i,n){
		cin>>b[i];
		b[i]--;
	}
	vector<int> ans;
	while(!b.empty()){
		bool flag=false;
		for(int i=b.size()-1;i>=0;i--){
			if(b[i]==i){
				auto itr=begin(b)+i;
				b.erase(itr);
				flag=true;
				ans.push_back(i+1);
				break;
			}
		}
		if(!flag){
			cout<<-1<<endl;
			return 0;
		}
	}
	reverse(begin(ans),end(ans));
	cout<<ans<<endl;
}

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

const long long md=1e9+7;//mod
const int maxn=300100;
long long fac[maxn],inv[maxn];


long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}

void csh(){
	fac[0]=1;
	for(int i=1;i<=1e5+30;i++)
		fac[i]=fac[i-1]*i%md;
	for(long long i=1;i<=1e5+30;i++)
    inv[i]=powd(i,md-2);
}

int main(){
  csh();
  long long N;
  cin >> N;
  vector<long long> A(N+1,0);
  for(auto i=1; i<=N; i++) cin >> A[i];
  long long ans=0;
  vector<long long> Psum(N+1,0);
  for (int i=1; i<=N; i++) Psum[i] = (Psum[i-1]+inv[i])%md;
  for (int i=1; i<=N; i++){
    ans += A[i]*(Psum[i]+Psum[N-i+1]+md-1)%md;
    ans %=md;
  }
  ans = (ans*fac[N])%md;
  cout << ans << endl;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
 
using namespace std;
using LL = long long int; 

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.st <<","<<P.nd <<")";
}

#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int h, w, k;
int board[13][1003];
int cnt[13];
int pref[13];

int solve(int mask) {
  vector<int> cuts;
  int pom = 1;
  int maskPom = mask;
  while (maskPom) {
    if (maskPom % 2 == 1) {
      cuts.push_back(pom);
    }
    ++pom;
    maskPom /= 2;
  }

  if (cuts.empty()) {
    return 1 << 30;
  }
  if (cuts.back() != h) {
    cuts.push_back(h);
  }
  int last = 1;
  vector<int> actVal;
  vector<vector<int>> toAdd;
  for (auto cut : cuts) {
    vector<int> v;
    for (int j = 1; j <= w; ++j) {
      int xx = 0;
      for (int i = last; i <= cut; ++i) {
        xx += board[i][j];
      }
      if (xx > k) {
        return 1 << 30;
      }
      v.push_back(xx);
    }
    toAdd.push_back(v);
    actVal.push_back(0);
    debug(cut, toAdd);
    last = cut + 1;
  }

  int res = 0;
  debug(mask);
  for (int j = 1; j <= w; ++j) {
    bool czy = true;
    debug(j);
    for (int i = 0; i < (int)actVal.size(); ++i) {
      debug(i, actVal[i], toAdd[i][j - 1]);
      actVal[i] += toAdd[i][j - 1];
      if (actVal[i] > k) {
        czy = false;
      }
    }

    if (czy == false) {
      for (int i = 0; i < (int)actVal.size(); ++i) {
        actVal[i] = toAdd[i][j - 1];
      }
      ++res;
    }
  }
  debug(res);
  return res + __builtin_popcount(mask);
}

int main() {
  cin >> h >> w >> k;
  bool czy = true;
  int l = 0;
  for (int i = 1; i <= h; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < w; ++j) {
      board[i][j + 1] = (s[j] == '1' ? 1 : 0);
      l += board[i][j + 1];
      cnt[i] += board[i][j + 1];
    }
    pref[i] = pref[i - 1] + cnt[i];
  }
  if (l <= k) {
    cout << 0 << endl;
    return 0;
  }
  int res = 1 << 30;
  for (int i = 0; i < (1 << h); ++i) {
    res = min(res, solve(i));
  }
  debug(l);
  cout << res << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a==b&&b!=c||b==c&&c!=a||c==a&&a!=b)
	    printf("Yes\n");
	else 
    	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
//WA
#include <bits/stdc++.h>
 
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ii pair<int,int>
#define qu queue <int>
#define qmax priority_queue <int>
#define qmin priority_queue <int, vector<int>,greater<int>>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll  n;
    cin>>n;

    if(n%2 != 0)
        cout<<n*2<<endl;
    else
        cout<<n<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    REP(i, M) { cin >> A[i]; }
    int cnt = A.end() - lower_bound(A.begin(), A.end(), X);
    cout << min(cnt, M - cnt) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    ll a,b,c; cin >> a >> b >> c;
    if (c-(a+b)<=0) cout << "No"<<endl;
    else {
        ll x = c*c + (a+b)*(a+b) - 2*c*(a+b) - 4*a*b;
        if (x>0) cout << "Yes" <<endl;
        else cout << "No" << endl;
    }
    return 0;
}

































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

Measured memory_bytes: 128
/**
 * Author : Dhakad_123
 * Created:27.06.2020
**/

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    
    char n;
    cin >> n;
    
    if(n >= 'A' && n <= 'Z'){
        cout << "A" << "\n";
    }
    else{
        cout << "a" << "\n";
    }
    
    return 0; 
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.nextLine());
        int[][] abc = new int[N][3];
        for (int i = 0; i < N; i++) {
            abc[i][0] = Integer.parseInt(sc.next());
            abc[i][1] = Integer.parseInt(sc.next());
            abc[i][2] = Integer.parseInt(sc.next());
        }

        int[][] dp = new int[N][3];
        dp[0][0] = abc[0][0];
        dp[0][1] = abc[0][1];
        dp[0][2] = abc[0][2];

        for (int i = 1; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (j == k) {
                        continue;
                    }

                    int todayDP = dp[i][k];
                    int yesterday = dp[i - 1][j];
                    int today = abc[i][k];

                    dp[i][k] = Math.max(todayDP, yesterday + today);
                }
            }
        }

        long ans = 0;
        for (int i = 0; i < 3; i++) {
            ans = Math.max(ans, dp[N - 1][i]);
        }

        System.out.println(ans);
    }
}



Measured memory_bytes: 66720
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
#define overload4(_1,_2,_3,_4,name,...) name
#define rep1(n) for(ll i=0;i<(n);++i)
#define rep2(i,n) for(ll i=0;i<(n);++i)
#define rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep4(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
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;}

struct Edge {
  ll t,i;
  Edge(ll t,ll i):t(t),i(i){}
};

vector<Edge> g[55];

ll bit;
bool dfs(ll v,ll t,ll p=-1){
  if(v==t)return true;
  for(Edge e:g[v]){
    if(e.t==p)continue;
    if(dfs(e.t,t,v)){
      bit|=1ll<<e.i;
      return true;
    }
  }
  return false;
}

void solve(){
  /* (´~`) */
  ll n;cin>>n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    g[a].emplace_back(b,i);
    g[b].emplace_back(a,i);
  }

  ll m;cin>>m;
  vec eset(m);
  rep(i,m){
    ll a,b;cin>>a>>b;
    a--;b--;
    bit=0;
    dfs(a,b);
    eset[i]=bit;
  }

  ll ans=0;
  rep(i,1<<m){
    ll mask=0;
    rep(j,m){
      if(i>>j&1)mask|=eset[j];
      ll white=__builtin_popcountll(mask);
      ll now=1ll<<(n-1-white);
      if(__builtin_popcountll(i)%2==0)ans+=now;
      else ans-=now;
    }
  }
  cout<<ans<<endl;
}

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


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

int main(){
    int a, b, ans=0;
    cin >> a >> b;
    rep2(i, a, b+1){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define fir first
#define sec second
#define mod 1000000007
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
inline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
inline int add(int x,int y,int z){return add(add(x,y),z);}
inline int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
inline int mul(int x,int y){return 1LL*x*y%mod;}
inline int mul(int x,int y,int z){return mul(mul(x,y),z);}
#define N 4005
int n,m,k;
int f[N][N][2];
signed main()
{
	cin>>n>>m>>k;
	if(n<m) swap(n,m);
	f[0][0][0]=1;
	int lim=(n+m-1)/(k-1);
	for(int i=1;i<=lim;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int c=1;c<=k-1;c++)
			{
				if(j>=c) f[i][j][1]=add(f[i-1][j-c][0],f[i-1][j-c][1],f[i][j][1]);
			}
			f[i][j][0]=add(f[i-1][j][0],f[i-1][j][1],f[i][j][0]);
		}
	}
	int ans=0;
	for(int i=1;i<=lim;i++)
	{
		for(int j=n%(k-1);j<=n;j+=k-1)
		{
			if(i*(k-1)-j+1<=m) ans=add(ans,f[i][j][1]);
		}
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 82060
#include<bits/stdc++.h>
#include <queue>
#define fs first
#define sc second
#define N 1010
#define nut pair<int,pair<int,int>>
using namespace std;

int kc(int a,int b,int c,int d)
{
    if(abs(a-c)+abs(b-d)==1) return 0;
        else return 1;
}

set<nut>s;
int n,m,xs,ys,xe,ye,dp[N][N];
string a[N];

bool check(int x,int y)
{
    return ((x>0&&x<=n)&&(y>0&&y<=m));
}

void update()
{
    dp[xs][ys]=0;
    s.insert({0,{xs,ys}});
    while(!s.empty())
    {
        nut u=*s.begin();
        s.erase(u);
        for(int i=-2;i<=2;i++)
            for(int j=-2;j<=2;j++)
                if((i!=0||j!=0)&&(check(u.sc.fs+i,u.sc.sc+j)&&a[u.sc.fs+i][u.sc.sc+j]=='.'))
                {
                    int x=u.sc.fs+i,y=u.sc.sc+j;
                    if(dp[x][y]==-1||dp[x][y]>dp[u.sc.fs][u.sc.sc]+kc(x,y,u.sc.fs,u.sc.sc))
                    {
                        s.erase({dp[x][y],{x,y}});
                        dp[x][y]=dp[u.sc.fs][u.sc.sc]+kc(x,y,u.sc.fs,u.sc.sc);
               //          cout<<u.x<<" "<<u.y<<" "<<x<<" "<<y<<" "<<dp[x][y]<<endl;
                        s.insert({dp[x][y],{x,y}});
                    }
                }
    }
}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    cin>>xs>>ys>>xe>>ye;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        a[i]=" "+a[i];
    }
    update();
    cout<<dp[xe][ye];
    return 0;
}


Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


int main(){
  ll n;
  cin >> n;
  ll dp[110][5][5][5]={0};
  dp[0][3][3][3]=1;
  
  for(int i=1;i<=n;i++){
    for(int j=0;j<=3;j++){
      for(int k=0;k<=3;k++){
        for(int l=0;l<=3;l++){
          for(int p=0;p<=3;p++){
            if(j==2 && l==1 && p==0)continue;
            if(j==2 && k==1 && p==0)continue;
            if(j==1 && k==2 && l==0)continue;
            if(j==2 && k==0 && l==1)continue;
            if(j==2 && k==1 && l==0)continue;
            dp[i][j][k][l]+=dp[i-1][k][l][p] ;
            dp[i][j][k][l]%=MOD; 
          }
        }
      }
    }
  }
  ll ans=0;
  for(int i=0;i<=3;i++){
    for(int j=0;j<=3;j++){
      for(int k=0;k<=3;k++){
        ans+=dp[n][i][j][k];
        ans%=MOD;
      }
    }
  }
  cout << ans << endl;
}


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

int set[100001];

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

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

    int dups = 0;
    for (int i=0; i<100001; i++) {
        if (set[i] > 0) {
            dups++;
        }
    }
    
    cout << (dups % 2 ? dups : dups - 1) << endl; // N は必ず奇数だから
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    int n, m, r, x[8];
    ll d[200][200], INF=1e16;
    cin>>n>>m>>r;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            d[i][j]=INF;
        }
    }
    for(int i=0;i<r;i++){
        cin>>x[i];
        x[i]--;
    }
    sort(x, x+r);
    for(int i=0;i<m;i++){
        int a,b;
        ll c;
        cin>>a>>b>>c;
        a--;
        b--;
        d[a][b]=d[b][a]=c;
    }
    for(int k=0;k<n;k++){
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
            }
        }
    }
    ll ans=INF;
    do{
        ll c=0;
        for(int i=0;i<r-1;i++){
            c+=d[x[i]][x[i+1]];
        }
        ans=min(ans, c);
        //cout<<c<<endl;
    }while(next_permutation(x, x+r));
    cout<<ans<<endl;
    
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
using namespace std;
int main()
{
	int n;
    long long k;
	scanf("%d%lld",&n,&k);
	long long x,y;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=k*k)
		{
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 1732
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

struct UnionFind{
    vector<int> data;
    UnionFind(int size) : data(size, -1) {}
    bool unionSet(int x,int y){
        x=root(x);y=root(y);
        if(x==y)return 0;
        if(data[y]<data[x])swap(x,y);
        data[x]+=data[y],data[y]=x;
        return 1;
    }
    bool findSet(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin>>n>>m;
	UnionFind uf(n);
	rep(i,m){
		int a,b,c;
		cin>>a>>b>>c;
		a--;b--;
		uf.unionSet(a,b);
	}
	int c=0;
	rep(i,n)if(uf.root(i)==i)c++;
	cout<<c<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	string S;
	int Q;
	cin >> S >> Q;
	bool turn = false;
	string fsum, esum;
	while (Q--) {
		int T;
		cin >> T;
		if (T == 1) turn = !turn;
		else {
			int f;
			char c;
			cin >> f >> c;
			if (f == 1) {
				if (turn) esum = esum + c;
				else fsum = c + fsum;
			}
			else {
				if (turn) fsum = c + fsum;
				else esum = esum + c;
			}
		}
	}
	string ans = fsum + S + esum;
	if (turn) reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
 
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> p(n), c(n);
  for (int i = 0; i < n; ++i) cin >> p[i], p[i]--;
  for (int i = 0; i < n; ++i) cin >> c[i];
  ll ans = LLONG_MIN;
  for (int i = 0; i < n; ++i) {
    int u = i, len = 0;
    ll sum = 0;
    while (true) {
      len++;
      u = p[u];
      sum += c[u];
      if (u == i) break;
    }
    u = i;
    int cur = 0;
    ll v = 0;
    while (true) {
      u = p[u];
      v += c[u];
      cur++;
      if (cur > k) break;
      ll x = (k - cur) / len;
      ans = max(ans, v + max(0LL, sum) * x); 
      if (u == i) break;
    }
  }
  cout << ans << '\n';
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  cout << (a - 1) * (b - 1) << endl;
}


Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))


if(min(y) <= max(x)):
    print("War")
elif(min([min(y),Y-1]) - max([max(x)+1,X+1]) <0):
    print("War")
else:
    print("No War")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
 int A,B,C,D;
  cin >> A>>B>>C>>D;
  while(1){
    C-=B;
    A-=D;
    if(C<=0){
      cout << "Yes"<<endl;
  		return 0;
    }
    if(A<=0){
      cout << "No"<<endl;
  		return 0;
    }
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(50)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, A[200010]; cin >> N;
  map<int, int> mp;
  mp[0]++;
  REP(i, N) cin >> A[i+1], A[i+1] += A[i], mp[A[i+1]]++;
  int ans = 0;
  for(auto itr : mp){
    ans += itr.second * (itr.second-1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 14336
N = int(input())
W = []
for i in range(N):
    A,B = map(int,input().split())
    W.append([B,A])
W.sort()
time = 0
State = "Yes"
for i in range(N):
    time += W[i][1]
    if W[i][0] < time:
        State = "No"
        break
print(State)

Measured memory_bytes: 37444
import re
s = input()
str = ["dream","dreamer","erase","eraser"]
str = ["maerd","remaerd","esare","resare"]
s=s[::-1]
while len(s)>0:
  if len(s) < 5:
    print("NO")
    break
  if s[0:7] == str[1] :
    s=s[7:]
  elif s[0:6] == str[3]:
    s=s[6:]
  elif s[0:5] == str[0] or s[0:5] == str[2]:
    s=s[5:]
  else:
    print("NO")
    break
  if len(s)==0:
    print("YES")
    break





Measured memory_bytes: 3316
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var d int
	var x int
	fmt.Scanf("%d %d\n", &d, &x)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scanf("%d\n", &tmp)
		as[i] = tmp
	}

	// day 1
	choco := x + n
	// day (1..d-1)+1 ..
	for i := 1; i <= d-1; i++ {
		for _, a := range as {
			if i%a == 0 {
				choco++
			}
		}
	}

	fmt.Printf("%d\n", choco)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i < b; i++)
using ll = long long;
using namespace std;
ll gcd(ll m, ll n)
{
    ll temp;
    if (m < n) swap(m, n);
    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }
    return n;
}
ll lcm(ll m, ll n)
{
    return m / gcd(m, n) * n;
}
int main()
{
    int n;
    cin >> n;
    vector<ll> t(n);
    REP(i, 0, n) cin >> t[i];
    sort(t.begin(), t.end());
    ll ans = t[0];
    REP(i, 1, n) {
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a;
	while(cin>>a){
		int b=0;
		for(int a1=0;a1<10;a1++){
			for(int a2=0;a2<10;a2++){
				for(int a3=0;a3<10;a3++){
					for(int a4=0;a4<10;a4++){
						if(a1+a2+a3+a4==a){
							b++;
						}
					}
				}
			}
		}
		cout<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int a,b,c;
    cin >> a >> b >> c;

    for(int d = 1; d < b; d++) {
        if((d*a)%b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
temp = input().split(" ")
a = min(int(temp[0]), int(temp[1]))
b = max(int(temp[0]), int(temp[1]))

def divisors(n):
  i = 2
  ret = [1]
  while True:
    while n % i == 0:
      if not i in ret:
        ret.append(i)
      n = n // i
    if n == 1 : break
    if i * i > n:
      ret.append(n)
      break
    i += 1
  return ret

# a < b
def gcd(a, b):
  if b % a == 0:
    return a
  else:
    return gcd(b % a, a)

print(len(divisors(gcd(a, b))))

Measured memory_bytes: 38768
import java.util.*;

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

        int n = sc.nextInt();

        HashMap<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            map.put(a, map.getOrDefault(a, 0) + 1);
        }

        int q = sc.nextInt();

        StringBuilder sb = new StringBuilder();

        long ans = 0;

        for(int i = 0; i < q; i++){
            int b = sc.nextInt();
            int c = sc.nextInt();

            int bNum = 0;
            if(map.containsKey(b)){
                bNum = map.get(b);
                if(map.containsKey(c)){
                    map.put(c, map.get(c) + bNum);
                }else{
                    map.put(c, bNum);
                }

                map.remove(b);
            }

            if(ans == 0){
                for(Integer j : map.keySet()){
                    //System.out.println(j + " "+ map.get(j));
                    ans += map.get(j) * (long)j;
                }
            }else{
                ans += (c - b) * bNum;
            }

            sb.append(ans).append("\n");
            //System.out.println(ans);

        }
        System.out.println(sb);

    }
}


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

const int MAXN = 100005;

int a[MAXN], n;
string str[2] = {"First", "Second"};

inline int gcd(int a, int b)
{ return b == 0 ? a : gcd(b, a%b); }

void solve(int a[], int n, int cur)
{
	int even = 0, odd = 0;
	for (int i = 1; i <= n; i++) {
	        if (a[i]&1) odd++;
		else even++;
	}
	if (odd == 1) {
		if (even&1) cout << str[cur] << endl;
		else {
			for (int i = 1; i <= n; i++)
				if (a[i]&1) {
					if (a[i] == 1) {
						cout << str[cur^1] << endl;
						return;
					}
					a[i]--;
					break;
				}
			int g = a[1];
			for (int i = 2; i <= n; i++)
				g = gcd(g, a[i]);
			for (int i = 1; i <= n; i++)
				a[i] /= g;
			solve(a, n, cur^1);
		}
	} else {
		if (even&1) cout << str[cur] << endl;
		else cout << str[cur^1] << endl;
	}
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) 
		scanf("%d", &a[i]);
	solve(a, n, 0);
	return 0;
}


Measured memory_bytes: 640
from bisect import bisect_left, bisect_right
a, b, q = map(int, input().split())
inf = 10**18
shrine = [-inf] + [int(input()) for _ in range(a)] + [inf]
temple = [-inf] + [int(input()) for _ in range(b)] + [inf]

for _ in range(q):
    ans = inf
    x = int(input())
    index_s = bisect_left(shrine, x)
    index_t = bisect_right(temple, x)
    for i in range(index_s-1, index_s+1):
        s = shrine[i]
        i_t = index_t
        t0, t1 = temple[i_t-1], temple[i_t]
        ans = min(
            ans,
            abs(x - s) + abs(s - t0),
            abs(x - s) + abs(s - t1),
        )

    for i in range(index_t-1, index_t+1):
        t = temple[i]
        i_s = index_s
        s0 = shrine[i_s - 1]
        s1 = shrine[i_s]
        ans = min(
            ans,
            abs(x - t) + abs(t - s0),
            abs(x - t) + abs(t - s1),
        )

    print(ans)


Measured memory_bytes: 12816
import math
N = int(input())
ans = 0

for i in range(N):
    num = int(input())
    if num == 2:
        ans +=1
        continue
    rt = math.ceil(math.sqrt(num))
    div = 2
    bool = True
    while (rt >= div):
        if num % div:
            div += 1
        else:
            bool = False
            break
    if bool:
        ans += 1
print(ans)



Measured memory_bytes: 5672
#include<bits/stdc++.h>
using namespace std;
long long dp[110][100010];


int main() {

	int n, W; cin >> n >> W;
	long long w[n + 10], v[n + 10];

	for (int i = 0; i < n; i++)cin >> w[i] >> v[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {

			if (j - w[i] >= 0) {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}

			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

		}
	}

	cout << dp[n][W] << endl;


	return 0;
}

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    long long n;

    cin >> n;

    if(n>=30) {

        cout << "Yes" <<'\n';

    } else {

        cout << "No" <<'\n';

    }

    return 0;

}



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

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
        cout<<s<<"es"<<endl;
    else
        cout<<s<<"s"<<endl;

    return 0;
}

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


int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n,k;cin>>n>>k;
  cout<<min(n%k, k-n%k)<<endl;
  return 0;
}


Measured memory_bytes: 3652
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


def main():
    def find(x):
        parent = data[x]
        if parent < 0: return x
        root = find(parent)
        data[x] = root
        return root

    def union(x, y):
        root, second = find(x), find(y)
        if root == second: return False
        if data[root] > data[second]:
            second, root = root, second
        data[root] += data[second]
        height[root] = max(height[root], height[second]+1)
        data[second] = root
        return True

    def size(x):
        return -data[find(x)]

    N, M = lr()
    P = lr()
    data = [-1] * (N+1)  # 1-indexed rootには-sizeが入る
    height = [0] * (N+1)

    for _ in range(M):
        x, y = lr()
        union(x, y)
    
    answer = 0
    for i in range(N):
        if find(i+1) == find(P[i]):
            answer += 1
    
    print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 14004
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
const int INF = 1 << 30;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end();
int V=10; /*最大頂点数*/
struct edge { int to, cost; };
typedef std::pair<int, int> PP;
// ↑costと頂点番号のペア
std::vector<edge> list[10];
int d[10];
void DIJX(int st) {
	for (int i = 0; i<V; i++)d[i] = INF; // std::fillでも書ける
	d[st] = 0; // 始点
	std::priority_queue<PP, std::vector<PP>, std::greater<PP>> pq;
	pq.push(std::make_pair(d[st], st)); // (cost,頂点番号)
	while (!pq.empty()) {
		PP p = pq.top();
		pq.pop();
		int i = p.second; // costがfirst、頂点番号がsecond
		if (d[i]<p.first)continue;
		for (int k = 0; k<list[i].size(); k++) {
			edge e = list[i][k];
			if (d[e.to] <= d[i] + e.cost)continue;
			d[e.to] = d[i] + e.cost;
			pq.push(std::make_pair(d[e.to], e.to));
		}
	}
}
int main() {
	int h,w, a, b, c;
	int ans = 0;
	std::cin >> h>>w;
	for (int i = 0; i<10; i++) {
		TFOR(j, 10) {
			std::cin >> a;
			//list[i].push_back(edge{ j, a });
			list[j].push_back(edge{ i, a });
		}
	}
	DIJX(1);
	//TFOR(i, 10)std::cout << i << ":" << d[i] << std::endl;
	TFOR(i, h) {
		TFOR(j, w) {
			int nn;
			std::cin >> nn;
			if (nn != -1) {
				//std::cout << nn << "を" << d[nn] << "支払って1にする ans=" << ans << std::endl;
				ans += d[nn];
			}
		}
	}
	std::cout <<ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    size_t c = 0;
    for (size_t i = 0; i < s.length(); ++i) {
        if (s[i] != s[s.length() - i - 1]) {
            s[s.length() - i - 1] = s[i];
            ++c;
        }
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

const std::string T = "2019/04/30";

int main(){
    std::string S;
    std::cin >> S;
    if(S <= T) std::cout << "Heisei" << std::endl;
    else std::cout << "TBD" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;


int main(int argc, char* argv[])
{
    ll x,y;
    scanf("%lld%lld", &x, &y);
    if(abs(x-y)<2) {
        printf("Brown\n");
    }
    else {
        printf("Alice\n");
    }
    return 0;
}


Measured memory_bytes: 128
package main
 
import (
    "fmt"
	"os"
	"bufio"
	"strconv"
	"strings"
)
 
var stdin = bufio.NewScanner(os.Stdin)
 
func nextLine() string {
    stdin.Scan()
    return stdin.Text()
}
 
func main() {
	line := nextLine()
	cols := strings.Split(line, " ")
	min, mid, max := 100, 100, 100
	for i, c := range cols {
		n, _ := strconv.Atoi(c)
		if i == 0 {
			min = n
		} else if n < min {
			max = mid
			mid = min
		 	min = n
		} else if n < mid {
			max = mid
		 	mid = n
		} else if n < max {
		 	max = n
		}
	}
	a := max - mid
	b := max - min
	c := mid - min
	if a < b {
		if b < c {
			fmt.Println(a+b)
		} else {
			fmt.Println(a+c)
		}
	} else {
		if a < c {
			fmt.Println(a+b)
		} else {
			fmt.Println(b+c)
		}
	}
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N, std::vector<long long> A){
    LL all = accumulate(ALL(A), 0LL);

    LL min_cnt = INFL;
    LL now = 0;
    REP(i, N - 1) {
        now += A[i];
        min_cnt = min(min_cnt, abs(all - now - now));
    }

    cout << min_cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
// AOJ 1369: Distribution Center
// 2017.11.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int yp[100002];
int l[200002], r[200002];

char buf[20], *bp;
int getint()
{
	int n = 0;
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, x, y, xmin, xmax;

	fgets(bp=buf, 20, stdin);
	n = getint(), bp++, m = getint();
	fgets(bp=buf, 20, stdin);
	x = getint(), bp++, y = getint();
	xmin = xmax = x; yp[x] = y;
	i = m-1; while (i-- > 0) {
		fgets(bp=buf, 20, stdin);
		x = getint(), bp++, y = getint();
		yp[x] = y;
		if (x < xmin) xmin = x;
		else if (x > xmax) xmax = x;
	}

	for (i = 1; i <= n; i++) l[i] = i;
	memcpy(r, l, sizeof(int)*(n+1));

	for (x = xmin; x <= xmax; x++) {
		if (yp[x] > 0) {
			i = yp[x];
			l[i+1] = l[i], r[i] = r[i+1];
		}
	}
	printf("%d", r[1]-l[1]+1);
	for (i = 2; i <= n; i++) printf(" %d", r[i]-l[i]+1);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 3756
#include<iostream>
using namespace std;
int N;
long A[2<<17];
long ans;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	int i=0;
	while(i<N)
	{
		while(i+1<N&&A[i]+1==A[i+1])i++;
		if(A[i]>i||i+1<N&&A[i]+1<A[i+1])
		{
			cout<<-1<<endl;
			return 0;
		}
		ans+=A[i];
		i++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
# coding: utf-8
n = int(raw_input())
s = raw_input()


clist = ['aa','bb','cc','dd','ee','ff','gg','hh','ii','jj','kk','ll','mm','nn','oo','pp','qq','rr','ss','tt','uu','ww','vv','xx','yy','zz']

for word in clist:
    while True:
        if s.count(word) > 0:
            s = s.replace(word,word[0])
        else:
            break

print len(s)


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int a,b,c;
    cin>>a>>b>>c;
    OUT(a+b+c-max({a,b,c}));
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define repm(i, n, m)  for(int i = n; i < m; ++i)
#define Repm(i, n, m)  for(int i = n; i <= m; ++i)
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repn(i, n) repm(i, 1, n)
#define mod 1000000000+7

int main(){
    int n, x; cin >> n >> x;
    int ans = 1;
    int l, d = 0;
    Repm(i, 1, n){
        cin >> l;
        d = d+l;
        if(x >= d)  ans++;
    }    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
int main(){
   ll k,n;
   cin>>k>>n;
   ll a[n];
   for(int i=0;i<n;i++)cin>>a[i];
   ll mx=min(k-(a[n-1]-a[0]),a[n-1]-a[0]);
   for(ll i=1;i<n;i++){
       mx=max(min(a[i]-a[i-1],k-(a[i]-a[i-1])),mx);
   }
   cout<<k-mx;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int t = Integer.parseInt(sc.next());
        int ans = 0;
        if(n % x == 0) {
            ans = n / x;
        }else {
            ans = n / x + 1;
        }
        System.out.println(t * ans);
    }
}


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

int main() {
    //
    long long num;
    long long sumA = 0;
    long long sumB = 0;
    long long Min = 9999999999;

    cin >> num;

    vector<long long> vec(num);

    for (int i = 0; i < num; i++) {
        cin >> vec.at(i);
        if (i != num - 1)
            sumA += vec.at(i);
        else
            sumB += vec.at(i);
    }

    for (int i = num - 1; i > 0; i--) {
        if (i == num - 1) {
            Min = min(Min,abs(sumA - sumB));
            continue;
        }

        sumA -= vec.at(i);
        sumB += vec.at(i);

        Min = min(Min,abs(sumA - sumB));
    }

    cout << Min;

    //
}


Measured memory_bytes: 4784
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	n <- readInt
	hs <- readInts
	putStrLn $ which "Yes" "No" $ solve 0 hs

solve _ [] = True
solve p (h:hs)
	| p > h = False
	| otherwise = solve ( max p $ h - 1 ) hs

Measured memory_bytes: 4092