akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

constexpr int num = 26;
int D;
vector<int> c(num);

vector<vector<int>> s; 

int point(vector<int> &t){
	int res = 0;
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		res += s[i][t[i]];
		
		for(int j = 0; j < num; j++){
			last[j]++;
		}
		
		last[t[i]] = 0;
		
		for(int j = 0; j < num; j++){
			res -= c[j] * last[j];
		}
	}
	
	return res + 1'000'000;
}

vector<int> solve(int Z){
	vector<int> t(D);
	
	vector<int> last(num);
	
	for(int i = 0; i < D; i++){
		for(int j = 0; j < num; j++){
			cin>>s[i][j];
			if(s[i][t[i]] + last[t[i]] * last[t[i]]/Z * c[t[i]] < s[i][j] + last[j] * last[j]/Z * c[j]) {
				t[i] = j;
			}
		}
		
		for(int j = 0; j < num; j++){
			if(j == t[i]) {
				last[j] = 0;
			} else {
				last[j]++;
			}
		}
	}
	
	return t;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	vector<int> t;
	
	
	cin>>D;
	
	s.resize(D, vector<int>(num));
	t.resize(D, 0);
	
	for(int i = 0; i < num; i++){
		cin>>c[i];
	}
	
	int p = 0;
	
	// for(int i = 1; i < 10; i++){
		// vector<int> nt;
		
		// nt = solve(i);
		// int np = point(nt);
		
		// if(p < np) {
			// t = nt;
			// p = np;
		// }
	// }

	t = solve(5);
	
	for(int i = 0; i < D; i++){
		cout<<t[i]+1<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 3764
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	char s[105],ans='1';
	ll k,n,i;
	scanf("%s%lld",s,&k);
	n=strlen(s);
	n=min(n,k);
	for(i=n-1;i>=0;i--) if(s[i]!='1') ans=s[i];
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
  long long int x,a,b;
  cin >> x;
  long long int I,J;
for(int i=-1000;i<=1000;i++){
  for(int j=-1000;j<=1000;j++){
    I=pow(i,5);
    J=pow(j,5);
 
    if(I-J==x){
      a=i; 
      b=j;
      break;
    }
  }
  if(I-J==x)break;
}
  cout << a << " " << b << endl;
      return 0;
}


Measured memory_bytes: 4088
X = int(input())

li = []
for x in range(2,10):
  li += [ i**x for i in range(1,int(1000**(1/x)//1)+2)]
ans_list = sorted(list(set(li)), reverse=True)

for x in ans_list:
  if x <=X:
    print(x)
    break

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int check(int n, int x, int b, char l, char r, string s, string t) {
    int c = x;
    rep(i, n) {
        if (s[i] == l) --c;
        if (c <= 0) return 1;
        if (t[i] == r) c = min(b, c + 1);
    }
    c = x;
    rep(i, n) {
        if (s[i] == r) ++c;
        if (c > b) return 1;
        if (t[i] == l) c = max(1, c - 1);
    }
    return 0;
}

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int sr, sc;
    cin >> sr >> sc;
    string s, t;
    cin >> s >> t;
    if (check(n, sr, h, 'U', 'D', s, t) || check(n, sc, w, 'L', 'R', s, t)) {
        puts("NO");
    }
    else {
        puts("YES");
    }
    return 0;
}


Measured memory_bytes: 4644
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
	long long a = rng();
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n;
    cin >> n;
    long long sum = 0;
    for(long long i = 1; i * i <= n; ++i)
    {
        long long a = (n - i) / i;
        if(!a)
            continue;
        if(n % a == n / a)
            sum += a;
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut dims = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        dims.push((v[0], v[1]));
    }

    let mut dp = vec![vec![std::i64::MAX; n]; n];
    for i in 0..n {
        dp[i][i] = 0;
    }
    for w in 1..n {
        for i in 0..n {
            let mut temp = std::i64::MAX;
            let j = i + w;
            if j > n - 1 {
                continue;
            }
            for k in i..j {
                temp = min(
                    temp,
                    dp[i][k] + dp[k + 1][j] + dims[i].0 * dims[k].1 * dims[j].1,
                );
            }
            dp[i][j] = temp;
        }
    }
    println!("{}", dp[0][n - 1]);
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}



Measured memory_bytes: 5048
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>

using namespace std;

#define ll long long
#define f0(i,n)for(int i=0;i<n;i++)
#define fc(i,c,n,s)for(int i=c;i<=n;i+=s)
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef list<ll> LST;
typedef vector<ll> VEC;
typedef map<ll, ll> MAP;

int main() {
    IO;
    //ifstream cin("In.txt");
    ll m,d,ans=0,d1,d2;
    cin>>m>>d;
    f0(i,m){
        f0(j,d){
            if(j+1>=22){
                d1=(j+1)/10;
                d2=(j+1)%10;
                if(d1*d2==(i+1) && d1>1 && d2>1)
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
N = int(input())
A = list(map(int,input().split()))

ans = [[None]*W for _ in range(H)]
i = j = a = 0
while A:
    n = len(A)
    a = A.pop()
    while a:
        ans[i][j] = n
        if i%2:
            if j:
                j -= 1
            else:
                i += 1
        else:
            if j==W-1:
                i += 1
            else:
                j += 1
        a -= 1
for row in ans:
    print(*row)

Measured memory_bytes: 3828
#include <stdio.h>

int main(void)
{
    int A, B;
    int n;
    
    scanf("%d%d", &A, &B);
    
    n = B / A;
    if (B % A > 0){
        n++;
    }
    
    printf("%d\n", n);

    return (0);
}


Measured memory_bytes: 2140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100000
#define EMAX 500000
#define INFTY 2000000000
typedef struct {
  int pre,next,x;
}Cost;
int n,d[MAX];
Cost E[EMAX];
void jr(int);
 
void jr(int cou){
  int i,tmp;
   
  for(i=0;i<n;i++){
    d[i]=INFTY;
  }
  d[0]=0;
 
  tmp=1;
   
  while(tmp!=0){
    tmp = 0;
    for(i = 0;i < cou; i++){
      if(E[i].x + d[E[i].pre] < d[E[i].next]){
    d[E[i].next] = E[i].x + d[E[i].pre];
    tmp = 1;
      }
    }
  }
}
 
int main()
{
  int i,j,u,k,cou=0;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      E[cou].pre = u;
      scanf("%d%d", &E[cou].next, &E[cou].x);
      cou++;
    }
  }
 
  jr(cou);
 
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
 
  return 0;
}

Measured memory_bytes: 8432
#include <stdio.h>
int main()
{
	int n, x;
	int a[1000];
	int max = 0;
	int min = 0;
	int ans = 0;
	
	scanf("%d", &n);
	
	for (x = 0; x < n; x++){
		scanf("%d", &a[x]);
	}
	min = a[0];
	for (x = 0; x < n; x++){
		if(a[x] <= min)
			min = a[x];
			
		if(a[x] >= max)
			max = a[x];
	}
	
	printf("%d", max - min);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double a,b,c;
    scanf("%lf",&a);
    scanf("%lf",&b);
    scanf("%lf",&c);
    if(a>=c){
        a-=c;
        printf("%.0f %.0f\n",a,b);
        return 0;
    }
    else if(a+b>c){
        b=a+b-c;
        a=0;
        printf("%.0f %.0f\n",a,b);
        return 0;
    }
    else if(a+b<=c){
        a=0;
        b=0;
        printf("%.0f %.0f\n",a,b);
        return 0;
    }
}

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

abc = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans = ''
while n:
    ans += abc[(n-1)%len(abc)]
    n = (n-1)//len(abc)
print(ans[::-1])


Measured memory_bytes: 61936
import math

n, d = map(int, input().split())
x = [list(map(int,input().split())) for i in range(n)]
count = 0

for i in range(n):
  distance = math.sqrt(x[i][0] ** 2 + x[i][1] ** 2)
  if distance <= d:
    count += 1
    
print(count)

Measured memory_bytes: 102608
package main
import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	prime := false

	for i := 2; i <= x; i++ {
		if x%i == 0 {
			if x == i {
				prime = true
			}
			break
		}
	} // from this loop we get the given num is prime or not

	if prime == true {
		fmt.Println(x)
	} else {
		for i := x + 1; ; i++ {
			for j := 2; j <= i; j++ {
				if i%j == 0 {
					if j == i {
						fmt.Println(i)
						prime = true
					}
					break
				}
			}
			if prime == true {
				break
			}
		}
	}
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<LL>;
using vs = vector<string>;
using vvi = vector<vi>;

//==============================================
int n, m, q;
vi color;
vvi G;

void antDfs(int r, int teamNum) {
	stack<int>S;
	S.push(r);
	color[r] = teamNum;
	while (!S.empty()) {
		int u = S.top(); S.pop();
		REP(i, G[u].size()) {
			int v = G[u][i];
			if (color[v] == -1) {
				color[v] = teamNum;
				S.push(v);
			}
		}
	}
}

void func() {
	int id = 1;
	REP(i, n) {
		if (color[i] == -1) {
			antDfs(i, id++);
		}
	}
}

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

	cin >> n >> m;

	color.resize(n, -1);
	G.resize(n);

	int a, b;
	REP(i, m) {
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	func();


	cin >> q;

	REP(i, q) {
		cin >> a >> b;
		if (color[a] == color[b]) {
			cout << "yes" << "\n";
		} else {
			cout << "no" << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 8660
#include<bits/stdc++.h>
using namespace std;
#define MAX 3005
int dp[MAX][MAX]={0};
int main(){
	string s,t;
	cin>>s>>t;
	//dp[i][j] 前i个字符，前j个字符中的 最长公共子串长度 
	int len1=s.length();
	int len2=t.length();
	for(int i=0;i<=len1;i++){
		dp[i][0]=0;
	}
	for(int j=0;j<=len2;j++){
		dp[0][j]=0;
	}
	for(int i=1;i<=len1;i++){
		for(int j=1;j<=len2;j++){
			if(s[i-1]==t[j-1]) dp[i][j] = dp[i-1][j-1] + 1;
			else{
				dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			}
		}
	}
	
	string res="";
	int x=len1,y=len2;
	while(x>=1&&y>=1){
		if(s[x-1]==t[y-1]){
			res+=s[x-1];
			x--;
			y--;
		}else{
			if(dp[x][y-1]>dp[x-1][y]){
				y--;
			}else x--;
		}
	}
	if(res.length()==0) cout<<"";
	for(int i=res.length()-1;i>=0;i--){
		cout<<res[i];
	}
	
	return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int main(){
    string ss;
    getline(cin,ss);
    int ans=0,len=ss.size();
    for(int i=0;i<len/2;i++){
        if(ss[i]!=ss[len-i-1]) ans++;
    }
    printf("%d",ans);
    return 0;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

char s[100005];

int main() {
	int n,m;

	scanf("%d%d %s", &n, &m, s);

	int cnt = 0;
	for(int i = 0; s[i]; i++) {
		if(s[i] == '1') cnt++;
		else cnt = 0;
		if(cnt == m) {
			printf("-1\n");
			return 0;
		}
	}

	string t = s;
	reverse(t.begin(), t.end());

	vector<int> ans;
	vector<int> pos;

	for(int i = 0; t[i]; i++)
		if(t[i] == '0') pos.push_back(i);

	int i = 0;
	while(pos[i] < n) {
		int j = i;
		while(j < pos.size() && pos[j] - pos[i] <= m) j++;
		j--;
		ans.push_back(pos[j] - pos[i]);
		i = j;
	}

	reverse(ans.begin(), ans.end());

	bool f = true;

	for(int x : ans) {
		if(f) printf("%d", x);
		else printf(" %d", x);
		f = false;
	}

	printf("\n");

    return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<climits>
using namespace std;
long long sum = 0;

void merge(int A[], int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1], R[n2];

	for(int i = 0; i < n1; i++){
		L[i] = A[left + i];
	//	cout << "L: "<< L[i] << ' ';
	}
//	cout << endl;

	for (int i = 0; i < n2; i++){
		R[i] = A[mid + i];
	//	cout << "R: "<< R[i] << ' ';
	}
//	cout << endl;
	L[n1] = R[n2] = INT_MAX;
	
	int i=0, j=0;
	for(int k=left; k<right; k++){
		if(L[i] < R[j]){
			A[k] = L[i];
			i++;
		}
		else{
			A[k] = R[j];
			j++;
			sum += n1 - i;
		}

	}
}
void mergesort(int A[], int left, int right)
{
	if(left + 1 < right){
		int mid = (left + right) / 2;
		mergesort(A,left,mid);
		mergesort(A,mid,right);
		merge(A,left,mid,right);

	}

}
int main()
{
	int n;
	cin >> n;
	int A[n];
	for(int i=0; i<n; i++)
		cin >> A[i];
	mergesort(A,0,n);
	cout << sum << endl;
	
}


Measured memory_bytes: 4656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    while (input.ready())
    {
      final String[] inputStr = input.readLine().split(" ");
      final double ans = getAns(inputStr);
      System.out.println(ans);
    }
  }

  private static double getAns(String[] input)
  {
    Deque<String> stack = new ArrayDeque<>();
    for (String s : input)
    {
      if (s.equals("+"))
      {
        double b = Double.parseDouble(stack.removeFirst());
        double a = Double.parseDouble(stack.removeFirst());
        stack.addFirst(String.valueOf(addition(a, b)));
        continue;
      }
      if (s.equals("-"))
      {
        double b = Double.parseDouble(stack.removeFirst());
        double a = Double.parseDouble(stack.removeFirst());
        stack.addFirst(String.valueOf(subtraction(a, b)));
        continue;
      }
      if (s.equals("*"))
      {
        double b = Double.parseDouble(stack.removeFirst());
        double a = Double.parseDouble(stack.removeFirst());
        stack.addFirst(String.valueOf(multiplication(a, b)));
        continue;
      }
      if (s.equals("/"))
      {
        double b = Double.parseDouble(stack.removeFirst());
        double a = Double.parseDouble(stack.removeFirst());
        stack.addFirst(String.valueOf(division(a, b)));
        continue;
      }
      stack.addFirst(s);
    }
    return Double.parseDouble(stack.removeFirst());
  }

  private static double addition(double a, double b)
  {
    return a + b;
  }

  private static double subtraction(double a, double b)
  {
    return a - b;
  }

  private static double multiplication(double a, double b)
  {
    return a * b;
  }

  private static double division(double a, double b)
  {
    return a / b;
  }

}

Measured memory_bytes: 24392
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define ull unsigned long long
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int cnt[30];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			char x;
			cin>>x;
			cnt[x-'a']++;
		}
	}
	int ans=0;
	for(int i=0;i<((h)/2);i++)
	{
		for(int j=0;j<((w)/2);j++)
		{
			for(int k=0;k<26;k++)
			{
				if(cnt[k]>=4)
				{
					cnt[k]-=4;
					ans+=4;
					break;
				}
			}
		}
	}
	if(h%2==1)
	{
		for(int i=0;i<((w)/2);i++)
		{
			for(int k=0;k<26;k++)
			{
				if(cnt[k]>=2)
				{
					cnt[k]-=2;
					ans+=2;
					break;
				}
			}
		}
	}
	if(w%2==1)
	{
		for(int i=0;i<((h)/2);i++)
		{
			for(int k=0;k<26;k++)
			{
				if(cnt[k]>=2)
				{
					cnt[k]-=2;
					ans+=2;
					break;
				}
			}
		}
	}
	if(h%2==1&&(w%2==1))
	{
		for(int k=0;k<26;k++)
		{
			if(cnt[k]>=1)
			{
				cnt[k]--;
				ans++;
				break;
			}
		}
	}
	if(ans==h*w)
	{
		cout<<"Yes\n";
	}
	else
	{
		cout<<"No\n";
	}
}

Measured memory_bytes: 256
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<typeinfo>
#include<typeindex>
#include<type_traits>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<chrono>
 
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; ++i)
#define rer(i,l,r) for(int i=l; i<=r; ++i)
#define gnr(i,l,r) for(int i=r; i>=l; --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define inarr(a,n,t) t a[n]; rep(i,n)cin>>a[i]; 
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,q,_,x,y;
string s,sb;
bool key;
char ch;

template<class T>
T mpow(T x,T n,const T &mod){
  T r=1;
  while(n>0){
    if(n&1)(r*=x)%=mod;
    (x*=x)%=mod;
    n>>=1;
  }
  return r;
}

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

  cin>>m>>n; pri1(mpow(m,n,Int(mod)));
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int ans[n] = { };
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		ans[a-1]++;
		ans[b-1]++;
	}
	for(int i = 0; i < n; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

typedef pair<int, int> P;
ll modnum = 1e9+7;

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

const int MAX = 1e5+5;

long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % modnum;
        inv[i] = modnum - inv[modnum%i] * (modnum / i) % modnum;
        finv[i] = finv[i - 1] * inv[i] % modnum;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % modnum) % modnum;
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> c(m, vector<int>());
    vector<int> a(m);
    rep(i, m) {
        int b; cin >> a[i] >> b;
        rep(j, b) {
            int t; cin >> t;
            c[i].push_back(t);
        }
    }

    vector<vector<int>> dp(m+1, vector<int>(4200, -1));


    rep(i, m) {
        int num = 0;
        rep(j, c[i].size()) {
            num += pow(2, c[i][j]-1);
        }
        dp[i+1][num] = a[i];

        for (int bit = 1; bit < (1<<n); bit++) {
            if(dp[i][bit] > -1) {
                if(dp[i+1][bit] == -1) {
                    dp[i+1][bit] = dp[i][bit];
                } else {
                    chmin(dp[i+1][bit], dp[i][bit]);
                }
                int state = bit | num;
                //cout << bit << ":" << num << ":" << state << endl;
                if(dp[i+1][state] == -1) {
                    dp[i+1][state] = dp[i][bit] + a[i];
                } else {
                    chmin(dp[i+1][state], dp[i][bit] + a[i]);
                }
            }
        }
    }

    cout << dp[m][(1<<n)-1] << endl;

    return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
  
 

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


 int n,k;
 cin>>n>>k;

 vector<int>v(n);
 int ans=0;

 for(int i=0;i<n;i++)
 cin>>v[i];
 sort(v.begin(),v.end(),greater<int>());

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

  if(i>k-1)ans+=v[i];
 }
 cout<<ans<<"\n";
   
}


