akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	static final Scanner stdin = new Scanner(System.in);
	public static void main(String[] args) {
		int[] freq = new int[7];
		int n;
		while((n = stdin.nextInt()) != 0){
			Arrays.fill(freq, 0);
			while((n--)>0){
				int k = stdin.nextInt(), x;
				x = k<10 ? 0 : k<20 ? 1 : k<30 ? 2 : k<40 ? 3 : k<50 ? 4 : k<60 ? 5 : 6;
				freq[x]++;
			}
			for(int i: freq) System.out.println(i);
		}
	}
}

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

int process(int *data){
  int x,y;
  sort(data,data+3);
  x = (data[0]*data[0])+(data[1]*data[1]);
  y = (data[2]*data[2]);
  if(data[0]+data[1] <= data[2]){
    return -1;
  }else if(x == y){
    return 1;
  }else if(x > y){
    return 2;
  }else{
    return 3;
  }
}

int main(){
  int tyokkaku,eikaku,donkaku;
  int data[3];
  tyokkaku = eikaku = donkaku = 0;
  cin >> data[0] >> data[1] >> data[2];
  while(process(data) != -1){
    if(process(data) == 1){
      tyokkaku++;
    }else if(process(data) == 2){
      eikaku++;
    }else{
      donkaku++;
    }
    cin >> data[0] >> data[1] >> data[2];
  }

  cout << tyokkaku+eikaku+donkaku << ' '<< tyokkaku << ' '<< eikaku << ' ' << donkaku << endl;

  return 0;

}



Measured memory_bytes: 3132
#include <iostream>

using namespace std;


#define INF 1e307

