akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

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

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int h, w;
	cin >> h >> w;

	vector<string> grid(h);
	trav(s, grid) cin >> s;

	vector<pii> ls;
	rep(i,0,h) rep(j,0,w) if(grid[i][j]=='#')
		ls.emplace_back(i,j), grid[i][j]='.';
	int ans = -1;
	while(!ls.empty()){
		bool boo = false;
		vector<pii> nx;
		trav(pa, ls){
			int i = pa.first, j = pa.second;
			if(grid[i][j]=='#') continue;	
			boo = true;
			grid[i][j]='#';
			rep(t,0,4){
				int ii = i + dx[t];
				int jj = j + dy[t];
				if(min(ii,jj)>= 0 && ii < h && jj < w)
					nx.emplace_back(ii,jj);
			}
		}
		if(!boo) break;
		++ans;
		ls = nx;
	}
	cout << ans << endl;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ret = 0;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= N; j++)
        {
            if (R * i + G * j > N)
                continue;
            int sum = N - R * i - G * j;
            if (sum % B == 0)
            {
                int cnt = sum / B;
                if (0 <= cnt)
                    ret++;
            }
        }
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int l[2005];
    for(int i = 0; i < n; ++i)
        scanf("%d", &l[i]);
    sort(l, l + n, greater<int>());
    long long ans = 0;
    for(int i = 0; i < n - 2; ++i)
    {
        int left = i + 1;
        int right = n - 1;
        while(left < right)
        {
            if(l[left] + l[right] > l[i])
            {
                ans += right - left;
                ++left;
            }
            else
                --right;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
// finish date: 2018/01/10
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

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

bool isExist(char c, string str) {
    rep(i, str.length()) {
        if (c == str[i]) return true;
    }
    return false;
}

int fact(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans *= i;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    int sum = 0;
    rep(i, N + 1) sum += i;
    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a[10][10];

int max(){
	int m=0;
	int i,j;
	for(i=0; i<10; i++){
		for(j=0; j<10; j++){
			if(m<a[i][j])m=a[i][j];
		}
	}
	return m;
}

int num0(){
	int i,j;
	int ans=0;
	for(i=0; i<10; i++){
		for(j=0; j<10; j++){
			if(a[i][j]==0)ans+=1;
		}
	}
	return ans;
}

int main(){
	int x,y,s;
	int i,j,k,l;

	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		if(s==1){
			if(x>0)a[x-1][y]+=1;
			if(x<9)a[x+1][y]+=1;
			if(y>0)a[x][y-1]+=1;
			if(y<9)a[x][y+1]+=1;
			a[x][y]+=1;
		}
		else if(s==2){
			for(i=x-1; i<=x+1; i++){
				for(j=y-1; j<=y+1; j++){
					if(i>0&&i<10&&j>0&&j<10)a[i][j]+=1;
				}
			}
		}
		else{
			for(i=x-1; i<=x+1; i++){
				for(j=y-1; j<=y+1; j++){
					if(i>=0&&i<10&&j>=0&&j<10)a[i][j]+=1;
				}
			}
			if(x>1)a[x-2][y]+=1;
			if(x<8)a[x+2][y]+=1;
			if(y>1)a[x][y-2]+=1;
			if(y<8)a[x][y+2]+=1;
		}
	}

	// for(i=0; i<10; i++){
	// 	for(j=0; j<10; j++){
	// 		printf("%d ",a[j][i]);
	// 		if(j==9)printf("\n");
	// 	}
	// }

	printf("%d\n%d\n",num0(),max());

	return 0;
}

Measured memory_bytes: 600
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        double diff = 1000000;
        int candidate = -1;
        for(int i = 0; i < n; i++) {
            int x = sc.nextInt();
            double temp = t - x * 0.006;
            double diffTemp =  Math.abs(a - temp);
            if(diffTemp < diff) {
                diff = diffTemp;
                candidate = i + 1;
            }
        }
        System.out.println(candidate);
    }
}


Measured memory_bytes: 22484
from bisect import bisect_left