Measured memory_bytes: 1792
import sys

#+++++


def oaa(a_ll, val, oe):
	#print(ll,val,oe)
	if val == 1:
		s=sum(a_ll)
	else:
		c=1
		s=0
		lll=len(a_ll)
		s=sum(a_ll[val-1::val])
		#print(a_ll, val, a_ll[val-1::val], s)
		#while c * val <= lll:
		#	s+=ll[(c*val)-1]
		#	c+=1
	return 1 if oe != s%2 else 0
		
def main():
	n = int(input())
	ll= list(map(int, input().split()))
	
	ret = [0 for _ in range(n)]
	for i in range(n):
		val=n-i
		rr=oaa(ret, val, ll[-i-1])
		ret[-i-1]=rr
	
	#print(ret)
	print(sum(ret))
	print(' '.join([str(i+1) for i,v in  enumerate(ret) if v == 1]))
		
		
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 14748
#include <bits/stdc++.h>
using namespace std;
long long INF = 100000000000000000;
int main(){
  long long n;
  cin >> n;
  vector<long long> A;
  A.push_back(0);
  while (1){
    long long tmp = (A.back() + 1) * 26;
    if (tmp < INF){
      A.push_back(tmp);
    } else {
      break;
    }
  }
  int len = lower_bound(A.begin(), A.end(), n) - A.begin();
  n -= A[len - 1];
  n--;
  string ans;
  for (int i = 0; i < len; i++){
    ans += 'a' + n % 26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

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

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

typedef long long ll;

int main(void) {

	int x, y, x_group, y_group;
	cin >> x >> y;

	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
		x_group = 1;
	}
	else if (x == 4 || x == 6 || x == 9 || x == 12){
		x_group = 2;
	}
	else if (x == 2) {
		x_group = 3;
	}

	if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
		y_group = 1;
	}
	else if (y == 4 || y == 6 || y == 9 || y == 12) {
		y_group = 2;
	}
	else if (y == 2) {
		y_group = 3;
	}

	if (x_group == y_group) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;

int main(){
	char s[105];
	bool flag=true;
	scanf("%s",s);
	for(int i=0;i<4;i++){
		if(i==0&&s[i]!='Y')
			flag=false;
		if(i==1&&s[i]!='A')
			flag=false;
		if(i==2&&s[i]!='K')
			flag=false;
		if(i==3&&s[i]!='I')
			flag=false;
	}
	if(flag)
		puts("Yes");
	else
		puts("No");
}

Measured memory_bytes: 128
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut cnt = vec![0; N+1];
    cnt[1] += 1;
    for n in 2..N+1 {
        let mut rem = n;
        for i in (2..).take_while(|&i| i * i <= n) {
            while rem % i == 0 {
                cnt[i] += 1;
                rem /= i;
            }
        }
        if rem != 1 {
            cnt[rem] += 1;
        }
    }
    let mut dp = vec![vec![0; 75 + 1]; N + 10];
    dp[1][1] = 1;
    for i in 1..N+1 {
        for x in 1..75+1 {
            for n in 0..cnt[i]+1 {
                if (n+1) * x > 75 {
                    continue;
                }
                dp[i+1][(n+1) * x] += dp[i][x];
            }
        }
    }
    println!("{}", dp[N][75]);
}


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

