akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll k, a, b;
    cin >> k >> a >> b;
    loop(i, 1010)
    {
        ll now = k * i;
        if (now <= b && now >= a)
        {
            putout("OK");
            return 0;
        }
    }
    putout("NG");
    return 0;
}


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10**7)

class Node:
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left  
        self.right = right

def preParse(T, u, pre):
    if u == -1:
        return
    pre.append(u)
    preParse(T, T[u].left, pre)
    preParse(T, T[u].right, pre)

def inParse(T, u, inl):
    if u == -1:
        return
    inParse(T, T[u].left, inl)
    inl.append(u)
    inParse(T, T[u].right, inl)

def postParse(T, u, post):
    if u == -1:
        return
    postParse(T, T[u].left, post)
    postParse(T, T[u].right, post)
    post.append(u)

n = int(input())
T = {k: Node(-1, -1, -1) for k in range(n)}  

for _ in range(n):
    tmp = list(map(int, input().split()))
    T[tmp[0]].left = tmp[1]  
    T[tmp[0]].right = tmp[2] 
    if tmp[1] != -1:
        T[tmp[1]].parent = tmp[0]  
    if tmp[2] != -1:
        T[tmp[2]].parent = tmp[0]

for id, node in T.items():
    if node.parent == -1:
        ROOT = id

pre, inl, post = [], [], []
preParse(T, ROOT, pre)
inParse(T, ROOT, inl)
postParse(T, ROOT, post)

print('Preorder')
print('', *pre)
print('Inorder')
print('', *inl)
print('Postorder')
print('', *post)


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
     
using namespace std;
     
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

     
int main(){
  string str;

  cin >> str;

  string res = str.substr(4, str.length()-1);

  cout << "2018" + res << endl;

  return 0;
}


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

int main()
{
    long long A;
    string B;
    cin >> A >> B;

    long long b = 0ll;
    b += 100 * (B[0] - '0');
    b += 10 * (B[2] - '0');
    b += B[3] - '0';
    cout << A * b / 100 << endl;
}


Measured memory_bytes: 3624
def findnumberofTriangles(arr): 
  
    # Sort array and initialize count as 0 
    n = len(arr) 
    arr.sort() 
    count = 0
  
    # Fix the first element. We need to run till n-3 as 
    # the other two elements are selected from arr[i+1...n-1] 
    for i in range(0,n-2): 
  
        # Initialize index of the rightmost third element 
        k = i + 2
  
        # Fix the second element 
        for j in range(i+1,n): 
  
            # Find the rightmost element which is smaller 
            # than the sum of two fixed elements 
            # The important thing to note here is, we use 
            # the previous value of k. If value of arr[i] + 
            # arr[j-1] was greater than arr[k], then arr[i] + 
            # arr[j] must be greater than k, because the array 
            # is sorted. 
            while (k < n and arr[i] + arr[j] > arr[k]): 
                k += 1
  
            # Total number of possible triangles that can be 
            # formed with the two fixed elements is k - j - 1. 
            # The two fixed elements are arr[i] and arr[j]. All 
            # elements between arr[j+1] to arr[k-1] can form a 
            # triangle with arr[i] and arr[j]. One is subtracted 
            # from k because k is incremented one extra in above 
            # while loop. k will always be greater than j. If j 
            # becomes equal to k, then above loop will increment k, 
            # because arr[k] + arr[i] is always greater than arr[k] 
            if(k>j): 
                count += k - j - 1
  
    return count 

n = int(input())
ar = list(map(int, input().split()))
print(findnumberofTriangles(ar))


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<int> num(100010,0);
	for (int i = 0; i < N; i++) {
		num[a[i]]++;
	}
	vector<int> ans(100010, 0);
	for (int i = 0; i < num.size(); i++) {
		if (i == 0)ans[i] = num[i] + num[i + 1];
		else if (i == num.size() - 1)ans[i] = num[i - 1] + num[i];
		else ans[i] = num[i - 1] + num[i] + num[i + 1];
	}
	int ANS=0;
	for (int i = 0; i < ans.size(); i++) {
		if (ANS < ans[i])ANS = ans[i];
	}
	cout << ANS;
}

