akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.stream.IntStream;

public class Main{
	public static void main(String[]$) throws IOException{
		new Main().solve();
	}
	static FastScanner s=new FastScanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt() throws IOException{return s.nextInt();}
	static long gLong() throws IOException{return s.nextLong();}
	static long gDouble() throws IOException{return s.nextLong();}

	int[] dx={-1,0,1,-1,1,-1,0,1},dy={-1,-1,-1,0,0,1,1,1};
	private void solve() throws IOException{
		int h=gInt(),w=gInt();
		char[][]f=new char[h][];
		for(int i=0;i<h;++i) {
			f[i]=s.next().toCharArray();
		}
		for(int i=0;i<h;++i) {
			for(int j=0;j<w;++j) if(f[i][j]!='#'){
				f[i][j]='0';
				for(int d=0;d<8;++d) if(0<=i+dx[d]&&i+dx[d]<h&&0<=j+dy[d]&&j+dy[d]<w){
					if(f[i+dx[d]][j+dy[d]]=='#')
						++f[i][j];
				}
			}
		}
		Arrays.stream(f).map(String::valueOf).forEach(System.out::println);
	}

	static void yesno(boolean f) {
		yesno(f,"Yes","No");
	}
	static void yesno(boolean f,String yes,String no) {
		System.out.println(f?yes:no);
	}
}
class FastScanner{
	private final BufferedInputStream	in;
	private static final int			bufSize	=1<<16;
	private final byte					buf[]	=new byte[bufSize];
	private int							i		=bufSize;
	private int							k		=bufSize;
	private final StringBuilder			str		=new StringBuilder();

	FastScanner(InputStream in){
		this.in=new BufferedInputStream(in,bufSize);
	}
	int nextInt() throws IOException{
		return (int)nextLong();
	}
	long nextLong() throws IOException{
		int c;
		long x=0;
		boolean sign=true;
		while((c=nextChar())<=32)
			;
		if(c=='-'){
			sign=false;
			c=nextChar();
		}
		if(c=='+'){
			c=nextChar();
		}
		while(c>='0'){
			x=x*10+(c-'0');
			c=nextChar();
		}
		return sign?x:-x;
	}
	int nextChar() throws IOException{
		if(i==k){
			k=in.read(buf,0,bufSize);
			i=0;
		}
		return i>=k?-1:buf[i++];
	}
	String next() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c>32){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
	String nextLine() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c!='\n'){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
}

Measured memory_bytes: 28500
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10,i,2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Measured memory_bytes: 9464
package main

import "fmt"

func main() {
	// in  9 45000
	// out 4 0 5
	// 10000 5000 1000

	var n, yen int
	fmt.Scan(&n)
	fmt.Scan(&yen)

	fmt.Println(calcYen(n, yen))
	calcYen(n, yen)

}

func calcYen(n int, yen int) (int, int, int) {
	for a := 0; a <= n; a++ {
		for b := 0; b <= n; b++ {

			if n-a-b < 0 {
				continue
			}

			if a*10000+b*5000+(n-a-b)*1000 == yen {
				return a, b, n - a - b
			}
		}
	}
	return -1, -1, -1
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define getchar gc
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline char gg(){
	char ch=getchar();
	while(ch!='.'&&ch!='#')ch=getchar();
	return ch;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=505;
int h,w,tot;
char ch[N];
char f[N][N],g[N][N];
char ans[N*N*2];
int main(){
	h=read(); w=read();
	for(int i=1;i<=h;i++){f[i][1]=1; g[i][w]=1;}
	for(int i=1;i<=h;i++){
		if(i&1)for(int j=2;j<w;j++)f[i][j]=1; else for(int j=2;j<w;j++)g[i][j]=1;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)if(gg()=='#')f[i][j]=g[i][j]=1;
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)ans[tot++]=f[i][j]?'#':'.'; ans[tot++]='\n';
	}
	ans[tot++]='\n';
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++)ans[tot++]=g[i][j]?'#':'.'; ans[tot++]='\n';
	}
	puts(ans);
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int h = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        double hx = a * Math.cos(Math.toRadians(90.0 - (30.0 * h + 0.5 * m)));
        double hy = a * Math.sin(Math.toRadians(90.0 - (30.0 * h + 0.5 * m)));
        double mx = b * Math.cos(Math.toRadians(90.0 - (6.0 * m)));
        double my = b * Math.sin(Math.toRadians(90.0 - (6.0 * m)));
        double rad = Math.sqrt((mx - hx) * (mx - hx) + (my - hy) * (my - hy));
        System.out.println(rad);
    }
}


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