using namespace std;

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

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

/*
 * Constraints:
 * n = 1e5
 */


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

	string x;
	cin >> x;
	int n = sz(x);
	rep(i, 0, n-1)
	{
		if (x[i] == x[i+1])
		{
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}

	rep(i, 0, n - 2)
	{
		if (x[i] != x[i+1] && x[i] == x[i+2])
		{
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
public class Main
{
    static long solve(int weight[],int value[],int w)
    {
        long dp[][] = new long[weight.length][w+1];
        for(int i=0;i<=w;i++)
        {
            if(weight[0]<=i)
            dp[0][i] = value[0];
        }
        for(int i=1;i<weight.length;i++)
        {
            for(int j=0;j<=w;j++)
            {
                if(j-weight[i]>=0)
                dp[i][j] = Math.max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j]);
                else
                dp[i][j] = dp[i-1][j];
            }
        }
        return dp[weight.length-1][w];
    }
    public static void main(String []args)throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
        int nw[] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int weight[] = new int[nw[0]];
        int value[] = new int[nw[0]];
        for(int i=0;i<nw[0];i++)
        {
            int wv[] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
            weight[i] = wv[0];
            value[i] = wv[1];
        }
        bw.write(Long.toString(solve(weight,value,nw[1])));
        br.close();
        bw.close();
    }
}


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