[A, B, Q] = list(map(int, input().split(" ")))
shrine_list = []
temple_list = []
question_list = []
for _ in range(A):
    shrine_list.append(int(input()))
for _ in range(B):
    temple_list.append(int(input()))
for _ in range(Q):
    question_list.append(int(input()))

minInf = - 1e11
inf = 1e11
shrine_list.insert(0, minInf)
shrine_list.append(inf)
temple_list.insert(0, minInf)
temple_list.append(inf)

for question in question_list:
    shrine_index = bisect_left(shrine_list, question)
    temple_index = bisect_left(temple_list, question)
    left_shrine = shrine_list[shrine_index - 1]
    right_shrine = shrine_list[shrine_index]
    left_temple = temple_list[temple_index - 1]
    right_temple = temple_list[temple_index]
    # left, left   left, right  right, left  right, right
    left_left = max(abs(question - left_shrine), abs(question - left_temple))
    right_right = max(abs(question - right_shrine), abs(question - right_temple))
    left_right = abs(question - left_shrine) + abs(question - right_temple) + min(abs(question - left_shrine),
                                                                                  abs(question - right_temple))
    right_left = abs(question - right_shrine) + abs(question - left_temple) + min(abs(question - right_shrine),
                                                                                  abs(question - left_temple))
    print(round(min(left_left, right_right, left_right, right_left)))


Measured memory_bytes: 16140
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
W = input().split(' ')

T = 2
min = 1000
while True:
    if N < T:
        break
    S1 = sum(map(int, W[0:T]))
    S2 = sum(map(int, W[T:]))
    T += 1

    if abs(S1-S2) < min:
        min = abs(S1-S2)