int main(){
	long long int n, maxw;
	cin>>n>>maxw;
	long long int w[n+1], val[n+1];
	for (int i=1;i<=n;i++)
		cin>>w[i]>>val[i];
	long long int dp[n+1][n*1001];
	for(int i=1;i<n*1001;i++)
		dp[0][i] = -1;
	for (int i=0;i<=n;i++)
		dp[i][0] = 0;
	for (int i=1;i<=n;i++){
		for (int j=1;j<n*1001;j++){
			if (j >= val[i]){
				if (dp[i-1][j] != -1 && dp[i-1][j-val[i]] != -1)
					dp[i][j] = min(dp[i-1][j-val[i]] + w[i], dp[i-1][j]);
				else if (dp[i-1][j-val[i]] != -1)
					dp[i][j] = dp[i-1][j-val[i]] + w[i];
				else if (dp[i-1][j] != -1)
					dp[i][j] = dp[i-1][j];
				else
					dp[i][j] = -1;

			}
			else{
				if (dp[i-1][j] != -1)
					dp[i][j] = dp[i-1][j];
				else
					dp[i][j] = -1;
			}
		}
	}
	// for (int i=0;i<=n;i++){
	// 	for (int j=0;j<=30;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	for (int i=n*1001;i>=0;i--){
		if (dp[n][i] != -1 && dp[n][i] <= maxw){
			cout<<i;
			break;
		}
	}
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli n,k;
    cin2(n,k);

    lli ans = 0;
    REPE(b,k+1,n) {
        // 何セットあるか
        lli x = n / b;
        // 最後のセットの前まで
        ans += x * (b-k);
        //cout3(b,x, x * (b-k));

        // 最後のセット
        lli last_q = n-x*b;
        ans += max((lli)0, last_q - k+1);
        //cout3(b,last_q, max((lli)0, last_q - k+1));

        if (k == 0)
            ans--;
    }
    cout << ans << endl;
}


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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t;
	map<string, int> mp;
	cin >> t;
	while (t--) {
		int n;
		string s;
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3664
from sys import stdin
s = input()
a = []
a.append(s.find('A'))
a.append(s.find('T'))
a.append(s.find('G'))
a.append(s.find('C'))
for i in range(len(a)):
    if a[i] == -1:
        a[i] = 100
start = min(a)
#print(a)
pos = 0
sol = 0
for i in range(start, len(s)):
    #print(start)
    if s[i] != 'A' and s[i]!='T' and s[i]!='G' and s[i]!='C':
        pos = i
        if pos - start > sol:
            sol = pos - start
        #start = i+1
        a.clear()
        a.append(s.find('A', i))
        a.append(s.find('T', i))
        a.append(s.find('G', i))
        a.append(s.find('C', i))
        for i in range(len(a)):
            if a[i] == -1:
                a[i] = 100
        start = min(a)
if len(s)- start > sol:
    sol = len(s)-start
print(sol)


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int a_max=0;
  for (int i=0; i<n; i++){
    cin >>a.at(i);
    a_max = max(a_max,a.at(i));
  }
  vector<int> count(a_max+2,0);
  for (int i=0; i<n; i++){
    count.at(a.at(i)) ++;
  } 
  int ans = 0;
  int tmpa= -1;
  for (int j=0; j<=a_max; j++){
    if (j==0) ans = max(ans,count.at(j)+count.at(j+1));
    else ans = max(ans,count.at(j-1)+count.at(j)+count.at(j+1));
  }
  cout << ans << endl;
}

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

// #define deb(x) cout << #x << " " << x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"

#define ll  long long
#define all(c) (c).begin(),(c).end()
#define nl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll; typedef map< int, int> mll;
int t[100][100];

void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}