int main() {

    int x;

    cin >> x;

    int ans = 1;

    for(int i=2; i*i<x; i++){
        int tmp = i;
        while(tmp <= x){
            ans = max(ans,tmp);
            tmp *= i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
s = ns()
a = [['S','S'],['S','W'],['W','S'],['W','W']]

for b in a:
    for i in range(1,n):
        c = 0 if b[i] == 'S' else 1
        d = 0 if s[i] == 'o' else 1
        e = b[i-1] if not c^d else 'W' if b[i-1] == 'S' else 'S'
        b.append(e)
    c = 0 if b[0] == 'S' else 1
    d = 0 if s[0] == 'o' else 1
    e = 0 if b[-2] == b[1] else 1
    if b[0] == b[-1] and c^d == e:
        print(''.join(b[:-1]))
        exit()

print(-1)

Measured memory_bytes: 7184
let _ = Scanf.scanf "%d\n" @@ fun n ->
  let ps = Array.init n @@ fun _ ->
    Scanf.scanf "%d\n" @@ fun p -> p in
  (* ps.(inv_ps.(i)) = i かつ inv_ps.(ps.(i)) = i なのを作る *)
  let inv_ps = Array.make (n + 1) 0 in
  Array.iteri (fun i p ->
    (* p = ps.(i) *)
    inv_ps.(p) <- i) ps;
  Array.init n (( + ) 1)
  |> Array.fold_left (fun (acc, s) p ->
      s :: acc,
      if inv_ps.(p - 1) <= inv_ps.(p)
      then s + 1
      else 1) ([], 0)
  |> (fun (acc, s) -> List.fold_left max s acc)
  |> (( - ) n)
  |> Printf.printf "%d\n"


Measured memory_bytes: 11520
import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;

    public class Main {

        public static void main(String[] args) throws IOException {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String line = br.readLine();

            if(line.contains("RRR")){
                System.out.println("3");
            }
            else if(line.contains("RR")){
                System.out.println("2");
            }
            else if(line.contains("R")){
                System.out.println(1);
            }
            else {
                System.out.println(0);
            }
        }
    }

Measured memory_bytes: 32740
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

int main(){
    int N, H, W; cin >> N >> H >> W;
    cout << (N-H+1) * (N-W+1) << endl;
    
    return 0;
}


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

int c[114514];
bool k[114514];

int main() {
	int n, m;
	cin >> n >> m;
	fill(c, c + n, 1);
	fill(k, k + n, false);
	k[0] = true;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		c[y - 1]++;
		if(k[x-1])k[y - 1] = true;
		c[x - 1]--;
		if (c[x - 1] == 0)k[x - 1] = false;
	}
	int ans = 0;
	for (int i = 0; i < n; i++)if (k[i])ans++;
	cout << ans << endl;
}

Measured memory_bytes: 768
import sys
sys.setrecursionlimit(20000)
w,h=list(map(int,input().split()))
def simaserach(i,j):
    if color[i][j]=="w":
        color[i][j]="g"
        if i>=1:
            if sima[i-1][j]==1:
                simaserach(i-1,j)
            if j>=1:
                if sima[i-1][j-1]==1:
                    simaserach(i-1,j-1)
            if j<=w-2:
                if sima[i-1][j+1]==1:
                    simaserach(i-1,j+1)
        if j>=1:
            if sima[i][j-1]==1:
                simaserach(i,j-1)
        if j<=w-2:
            if sima[i][j+1]==1:
                simaserach(i,j+1)
        if i<=h-2:
            if j>=1:
                if sima[i+1][j-1]==1:
                    simaserach(i+1,j-1)
            if sima[i+1][j]==1:
                simaserach(i+1,j)
            if j<=w-2:
                if sima[i+1][j+1]:
                    simaserach(i+1,j+1)

while(w!=0):
    count=0
    color = [["w" for i in range(w)] for j in range(h)]
    sima=[[]for i in range(h)]
    for i in range(h):
        a=list(map(int,input().split()))
        sima[i]=a
    for i in range(h):
        for j in range(w):
            if sima[i][j]==1 and color[i][j]=="w":
                simaserach(i,j)
                count+=1
    print(count)
    w, h = list(map(int, input().split()))


Measured memory_bytes: 7916
#coding:utf-8
import math
n, l = map(int,input().split())
#print(n, l)

all_taste = 0
#全てのりんごを使った時の味
for i in range(1, n+1):
    #print(i)
    tmp = l + i - 1
    all_taste = all_taste + tmp

#print(all_taste)
act_taste = 0

#食べるりんご（味がいちばん低いもの）を求める
eat_apple = l + 1 - 1
for i in range(1, n+1):
    cmp_apple = l + i - 1
    #print(eat_apple, cmp_apple)
    if abs(cmp_apple) <= abs(eat_apple):
        eat_apple = cmp_apple
        act_taste = all_taste - eat_apple

#print(eat_apple)
print(act_taste)

Measured memory_bytes: 3064
K = int(input())
N = len(input()) + K
P = 10**9+7

nn = 2002002
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P

C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] % P if 0 <= b <= a else 0

s = 0
po = 1
for i in range(K + 1):
    s = (s + C(N, i) * po) % P
    po = po * 25 % P
print(s)

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

const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 10;

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

typedef struct {
	int x, y;
} node;
node makeNode(int x, int y) {
	node n = {x, y};
	return n;
}

int w, h, n;
// 入力されたフィールド (W * H)
char field[MAX_H][MAX_W + 1];
// 各地点までのステップ数，未到達なら -1
int step[MAX_H][MAX_W + 1];

int bfs(int startX, int startY, int goalX, int goalY) {
	queue<node> que;
	que.push(makeNode(startX, startY));
	step[startY][startX] = 0;
	while (!que.empty()) {
		node current = que.front();
		que.pop();
		if (current.x == goalX && current.y == goalY) {
			return step[current.y][current.x];
		}
		for (int i = 0; i < 4; i++) {
			int nextX = current.x + dx[i];
			int nextY = current.y + dy[i];
			if (0 <= nextX && nextX < w
					&& 0 <= nextY && nextY < h
					&& field[nextY][nextX] != 'X'
					&& step[nextY][nextX] == -1) {
				que.push(makeNode(nextX, nextY));
				step[nextY][nextX] = step[current.y][current.x] + 1;
			}
		}
	}
	return -1;
}

int main () {
	cin >> h >> w >> n;
	int startX, startY;
	// 入力しながらスタートの座標を探す
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> field[i][j];
			if (field[i][j] == 'S') {
				startX = j;
				startY = i;
			}
		}
	}
	
	// 工場を順番に回って合計ステップを計算する
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		// step を -1 で初期化しながらゴールの座標を探す
		int goalX, goalY;
		for (int j = 0; j < h; j++) {
			for (int k = 0; k < w; k++) {
				step[j][k] = -1;
				if (field[j][k] == '0' + i) {
					goalX = k;
					goalY = j;
				}
			}
		}
		
		
		ans += bfs(startX, startY, goalX, goalY);
		
		startX = goalX;
		startY = goalY;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6104