int main()
{
	double max = 0;
	double min = INF;

	double height;

	while (cin >> height)
	{
		if (height > max) { max = height; }
		if (height < min) { min = height; }
	}

	cout << max - min << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RainySeason | diff RainySeason.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RainySeason.cpp && ./a.out

/*

 8/15/2020

 5:00-

 */

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  string S; cin>>S;
  int res=0;
  if(S=="RRR") {
    res=3;
  } else if(S=="RRS"||S=="SRR") {
    res=2;
  } else if(S=="RSR") {
    res=1;
  } else  {
    res=count(ALL(S),'R');
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 3596
N, H = gets.split.map(&:to_i)
As, Bs = readlines.map{|l| l.split.map(&:to_i)}.transpose

c, d, a = 0, 0, As.max
bs = Bs.sort.reverse.take_while{|b| b > a}
bs.each do |b|
  c += 1
  d += b
  if d >= H
    puts c
    exit
  end
end
puts ((H - d) / a.to_f).ceil + bs.size

Measured memory_bytes: 19848
#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)

// ---- ----

int n, a[1000][999], p[1000];
set<int> in[1000], w, fin;

int main() {
	cin >> n;
	inc(i, n) {
	inc(j, n - 1) {
		cin >> a[i][j];
		a[i][j]--;
	}
	}
	
	inc(i, n) { w.insert(i); }
	int ans = -1;
	inc(i, n * n) {
		if(SI(fin) == n) { ans = i; break; }
		
		RF(e, w) { in[a[e][p[e]]].insert(e); }
		
		set<int> nex;
		RF(e, w) {
			if(in[e].count(a[e][p[e]]) == 1) {
				nex.insert(e);
				nex.insert(a[e][p[e]]);
			}
		}
		if(nex.empty()) { break; }
		
		w.clear();
		RF(e, nex) {
			in[e].erase(a[e][p[e]]);
			p[e]++;
			if(p[e] < n - 1) { w.insert(e); } else { fin.insert(e); }
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	int sum = 0;
    	while(true) {
        	String moji = sc.next();
    		if(moji.equals("-")) break;
    		int m = sc.nextInt();
    		for(i = 0; i < m; i++) {
    			int h = sc.nextInt();
    			moji = moji.substring(h) + moji.substring(0, h);
    		}
    		System.out.println(moji);
    	}
    }
}


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

using namespace std;

int main()
{
    double n;
    vector<int> v;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%2!=0)v.push_back(i);
    }
    double s=v.size();
    double ans=s/n;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define trace(x) cerr<<#x<<" : "<<x<<"\n"; 
int main() 
{ 
    string b,u; 
    ll n,x;
    cin>>n; 
    set<ll> s;
    for (int i = 0; i<n; ++i)
    {
     cin>>x; 
     s.insert(x); 
    }
    if(s.size()==n) 
        cout<<"YES"; 
    else 
        cout<<"NO";
    return 0; 
} 

Measured memory_bytes: 9600
//Atcoder regular contest 075 Problem D
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
ll n,a,b;
ll arr[100005];
bool chk(ll mid)
{
	ll cnt=0;
	ll x=b*mid;
	ll y=a-b;
	for(ll i=0;i<n;i++)
	{
		if(arr[i]-x>0){
			if((arr[i]-x)%y==0)
				cnt+=((arr[i]-x)/y);
			else
				cnt+=((arr[i]-x)/y)+1;
		}
	}
	//cout<<cnt<<" "<<mid<<" "<<x<<" "<<y<<endl;
	if(cnt>mid)
		return false;
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("test.txt","r",stdin);
	cin>>n>>a>>b;
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	ll low=0,high=1e9;
	ll ans=1e10;
	while(low<=high)
	{
		ll mid=(low+high)/2;
		if(chk(mid))
		{
			ans=min(ans,mid);
			high=mid-1;
		}
		else
			low=mid+1;
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define REV(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/*---------------------template----------------------*/
/*----------------------end--------------------------*/
/* --------------------ライブラリ--------------------*/
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
/*---------------------臨時--------------------------*/
/*----------------------end-------------------------*/
signed main(){
  int N,K,X,Y;cin>>N>>K>>X>>Y;
  N<K?cout<<N*X<<endl:cout<<K*X+(N-K)*Y<<endl;
}


Measured memory_bytes: 3660
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let a: i64 = read();
    let o: String = read();
    let b: i64 = read();

    if o == "+" {
        println!("{}", a + b);
    } else {
        println!("{}", a - b);
    }
}


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

using namespace std;

struct edge
{
	int v,nxt;
}e[4050];

int ecnt,head[2050];

void adde(int u,int v)
{
	e[++ ecnt].v = v;
	e[ecnt].nxt = head[u];
	head[u] = ecnt;
}

int sz[2050],lft[2050],dist[2050];
char str[2050];
int n;

void dfs(int pos,int lst)
{
	sz[pos] = str[pos] == '1' ? 1 : 0;
	dist[pos] = 0;
	int maxn = 0;
	for(int i = head[pos];i;i = e[i].nxt)
	{
		int v = e[i].v;
		if(v != lst)
		{
			dfs(v,pos);
			sz[pos] += sz[v];
			dist[pos] += dist[v] + sz[v];
			lft[v] += sz[v];
			if(lft[v] > lft[maxn]) maxn = v;
		}
	}
	if(!maxn) lft[pos] = 0;
	else
	{
		int tot = dist[pos] - dist[maxn] - sz[maxn];
		if(tot >= lft[maxn]) lft[pos] = dist[pos] & 1;
		else lft[pos] = lft[maxn] - tot;
	}
}

int main()
{
	scanf("%d %s",&n,str + 1);
	for(int i = 1;i < n; ++ i)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		adde(u,v),adde(v,u);
	}
	lft[0] = -0x3f3f3f3f;
	int ans = 0x3f3f3f3f;
	for(int i = 1;i <= n; ++ i)
	{
		dfs(i,0);
		if(lft[i] == 0)
			ans = min(ans,dist[i] / 2);
	}
	if(ans == 0x3f3f3f3f) printf("-1\n");
	else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <string>
#include <random>
#include <map>
#include <math.h>
#pragma warning(disable : 4996)

#define MAX_N 40

int N, MA, MB;

int A[MAX_N+1];
int B[MAX_N+1];
int C[MAX_N+1];

int DP[MAX_N+1][MAX_N * 10+1][MAX_N * 10+1];

int INF = 10000;

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

int main(void) {
	scanf("%d %d %d", &N, &MA, &MB);
	for (int i = 0; i < N; ++i) {
		scanf("%d %d %d", &A[i+1], &B[i+1], &C[i+1]);
	}
	for (int i = 0; i < N+1; ++i) {
		for (int j = 0; j <= N * 10; ++j) {
			for (int k = 0; k <= N * 10; ++k) {
				DP[i][j][k] = INF;
			}
		}
	}


	for (int i = 1; i < N+1; ++i) {
		for (int j = 1; j <= N * 10; ++j) {
			for (int k = 1; k <= N * 10; ++k) {
				int prev = DP[i-1][j][k];
				int now = INF;
				if ((j - A[i] >= 0) && (k - B[i] >= 0)) {
					int base = DP[i - 1][j - A[i]][k - B[i]];
					if ((base == INF) && (j == A[i]) && (k == B[i])) {
						now = C[i];
					}
					else if (base == INF) {
						now = INF;
					}
					else {
						now = base + C[i];
					}
				}
				DP[i][j][k] = min(prev, now);
			}
		}
	}

	int minC = INF;

	for (int i = 1; i <= N * 10; ++i) {
		for (int j = 1; j <= N * 10; ++j) {
			if (MB*i == MA * j) {
				if (DP[N][i][j] < minC) {
					minC = DP[N][i][j];
				}
			}
		}
	}
	if (minC == INF) {
		printf("-1");
	}
	else {
		printf("%d", minC);
	}

	return 0;
}


Measured memory_bytes: 25856
#include<stdio.h>
#include<string.h>
void rev(char *s){
  int l=strlen(s),i;
  for(i = 0;i<l/2;i++){
  char t=s[i];
  s[i] = s[l - i -1];
  s[l-1-i]=t;
}
}
char T[4][8]={"dream","dreamer","erase","eraser"};
int main(){
  int i =0,c,l;
  char s[100001];
  for(i = 0;i<4;i++)rev(T[i]);
  scanf("%s",s);
  l = strlen(s);
  rev(s);
  for(;c<l;){
    int k=-1;
    for(i = 0;i < 4;i++){
      if(!strncmp(s+c,T[i],strlen(T[i]))){
	k = strlen(T[i]);
        break;
      }
    }
    if(k < 0){
      puts("NO");
      return 0;
    }
    c += k;
  }
    puts("YES");
    return 0; 
}


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

#define ED return 0;
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) int(pow(x,y))
#define FI first
#define SE second
const long mod = 1000000007;

int main(){
    long long int N, Y;
    cin >> N >> Y;
    for(long int i = 0;i <= N;i++){
        for(long int j = 0;j + i <= N;j++){
            if((Y - ((i * 10000) + (j * 5000)))/1000 == N - i - j){
                cout << i << " " << j << " " << N-i-j << endl;
                ED
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}


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

int main() {

    while(1) {
        int n;

        cin >> n;

        if(n == 0){
            break;
        }

        int k=1;

        vector<vector<string> > s;

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

            string input;
            cin >> input;
            string code = "";

            code += input[0];

            for (int i = 0; i < input.size() - 1; i++) {
                if (input[i] == 'a' || input[i] == 'i' || input[i] == 'u' || input[i] == 'e' || input[i] == 'o') {
                    code += input[i + 1];
                }
            }

            vector<string> v;
            string inser = "";
            for (int i = 0; i <= 50; i++) {
                if (i < code.size()) {
                    inser += code[i];
                }
                v.push_back(inser);
            }
            s.push_back(v);
        }

        int ans = -1;

        for(int loop = 1; loop <= 50; loop++){
            set<string> codes;
            for(int i=0; i<n; i++){
                codes.insert(s[i][loop-1]);
            }
            if(codes.size() == n){
                ans = loop;
                break;
            }
        }

        cout << ans << endl;




    }


    return 0;
}


Measured memory_bytes: 3244
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        int n = input.nextInt();
        int X = input.nextInt();

        int[] L = new int[n];

        for (int i = 0; i < L.length; i++) {
            L[i] = input.nextInt();;
        }
        int[] D = new int[n + 1];
        D[0] = 0;
        for (int j = 1; j < D.length; j++) {
            D[j] = D[j - 1] + L[j - 1];
        }
        int count = 0;
        for (int k = 0; k < D.length; k++) {
            if (D[k] <= X) {
                count += 1;
            }

        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23892
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp2
{
    using static System.Console;
    using static System.Math;

    class Program
    {
        static void Main(string[] args)
        {
            S = ReadLine();
            Solve();
        }

        static string S;

        static void Solve()
        {
            var l = uint.Parse(S.Substring(0, 2)) - 1;
            var r = uint.Parse(S.Substring(2)) - 1;
            if (l <= 11)
                if (r > 11)
                    WriteLine("MMYY");
                else
                    WriteLine("AMBIGUOUS");
            else if (r <= 11)
                WriteLine("YYMM");
            else
                WriteLine("NA");
        }
    }
}


Measured memory_bytes: 13140
N=int(input())
la=list(map(int,input().split()))
ldp=[[0,0] for i in range(N-1)]
ldp[0]=[la[0]+la[1],-la[0]-la[1]]
for i in range(N-2):
    ldp[i+1][0]=max(ldp[i])+la[i+2]
    ldp[i+1][1]=max(ldp[i][0]-2*la[i+1]-la[i+2],ldp[i][1]+2*la[i+1]-la[i+2])
print(max(ldp[N-2]))


Measured memory_bytes: 24804
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    if (b > a) swap(a, b);
    if (c > a) swap(a, c);
    cout << a * 10 + b + c;
}


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

void compute()
{
    long long a[100010];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%lld", &a[i]);
    int zero = 0;
    for (int i = 0; i < n; i++)
        if (a[i] == 0)
            zero++;
    if (zero > 0)
    {
        // a[i] contains 0
        printf("0\n");
        return;
    }
    long long prod = 1;
    for (int i = 0; i < n; i++)
    {
        if (a[i] <= 1000000000000000000 / prod)
        {
            // This condition is equivalent to prod*a[i] <=10ˆ18
            prod *= a[i];
        }
        else
        {
            printf("-1\n");
            return;
        }
    }
    printf("%lld\n", prod);
} //end compute

int main()
{
#ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("log.txt", "w", stderr);
#endif
    compute();
#ifdef debug
    fprintf(stdout, "\nTIME: %.3lf sec\n", (double)clock() / (CLOCKS_PER_SEC));
#endif
    return 0;
} //end main*

Measured memory_bytes: 4472
l,r = map(int,input().split())
if (r-l)>=2019:
  print(0)
else:
  mini = 2018
  for i in range(l,r+1):
    for j in range(i+1,r+1):
      ans = ( i*j )% 2019
      mini = min(ans,mini)
  print(mini)
  


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }

  const int dh[] = {0, 1, 0, -1};
  const int dw[] = {1, 0, -1, 0};
  vector<vector<bool>> visited(h, vector<bool>(w, false));

  ll ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (visited[i][j] || s[i][j] == '.') {
        continue;
      }

      ll b_cnt = 1;
      ll w_cnt = 0;

      queue<tuple<int, int>> q;
      q.push({i, j});
      visited[i][j] = true;

      while (!q.empty()) {
        int ch, cw, nh, nw;
        tie(ch, cw) = q.front();
        q.pop();
        for (int k = 0; k < 4; ++k) {
          nh = ch + dh[k];
          nw = cw + dw[k];
          bool out_of_range = nh < 0 || h <= nh || nw < 0 || w <= nw;
          if (out_of_range || visited[nh][nw] || s[ch][cw] == s[nh][nw]) {
            continue;
          }
          q.push({nh, nw});
          visited[nh][nw] = true;
          if (s[nh][nw] == '#') {
            b_cnt += 1;
          } else {
            w_cnt += 1;
          }
        }
      }

      ans += b_cnt * w_cnt;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3876
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<iomanip>
#include<algorithm>
#include<cstdio>
using namespace std;


int main()
{
	int n;
	string a;
	cin>>n;
	n%=26;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		a[i]=(a[i]-'A'+n)%26+'A';
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
signed main() { 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n; 
	cin>>n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int z = 1; z <= n; z++){
				ll g = gcd(i, j);
				g = gcd(g, z);
				sum += g;
			}
		}
	}
	cout << sum;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	int a,b,c,d,e;
  cin>>a>>b>>c;
  d=max(a,b);
  e=max(d,c);
  while(1){
  if(e==a){
    if(e==b+c){
      cout<<"Yes\n";
      break;
    }else{
      cout<<"No\n";
      break;
    }
  }
  if(e==b){
     if(e==a+c){
       cout<<"Yes\n";
       break;
     }else{
       cout<<"No\n";
       break;
    }
  }
  if(e==c){
    if(e==a+b){
      cout<<"Yes\n";
      break;
    }else{
      cout<<"No\n";
      break;
    }
  }
}
}


Measured memory_bytes: 256
#pragma GCC diagnostic ignored "-Wunused-result"
#define NDEBUG

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <cstdio>
#include <vector>

#ifdef NDEBUG
#  define debug(...)
#else
#  define debug(...)                                \
  do {                                              \
    fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
    fprintf(stderr, __VA_ARGS__);                   \
    fputc('\n', stderr);                            \
  } while (false)
#endif

using namespace std;

int N, K;

int64_t solve() {
  if (K % 2 != 0) {
    int64_t x = N/K;
    return x*x*x;
  } else {
    int64_t x = 2*N/K, odd = (x+1)/2, even = x/2;
    return odd*odd*odd + even*even*even;
  }
}

int main() {
  scanf("%d %d", &N, &K);
  printf("%" PRId64 "\n", solve());
  return 0;
}


Measured memory_bytes: 128
main :: IO ()
main = readLn >>= putStrLn . f ""

f :: String -> Int -> String
f "" 0 = "0"
f s  0 = s
f s n | even n    = f ('0' : s) $ n `div` (-2)
      | otherwise = f ('1' : s) $ (n - 1) `div` (-2)


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    string s; cin >> s;
    int ans = 700;
    if(s[0] == 'o') ans+=100;
    if(s[1] == 'o') ans+=100;
    if(s[2] == 'o') ans+=100;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
typedef pair<int, int> pint;

int main() {
  int N;    ll X ; cin>>N>>X;
  vector<ll> x(N);
  REP(i,N) cin>>x[i];
  ll ans = 1LL<<62;

  reverse(x.begin(), x.end());
  // 累積和
  vector<ll> sum(N+1, 0LL);
  REP(i,N) sum[i+1] = sum[i] + x[i];
  for(int skip = 1; skip <= N; skip++) {
    ll work = 0LL;
    for(int i = 0; ; i++) {
      int a = i * skip;
      if(a >= N) break;
      int b = min((i+1) * skip, N);
      ll s = sum[b] - sum[a];
      if(i == 0) work += (ll)skip * X + 5LL * s;
      else {
	work += (ll)(3 + 2 * i) * s;
      }
    }
    ans = min(ans, work);
#ifdef DEBUG
    cout << skip << " " << work << " " << ans << endl;
#endif
  }
  cout << ans + (ll)N * X << endl;
  return 0;
}


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

typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vp;
const int inf = 1e9;
const ll INF = 1e18;
const db eps = 1e-10;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ep emplace
#define mem(a) memset(a, 0, sizeof(a))
#define copy(a, b) memcpy(a, b, sizeof(b))
#define PA cout << "pass\n"
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define TM cout << db(clock()) / CLOCKS_PER_SEC << '\n'

const int maxn = 5050;
int f[maxn][maxn];
int n, mod;

void add(int &x, int y){
    x += y;
    if(x >= mod) x -= mod;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> mod;
    int m = n - 1 >> 1;
    f[0][0] = 1;
    for(int i = 1; i <= m; i++){
        for(int j = 0; j <= n; j++){
            for(int k = 0; i * k <= j; k++){
                add(f[i][j], 1ll * f[i - 1][j - i * k] * (k + 1) % mod);
            }
        }
    }
    int res = 0;
    if(n & 1){
        for(int i = 1; i <= n; i++){
            for(int j = 0; j * (m + 1) <= n - i; j++){
                add(res, f[m][n - i - j * (m + 1)]);
            }
        }
    }
    else{
        for(int i = 1; i <= n; i++){
            for(int j = 0; j * (m + 1) <= n - i; j++){
                add(res, 1ll * f[m][n - i - j * (m + 1)] * (j + 1) % mod);
            }
        }
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 51456
/**
*	  Name: Ajay
*	  Institute: IIITH 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
#define fi first
#define se second
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void input()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
vii a;
vii b;
bool cmp(ppi a,ppi b)
{
	if(a.fi==b.fi)
		return a.se<b.se;
	return a.fi<b.fi;
}
int main()
{      
  int n,m,i,j,t;
  cin>>n;

  for(i=0;i<n;i++)
  {
  	int x;
  	cin>>x;
  	a.pb(mp(x,i));
  	b.pb(mp(x,i));
  }
  sort(b.begin(),b.end(),cmp);
  map<int,int> indices;
  REP(i,n)
  {
  	indices[b[i].se]=i;
  }
  REP(i,n)
  {
  	int ind=indices[a[i].se];
  	if(n%2!=0)
  	{
  		int med_ind=(n/2);
  		if(med_ind==ind)
  			cout<<b[med_ind+1].fi<<"\n";
  		else if(med_ind>ind)
  			cout<<b[med_ind].fi<<"\n";
  		else
  			cout<<b[med_ind-1].fi<<"\n";
  	}
  	else
  	{
  		int med_ind=(n/2)-1;
  		if(med_ind>=ind)
  			cout<<b[med_ind+1].fi<<"\n";
  		else
  			cout<<b[med_ind].fi<<"\n";
  	}
  }
  return 0;
}

Measured memory_bytes: 14692
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    int a = 0, b = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] == '0') a++;
        else b++;
    }
    cout << (ll)s.size()-abs(b-a) << "\n";
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

struct data{
  double d;
  P p;
  bool operator < (const data &a)const{
    return d < a.d;
  }
};

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
bool eq(P a,P b){return (abs(a-b)<eps);}
bool onSegment(P a,P b,P p){
  return eq( abs(a-b) , abs(a-p) + abs(b-p) );
}

double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P getPoint(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
bool isParallel(P a,P b,P c,P d){
  return eq(0,cross(a-b,c-d));
}
int n;
P t[16];
vector<P> A,B;

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}
 
bool inPolygon(P p){
  double sum=0;  
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if(onSegment(a,b,p))return true;
    sum+= Arg(p,a,b);
  }
  if( abs(sum) < eps )return false;
  else  return true;
}

bool inPolygon(P a,P b){
  vector< data > v;
  for(int i=0;i<n;i++){
    P c=t[i],d=t[(i+1)%n];
    if(isParallel(a,b,c,d))continue;
    P sp=getPoint(a,b,c,d);
    if(!onSegment(a,b,sp))continue;
    if(!onSegment(c,d,sp))continue;
    v.push_back((data){ abs(a-sp) , sp});
  }
  v.push_back( (data){0,a} );
  v.push_back( (data){abs(a-b),b} );
  sort(v.begin(),v.end());

  for(int i=0;i<(int)v.size();i++){
    if( !inPolygon(v[i].p) )return false;
    if(i&& !inPolygon( (v[i].p+v[i-1].p)*0.5 ) )return false;
  }
  return true;
}


int solve(){
  A.clear();B.clear();
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1)%n];
    vector< data > v;
    for(int j=0;j<n;j++){
      P c=t[j];
      for(int k=0;k<j;k++){
        P d=t[k];
        if( eq( 0, cross(a-b,c-d) ) )continue;
        P np = getPoint(a,b,c,d);
        if(!onSegment(a,b,np))continue;
        v.push_back((data){ abs(np-a) , np } );
      }
    }
    sort(v.begin(),v.end());
    A.push_back(a);
    for(int j=0;j<(int)v.size();j++){
      A.push_back(v[j].p);
    }
  }

  for(int i=0;i<(int)A.size();i++){
    P a=A[i],b=A[(i+1)%A.size()];
    B.push_back(a);
    //P c=(a+b)*0.5;
    //        if( inPolygon(c) )B.push_back(c);
  }
  
  bool g[1000][16]={};
  for(int i=0;i<(int)B.size();i++){
    P a=B[i];
    for(int j=0;j<n;j++){
      g[i][j]=inPolygon(a,t[j]);
      //      cout<<a<<' '<<t[j]<<' '<<g[i][j]<<endl;        ////////////////
    }
  }
  
  vector<int> G[7];
  for(int i=0;i<(1<<n);i++){
    int cnt=__builtin_popcount(i);
    if(cnt<=6)G[cnt].push_back(i);
  }
  
  for(int i=1;i<=6;i++){
    for(int j=0;j<(int)G[i].size();j++){
      int bit=G[i][j];
      int cnt=0;
      for(int k=0;k<(int)B.size();k++){
        bool flg=false;
        for(int l=0;l<n;l++){
          if(bit>>l&1){
            flg|=g[k][l];
          }
        }
        if(flg)cnt++;
      }
      if(cnt==(int)B.size()){
         return i;
      }
    }
  }
  assert(0);
  return 7;
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      double x,y;
      cin>>x>>y;
      t[i]=P(x,y);
    }
    cout<<solve()<<endl;
  }
  return 0;
}

Measured memory_bytes: 1528
from collections import deque
import heapq

def move(P,p):
    if p > 3:
        tmp = P[:]
        tmp[p],tmp[p-4] = tmp[p-4],tmp[p]
        tmpp = p - 4
        yield tmp,tmpp
    if p < 12:
        tmp = P[:]
        tmp[p],tmp[p+4] = tmp[p+4],tmp[p]
        tmpp = p + 4
        yield tmp,tmpp
    if p%4 > 0:
        tmp = P[:]
        tmp[p],tmp[p-1] = tmp[p-1],tmp[p]
        tmpp = p - 1
        yield tmp,tmpp
    if p%4 < 3:
        tmp = P[:]
        tmp[p],tmp[p+1] = tmp[p+1],tmp[p]
        tmpp = p + 1
        yield tmp,tmpp

def evaluate(P,Q):
    mht = 0
    for i in range(16):
        pi = P.index(i)
        qi = Q.index(i)
        pc,pr = pi//4,pi%4
        qc,qr = qi//4,qi%4
        mht += abs(pc-qc)+abs(pr-qr)
    return mht
        
A = []
B = [int(i)%16 for i in range(1,17)]
for i in range(4):
        A+=[int(i) for i in input().split()]
dp = {str(A) : (1,0),str(B) : (2,0)}
h = [(evaluate(A,B),A,0,A.index(0))]
e = [(evaluate(A,B),B,0,15)]
heapq.heapify(h)
heapq.heapify(e)
sw = False
ans = 46
while(len(h)>0 and len(e)>0):
    mht,tmp,count,p = heapq.heappop(h)
    if sw and len(h)>0:
        tmph = (mht,tmp,count,p)
        mht,tmp,count,p = heapq.heappop(h)
        heapq.heappush(h,tmph)
        sw = True
    else:
        if sw:
            sw = False
    for i,j in move(tmp,p):
        key = str(i)
        if key in dp:
            if dp[key][0] == 2:
                tmpcount = count + 1 + dp[key][1]
                if tmpcount < ans:
                    ans = tmpcount
            else:
                continue
        else:
            dp[key] = (1,count+1)
            mht = evaluate(B,i)
            if count+mht*14//13 < ans:
                heapq.heappush(h,(mht//2+count,i,count+1,j))
    _,tmp,count,p = heapq.heappop(e)
    for i,j in move(tmp,p):
        key = str(i)
        if key in dp:
            if dp[key][0] == 1:
                tmpcount = count + 1 + dp[key][1]
                if tmpcount < ans:
                    ans = tmpcount
            else:
                continue
        else:
            dp[key] = (2,count+1)
            mht = evaluate(A,i)
            if count+mht*14//13 < ans:
                heapq.heappush(e,(mht//2+count,i,count+1,j))

if str(A) == "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]":
    ans = 0
print(ans)


Measured memory_bytes: 114412
#include<cstdio>
#define MAX 10001
#define NIL -1

struct Node{int parent,left,right;};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
    if (u == NIL) return;
    D[u] = d;
    setDepth(T[u].right,d+1);
    setDepth(T[u].left, d+1);
}

int setHeight(int u){
    int h1 = 0;
    int h2 = 0;
    if(T[u].left != NIL){
        h1 = setHeight(T[u].left)+1;
    }if (T[u].right != NIL){
        h2 = setHeight(T[u].right)+1;
    }
    return H[u] =(h1 > h2 ? h1 : h2);
}

//接点uの兄弟を返す
int getSibling(int u){
    if(T[u].parent == NIL) return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL){
        return T[T[u].parent].left;
    }else if(T[T[u].parent].right != u && T[T[u].parent].right != NIL){
        return T[T[u].parent].right;
    }
    return NIL;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg = 0; // 子の数
    if (T[u].left !=NIL) deg++;
    if (T[u].right != NIL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ", D[u]);
    printf("height = %d, ",H[u]);

    if(T[u].parent == NIL){
        printf("root\n");
    }else if (T[u].right == NIL && T[u].left == NIL){
        printf("leaf\n");
    }else
    {
        printf("internal node\n");
    }
    
}
int main(){
    int v,l,r,root = 0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        T[i].parent= NIL;
    }
    for (int i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].left = l;
        T[v].right = r;
        if (l != NIL)T[l].parent = v;
        if (r != NIL)T[r].parent = v;
    }
    for(int i=0;i<n;i++) if(T[i].parent ==NIL) root = i;

    setDepth(root,0);
    setHeight(root);

    for(int i=0;i<n;i++)print(i);
    return 0;
}


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

int main(){
    int h,w ;
    cin >> h >> w ;
    vector<vector<char> > maze(h,vector<char>(w)) ;
    for (size_t i = 0; i < h; i++)
    {
        for (size_t j = 0; j < w; j++)
        {
            cin >> maze.at(i).at(j) ;
        }
        
    }
    vector<vector<int> > table(h,vector<int>(w,-1)) ;
    queue<pair<int,int> > wait ;
    table.at(0).at(0) = 0 ;
    wait.push(make_pair(0,0)) ;
    int delta[2][2] = {{0,1},{1,0},} ;
    if (maze.at(0).at(0) == '#')
    {
        table.at(0).at(0) ++ ;
    }
    int row,col,nrow,ncol ;
    while (wait.empty() == 0)
    {
        row = wait.front().first ;
        col = wait.front().second ;
        wait.pop() ;
        for (size_t i = 0; i < 2; i++)
        {
            if (row + delta[i][0] < h && col + delta[i][1] < w )
            {
                nrow = row + delta[i][0] ;
                ncol = col + delta[i][1] ;
            }else
            {
                continue ;
            }
            if (maze.at(row).at(col) == '.')
            {
                if (maze.at(nrow).at(ncol) == '.')
                {
                    if (table.at(nrow).at(ncol) == -1 || table.at(nrow).at(ncol) > table.at(row).at(col) )
                    {
                        table.at(nrow).at(ncol) = table.at(row).at(col) ;
                        wait.push(make_pair(nrow,ncol)) ;
                    }
                        
                }else
                {
                    if (table.at(nrow).at(ncol) == -1 || table.at(nrow).at(ncol) > table.at(row).at(col) + 1)
                    {
                        table.at(nrow).at(ncol) = table.at(row).at(col) + 1;
                        wait.push(make_pair(nrow,ncol)) ;
                    }

                }
                
                
            }else
            {
                if (table.at(nrow).at(ncol) == -1 || table.at(nrow).at(ncol) > table.at(row).at(col) )
                {
                    table.at(nrow).at(ncol) = table.at(row).at(col) ;
                    wait.push(make_pair(nrow,ncol)) ;
                }
            }
            
            
            
        }
        
    }
    
    cout << table.at(h-1).at(w-1) << endl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, c);
    Cin(int, x);
    Cin(int, y);
    
    if(a+b <= 2*c){
        Cout(a*x + b*y);
        return 0;
    }
    int z = abs(x-y), d = ((x > y) ? a : b);
    int ans = min(x, y)*2*c + min(d, 2*c)*z;
    Cout(ans);
}


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


int main(){
ll N,M;
cin>>N>>M;
vector<pair<ll, ll>> a(N);
for(int i = 0;i<N;i++){
ll A, B;
cin >> A >> B;
a[i].first=A;
a[i].second=B;
}
sort(a.begin(),a.end());
ll ans = 0;
for(int i = 0;i<N&&M>0;i++){
ans+=a[i].first*min(M,a[i].second);
M-=a[i].second;
}
cout<<ans<<endl;

}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

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

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}

void solve()
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    //cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((long double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) cin >> B.at(i);

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int X = 0;
    for (int j = 0; j < M; j++) {
      int A;
      cin >> A;
      X += A * B.at(j);
    }
    if (X + C > 0) ans++;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
s = list(input())

while len(s) > 1:
  last_char = s.pop(-1)
  len_str = len(s)
  if(len_str % 2 != 0):
    continue
  if(s[0:len_str//2] == s[len_str//2:]):
    print(len(s))
    exit()

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<char, int>> cards(n);
    const vector<char> CARD_TYPE = {'S', 'H', 'C', 'D'};

    for (int i = 0; i < n; i++) {
        cin >> cards.at(i).first >> cards.at(i).second;
    }

    for (int i = 0; i < CARD_TYPE.size(); i++) {  // 絵柄
        for (int j = 1; j <= 13; j++) {            // 数字
            bool exist = false;
            for (pair<char, int> card : cards) {
                if (card.first == CARD_TYPE.at(i) && card.second == j) {
                    exist = true;
                }
            }
            if (!exist) {
                cout << CARD_TYPE.at(i) << " " << j << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {

//+++++000++++--+++0000-----
	LL N;
	cin >> N;
	vector<LL> v(N, 0);
	LL now = 0;
	LL sum = 1;
	REP(i, N) {
		cin >> v[i];
		if (i >= 1) {
			if (v[i] > v[i - 1]) {
				if (now == -1) {
					sum++;
					now = 0;
				}
				else {
					now = 1;
				}
			}
			if (v[i] < v[i - 1]) {
				if (now == 1) {
					sum++;
					now = 0;
				}
				else {
					now = -1;
				}
			}
		}
	}
	cout << sum << endl;


}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int n = sc.nextInt();
        int ret = n % 1000;
        if(ret > 0) {
            ret = 1000 - ret;
        }

        System.out.println(String.valueOf(ret));
    }
}

Measured memory_bytes: 35792
#include <stdio.h>

using namespace std;

int main()
{
    int dice[7];
    dice[0]=0;
    char str[110];
    int top=0;
    for(int i=0; i<6; i++)
    {
    scanf("%d",&dice[i+1]);
    }


    

    

    scanf("%s",str);
    for(int i=0; str[i]!='\0'; i++)
    {
        
        switch (str[i])
        {
        case 'N':{
            top =dice[1];
            dice[1]=dice[2];
            dice[2]=dice[6];
            dice[6]=dice[5];
            dice[5]= top;
            break;
        }
        case 'E':{
            top =dice[1];
            dice[1]=dice[4];
            dice[4]=dice[6];
            dice[6]=dice[3];
            dice[3]= top;
            break;
        }
        case 'W':{
            top =dice[1];
            dice[1]=dice[3];
            dice[3]=dice[6];
            dice[6]=dice[4];
            dice[4]= top;
            break;
        }
        case 'S':{
            top =dice[1];
            dice[1]=dice[5];
            dice[5]=dice[6];
            dice[6]=dice[2];
            dice[2]= top;
            break;
        }

        }
    }

    printf("%d\n",dice[1]);

 }


    


Measured memory_bytes: 2760
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> H(N); REP(i, N) cin >> H[i];

  int ans = 0;
  int h = H[0];
  for (int i = 0; i < N; ++i) {
    if (H[i] >= h) {
      ans++;
      h = H[i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#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<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int n, a; cin >> n >> a;
    cout << n * n - a;
}


Measured memory_bytes: 256
import java.util.*;

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

    int ans = 0;
    for (int i = 1; i <= N; i+=2) {
      if (countYakusu(i) == 8) {
        ans++;
      }
    }
    System.out.println(ans);
  }
  
  private static int countYakusu(int n) {
    int ret = 0;
    for (int i = 1; i <= n; i++) {
      if (n % i == 0) {
        ret++;
      }
    }
    return ret;
  }
}

Measured memory_bytes: 21716