int main() {
 
    int i;

    c_p_c();
    int c=0;
    string s,r;
    cin>>s>>r;
    for (int i = 0; i < s.size(); ++i)
    {
        if(s[i]!=r[i])
            c++;
    }
    cout<<c<<endl;
  return 0;

}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() 
{
 
	ll T=1;
	while(T--)
	{
	ll a,b;
	cin>>a>>b;
	ll k=0;
	while(1)
	{
		if((a-1)*(k-1)+a>=b)
			break;
		k++;
	}
	cout<<k<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define NMAX 500
#define zeros(x) (x ^ (x-1)) & x

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, k, x, V[200005], sp, tot, A[200005];
map<ll, ll> F;

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
    {
        cin>>x;
        V[i] = x - 1;
        if (V[i] == -1)
            V[i] = k - 1;
    }

    if (k==1)
    {
        cout<<0;
        return 0;
    }

    F[0] = 1;
    A[0] = 0;
    for (int i=1; i<=n; i++)
    {
        sp += V[i];
        sp %= k;

        tot += F[sp];
        F[sp]++;
        A[i] = sp;

        if (i>=k-1)
            F[A[i-(k-1)]]--;
    }
    cout << tot;
    return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>

int main(void)
{
	int x, y;
	
	while(1)
	{
		
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0) break;
		if(x < y)
		    printf("%d %d\n", x, y);
		else if(y < x)
		    printf("%d %d\n", y, x);
		else
		    printf("%d %d\n", x, y);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll a, b;
int main() {
    cin>>a>>b;
    if(b%a==0) cout<<a+b<<endl;
    else cout<<b-a<<endl;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (A, B) = readLine()!!.split(" ").map { it.toLong() }

    var ans = 0L
    ans = if(A > B){
        calc(A, B)
    }else{
        calc(B, A)
    }

    println(ans)
}

fun calc(large:Long, small:Long): Long{
    var ans = 0L
    for(i in large .. Long.MAX_VALUE step large){
        if(i % small == 0L){
            ans = i
            break
        }
    }

    return ans
}

Measured memory_bytes: 36032
from bisect import *
s = input()
t = input()
pos = {}
for j,i in enumerate(s):
  if i in pos.keys():
  	pos[i].append(j+1)
  else:
    pos[i] = [j+1]
n = len(s)
for i in pos.keys():
  pos[i].append(pos[i][0] + n)
ans = 0
last = 0
for i in t:
  if not i in s:
    print(-1)
    exit()
  last = pos[i][bisect(pos[i],last)]
  if last > n:
    last -= n
    ans += n
print(ans + last)


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

int main()
{
    int M, D;
    cin >> M >> D;

    int maxD10 = D / 10;
    int ans = 0;

    for (int d10 = 2; d10 <= maxD10; ++d10) {
        int maxD1 = D - d10 * 10;
        for (int d1 = 2; d1 <= 9 && d1 <= maxD1; ++d1) {
            if (d1 * d10 <= M) {
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define debug(n) cout<<"# "<<#n<<": "<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

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

int main()
{
	for(int a,b;cin>>a>>b;){
		ostringstream oss;
		oss<<a+b;
		cout<<oss.str().size()<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int rot[5][7]={{0,1,2,3,4,5,6},{0,2,6,3,4,1,5},{0,4,2,1,6,5,3},{0,3,2,6,1,5,4},{0,5,1,3,4,6,2}};
int assign[7];
int tr['Z'];
void dice_init(int*a){
    int i;
    int t[5]={0,'N','E','W','S'};
    for(i=1;i<=6;i++)assign[i]=a[i];
    for(i=1;i<=4;i++)tr[t[i]]=i;}
    
char s[102];
int main (){
    int i,k1,k2;
    int a[7],dice[2][7];
    char*p;
    for(i=1;i<=6;i++)scanf("%d",a+i);
    dice_init(a);
    scanf("%s",p=s);
    for(i=1;i<=6;i++)dice[0][i]=rot[0][i];
    for(k1=0,k2=1;*p;k1=k2,k2=!k2){
        for(i=1;i<=6;i++)dice[k2][i]=dice[k1][rot[tr[*p]][i]];
        p++;
    }
    printf("%d\n",assign[dice[k1][1]]);
    return 0;
}




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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, d;
	cin>>n>>d;
	d=d*2+1;
	cout<<(n-1)/d+1<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
    int p;
    cin >> p;
    vec.at(i) = p;
  }
  sort(vec.begin(),vec.end());
  int ans = 0;
  for (int i = 0; i < k; i++){
    ans += vec.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define rep(i,a,b) for(uint32 i = (a); i < (b); ++i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define ALL(x) (x).begin(),(x).end()
#define C(x) std::cout << #x << " : " << x << std::endl
#define scanf scanf_s

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;

template<typename T>
class hashmap64 {
	std::vector<std::pair<uint64, T>> map;
	uint64 mask, count, temp;
	uint64 hash64(uint64 key) {
		key = ~key;
		key ^= key << 13;
		key ^= key >> 19;
		return key ^ (key << 17);
	}
public:
	hashmap64() :map(8192, std::make_pair(~static_cast<std::uint_fast64_t>(0), T())) {
		mask = 8191; count = 0;
	}
	hashmap64(size_t s) {
		s |= s << 1;
		s |= s >> 2;
		s |= s >> 4;
		s |= s >> 8;
		s |= s >> 16;
		s |= s >> 32;
		mask = s;
		count = 0;
		map.resize(s + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
	}
	T &operator[](uint64 suf) {
		temp = mask&hash64(suf);
		while (map[temp].first != suf) {
			temp = mask&(temp + 1);
		}
		return map[temp].second;
	}
	void insert(uint64 key, const T &value) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				map[temp].second = value;
				return;
			}
			temp = mask&(temp + 1);
		}
		map[temp] = std::make_pair(key, value);
		++count;
		if ((count << 1) > mask) {
			std::pair<uint64, T> mkey;
			mask = mask << 1 | 1;
			map.resize(mask + 1, std::make_pair(~static_cast<std::uint_fast64_t>(0), T()));
			for (uint64 t = 0;t <= mask >> 1;++t) {
				if (~map[t].first) {
					mkey = map[t];
					map[t].first = ~static_cast<std::uint_fast64_t>(0);
					temp = mask&hash64(mkey.first);
					while (~map[temp].first) {
						temp = mask&(temp + 1);
					}
					map[temp] = mkey;
				}
			}
		}
		return;
	}
	bool find(uint64 key) {
		temp = mask&hash64(key);
		while (~map[temp].first) {
			if (map[temp].first == key) {
				return true;
			}
			temp = mask&(temp + 1);
		}
		return false;
	}
	bool empty(void) {
		return !count;
	}
	size_t size(void) {
		return count;
	}
};

int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	hashmap64<uint32> map(250);
	uint32 n;
	std::cin >> n;
	int64 a, sum = 1e15;
	uint32 ans = 0;
	map.insert(sum, 0);
	rep(i, 0, n) {
		std::cin >> a;
		sum += a;
		if (map.find(sum)) {
			ans = std::max(ans, i + 1 - map[sum]);
		}
		else {
			map.insert(sum, i + 1);
		}
	}
	std::cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 15180
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int x;cin>>x;
    int maxv = 0;
    repsg(i,2,1001){
        rep(j,1001){
            int val = pow(j,i);
            if(val<=x) maxv = max(maxv,val);
        }
    }
    cout<<maxv<<endl;
    return 0;
}







Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
C = [INT() for _ in range(N)]

dp = [0]*(N+1)
dp[0] = 1
dp2 = [-1]*(max(C)+1) #前に色iが出てきたインデックスの保存

for i in range(1, N+1):
	p = dp2[C[i-1]]
	if 1 < i-p and p != -1:
		dp[i] += dp[p]
	dp[i] += dp[i-1]
	dp2[C[i-1]] = i
	dp[i] %= mod

print(dp[N])


Measured memory_bytes: 31068
#include <bits/stdc++.h>
  
using namespace std;
  
typedef pair< int, int > T;
  
const int mod1 = 1000000007;
const int base1 = 1009;
  
const int mod2 = 1000000007;
const int base2 = 1007;
  
int N, M;
char s[100000][201];
char d[100000][201];
int ans[100000];
bool rev[100000];
map< pair< int, int >, int > hash1[200];
set< pair< int, int > > endd[200];
  
T connect(T& hash, char c)
{
  return (make_pair(1LL * (hash.first + c) * base1 % mod1,
                    1LL * (hash.second + c) * base2 % mod2));
}
  
int countStrings(int p, int idx, T val)
{
  if(d[p][idx] == '\0') {
    return (endd[idx - 1].find(val) != endd[idx - 1].end());
  } else if(d[p][idx] == '*') {
    return (hash1[idx - 1].find(val) != hash1[idx - 1].end() ? hash1[idx - 1][val] : 0);
  } else if(d[p][idx] == '?') {
    int ret = 0;
    for(char c = 'a'; c <= 'z'; c++) {
      ret += countStrings(p, idx + 1, connect(val, c));
    }
    return (ret);
  } else {
    return (countStrings(p, idx + 1, connect(val, d[p][idx])));
  }
}
  
int main()
{
  scanf("%d %d", &N, &M);
  for(int i = 0; i < N; i++) {
    scanf(" %s", s[i]);
  }
  for(int i = 0; i < M; i++) {
    scanf(" %s", d[i]);
    if(d[i][0] == '*') {
      reverse(d[i], d[i] + strlen(d[i]));
      rev[i] = true;
    }
  }
  
  const int BACKET = 3000;
  for(int i = 0; i < N; i += BACKET) {
    for(int j = 0; j < 200; j++) {
      hash1[j].clear();
      endd[j].clear();
    }
    for(int k = i; k < min(N, i + BACKET); k++) {
      int len = strlen(s[k]);
      T val = {0, 0};
      for(int j = 0; j < len; j++) {
        val = connect(val, s[k][j]);
        hash1[j][val]++;
      }
      endd[len - 1].insert(val);
    }
    for(int j = 0; j < M; j++) {
      if(!rev[j]) ans[j] += countStrings(j, 0, {0, 0});
    }
  }
  
  for(int i = 0; i < N; i++) {
    reverse(s[i], s[i] + strlen(s[i]));
  }
  
  for(int i = 0; i < N; i += BACKET) {
    for(int j = 0; j < 200; j++) {
      hash1[j].clear();
    }
    for(int k = i; k < min(N, i + BACKET); k++) {
      T val(0, 0);
      int len = strlen(s[k]);
      for(int j = 0; j < len; j++) {
        val = connect(val, s[k][j]);
        hash1[j][val]++;
      }
    }
    for(int j = 0; j < M; j++) {
      if(rev[j]) ans[j] += countStrings(j, 0, {0, 0});
    }
  }
  for(int i = 0; i < M; i++) {
    printf("%d\n", ans[i]);
  }
}

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

int main() {
   char a,b;
   cin >> a >> b;
   if(a=='H'&&b=='H')cout << 'H' <<endl;
   if(a=='D'&&b=='H')cout << 'D' <<endl;
   if(a=='D'&&b=='D')cout << 'H' <<endl;
   if(a=='H'&&b=='D')cout << 'D' <<endl;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (true) {
		int N;cin>>N;
		if(!N)break;
		string st;cin>>st;
		vector<int>v;
		for (auto c : st) {
			v.push_back(c-'a');
		}
		vector<pair<int,int>>ps;
		for (int i = 0; i < N; ++i) {
			int a,b;cin>>a>>b;
			a--;b--;
			ps.push_back(make_pair(a,b));
		}
		for (int i = N - 1; i >= 0; --i) {
			int a=ps[i].first;
			int b=ps[i].second;
			int plus=abs(a-b);
			v[a]+=plus;
			v[a]%=26;
			v[b]+=plus;
			v[b]%=26;
			swap(v[a],v[b]);

		}
		for (int i = 0; i < st.size(); ++i) {
			cout<<char(v[i]+'a');
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int rec(int N) {
	if (N <= 0)return 0;
	return N + rec(N - 1);
}
int main() {
	init();

	int N, M; cin >> N >> M;
	int ans = rec(N - 1) + rec(M - 1);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return min;
	}
	if (val > max) {
		return max;
	}
	return val;
}
int main() {
	int n;
	cin >> n;
	int endn = n * 100 / 108 + 2;
	REP(i, endn ) {
		int check = (i + 1) * 1.08;
		if (check == n) {
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << ":(" << endl;
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


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

using namespace std;

typedef long long ll;

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    ll t = A + B;
    ll ans = 0;
    ans += N / t *A;
    if(N % t > A)
        ans += A;
    else
    {
        ans += N % t;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
print(n,': ',sep='',end='')
a=2
A=[]
while a*a<=n:
    while n%a==0:
        n //= a
        A.append(str(a))
    a+=1
if n>1:
    A.append(str(n))
A=' '.join(A)
print(A)


Measured memory_bytes: 5596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main()
	{
		int N = GetInt();
		int[] A = new int[N + 2];
		for(int i = 1; i <= N; i++)
			A[i] = GetInt();

		var st = new SegmentTree<int>(N + 2, 0, (x, y) => (int)Math.Max(x, y));
		for(int i = 1; i <= N; i++)
			st.Update(i, A[i]);

		var sb = new StringBuilder();
		for(int i = 1; i <= N; i++)
		{
			int x = st.Query(0, i);
			int y = st.Query(i + 1, N + 1);
			sb.AppendFormat($"{Math.Max(x, y)}\n");
		}

		Console.Write(sb);
	}
}


public class SegmentTree<T>
{
	private int N;
	private T INI;
	private Func<T, T, T> Func;
	private T[] dat;

	public SegmentTree(int n, T ini, Func<T, T, T> func)
	{
		N = 1;		
		while(N < n)
			N <<= 1;

		INI = ini;
		Func = func;
			
		dat = new T[2 * N - 1];
		for(int i = 0; i < 2 * N - 1; i++)
			dat[i] = INI;
	}

	public void Update(int k, T a)
	{
		k += N - 1;
		dat[k] = a;
		while(k > 0)
		{
			k = (k - 1) / 2;
			dat[k] = Func(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}

	public T Query(int a, int b, int k = 0, int l = 0, int r = -1)
	{
		if(r == -1)
			r = N;

		if(r <= a || b <= l)
			return INI;

		if(a <= l && r <= b)
			return dat[k];
		else
		{
			T vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
			T vr = Query(a, b, k * 2 + 2, (l + r) / 2, r);
			return Func(vl, vr);
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 24876
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional, std.meta;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.ascii, std.typecons;

void main()
{
    long n;
    readf("%s", &n);
    readln;

    const int BASE = 26;
    
    long high = 1;
    while (n > high * BASE) {
        high *= BASE;
        n -= high;
    }
    
    n -= 1;
    
    char[] ans;
    while (high > 0) {
        int cur = (n / high).to!int;
        
        ans ~= ('a' + cur);
        
        n -= cur * high;
        high /= BASE;
    }
    
    ans.writeln;
}

Measured memory_bytes: 2828
N=int(input())
ABC=["a","b","c","d","e","f","g","h","i","j"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")

Measured memory_bytes: 4340
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
namespace mp = boost::multiprecision;
long long int gcd(long long int x, long long int y){
  return y!=0 ? gcd(y, x%y) : x;
}
long long int lcm(long long int x, long long int y){
  return x*y/gcd(x, y);
}
long long int factorial(long long int x){
  return x==0 ? 1 : x*factorial(x-1);
}
int main(){
  int i, j, n, k;
  mp::cpp_int tmp, ct=1000000007;
  cin >> n >> k;
  if(n-k==0){
    cout << 1 << endl;
    for(i=0; i<k-1; i++)
      cout << 0 << endl;
    return 0;
  }
  cout << n-k+1 << endl;
  tmp=n-k+1;
  for(i=2; i<=k; i++){
    if(n-k<i-1) cout << 0 << endl;
    else{
      tmp=tmp*(n-k-i+2)*(k-i+1)/(i*(i-1));
      cout << tmp%ct << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int ll;
typedef vector<int > vecint;
typedef vector<bool > vecbool;
typedef vector<string > vecstr;
typedef vector<vector<int > > vec2int;
typedef vector<vector<bool > > vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
bool allblack(const vec2bool& g, const int h , const int w){
  REP(i,h){
    REP(j,w){
      if(g[i][j]) return false;
    }
  }
  return true;
}
int main()
{
  int h, w;
  cin >> h >> w;
  vec2bool g(h,vecbool(w,false));
  vec2bool looked(h,vecbool(w,false));
  queue<pair<int, int>> q1, q2;
  char tmp;
  int n = 0;
  REP(i,h){
    REP(j,w){
      cin >> tmp;
      if(tmp == '#'){
	g[i][j] = false;
	looked[i][j] = true;
	q1.push(make_pair(i, j));
	n ++;
      }else{
	g[i][j] = true;
      }
    }
  }

  // REP(i,h){
  //   REP(j,w){
  //     cout << g[i][j] << " " ;
  //   }
  //   cout << endl;
  // }

  // cout << n << endl;
  ////////////////////////////
  int ans = 0;
  //q1: outmost black 
  //q2: white to be changed
  int i, j, x, y;
  while(true){
    while(!q1.empty()){
      i = q1.front().first;
      j = q1.front().second;
      q1.pop();
      REP(k,4){
	x = i + dx[k];
	y = j + dy[k];
	if(0 <= x &&x<= h - 1&&0 <= y && y<= w - 1){
	  if(g[x][y]&&!looked[x][y]){
	    q2.push(make_pair(x, y));
	    looked[x][y] = true;
	  }
	}
      }
    }
    while(!q2.empty()){
      i = q2.front().first;
      j = q2.front().second;
      q2.pop();
      g[i][j] = false;
      n++;
      q1.push(make_pair(i,j));
    }
    if(q1.empty()){break;}
    ans ++;

  }
  cout << ans << endl;
}


Measured memory_bytes: 8848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, arr[200005], dist[200005], a, b, len, head;
ll k;
bool vis[200005];

int main() {
	fastio; cin >> n >> k;
	FOR(i, 1, n) cin >> arr[i];
	a = arr[arr[1]], b = arr[1];
	while (a != b) a = arr[arr[a]], b = arr[b];
	head = a; b = arr[b]; len = 1;
	while (b != a) {
		b = arr[b];
		len++;
	}
	int cur = 1;
	while (true) {
		if (k == 0) break;
		if (cur == head) break;
		cur = arr[cur]; k--;
	}
	if (k == 0) cout << cur;
	else {
		k %= len;
		while (k--) head = arr[head];
		cout << head;
	}
}


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

int main() {
	int x, y;
	cin >> x >> y;
	if (y % 2 == 1 || (x * 4) < y || (((x * 4) - y) % 2) != 0) {
		cout << "No" << endl;
	}
	else if((((x*4)-y)/2) > x){
		cout << "No" << endl;

	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3632
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  let f e = print_string " "; print_int e in
  inorder f t;
  print_newline ();
  preorder f t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let delete x t =
  let rec dudu = function
    | Nil -> exit 1
    | Node (x, Nil, _) -> x
    | Node (_, l, _) -> dudu l
  and wa = function
    | Nil -> exit 1
    | Node (_, Nil, r) -> r
    | Node (x, l, r) -> Node (x, wa l, r)
  and doit = function
    | Nil -> exit 1
    | Node (y, l, r) when x = y ->
      if l = Nil then r
      else if r = Nil then l
      else Node (dudu r, l, wa r)
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r) in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then
      match split_on_char ' ' (read_line ()) with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | ["find"; n] -> print_endline (if find (int_of_string n) t then "yes" else "no"); read (i + 1) t
      | ["delete"; n] -> read (i + 1) (delete (int_of_string n) t)
      | _ -> print t; read (i + 1) t in
  read 0 (create ())

Measured memory_bytes: 27044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int m = max(a, max(b, c));
    for (int i = 0; i < k; ++i) m <<= 1;
    cout<< a + b + c + m - max(a, max(b, c)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

int main()
{
  int stack[100],top=0,n1,n2;
  char buf[1000000],*p;
  
  fgets(p=buf,400,stdin);
  while (*p >= ' ') {
    while (isspace(*p)) p++;
    if (isdigit(*p)) {
      n1=0;
      while (isdigit(*p))n1=(10*n1)+(*p++ & 0xf);
      stack[top++] = n1;
    } else {
      n1 = stack[--top];
      n2 = stack[--top];
      if     (*p=='+') n2=n2+n1;
      else if (*p=='-') n2=n2-n1;
      else if (*p=='*') n2=n2*n1;
      stack[top++]=n2;
      p=p+1;
    }
  }
  printf("%d",stack[--top]);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >> s;
    rep(i, s.length()){
        if(s[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  long long n;
  cin >> n;
  cout << n*(n+1)/2 - 3*((n/3) + 1)*(n/3)/2 - 5*((n/5) + 1)*(n/5)/2 + 15*((n/15) + 1)*(n/15)/2 << endl;
  return 0;
}
  

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

int is_palindrome(string str, int l, int r)
{
    while(l < r)
    {
        if(str[l] != str[r])
            return 0;
        l++;
        r--;
    }
    return 1;
}

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    string str;
    cin >> str;
    int n = str.size();
    int f = (n - 1) / 2, l = (n + 3) / 2;
    if(is_palindrome(str, 0, n-1) && is_palindrome(str, 0, f-1) && is_palindrome(str, l-1, n-1))
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

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

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

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fr(i,a,b) for(int i=a;i<b;i++)


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    int k=n%1000;
    if(k==0)
    {
        cout<<0;
    }
    else
    {
        cout<<1000-k;
    }
    
    
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main()
{
	int n;
	cin >> n;
	vector<unsigned int> a(n);
	rep(i, n){
		cin >> a[i];

	}

	

	sort(a.begin(), a.end());
	vector<unsigned int> b = a;

	a.erase(unique(a.begin(), a.end()), a.end());

	/*rep(i, a.size())
		cout << a[i];*/

	if(a.size() > 3){
		cout << "No";
		return 0;
	}

	bool flag = false;
	if(a.size() == 1){
		if(b[n-1] == 0)
			flag = true;

	}else if(a.size() == 2){
		
		if(n % 3 != 0){
			cout << "No";
			return 0;
		}
		if(a[0] == 0){
			if(b[n/3-1]==0 && b[n/3]==a[1])
				flag = true;
		}

	}else if(a. size() == 3){
		
		if(n % 3 != 0){
			cout << "No";
			return 0;
		}

		//printf("%d\n", ((a[0] ^ a[1]) ^ a[2]));
		if(((a[0] ^ a[1]) ^ a[2]) == 0){
			//cout << b[n/3-1] << b[n/3] <<  b[2*n/3-1] << b[2*n/3] << endl;
			if(b[n/3-1]==a[0] && b[n/3]==a[1] && b[2*n/3-1]==a[1] && b[2*n/3]==a[2])
				flag = true;
		}
	}

	if(flag) cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 1024
def cost(x,y):
    return (x-y)*(x-y)

N = int(input())
A = list(map(int, input().split()))

ans = 1000000000
tmp = 0
for i in range(min(A),max(A)+1):
    tmp = 0
    for a in A:
        tmp += cost(a,i)
    if ans > tmp:
        ans = tmp
print(ans)


Measured memory_bytes: 3060
def bin_(n):
    return str(bin(n))[2: ]

N = int(input())
syougen = [[] for i in range(N)]
for i in range(N):
    a = int(input())
    for j in range(a):
        x,y = input().split()
        x,y = int(x)-1,int(y)
        syougen[i].append((x,y))

start = 2**N-1
max_ = 0
for i in range(2**N):
    num = i
    uso = 0
    
    keta=bin(num)[2:]
    
    while(len(keta)<N):
        keta = "0"+keta
    for j in range(N):
        if(keta[j]=="1"):
            for p in range(len(syougen[j])):
                
                x,y = syougen[j][p]
                if(keta[x] != str(y)):
                    uso = 1
                    break
    
    suuji = str(bin(num))[2:]
    count  = 0
    for i in range(len(suuji)):
        if(suuji[i]=="1"):
            count += 1
            
    if(uso==0):
        max_ = max(max_,count)
        
print(max_)

Measured memory_bytes: 3064
from queue import LifoQueue


def print_sol(c, sol):
    print('Case #{}: {}'.format(c, sol))


def rd_int():
    return int(input())


def rd_str():
    return input()


def rd_str_lst():
    return input().split(' ')


def sp_str_lst():
    return list(input())


def rd_int_lst():
    return [int(i) for i in rd_str_lst()]


def sp_int_lst():
    return [int(i) for i in sp_str_lst()]


def dfs(g, i, v):
    """
    recursive post order dfs
    Args:
        g: array of graph nodes
        i: node to traverse
        v: visited array

    Returns: a post order dfs of graph g
    """
    v[i] = True
    for j in g[i]:
        if not v[j]:
            dfs(g, j, v)

    print(i)


def dfs_iter(g, i, n):
    v = [False] * n
    stack = LifoQueue()
    stack.put(i)
    while stack.not_empty:
        u = stack.get()
        v[u] = True
        print(u)
        for i in g[u]:
            if not v[i]:
                stack.put(i)


def main():
    n, k = rd_int_lst()
    p = rd_int_lst()
    p.sort()

    print(sum(p[:k]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9644
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())



int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int h, w, a, b;
	cin >> h >> w >> a >> b;

	int inv = 0;
	for (int i = 0; i < h; i++)
	{
		if (i == b) inv = 1;
		if (!inv)
		{
			for (int j = 0; j < w; j++)
				cout << (j < a) << "";
			cout << "\n";
		}
		else
		{
			for (int j = 0; j < w; j++)
				cout << (j >= a) << "";
			cout << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1280
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] n = new int[5];
        for(int i = 0; i < 6; i++){
            n[sc.nextInt()]++;
        }
        for(int i = 0; i < 5; i++){
            if(n[i] >= 3){
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");

    }
}


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

int main(){
      int n;cin >> n;
      vector<pair<string, int>> v;
      map<pair<string, int>, int> m;
      for(int i = 0;i < n;i++){
            string s;cin >> s;
            int t;cin >> t;
            v.push_back(make_pair(s, -t));
            m[make_pair(s, -t)] = i + 1;
      }
      sort(v.begin(), v.end());
      int t = v.size();
      for(int i = 0;i < t;i++)cout << m[v[i]] << "\n";
}

Measured memory_bytes: 256