N = int(input())
H = list(map(int, input().split()))
ans = 'Yes'
H[0] -= 1
for i in range(1, len(H)-1):
  if (H[i - 1] <=  H[i] - 1  <= H[i + 1]):
    H[i] -= 1
  elif(H[i - 1] <=  H[i]  <= H[i + 1]):
    continue
  else:
    ans = 'No'
    break
print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
ll n;
ll m;
ll a[100005];
ll p[100005];
vector<ll> g[100005];
set<ll> ss[100005];
ll fs(ll x)
{
        return p[x] == x ? x : p[x] = fs(p[x]);
}
void ms(ll x , ll y)
{
        x = fs(x);
        y = fs(y);
        p[y]  = x;
}
int main()
{
        cin >> n >> m;
        for(ll i=1;i<=n;i++) cin >> a[i];
        for(ll i=1;i<=n;i++) p[i] = i;
        for(ll i=1;i<=m;i++) {
                 ll a , b;
                 cin >>  a>> b;
                 ms(a , b);
        }
        for(ll i=1;i<=n;i++) {
                ll cap = fs(i);
                g[cap].pb(i);
                ss[cap].insert(a[i]);
        }
        ll ans = 0;
        for(ll i=1;i<=n;i++)
        {
                ll cap = fs(i);
                if(ss[cap].find(i) != ss[cap].end()) ans++;
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 16640
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 100010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int n,a[N]; ll ans=0,f[N],top[N];
int main()
{
	n=read(); for(int i=0;i<=n;i++)	a[i]=read(); top[0]=1-a[0];
	for(int i=0;i<=n;i++)	top[i+1] = min((top[i]<<1)-a[i+1],(ll)1e16);
	for(int i=n;~i;i--)
	{
		f[i]=min(top[i],f[i+1])+a[i];
		if(top[i]<0)	return puts("-1"),0; 
	}
	for(int i=0;i<=n;i++)	ans+=f[i];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	string z;
	cin>>z;
	for(int i=0;i<z.size();i++){
		if(z[i]=='-'&&i!=a){
			cout<<"No"<<endl;
			return 0;
		}
		if(i==a&&z[i]!='-'){
			cout<<"No"<<endl;
			return 0;	
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c;
  cin >> a >> b;
  c=a+b;
  if(a%3==0 || b%3==0 || c%3==0)cout <<"Possible"<< endl;
  else cout << "Impossible" << endl;
}

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

int main(void){
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    vector<long long> dp(n,INT_MAX);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= k; j++){
            if(i >= j)
                dp[i] = min(dp[i],dp[i - j] + abs(a[i] - a[i - j]));
            else
                break;
        }
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
    string a, b;
    long int sizea, sizeb;
    cin >> a >> b;
    
    sizea=a.length();
    sizeb=b.length();
    if(sizea>sizeb){
        cout << "GREATER" << endl;
        return 0;
    }
    else if(sizea<sizeb){
        cout << "LESS" << endl;
        return 0;
    }
   
    if(a>b) cout << "GREATER" << endl;
    else if(a==b) cout << "EQUAL" << endl;
    else cout << "LESS" << endl;
    return 0;
}
    

Measured memory_bytes: 256
n,t = map(int,raw_input().split())

arr = map(int,raw_input().split())

mintable = []
m = float("inf")
for i in arr :
	mintable.append(min(m,i))
	m = min(m,i)

ma = float("-inf")
for i in range(n):
	ma = max(ma,arr[i] - mintable[i])
ans = 0
for i in range(n):
	if arr[i] - mintable[i] == ma:	
		ans += 1

print ans

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

using namespace std;

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

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }



int h,w,n, x[101],y[101],a[101];
void solve(){
	cin >> h >> w >> n;
	int l = 0, r = h, u = 0, d = w;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> a[i];
		if(a[i] == 1){
			chmax(l, x[i]);
		}
		if(a[i] == 2){
			chmin(r, x[i]);
		}
		if(a[i] == 3){
			chmax(u, y[i]);
		}
		if(a[i] == 4){
			chmin(d, y[i]);
		}
	}
	//cout << l << " " << r << " " << u << " " << d << endl;
	cout << max(0,r-l)*max(0,d-u) << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main() {
  int n,k,ans=0;
  cin>>n>>k;
  if(n==k) cout<<1;
  else {
    while(n>0){
      if(n-k > 0) n++;
      n -= k;
      ans++;
    }
    cout<<ans;
  }
}

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

int main() {
	int h,w;
	cin>>h>>w;
	char pix[h][w];
	for(int i=0;i<h;i++){
	    for(int j=0;j<w;j++)
	    cin>>pix[i][j];
	}
	for(int i=0;i<w+2;i++)
	cout<<"#";
	cout<<endl;
	for(int i=0;i<h;i++){
	    cout<<"#";
	    for(int j=0;j<w;j++){
	        cout<<pix[i][j];
	    }
	    cout<<"#"<<endl;
	}
	for(int i=0;i<w+2;i++)
	cout<<"#";
	
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Numerics;

class Program {
    static void Main (string[] args) {
        string[] S = Console.ReadLine ().Split (' ');
        long N = long.Parse (S[0]);
        long K = long.Parse (S[1]);
        string[] S2 = Console.ReadLine ().Split (' ');

        long[] numList = new long[N];
        long[] indexList = new long[N];
        for (int i = 0; i < N; i++) {
            numList[int.Parse (S2[i]) - 1]++;
            indexList[i] = i;
        }

        int numofkind = 0;
        for (int i = 0; i < N; i++) {
            if (numList[i] > 0) {
                numofkind++;
            }
        }

        if (numofkind <= K) {
            Console.WriteLine (0);
        } else {
            quickSortS2B (numList, indexList);
            long totalchange = 0;
            long changekind = 0;
            int i = 0;
            while (changekind < numofkind - K) {
                if (numList[i] > 0) {
                    totalchange += numList[i];
                    changekind++;
                }
                i++;
            }
            Console.WriteLine (totalchange);
        }
    }

    static void quickSortS2B (long[] a, long[] index) {
        quickSortS2B (a, index, 0, a.Length - 1);
    }

    static void quickSortS2B (long[] a, long[] index, int left, int right) {
        if (left < right) {
            int i = left;
            int j = right;
            long tmp;
            long pivot = med3 (a[i], a[i + (j - i) / 2], a[j]);
            while (true) {
                while (a[i] < pivot) i++;
                while (pivot < a[j]) j--;
                if (i >= j) break;
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
                tmp = index[i];
                index[i] = index[j];
                index[j] = tmp;
                i++;
                j--;
            }
            quickSortS2B (a, index, left, i - 1);
            quickSortS2B (a, index, j + 1, right);
        }
    }

    static long med3 (long x, long y, long z) {
        if (x < y) {
            if (y < z) {
                return y;
            } else if (z < x) {
                return x;
            } else {
                return z;
            }
        } else {
            if (z < y) {
                return y;
            } else if (x < z) {
                return x;
            } else {
                return z;
            }
        }
    }
}

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll,ll> > vpll;
typedef vector< vector<int> > matrix;

#define SET(Ar,val) memset(Ar,val,sizeof(Ar))
#define rep(i,val,n)  for(int i=val;i<n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LMAX LONG_LONG_MAX
#define LMIN LONG_LONG_MIN
#define IMAX INT_MAX
#define IMIN INT_MIN
#define Modulo 1000000007ll

/*--------------------------------------------------------------------------------------------------------------------------------*/

template <class T> T modpower(T a,T b,T MOD)
{
    T ans=1;
    while(b!=0)
    {
        if(b%2==1)
        ans=(ans*a)%MOD;
        a=(a*a)%MOD;
        b/=2;
    }
    return ans;
}

string f(int N)
{
    if(N == 0)
        return "0";
    string res = "";
    int b = -2;
    while(N)
    {
        int d = N%b;
        N/=b;
        if(d < 0)
        {
            d+=abs(b);
            N++;
        }
        res = to_string(d) + res;
    }
    return res;
}

void init()
{
    int n;
    cin >> n ;
    cout << f(n);
}

int main()
{
    clock_t time1 = clock();
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    init();
    clock_t time2 = clock();
    cerr <<"Time: " <<(double)(time2-time1)/CLOCKS_PER_SEC * 100000 <<" seconds" <<endl;
	return 0;
    }


Measured memory_bytes: 256