Measured memory_bytes: 1408
//https://atcoder.jp/contests/code-festival-2016-quala/tasks/codefestival_2016_qualA_c
//C - 次のアルファベット / Next Letter
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    string is; cin>>is;
    string s=is;
    ll K; cin>>K;    
    ll p=0;
    while(K>0&&p<s.size()){
        auto ch=s.at(p);
        if(ch!='a'){
            ll dif=26-s.at(p)+'a';
            if(dif<=K&&dif>0){
                s.at(p)='a';
                K-=dif;
            }
        }
        ++p;
    }
    //のこり
    K%=26;
    s.back()+=K;
    if(s.back()>'z') s.back()-=26;
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel par;
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; ans %= p; }
	return ans;
}
signed main() {
	int p, q, r; cin >> p >> q >> r;
	cout << p + q + r - max({ p,q,r }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int S = 0;

    if (K <= A) {
        S = K;
    } else if (K <= A + B) {
        S = A;
    } else {
        S = A - (K - (A + B));
    }

    cout << S << "\n";

    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a/b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

// matrix
template<int MOD> struct Matrix {
	vector<vector<long long> > val;
	Matrix(int n, int m, long long x = 0) : val(n, vector<long long>(m, x)) {}
	void init(int n, int m, long long x = 0) {val.assign(n, vector<long long>(m, x));}
	size_t size() const {return val.size();}
	inline vector<long long>& operator [] (int i) {return val[i];}
};

template<int MOD> int GaussJordan(Matrix<MOD> &A, bool is_extended = false) {
	int m = A.size(), n = A[0].size();
	for (int row = 0; row < m; ++row)
		for (int col = 0; col < n; ++col)
			A[row][col] = (A[row][col] % MOD + MOD) % MOD;
	int rank = 0;
	for (int col = 0; col < n; ++col) {
		if (is_extended && col == n-1) break;
		int pivot = -1;
		for (int row = rank; row < m; ++row) {
			if (A[row][col] != 0) {
				pivot = row;
				break;
			}
		}
		if (pivot == -1) continue;
		swap(A[pivot], A[rank]);
		auto inv = modinv(A[rank][col], MOD);
		for (int col2 = 0; col2 < n; ++col2)
			A[rank][col2] = A[rank][col2] * inv % MOD;
		for (int row = 0; row < m; ++row) {
			if (row != rank && A[row][col]) {
				auto fac = A[row][col];
				for (int col2 = 0; col2 < n; ++col2) {
					A[row][col2] -= A[rank][col2] * fac % MOD;
					if (A[row][col2] < 0) A[row][col2] += MOD;
				}
			}
		}
		++rank;
	}
	return rank;
}

ll n,m,k[11],s[11][11],p[11],mod=2;

void init(){
	cin>>n>>m;
	rep(i,m){
		cin>>k[i];
		rep(j,k[i]){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	rep(i,m){
		cin>>p[i];
	}
}

int main(void){
	init();
	Matrix<2> mt(m,n+1),mt2(m,n);
	rep(i,m){
		rep(j,k[i]){
			mt[i][s[i][j]]=1;
			mt2[i][s[i][j]]=1;
		}
	}
	rep(i,m)mt[i][n]=p[i]%mod;
	ll t=GaussJordan(mt);
	ll t2=GaussJordan(mt2);
	if(t==t2){
		cout<<(1<<(n-t))<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)

int main() {
  int N, K;
  string S;
  cin >> N >> K;
  cin >> S;
  vector<int> c;
  int c0 = 0, c1 = 0;
  REP(i, N) {
    if(S[i] == '0') {
      c0++;
      if(c1 != 0) {
        c.push_back(c1);
        c1 = 0;
      }
    } else {
      c1++;
      if(c0 != 0) {
        c.push_back(c0);
        c0 = 0;
      }
    }
  }
  if(c0 != 0) {
    c.push_back(c0);
  }
  if(c1 != 0) {
    c.push_back(c1);
  }

  if(S[0] == '0') {
    c.insert(c.begin(), 0);
  }
  if(S[S.size()-1] == '0') {
    c.push_back(0);
  }

  if(c.size() <= 2 * K + 1) {
    cout << N << endl;
    return 0;
  }

  int ans = 0;
  for(int i = 0; i < c.size()-(2*K+1)+1; i += 2) {
    int t = 0;
    REP(j, (2*K+1)) {
      t += c[j+i];
    }
    ans = max(ans, t);
  }
  cout << ans << endl;
  return 0;
}


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

const long long MOD=998244353;
int dp[3005][3005];
int arr[3005];
long long n,s;

int solve(int idx,int sum_reqd){
    if(sum_reqd==0) return n-idx+1;
    if(sum_reqd<0) return 0;
    if(idx>=n) return 0;
    if(dp[idx][sum_reqd]!=-1) return dp[idx][sum_reqd];

    int ans=(solve(idx+1,sum_reqd)+solve(idx+1,sum_reqd-arr[idx]))%MOD;
    return dp[idx][sum_reqd]=ans;
}

int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n>>s;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    long long ans=0;
    for(int i=0;i<n;i++){
        ans=(ans+solve(i,s))%MOD;
    }
    cout<<ans<<"\n";
    
}

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

const long mod = 1000000007;
long fact[100001];

void calc_fact()
{
  fact[0] = 1;
  for (int i = 1; i <= 100000; i++)
    fact[i] = fact[i - 1] * i % mod;
}

int main()
{
  long N, M;
  cin >> N >> M;
  calc_fact();
  if (1 < abs(N - M))
    cout << 0 << endl;
  else if (abs(N - M) == 1)
    cout << fact[N] * fact[M] % mod << endl;
  else
    cout << fact[N] * fact[M] % mod * 2 % mod << endl;
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC122_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char chr = str[0];

            if (chr == 'A')
            {
                Console.WriteLine("T");
            }
            if (chr == 'T')
            {
                Console.WriteLine("A");
            }
            if (chr == 'C')
            {
                Console.WriteLine("G");
            }
            if (chr == 'G')
            {
                Console.WriteLine("C");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>


int main() {

	int N;
	std::cin >> N;

	std::vector<int> vec(N);

	for (int i = 0; i < N-1; i++) {
		int buffer;
		std::cin >> buffer;
		vec[buffer-1]++;
	}


	for (int i = 0; i < N; i++) {
		std::cout << vec[i] << std::endl;
	}


}


Measured memory_bytes: 3556
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <list>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <iomanip>
#define INF 2147483647
 
using namespace std;


int S[10000];


bool search(int x, int n)
{
	for (int i = 0; i < n; i++) {
		if (S[i] == x) return (true);
	}
	return (false);
} 

int main(void)
{
	 int n, q;
	 int cnt = 0;
	 int x;

	 cin >> n;
	 for (int i = 0; i < n; i++) cin >> S[i];
	 
	 cin >> q;

	 for (int i = 0; i < q; i++) {
		 cin >> x;
		 if (search(x, n)) cnt++; 
	 }
	 cout << cnt << endl;

	 return (0);
}

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

int main()
{
    int h1,m1,h2,m2,k,t1,t2,t3;
    cin>>h1>>m1>>h2>>m2>>k;
    t1=60*h1+m1;
    t2=60*h2+m2;
    t3=t2-t1-k;
    cout<<t3<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int get_int(char *line, int size) {
  if(!fgets(line, size, stdin)) return 0;
  int num;
  sscanf(line, "%d", &num);
  return num;
}

int table[7] = {
  [1] = 9,
  [3] = 999-100+1,
  [5] = 99999-10000+1
};

int pw_table[7] = {
  [1] = 1,
  [3] = 100,
  [5] = 10000
};

int get_digit(int num) {
  int cnt = 0;
  while(num != 0) {
    cnt++;
    num /= 10;
  }
  return cnt;
}

#define BUF_SIZE 10
int main(void) {
  char line[BUF_SIZE];
  int i;
  int num = get_int(line, BUF_SIZE);
  int d = get_digit(num);
  int cnt = 0;
  for(i = 1; i < d; i++) {
    cnt += table[i];
  }
  cnt += (!!table[d]) * (num - pw_table[d] + 1);
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<int, ll> PP;

template<typename T>

struct Kruskal{

  struct edge{
    int from,to;
    T cost;
    int used;
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };
  vector<int> r,p;
  vector<edge> es;
  vector<vector<pair<int,T>>> G;

  Kruskal(){}
  Kruskal(int n):r(n,1),p(n),G(n){
    iota(p.begin(),p.end(),0);
  }

  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
  }

  T build(){
    sort(es.begin(),es.end());
    T res=0;
    for(auto &e:es){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        G[e.from].push_back(make_pair(e.to,e.cost));
        G[e.to].push_back(make_pair(e.from,e.cost));
        e.used=1;
      }
    }
    return res;
  }

  vector<vector<pair<int,T>>> graph(){
    return G;
  }
};

int n;
ll d,a[200010];
vector<vector<PP>> G;

void rec(int l,int r,Kruskal<ll> &k){
  if (r-l<=1) return;
  int mid=(l+r)/2;
  ll mi1=INF;int idx1=-1;
  Rep(i,l,mid){
    if(mi1>a[i]-d*(ll)i){
      mi1=a[i]-d*(ll)i;
      idx1=i;
    }
  }
  Rep(i,mid,r){
    k.add_edge(i,idx1,mi1+a[i]+d*(ll)i);
  }
  ll mi2=INF;int idx2=-1;
  Rep(i,mid,r){
    if(mi2>a[i]+d*(ll)i){
      mi2=a[i]+d*(ll)i;
      idx2=i;
    }
  }
  Rep(i,l,mid){
    k.add_edge(i,idx2,mi2+a[i]-d*(ll)i);
  }
  rec(l,mid,k);rec(mid,r,k);
}

void solve(){
  cin >> n >> d;
  rep(i,n){
    cin >> a[i];
  }
  Kruskal<ll> K(n);
  rec(0,n,K);
  cout << K.build() << endl;
  // G=K.graph();
  // rep(i,n){
   
  //   for(PP k:G[i]){
  //     cout << i << " " << k.first << " " << k.second << endl;
  //   }
  // }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 108512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> m(h);
	vector<int> count(26);
	FOR(i,0,h) {
		string s;
		cin >> s;
		for (char c : s) count[c-'a']++;
	}
	int mod4 = 0, mod2 = 0, mod1 = 0;
	FOR(i,0,26) {
		if (count[i] > 0) {
			if (count[i] % 4 == 0) mod4++;
			else if (count[i] % 2 == 0) mod2++;
			else {
				mod1++;
				if (count[i] % 4 == 1) mod4++;
				else mod2++;
			}
		}
	}
	if (h % 2 == 0 && w % 2 ==  0) {
		if (mod2 == 0 && mod1 == 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else if (w % 2 == 0) {
		//h ungerade
		if (mod1 == 0 && mod2 <= w / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else if (h % 2 == 0) {
		//w ungerade
		if (mod1 == 0 && mod2 <= h / 2) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else {
		if (mod1 != 1 || mod2 > w/2 + h/2) cout << "No" << endl;
		else cout << "Yes" << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MOD=1000000007;

int main(){
  int n;
  cin>>n;
  
  long power=1;
  for(int i=1;i<=n;i++){
   power=i*power%MOD; 
  }
  cout<<power<<endl;
  return 0;
}

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

int main(){
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    for(int i = 0; i < m; i++){
        cin >> y[i];
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    vector<int> ans;
    if(x[n - 1] < y[0]){
        int tmp = x[n - 1] + 1;
        while(true){
            //cout << "unko" << endl;
            if(tmp == y[0]){
                ans.push_back(tmp);
                break;
            }
            ans.push_back(tmp);
            tmp++;
        }
    }
    else{
        cout << "War" << endl;
        return 0;
    }

    for(int i = 0; i < ans.size(); i++){
        if(X < ans[i] && ans[i] <= Y){
            cout << "No War" << endl;
            return 0;
        }
    }

    cout << "War" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>   //PBDS
#include <ext/pb_ds/tree_policy.hpp>       //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int,int>>
#define pi pair<int,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mi map<int,int>
#define PI   3.141592653589
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define f(i,x,n) for(int i=x;i<n;i++)
#define rf(i,x,n) for(int i=n-1;i>=x;i--)
#define check(x)   cerr<<#x<<" : "<<x<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define fbo find_by_order                    //return iterator PBDS
#define ook order_of_key                     //return number :)) PBDS
#define baar exit(0)
#define INF 1000000000000000000
using namespace __gnu_pbds;
using namespace std;
int powmod(int base,int exponent,int mod)
{
	int ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
string ans="";
int LCS[3005][3005];
void findLCS(string text1,string text2,int  n,int m)
{
	if(n==0 or m==0) return ;
	if(text1[n-1]==text2[m-1])
	{
		ans+=(text1[n-1]);
		findLCS(text1,text2,n-1,m-1);
	}
	else
	{
		if(LCS[n-1][m]>=LCS[n][m-1])
		{
			findLCS(text1,text2,n-1,m);
		}
		else 
		{
			findLCS(text1,text2,n,m-1);
		}
	}
}
signed main()
{
	fast
	string text1,text2;
	cin>>text1>>text2;
	int n=text1.length();
    int m=text2.length();
    memset(LCS,0,sizeof(LCS));
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
          {
                if(i==0 or j==0) LCS[i][j]=0;
                else if(text1[i-1]==text2[j-1]) LCS[i][j]=LCS[i-1][j-1]+1;
                else LCS[i][j]=max(LCS[i-1][j],LCS[i][j-1]);
          }
    }
    findLCS(text1,text2,n,m);
    reverse(all(ans));
	cout<<ans;
	return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

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

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  int r;
  cin >> r;
  cout << 3*r*r << endl;

  return 0;
}


Measured memory_bytes: 256
#intの場合
N = int(input()) #ここで標準入力

#List にしたい時
#intの場合
huga = list(map(int, input().split()))
if 0 in huga:
    print(0)
else:
    ans = 1
    flg = 0
    for number in huga:
        ans = ans * number
        if ans > 10**18:
            flg = 1
            break
    if flg == 0:
        print(ans)
    else:
        print('-1')


Measured memory_bytes: 21528
N = int(input())
l = []
r = []
for i in range(N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    l = l + [a]
    r = r + [b]
c = 0
for i in range(N):
    c = c + r[i - 1] - l[i - 1] + 1
print(c)

Measured memory_bytes: 3060
#include<cstdio>
#include<cmath>
using namespace std;
int n,d;
int a[12][12];
float check;
int ans=0,base;

int main()
{
    scanf("%d%d",&n,&d);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=d;j++) scanf("%d",&a[i][j]);
    }
    for(int i=1;i<=n-1;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            check = 0;
            for(int k=1;k<=d;k++)
            {
                check += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
            check = pow(check,0.5);
            base = (int)check;
            if ((double)base==check) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
using namespace std;
#define INF 999999999
#define FOR(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define lin long long

int main(void)
{
    int n;
    cin >> n;
    int a[n];
    REP(i, n)
    {
        cin >> a[i];
    }

    int res = -1;
    bool loop = true;
    while (loop)
    {
        REP(i, n)
        {
            if (a[i] % 2 == 1)
                loop = false;
            a[i] /= 2;
        }
        res++;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Khela_Sesh ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
//const int sz=1e5+100;
const int inf=1e9+10;
int main()
{
    Khela_Sesh
    int i,j,k,q,p,x,y,sum,ct,ct1,m,l,r,len,x1,y1,mn,t,mx,W,n;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    while(cin>>str>>str1)
    {
        len=str.length();
        int len1=str1.length();
        int ara[len+2][len1+2];
        for(i=0;i<=len;i++)
        {
            for(j=0;j<=len1;j++){
                if(i==0 || j==0) ara[i][j]=0;
                else if(str[i-1]==str1[j-1]) ara[i][j]=ara[i-1][j-1]+1;
                else ara[i][j]=max(ara[i-1][j],ara[i][j-1]);
            }
        }
        vector<char> ans;
        i=len,j=len1;


       /* while(i && j) ///////// >>>> *This process is false......./
        {                                                           /
            if((ara[i-1][j-1]+1)==ara[i][j]) {                      /
                    ans.push_back(str[i-1]);                        /
                    --i,--j;                                        /
            }                                                       /
            else if(ara[i][j]==ara[i][j-1]) --j;                    /
            else --i;                                               /
            }                                                       /
                                                                    /
             >>>>>>         /////////////////////////////////////////
     */

        while(i && j)
        {
            if(str[i-1]==str1[j-1]) {
                ans.push_back(str[i-1]);
                --i,--j;
            }
            else if(ara[i][j]==ara[i-1][j]) --i;
            else --j;
        }
        reverse(ans.begin(),ans.end());
        for(auto tl : ans) cout<<tl;
        cout<<endl;
    }

}



Measured memory_bytes: 35584
'''
Created on 2020/08/16

@author: harurun
'''
N,T=map(int,input().split())
t=list(map(int,input().split()))
ans=T
s=t[0]
for i in range(1,N):
  if t[i]-s>=T:
    ans+=T 
  else:
    ans-=T-(t[i]-s)
    ans+=T
  s=t[i]
print(ans)  

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,k;
  cin>>n>>k;
  vll h(n);
  REP(i,n)cin>>h[i];

  sort(h.begin(), h.end(), greater<ll>());

  ll ans = 0;
  REP(i,n){
    if(k>0)
      k--;
    else
      ans+=h[i];
  }

  cout << ans <<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b;
cin >> a >> b;
if (a==1 && 2<=b && b<=13 ) {
	cout << "Alice" << endl;
} else if (2<=a && a<=13 && b==1){
	cout << "Bob" << endl;
} else if (a == b){
	cout << "Draw" << endl;
} else if (2<=a && a<=13 && 2<=b && b<= 13 && a<b){
	cout << "Bob" << endl ;
} else if (2<=a && a<=13 && 2<=b && b<= 13 && a>b)
	cout << "Alice" << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int K, A[2];
  cin >> A[0] >> A[1] >> K;
  for (int i = 0; i < K; i++) {
	  if (A[i % 2] == 1) {
		  A[i % 2]--;
		}
	  A[i % 2]       /= 2;
	  A[(i + 1) % 2] += A[i % 2];
	}
  cout << A[0] << " " << A[1] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            int x = Integer.parseInt(line);
            System.out.println(x*x*x);
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println("ミス");
        }
    }
}


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

std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

int main() {
  int n; cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
      cin >> a.at(i);
      if(a.at(i)==0){
          cout << 0 << endl;
          return 0;
      }
  }
  __int128 cur = 1;
  for(int i=0;i<n;i++){
      cur *= a.at(i);
      if(cur > 1000000000000000000){
          cout << -1 << endl;
          return 0;
      }
  }
  cout << cur << endl;
    return 0;
}

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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const int M = 1000000007;
const int N = 501;

char arr[N][N];


int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

int h,w;

cin>>h>>w;

int i,j;

for(i=0;i<h;i++)
	for(j=0;j<w;j++) 
		cin>>arr[i][j];

for(i=0;i<h;i++)
	{
	for(j=0;j<w;j++)
		{
		if(i==0) cout<<'#';	
		else if (i!=(h-1) && j%2 == 1) cout<<'#';
		else  cout<<arr[i][j]; 
		}
	cout<<endl;
	}

cout<<endl;


for(i=0;i<h;i++)
	{
	for(j=0;j<w;j++)
		{
		if(i==(h-1)) cout<<'#';	
		else if (i!=0 && j%2 == 0) cout<<'#';
		else  cout<<arr[i][j]; 
		}
	cout<<endl;
	}


}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#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 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;

lint dp[1001][1001] = {0};

int main(){
    int h, w;
    cin >> h >> w;
    vector< vector<char> > a(h + 1);
    rep(i, h + 1){
        a[i].resize(w + 1);
    }
    REP(i, 1, h + 1){
        REP(j, 1, w + 1){
            cin >> a[i][j];
        }
    }
    dp[0][1] = 1;
    REP(i, 1, h + 1){
        REP(j, 1, w + 1){
            if(a[i][j] == '#'){
                dp[i][j] = 0;
            }else{
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 9088
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  map<int, int> m;
  FOR(i,0,3) {
    int a, b;
    cin >> a >> b;
    m[a]++;
    m[b]++;
  }
  string ans = "YES";
  FOR(i,1,5) {
    if (m[i] >= 3) {
      ans = "NO";
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

struct task{
	int cost;
	int deadLine;
};

bool myComp(task left,task right){
	return (left.deadLine < right.deadLine);
}

int main()
{
	int N,A,B,C;
	cin>>N;
	ll ans = 0;
	for(C = 1; C <= N-1; C++){
		if(N-C == 1){
			ans++;
		}else{
			for(A = 1; A*A <= (N-C); A++){
				if((N-C) % A == 0){
					B = (N-C)/A;
					if( A != B){
						ans += 2;
					}else{
						ans++;
					}
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3156
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1LL<<60
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;

int main() {
	ll i, j, num, D, G;
	ll ans = 1e15;
	cin >> D >> G;
	vector<ll> p(D), c(D);
	for (i = 0; i < D; i++)cin >> p[i] >> c[i];

	for (i = 0; i < (1LL << D); i++) {
		vector<ll> s, t;//s:全完、t:その他
		for (j = 0; j < D; j++) {
			if (i >> j & 1)s.push_back(j);
			else t.push_back(j);
		}

		ll sum = 0, cnt = 0;
		for (j = s.size() - 1; j >= 0; j--) {
			sum += 100LL * (s[j] + 1)*p[s[j]] + c[s[j]];
			cnt += p[s[j]];
		}
		if (sum >= G)ans = min(ans, cnt);
		else {
			for (j = t.size() - 1; j >= 0; j--) {
				if (sum >= G)break;
				for (num = 1; num < p[t[j]]; num++) {
					cnt++;
					sum += 100LL * (t[j] + 1);
					if (sum >= G) break;
				}
			}
			if (sum >= G)ans = min(ans, cnt);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

string s;

int main() {
	cin >> s;
	
	cout << (count(ALL(s), 'o') + (15 - SI(s)) >= 8 ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

class Program
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        int max = A.Max();
        int min = A.Min();

        Console.WriteLine(max - min);
    }
    
}



static class MathUtil
{
    public static IEnumerable<IEnumerable<int>> GetPermutation(int n)
    {
        if (n == 0)
        {
            yield return Single(0);
            yield break;
        }

        for (int i = 0; i <= n; i++)
        {
            foreach (var x in GetPermutation(n - 1))
            {
                yield return Single(i).Concat(x.Select(itm => itm < i ? itm : itm + 1));
            }
        }
    }

    private static IEnumerable<int> Single(int x)
    {
        yield return x;
    }

    public static IEnumerable<int> EnumeratePrimeNumbers()
    {
        List<int> primes = new List<int>() { 2 };
        yield return 2;

        for (int i = 3; i < int.MaxValue; i++)
        {
            bool isPrime = true;
            int Sqrt = (int)Math.Sqrt(i) + 1;

            foreach (var prime in primes)
            {
                if (prime > Sqrt)
                {
                    break;
                }
                if (i % prime == 0)
                {
                    isPrime = false;
                    break;
                }
            }

            if (isPrime)
            {
                primes.Add(i);
                yield return i;
            }
        }
    }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
#define rll register ll
const int N=1e3+5;
int ax[N],ay[N];
ll p[N],q[N];
char ans[N];
inline bool check(rll x,rll y,rll s){
	return abs(x)+abs(y)<=s;
}
int main(){
	ri n,i,j,v1,v,d;
	rll x,y;
	scanf("%d",&n);
	d=0;
	for(i=1;i<=n;++i){
		scanf("%d%d",&ax[i],&ay[i]);
		v=abs(ax[i])+abs(ay[i]);
		if(i==1) v1=v&1;
		else if((v&1)!=v1)
			return puts("-1"),0;
		while(v>1ll<<d)
			++d;
	}
	if(v1)
		for(i=1;i<=d;++i) p[i]=1ll<<i-1,q[i]=1ll<<i;
	else{
		p[1]=1;q[1]=2;
		for(i=2;i<=d+1;++i)
			p[i]=1ll<<i-2,q[i]=1ll<<i-1;
		++d;
	}
	printf("%d\n",d);
	for(i=1;i<=d;++i) printf("%lld ",p[i]);
	puts("");
	for(i=1;i<=n;++i){
		x=ax[i];y=ay[i];
		for(j=d;j;--j)
			if(check(x-p[j],y,q[j-1]))
				x-=p[j],
				ans[j]='R';
			else if(check(x+p[j],y,q[j-1]))
				x+=p[j],
				ans[j]='L';
			else if(check(x,y-p[j],q[j-1]))
				y-=p[j],
				ans[j]='U';
			else
				y+=p[j], 
				ans[j]='D';
		ans[d+1]='\0';
		printf("%s\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 256
from sys import exit, stdin

N = int(stdin.readline().rstrip())
H = [int(_) for _ in stdin.readline().rstrip().split()]
length = len(H)

if length == 1:
    print('Yes')
    exit()

x = 0
for i in H:
    if x > i:
        print('No')
        exit()
    x = max(x, i-1)
print("Yes")

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

int main(){
  int a,b,c;cin>>a>>b>>c;
  int x,y,z;
  x=abs(c-a)+abs(c-b);
  y=abs(a-b)+abs(a-c);
  z=abs(b-a)+abs(b-c);
  cout<<min(min(x,y),z)<<endl;
  return 0;

}


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

int main(){
    char c[2][3];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }
    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]){
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int n,m;
char s[101][101];bool c[101],l[101];int cv[101],lv[101];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>s[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(s[i][j]=='.')++cv[i],++lv[j];
	for(int i=1;i<=n;i++)
		if(cv[i]==m)c[i]=1;
	for(int j=1;j<=m;j++)
		if(lv[j]==n)l[j]=1;
	for(int i=1;i<=n;i++)
	{
		if(c[i])continue;
		for(int j=1;j<=m;j++)
			if(!l[j])cout<<s[i][j];
		cout<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = Integer.parseInt(sc.next());
		for (int i=0; i<10; i++){
			if (Math.pow(2, i) > N){
				System.out.println((int)Math.pow(2, i-1));
				return;
			}
		}
	}
}

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

int main() {
  int N, sum = 0;
  cin >> N;
  int s[N];
  rep(i, N) {
    cin >> s[i];
    sum += s[i];
  }
  if (sum % 10 != 0) {
    cout << sum << endl;
    return 0;
  } else if (sum % 10 == 0) {
    sort(s, s + N);
    for (int i = 0; i < N; i++) {
      if (s[i] % 10 != 0) {
        cout << sum - s[i] << endl;
        return 0;
      }
    }
  }
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

ans = [0] * (N+1)
for a in range(1, 105):
  if a*a > N :
    break
  for b in range(1, 105):
    if a*a + b*b > N:
      break      
    for c in range(1, 105):
      if a*a + b*b + c*c + a*b + b*c + c*a > N:
        break
      ans[a*a + b*b + c*c + a*b + b*c + c*a] += 1

for i in range(1, N+1):
  print(ans[i])


Measured memory_bytes: 74184
import java.util.Scanner;


public class Main {
	public static boolean[][] visited;
	public static int[][] map;
	public static void CheckIsland(int a, int b, int w, int h){
		visited[a][b] = true;
		for(int i=-1;i<2;i++){
			for(int k=-1;k<2;k++){
				int a2 = a+i; int b2 = b+k;
				if(a2>=0&&b2>=0&&a2<h&&b2<w&&visited[a2][b2]==false&&map[a2][b2]==1){
					visited[a2][b2] = true;
					CheckIsland(a2,b2,w,h);
				}
			}
		}
		}
	
	
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		while(true){
			int numberOfIslands=0;
			int w = in.nextInt();
			int h = in.nextInt();
			if(w==0||h==0) break;
		
			map = new int[h][w];
			visited = new boolean[h][w];
		
			for(int i=0; i<h;i++){
				for(int k=0; k<w;k++){
					map[i][k]= in.nextInt();
					visited[i][k]= false;
				}
			}
			for(int i=0; i<h;i++){
				for(int k=0; k<w;k++){
					if(map[i][k]==1&&visited[i][k]==false){
						numberOfIslands++;
						CheckIsland(i,k,w,h);
					}
				}	
			}
			System.out.println(numberOfIslands);
		}
		in.close();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
#include <stdio.h>
using namespace std;


int main(){
    int n;
    int w;
    cin >> n >> w;
    int weight[110];
    long long value[110];
    for (int i=0;i<n;i++){
        cin >> weight[i] >> value[i];
    }
    vector<vector<long long>> dp;
    dp.resize(110);
    for(int i=0;i<n+2;i++)dp[i].resize(w+10);
    for(int i=0;i<n;i++){
        for(int j=1;j<w+1;j++){
            if(weight[i]>j)dp[i+1][j]=dp[i][j];
            if(weight[i]<=j && dp[i][j-weight[i]]+value[i] > dp[i][j]){
                dp[i+1][j]=dp[i][j-weight[i]]+value[i];
            }else{dp[i+1][j]=dp[i][j];
            }
        }
    }
    
    long long ans=dp[n][w];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
program main;
var
	n, sum : integer;
    i, j, k : integer;
    
function gcd(x, y : integer) : integer;
begin
	if y = 0 then gcd := x
	else gcd := gcd(y, x mod y);
end;
    
begin
	sum := 0;
	readln(n);
    for i := 1 to n do
    	for j := 1 to n do
        	for k := 1 to n do
            	sum := sum + gcd(gcd(i, j), k);
    writeln(sum);
end.

Measured memory_bytes: 1380
#include <iostream>
#include <algorithm>
typedef long double D;
const D INF = 1e100;
using namespace std;
int main(void){
        int n; int num[5000]; int MAX,CMAX;
        while(cin >> n ,n){
				MAX=-INF,CMAX=0;
                for(int i=0; i<n; i++)
                        cin >> num[i];
				for(int i=0; i<n; i++){
					CMAX+=num[i];
					MAX=max(MAX,CMAX);
					if(CMAX<0)
						CMAX=0;
				}
                cout << MAX << endl;
        }
 
 
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
#include <string>
using namespace std;

#define rep(i,a,b) for(long long int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)


int main()
{
  int A, B, M; cin >> A >> B >> M;
  vector<long long int> val_a(A); 
  vector<long long int> val_b(B); 
  vector<int> x(M);
  vector<int> y(M);
  vector<long long int> val_c(M);
  REP(i, A){ cin >> val_a[i]; }
  REP(i, B){ cin >> val_b[i]; }
  REP(i, M){ cin >> x[i] >> y[i] >>val_c[i]; }


  long long int best_value = *std::min_element(val_a.begin(), val_a.end()) + *std::min_element(val_b.begin(), val_b.end());

  REP(i, M){
    long long int tmp = val_a[ x[i]-1 ] + val_b[ y[i]-1 ] - val_c[i];
    if(best_value > tmp){ best_value = tmp; }
  }

  cout << best_value << endl;
  return 0;
}


Measured memory_bytes: 3328