print(min)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m;cin>>n>>m;
  vector<ll>s(n),t(m);
  rep(i,n)cin>>s[i];
  rep(i,m)cin>>t[i];
  ll mod=1e9+7;
  vector<vector<ll>>dp(n+1,vector<ll>(m+1,1));
  rep(i,n)rep(j,m){
    dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j];
    if(s[i]==t[j]){
      dp[i+1][j+1]+=dp[i][j];
    }
    dp[i+1][j+1]%=mod;
  }

  cout<<(dp[n][m]+mod)%mod<<endl;

  return 0;

}


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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while(0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

// {{{ Modint
// using mint = modint<1000000007>;
// mint x = 2;
// std::cout << x.a << std::endl;
template <std::int64_t M>
class modint {
 public:
  int64_t a;

  explicit constexpr modint(const int64_t x = 0) noexcept :
    a((x % M + M) % M) {}
  constexpr int64_t &value() noexcept { return a; }
  constexpr const int64_t &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= M) {
      a -= M;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += M;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % M;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    int64_t exp = M - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
// }}}

using mint = modint<1000000007>;
mint Z;
ll N;
ll A[1000000];

signed main() {
  cin >> N;
  for (ll i=1; i<=N; i++) {
    cin >> A[i];
  }

  for (ull bit = 1; bit < (((ull)1) << 61); bit *= 2) {
    ll nOne = 0, nZero = 0;
    for (ll j=1; j<=N; j++) {
      if (A[j] & bit)
        nOne++;
      else
        nZero++;
    }
    for (ll i=1; i<=N-1; i++) {
      if ((A[i]&bit)) {
        Z += mint(bit) * mint(nZero);
        nOne--;
      } else {
        Z += mint(bit) * mint(nOne);
        nZero--;
      }
    }
  }
  cout << Z.value() << endl;
  return 0;
}


Measured memory_bytes: 4352
A, B, K = list(map(int, input().split()))
ans = set() 
mi = max(B-K+1, A)
ma = min(A+K, B+1)
for i in range(A, ma):
    ans.add(i)
for i in range(mi, B+1):
    ans.add(i)
ans = list(ans)
for i in sorted(ans):
    print(i)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
#define rep(i,j,k) for (int i=j;i<=k;++i)
const int N=1e5+100;
char s[N];
int a[N];
bool check(int n)
{
	for (int i=2;i<n;++i) 
	{
		if (a[i]==1) 
		{
			if (s[i]=='o') a[i+1]=a[i-1];
			else a[i+1]=1-a[i-1];
		}
		else 
		{
			if (s[i]=='o') a[i+1]=1-a[i-1];
			else a[i+1]=a[i-1];
		}
	}
	if (a[1]) 
	{
		if (s[1]=='o'&&a[2]!=a[n])  return 0;
 		if (s[1]=='x'&&a[2]==a[n]) return 0;
 	}
 	else 
 	{
 		if (s[1]=='o'&&a[2]==a[n]) return 0;
 		if (s[1]=='x'&&a[2]!=a[n]) return 0;
 	}
 	if (a[n])
 	{
 		if (s[n]=='o'&&a[n-1]!=a[1]) return 0;
 		if (s[n]=='x'&&a[n-1]==a[1]) return 0;
 	}
 	else 
 	{
 		if (s[n]=='o'&&a[n-1]==a[1]) return 0;
 		if (s[n]=='x'&&a[n-1]!=a[1]) return 0;
 	}
 	return 1;
}
void print(int n)
{
	for (int i=1;i<=n;++i) if (a[i]) printf("S"); else printf("W");
	printf("\n");
}
void solve(int n)
{
	rep(i,0,1) 
	{
		a[1]=i;
		rep(j,0,1)
		{
			a[2]=j;
			if (check(n))
			{
				print(n); return;
			}
		}
	}
	puts("-1");
}
int main(int argc, char const *argv[])
{
	int n;
	while (scanf("%d%s",&n,s+1)!=-1) solve(n);
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int64_t ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i%3 != 0 && i%5 != 0) {
      ans += i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int n = s.length();
  string r = s;
  reverse(r.begin(),r.end());
  if(r==s){
    r = s.substr(0,(n-1)/2);
    reverse(r.begin(),r.end());
    if(s.substr(0,(n-1)/2) == r){
      r = s.substr((n+3)/2-1,(n-1)/2);
      reverse(r.begin(),r.end());
      if(s.substr((n+3)/2-1,(n-1)/2) == r){
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


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

signed main(){
    int M; cin >> M;
    vector<int> b(M + 1), box(M + 1, 0);
    for(int i = 1; i <= M; i++) cin >> b[i];
    for(int i = M; i >= 1; i--){
        int number = 0;
        for(int j = i; j <= M; j += i){
            number += box[j];
        }
        number %= 2;
        if(number != b[i]) box[i] = 1;
    }
    int k = count(box.begin(), box.end(), 1);
    cout << k << endl;
    if(k == 0){
        return 0;
    }
    for(int i = 1; i <= M; i++){
        if(box[i]){
            cout << i << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 3968
import java.lang.Math
import kotlin.comparisons.*

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

fun main(args: Array<String>)
{
    val (a, b, k) = read().split().toLong()
    if (k >= a) {
        println("0 ${Math.max(b - (k - a), 0)}")
    } else {
        println("${a - k} $b")
    }
}

fun read(): String = readLine()!!
fun CharSequence.split(): List<String> = this.split(" ")
fun Iterable<String>.toInt(): List<Int> = this.map{it.toInt()}
fun Iterable<String>.toLong(): List<Long> = this.map{it.toLong()}


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

int main(){
	int n,x,y=-1;
	cin>>n;
	while(n--){
		int a,b;
		cin>>a>>b;
		if(y<b || b==y&&a<x)x=a,y=b;
	}
	cout<<x<<' '<<y<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

#define MAX_N (52)
#define MAX_X (52)

ll dp[MAX_N][MAX_N][MAX_N*MAX_X];	// dp[i][j][k] : 0~iまでで、j枚選んで、合計kとなる場合の数
int N, A;
ll x[MAX_N];
int main()
{
    int i, j, k;
    
    scanf("%d %d", &N, &A);
    for ( i = 0; i < N; i++ ) scanf("%lld", &x[i]);

    dp[0][0][0] = 1;
    
    for ( i = 0; i < N; i++ ) {
	for ( j = 0; j < N; j++ ) {
	    for ( k = 0; k <= i * MAX_X; k++ ) {
		if ( dp[i][j][k] ) {
		    dp[i+1][j][k] += dp[i][j][k];
		    dp[i+1][j+1][k + x[i]] += dp[i][j][k];
		}
	    }
	}
    }

    ll ans = 0;
    for ( j = 1; j <= N; j++ ) {
	if ( dp[N][j][j*A] ) {
	    ans += dp[i][j][j*A];
	}
    }

    printf("%lld\n", ans);

    return 0;
}


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

int main(){
  int n;
  string s,t;
  cin >> n >> s >> t;
  int ans = 0;
  rep(i,n+1){
    if(s.substr(n-i) == t.substr(0,i)){
      ans = max(ans,i);
    }
  }
  cout << 2*n - ans << endl;
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
D=[1] * (n + 1)
for _ in range(m):
    D[int(input())] = 0
for i in range(n+1):
    if i < 2 or D[i] == 0:
        continue
    D[i] = (D[i-1] + D[i-2]) % 1000000007 
print(D[i])

Measured memory_bytes: 6900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    
	public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  String s = sc.next();
	  int n = s.length();
	  // There are only two pattern s will transform to...
	  // 101010101010101010...
	  // 010101010101010101...
	  char p1 = '0';
	  char p2 = '1';
	  int pattern1 = 0;
	  int pattern2 = 0;
	  
	  for(char c: s.toCharArray()) {
		  if (c != p1) { pattern1++; }
		  if (c != p2) { pattern2++; }
		  
		  p1 = (p1 == '0') ? '1' : '0';
		  p2 = (p2 == '1') ? '0' : '1';
	  }
	  
	  System.out.println(Math.min(pattern1, pattern2));
	  
  }

  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 25044
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int A,B,C,D,E,F;
vector<int> waterlist;
vector<int> sugarlist;
long long x,y;
vector<long long> ans;
double conce=0.0;
int answater,anssugar;
int main(int argc,char const* argv[])
{
  cin >> A >> B >> C >> D >> E >> F;
  for(int i=0;i<=F;i++)
    {
      for(int j=0;j<=F;j++)
	{
	  int x=100*A*i+100*B*j;
	  if(x<=F)
	    {
	      waterlist.push_back(x);
	    }
	  int y=C*i+D*j;
	  if(y<=F)
	    {
	      sugarlist.push_back(y);
	    }
	}
    }
  for(int i=0;i<int(waterlist.size());i++)
    {
      for(int j=0;j<int(sugarlist.size());j++)
	{
	  if(waterlist[i]+sugarlist[j]<=F)
	    {
	      if((double(sugarlist[j]+0.0)/double(waterlist[i]+0.0))<=double(E+0.0)/100.0)
		{
		  if(double(100*sugarlist[j]*1.0)/double(waterlist[i]+sugarlist[j]+0.0)>=conce)
		    {
		      answater=waterlist[i];
		      anssugar=sugarlist[j];
		      conce=double(100*sugarlist[j]*1.0)/double(waterlist[i]+sugarlist[j]+0.0);
		    }
		}
	    }
	}
    }
  cout << answater+anssugar << ' ' << anssugar << endl;
  return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,ans,x,m;
map<ll,ll> a;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> m;
		x+=m;
		ans+=a[x];
		if(x==0)ans++;
		a[x]++;
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 998244353;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  Combination<MOD> comb(1<<21);
  ll tmp1 = 0, tmp2 = 0, tmp3 = 0;
  for(int a=m%2;a<=min(n, m);a+=2) {
    tmp1 += comb.C((3*m-a)/2+n-1, n-1) * comb.C(n, a) % MOD;
    tmp1 %= MOD;
  }
  for(int a=m%2;a<=min(n, m);a+=2) {
    tmp2 += comb.C((m-a)/2+n-1, n-1) * comb.C(n, a) % MOD;
    tmp2 %= MOD;
  }
  for(int a=m%2;a<=min(n-1, m);a+=2) {
    tmp3 += comb.C((m-a)/2+n-2, n-2) * comb.C(n-1, a) % MOD;
    tmp3 %= MOD;
  }
  cout << (tmp1 - (tmp2 - tmp3 + MOD) % MOD * n % MOD + MOD) % MOD << endl;
}


Measured memory_bytes: 49408
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
	int a,  b, c, d;
	cin >> a >> b;
	cin >> c >> d;
	if (a != c) {
		cout << 1 << endl;
		return 0;
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
import numpy as np
H, N = map(int, input().split())
ATK, MP = np.array(tuple(tuple(map(int, input().split())) for _ in range(N)), dtype=np.int32).T
table = np.zeros((H + ATK.max(),), dtype=np.int32)
for damage in range(1, H + 1):
    table[damage] = (table[damage - ATK] + MP).min()
print(table[H])


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL a;
    string b;
    cin>>a>>b;

    LL seisuu = b[0]-'0';
    LL shousuu = (b[2]-'0')*10+(b[3]-'0');

    LL result = a*seisuu;
    result += a*shousuu/100;


    cout<<result<<endl;


	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll t,d,s;
    cin>>d>>t>>s;
    ll check = s*t;

    if(s*t>=d)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)998244353
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
void solve(){
	ll cnt=0, ans=0, n;
	cin>>n;
	rep(i,1,n+1){
		if(i%3==0 or i%5==0)continue;
		else{
			cnt++;
			ans+=i;
			if(cnt==n)break;
		}
	}
	cout<<ans<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;

int main(){
  int x,t;
  cin >> x >> t;
  cout << max(x-t,0);

}


Measured memory_bytes: 256
#include <iostream>

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

Measured memory_bytes: 1164
#include<stdio.h>
int main(void)
{
	int a,b,count,val,sum;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		count=0;
		sum=a+b;
		while(sum)
		{
			val=sum%10;
			if(val>=0)
			count+=1;
			sum/=10;
		}
		printf("%d\n",count);
	}
	return 0;
}


Measured memory_bytes: 2040
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);

		String line = "";

		while(sc.hasNext()){
			line += sc.nextLine();
		}

		char[] ca = line.toCharArray();
		char[] al = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'
				, 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't'
				, 'u', 'v', 'w', 'x', 'y', 'z'};
		int[] count = new int[26];

		for(int i=0;i<ca.length;i++) {
			ca[i] = Character.toLowerCase(ca[i]);
			for(int j=0;j<26;j++) {
				if(ca[i]==al[j]) {
					count[j]+=1;
				}
			}
		}

		for(int i=0;i<26;i++) {
			System.out.println(al[i] + " : " + count[i]);
		}

		sc.close();
	}
}


Measured memory_bytes: 26324
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	A, B := nextInt(), nextInt()

	sum := 0
	for _, v := range [3]int{1, 2, 3} {
		sum += v
	}
	fmt.Println(sum - A - B)
}


Measured memory_bytes: 640
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: u64 = input();
    let mut h_vec = input_vec();
    h_vec.insert(0, 0);
    let mut sum = 0;
    for i in 1..h_vec.len() {
        if h_vec[i] > h_vec[i - 1] {
            sum += h_vec[i] - h_vec[i - 1];
        }
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <queue>
#include <sstream>
using namespace std;

int main(void){
	int stu[30];
	fill_n(stu, 30, 0);
	for(int i = 0; i < 28; i++){
		int a;
		cin >> a;
		stu[a-1] = 1;
	}
	for(int i = 0; i < 30; i++){
		if(stu[i] != 1) cout << i+1 << endl;
	}
}

Measured memory_bytes: 1160
#数字の桁を求める関数
def func(num):
    cnt=0
    while(num>0):
        num=int(num/10)
        cnt+=1
    return cnt

N=int(input())
ans=100
#約数全列挙 O(sqrt(N))でできるので間に合う
for i in range(1,int(N**(1/2)+1)):
    #tmpは桁数が入るので最初大きめで持っておく
    tmp=100
    if(N%i==0):
        #問題文通り比較
        tmp=max(func(i),func(N/i))
    ans=min(ans,tmp)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int a,b;
  int p,s,m;
  cin>>a>>b;
  p=a+b;
  s=a-b;
  m=a*b;
  cout<< max(p,max(s,m))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

int main()
{
    int N, A, B; cin >> N >> A >> B;
    string S; cin >> S;

    bool ans[N]={false};
    int res=0, cntB=0;
    REP(i,N){
        if(S[i]=='a'){
            if(res<A+B){
                ans[i]=true;
                res++;
            }
        }else if(S[i]=='b'){
            if(res<A+B and cntB<B){
                ans[i]=true;
                cntB++;
                res++;
            }
        }
    }

    REP(i,N){
        if(ans[i]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const ll MOD = 1e9+7;


#define REP(i, N) for (ll i = 0; i < (N); i++)
#define REPP(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((ll)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<ll>>

using namespace std;


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

    string s,r;
    cin >> s;
    r = s;
    bool f = true;
    for(ll i = 0; i < (s.length()-1)/2;i++){
        if(s[i] != s[(s.length()-1)/2-1-i]){
            f = false;
        }
    }
    for(ll i =(s.length()+3)/2; i < s.length();i++){
        if(s[i] != s[s.length()-1-i]){
            f = false;
        }
    }
    reverse(ALL(r));
    if(s != r){
        f = false;
    }


    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N=int(input())
dp=[float("INF")]*(N+2)#i円払うのに必要な回数dp[i]
dp[0]=0#0円は0枚でよい
a,b,c=1,1,0
for i in range(1,N+1):
  if i==6*a:
    a*=6
  if i==9*b:
    b*=9
  dp[i]=min(dp[i],dp[i-1],dp[i-a],dp[i-b])+1
print(dp[N])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll unsigned long long

const ll MOD = 1000000000000000000;

int main() {
	//入力
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	rep(i, m) cin >> a[i];

	//処理
	int k = 0;
	rep(i, m) {
		k += a[i];
	}

	//出力
	int ans = -1;
	if (k <= n)
		ans = n - k;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define eps LDBL_EPSILON
#define moder INF
#define int long long
#define double long double
#define ll long long
#define INF LLONG_MAX/3
#define P pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
#define ggr getchar();getchar();return 0
using namespace std;
int n;
string s;
signed main(){
	cin>>n>>s;
	int r=0,b=0;
	rep(i,n){
		if(s[i]=='R')r++;
		else b++;
	}
	if(r>b)puts("Yes");
	else puts("No");
	ggr;
}

Measured memory_bytes: 256
#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;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int main() {
  int R, L;
  cin >> L >> R;

  if (R >= L + 2019) {
    cout << 0 << endl;
    return 0;
  }

  int l = L % 2019;
  int r = R % 2019;
  if (l >= r) {
    cout << 0 << endl;
    return 0;
  }

  int ans = 10000;

  for (int i = l ; i < r ; i++) {
    for (int j = i + 1; j <= r ; j++) {
      int x = (i * j) % 2019;
      ans = min(ans, x);
    }
  }

  cout << ans << endl;
  return 0;

}


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

vector<int> check(string a, string b) {
    vector<int> n(2001,2000);
    int k=0;
    rep(i,a.size()) {
        bool ok=true;
        rep(j,min(a.size()-i,b.size())) {
            if(a[i+j]!=b[j] && a[i+j]!='?' && b[j]!='?') {
                ok=false;
                break;
            }
        }
        if(ok) {
            n[k]=i;
            k++;
        }
    }
    return n;
}

vector<int> checker(string a, string b) {
    vector<int> n(2001);
    int k=0;
    rep(i,a.size()) {
        bool ok=true;
        rep(j,min(a.size()-i,b.size())) {
            if(a[i+j]!=b[j] && a[i+j]!='?' && b[j]!='?') {
                ok=false;
                break;
            }
        }
        if(ok) {
            n[i]++;
        }
    }
    return n;
}

int main() {
    vector<string> s(3);
    rep(i,3) cin >> s[i];
    sort(s.begin(),s.end());
    int mn=s[0].size()+s[1].size()+s[2].size();
    do {
        vector<int> ab=check(s[0],s[1]);
        vector<int> bc=check(s[1],s[2]);
        vector<int> acc=check(s[0],s[2]);
        rep(i,acc.size()) rep(j,ab.size()){
            if(acc[i]>=ab[j]+s[1].size()) {
                int mc=acc[i]+s[2].size();
                int mcc=s[0].size();
                mc=max(mc,mcc);
                mn=min(mn,mc);
            }
        }
        vector<int> ac=checker(s[0],s[2]);
        rep(i,ab.size()) rep(j,bc.size()) {
            bool ok=true;
            if(ab[i]+bc[j]>=s[0].size()) {
                ok=true;
            }
            else {
                if(ac[ab[i]+bc[j]]!=1) ok=false;
            }
            if(ok) {
                int m=max(ab[i]+bc[j]+s[2].size(),s[0].size());
                int mc=ab[i]+s[1].size();
                m=max(m,mc);
                mn=min(mn,m);
            }
        }
    } while (next_permutation(s.begin(),s.end()));
    cout << mn << endl;
    return 0;
}

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

using namespace std;

int read() {
  int res = 0, w = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

#define ll long long
#define ld long double
#define pi pair<int, int>
#define fi first
#define se second

const int N = 1e5 + 10;

int n, k, f[N][2];
char s[N];

int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  k = read();
  if (s[1] != s[n]) {
    int res = 0;
    for (int l = 1, r; l <= n; l = r + 1) {
      r = l;
      while (r != n && s[r + 1] == s[r]) ++r;
      res += (r - l + 1) / 2;
    }
    cout << 1ll * res * k;
    return 0;
  }
  bool ff = 1;
  for (int i = 2; i <= n; ++i)
    if (s[i] != s[i - 1]) {
      ff = 0;
      break;
    }
  if (ff) {
    cout << 1ll * n * k / 2;
    return 0;
  }
  int ct = 2, pos1, pos2;
  for (int i = 2; i <= n; ++i) {
    if (s[i] == s[i - 1])
      ++ct;
    else {
      pos1 = i;
      break;
    }
  }
  for (int i = n - 1; i; --i) {
    if (s[i] == s[i + 1])
      ++ct;
    else {
      pos2 = i;
      break;
    }
  }
  int res = ct / 2;
  for (int l = pos1, r; l <= pos2; l = r + 1) {
    r = l;
    while (r != pos2 && s[r + 1] == s[r]) ++r;
    res += (r - l + 1) / 2;
  }
  ll ans = 1ll * res * (k - 1);
  for (int l = 1, r; l <= n; l = r + 1) {
    r = l;
    while (r != n && s[r + 1] == s[r]) ++r;
    ans += (r - l + 1) / 2;
  }
  cout << ans;
  return 0;
}

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

int main() {
	int a,b;
	cin>>a>>b;
	int c=abs(a-b);
	if(c%2==1) cout<<"IMPOSSIBLE";
	else {
		if(a>b) cout<<a-c/2;
		else cout<<b-c/2;
	}
	cout<<endl;
}

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

int n, m, p, b, c, ans;
int a[100010];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a+i);
	}
	sort(a, a+n);
	m = lower_bound(a, a+n, 0)-a;
	if (!m) m++;
	if (m == n) m--;
	for (int i = 0; i < n; ++i) {
		ans += (i<m)?-a[i]:a[i];
	}
	printf("%d\n", ans);
	for (int i = 1; i < n-m; ++i) {
		printf("%d %d\n", a[0], a[n-i-1]);
		a[0] -= a[n-i-1];
	}
	for (int i = 0; i < m; ++i) {
		printf("%d %d\n", a[n-1], a[i]);
		a[n-1] -= a[i];
	}
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define fori(j,n) for(ll i=j;i<n;i++)
#define forb(n,j) for(ll i=n-1;i>=0;i--)
#define endl "\n"
#define pb push_back
#define ll long long
#define mp make_pair
#define ff first
#define ss second
#define vec vector<int>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll sgn(ll x){
    if(x>0)
        return 1;
    if(x==0)
        return 0;
    return -1;
}
//const ll N = 2e5 + 5;
int main()
{
    IOS;
    ll n;
    cin>>n;
    string s[n];
    ll ac=0,tle=0,wa=0,re=0;
    fori(0,n)
    {
        cin>>s[i];
        if(s[i]=="AC")
            ac++;
        else if(s[i]=="TLE")
            tle++;
        else if(s[i]=="WA")
            wa++;
        else
            re++;
    }
    cout<<"AC x "<<ac<<endl<<"WA x "<<wa<<endl<<"TLE x "<<tle<<endl<<"RE x "<<re<<endl;
    return 0;
}




Measured memory_bytes: 6796
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int& a, int b) { if (a < b) { a = b; return true; } else return false; }
inline bool minch(int& a, int b) { if (a > b) { a = b; return true; } else return false; }

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

	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	cout << a[n-1] << endl;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        k: u64
    }

    println!("{}", k / 2 * ceil_div(k, 2));
}

#[allow(dead_code)]
fn ceil_div(x: u64, y: u64) -> u64 {
    (x + y - 1) / y
}

Measured memory_bytes: 4352
//Mahmudul Alam
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ll n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<ll> xn(n), yn(m);
    for(auto &i: xn) cin >> i;
    for(auto &i: yn) cin >> i;
    xn.push_back(x);
    yn.push_back(y);
    sort(xn.rbegin(), xn.rend());
    sort(yn.begin(), yn.end());
    if(xn[0] < yn[0]) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		cout<<(A<=8 && B<=8 ? "Yay!":":(")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, i, max;//入力数,制御変数,現在の最高高度,踏み台の和
  long long base=0;
  int a[2000000];
  //入力///////////////
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  //処理///////////////
  max=a[0];
  for(i=0;i<n;i++){
    //最高高度更新処理
    if(max<a[i]){
      max=a[i];
    }
    base+=max-a[i];
    //printf("%d ",max-a[i]);
    
    
  }
  printf("%lld",base);
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int sol = 0;
	int s = 0;
	while(A != B && B != C && A % 2 == 0 && B % 2 == 0 && C % 2 == 0){
		s = A+B+C;
		A = (s-A)/2;
		B = (s-B)/2;
		C = (s-C)/2;
		++sol;
	}
	if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0) cout << sol << "\n";
	else cout << -1 << "\n";
}


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

int i;
char cad[' '];

int main()
{
	scanf("%s",&cad);
	for(i=0;i<6;i++)
	{
		if(cad[i]>=65 && cad[i]<=90)
		{
			printf("No");
			return 0;
		}
	}
	
	if(cad[2]==cad[3] && cad[4]==cad[5])
	{
		printf("Yes");
	}
	else
		printf("No");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    static int INF = 1000000000;
    static int res = INF;
    static int rLen;
    static boolean[] used = new boolean[9];
    static int[] r;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        rLen = sc.nextInt();
        r = new int[rLen + 1];
        for (int i = 1; i <= rLen; i++) {
            r[i] = sc.nextInt();
        }

        int[][] d = new int[n + 1][n + 1];
        for (int x[] : d) {
            Arrays.fill(x, INF);
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            d[a][b] = c;
            d[b][a] = c;
        }
        d = warshallFloyd(n, d);
        dfs(1, -1, 0, d);
        System.out.println(res);
    }
    public static void dfs(int c, int las, int dist, int[][] d) {
        // System.out.printf("c = %d,las = %d %n", c, las);
        // System.out.printf("used = %s %n", Arrays.toString(used));
        if (c == rLen + 1) {
            if (res > dist) {
                res = dist;
                return;
            }
        }
        for (int i = 1; i <= rLen; i++) {
            if (!used[i]) {
                used[i] = true;
                if (las == -1) {
                    dfs(c + 1, i, 0, d);
                } else {
                    dfs(c + 1, i, dist + d[r[las]][r[i]], d);
                }
                used[i] = false;
            }
        }
    }
    public static int[][] warshallFloyd(int n, int[][] d) {
        for (int k = 1; k <= n; k++) {
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= n; j++) {
                    if (d[i][j] > d[i][k] + d[k][j]) {
                        d[i][j] = d[i][k] + d[k][j];
                    }
                }
            }
        }
        return d;
    }
}


Measured memory_bytes: 47956