akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


int main() {
    int N;
    cin >> N;
    rep(i,0,INT_MAX){
        if(i * i > N){
            cout << (i-1) * (i-1) << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

type stack struct {
	a []int
	i int
}

func newStack() stack {
	return stack{
		a: make([]int, 200),
		i: 0,
	}
}

func (s *stack) push(num int) {
	s.a[s.i] = num
	s.i++
}

func (s *stack) pop() int {
	s.i--
	return s.a[s.i]
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	in := stdin.Text()
	ss := strings.Split(in, " ")
	stack := newStack()

	for _, s := range ss {
		switch s {
		case "+":
			l := stack.pop()
			r := stack.pop()
			stack.push(r + l)
		case "-":
			l := stack.pop()
			r := stack.pop()
			stack.push(r - l)
		case "*":
			l := stack.pop()
			r := stack.pop()
			stack.push(r * l)
		default:
			n, err := strconv.Atoi(s)
			if err != nil {
				panic(err)
			}
			stack.push(n)
		}
	}
	fmt.Println(stack.pop())
}



Measured memory_bytes: 1104
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar(); 
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
int n;
int a[maxn],b[maxn],sum[maxn][2];

namespace BIT{
	int t[maxn*2];
	void init(){
		rep(i,200004)t[i]=0;
	}
	void add(int v){
//		cout<<"add: "<<v<<endl;
		for(v+=100002;v<=200003;v+=(v&-v))t[v]++;
	}
	int qry(int v){
//		cout<<"qry: "<<v<<endl;
		int res=0;
		for(v+=100002;v;v-=(v&-v))res+=t[v];
		return res;
	}
}

bool check(int x){
	ll cur=0;
	BIT::init();
	rep(i,n){
		b[i]=a[i]<=x?1:0;
		if(i)sum[i][0]=sum[i-1][0],sum[i][1]=sum[i-1][1];
		else sum[i][0]=sum[i][1]=0;
		sum[i][b[i]]++;
	}
	BIT::add(0);
	rep(i,n){
		cur+=BIT::qry(sum[i][1]-sum[i][0]-1);
		BIT::add(sum[i][1]-sum[i][0]);
	}
//	cout<<x<<" "<<cur<<endl;
	return cur>=(1LL*n*(n+1)/2)/2+1;
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	int l=0,r=INF;
	while(r-l>1){
		int mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid;
	}
	printf("%d",r);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 2560
using System;
using System.Linq;

   class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var str = Console.ReadLine();
            var rCount = str.Count(x => x.Equals('R'));
            var ans = 0;
            for (int i = 0; i < rCount; i++)
            {
                if (str[i] == 'W') ans++;
            }
            Console.WriteLine(ans);
        }
    }

Measured memory_bytes: 28652
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
k=[]
for i in range(1,m):
    dif=l[i]-l[i-1]
    k.append(dif)
k.sort()
ans=0
for i in range(m-n):
    ans+=k[i]
print(ans)   

Measured memory_bytes: 13316
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  string s[3];
  for(int i = 0; i < 3; i++){
    cin >> s[i];
  }

  cout << s[0][0];
  cout << s[1][1];
  cout << s[2][2] << endl;

  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
main (void){
int a,b,c,tmp;
scanf("%d%d%d",&a,&b,&c);
if(a > b){tmp = a;a = b; b = tmp;};
if(b > c){tmp = b; b = c; c = tmp;};
if(a > b){tmp = a;a = b; b = tmp;};
printf("%d %d %d\n",a,b,c);

return 0;

}

Measured memory_bytes: 596
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <tuple>
# include <functional>
# include <utility>
# define INF 1000000000
# define MOD 1000000000+7
using namespace std;

int H, W;
char fruit[200][200];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

void dfs(int h, int w, char c) {
	fruit[h][w] = '.';
	for (int i = 0; i < 4; i++) {
		if (h + dx[i] >= 0 && h + dx[i] <= H && w + dy[i] >= 0 && w + dy[i] <= W && fruit[h + dx[i]][w + dy[i]] == c) {
			dfs(h + dx[i], w + dy[i], c);
		}
	}
}
int main() {
	while (cin >> H >> W&&H != 0 && W != 0) {
		string a;
		for (int i = 0; i < H; i++) {
			cin >> a;
			for (int j = 0; j < W; j++) {
				fruit[i][j] = a[j];
			}
		}
		int ans = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (fruit[i][j] == '#')dfs(i, j, '#'), ans++;
				if (fruit[i][j] == '*')dfs(i, j, '*'), ans++;
				if (fruit[i][j] == '@')dfs(i, j, '@'), ans++;
			}
		}
		cout << ans << endl;
	}
}

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

int main()
{
    int x, y;
    int buff;

    for (;;) {
	cin >> x >> y;
	if (x >= y) {
	    buff = y;
	    y = x;
	    x = buff;
	}
	if (x != 0 || y != 0)
	    cout << x << " " << y << endl;
	else
	    break;

    }
    return 0;
}

Measured memory_bytes: 1160
N = list(map(int,input().split()))
M = (N[2] - N[1]) * (N[0] - 2) + 1
if N[0] == 1 and N[1] == N[2]:
    print(1)
elif N[0] == 1:
    print(0)
elif N[0] == 2:
    print(1)
elif N[1] > N[2]:
    print(0)
else:
    print(M)

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

int main(){
    long long w, h, x, y; cin>>w>>h>>x>>y;
    cout << setprecision(20) << w * h / 2.0 << " ";
    if (w / 2.0 == x && h / 2.0 == y){
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<string> svec;

#define IN_LL(in) ll in; cin >> in
#define IN_STR(in) string in; cin >> in
#define IN_VEC(in, size) vec in; for(int i = 0; i < (size); ++i){int ____cur; cin >> ____cur; in.push_back(____cur); } 0
#define IN_SVEC(in, size) svec in; for(int i = 0; i < (size); ++i){string ____cur; cin >> ____cur; in.push_back(____cur); } 0

#define OUT(out) cout << (out)
#define OUT_VEC(out) for(ll i = 0; i < (out).size(); ++i) cout << (out)[i]

string func(int n){
	int r = n % 10;
	if(r == 3) {
		return "bon";
	} else if(r <= 1 || r == 6 || r == 8){
		return "pon";
	} else {
		return "hon";
	}
}

int main(void){
	IN_LL(n);

	string s = func(n);

	OUT(s);
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cctype>
using namespace std;

const int INF=0x3f3f3f3f;

long long n;

int sol(long long a,long long b){
    int ac=0,bc=0;
    while(a){ a/=10;ac++;}
    while(b){ b/=10;bc++;}
    //cout <<ac<<" "<<bc<<endl;
    return max(ac,bc);
}

int main(){
    cin>>n;
    long long i,j;
    int tem,res=INF;
    for(i=1;i*i<=n;i++){
        if(n%i==0){
            j=n/i;
            tem=sol(i,j);
            if(tem<res) res=tem;
        }
    }
    printf("%d\n",res);
    return 0;
}


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

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

    int hans, wans;
    for(hans = 0; hans < h; hans++){
        bool isexist = false;
        for(wans = 0; wans < w; wans++){
            if(s[hans][wans] == "snuke"){
                isexist = true;
                break;
            }
        }
        if(isexist) break;
    }
    cout << (char)('A'+wans) << hans+1 << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
const int INF = 1000000;

int main(){
        int N,M,i,a,b;
        cin >> N >> M;
        vector<vector<int>> r(100000);
        for(i=0;i<M;++i){
                cin >> a >> b;
                --a; --b;
                r[a].push_back(b);
                r[b].push_back(a);
        }
        queue<int> q;
        vector<int> dist(100000, INF);
        vector<int> pre(100000);
        q.push(0);
        while(!q.empty()){
                int idx = q.front(); q.pop();
                for(int e : r[idx]){
                        if(dist[e]==INF){
                                dist[e] = dist[idx] + 1;
                                pre[e] = idx;
                                q.push(e);
                        }
                }
        }
        cout << "Yes" << endl;
        for(i=1;i<N;++i) cout << pre[i]+1 << endl;
        return 0;
}

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

int main(){
    int A,B,C,Ans=0;
    scanf("%d%d%d",&A,&B,&C);
    int Max1=max(A,max(B,C));
    int Max2;
    if(A==Max1) Max2=max(B,C);
    else if(B==Max1) Max2=max(A,C);
    else if(C==Max1) Max2=max(A,B);
    int Max3=A+B+C-Max1-Max2;
    int tmp1=Max1-Max2;
    Ans+=tmp1,Max3+=tmp1,Max2+=tmp1;

    if((Max1-Max3)%2) Ans+=(Max1-Max3)/2+2;
    else Ans+=(Max1-Max3)/2;
    printf("%d",Ans);
}
/*
Sample Input 1
2 5 4
Sample Output 1
2

Sample Input 2
2 6 3
Sample Output 2
5

Sample Input 3
31 41 5
Sample Output 3
23
*/


Measured memory_bytes: 128
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def resolve():
    n, m = map(int, input().split())
    s = input()
    t = input()

    L = lcm(n, m)

    X = dict()
    for i in range(n):
        idx = (L // n) * i
        X[idx] = s[i]

    for i in range(m):
        idx = (L // m) * i
        if X.get(idx) != None and X[idx] != t[i]:
            print("-1")
            break
    else:
        print(L)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 15644
#include <stdio.h>

int main(void){
	int p,c, j;
	int n,r;
	int dx[50], a[50], b[50];
	int i, tempa, tempb, cnt;
	
	while(1){
		
		scanf("%d %d", &n, &r);
		if (n==0 && r==0) break;
		for(j = 0; j < n; j++){
				dx[j] = (j + 1);
		}
		for(i=0; i<r; i++){
			scanf("%d %d", &p, &c);
			tempa = 0;
			for(j = n - p; j != n - p - c; j--){
				a[tempa] = dx[j];
				tempa++;
			}
			tempb = 0;
			cnt = 0;
			for(j = n - 1; j > n - p; j--){
				b[tempb] = dx[j];
				tempb++;
				cnt++;
			}
			tempa = 0;
			tempb = 0;
			for(j = n - 1; j > n - 1 - c; j--){
				dx[j] = a[tempa];
				tempa++;
			}
			for(; j > n - 1 - c - cnt; j--){
				dx[j] = b[tempb];
				tempb++;
			}
		}		
		printf("%d\n", dx[n - 1]);
	}
	
	return(0);
	
}

Measured memory_bytes: 0
def main():
    # input
    H, W = map(int, input().split())
    _ = input()
    A = tuple(map(int, input().split()))

    # preprocess
    color_seq = [0] * (H*W)
    now = 0
    for i, num in enumerate(A):
        for j in range(num):
            color_seq[now+j] = i+1
        now += num

    # zig-zag coloring
    field = [[0]*W for _ in range(H)]
    for i in range(H):
        if i%2 == 0:
            for j in range(W):
                field[i][j] = color_seq[W*i + j]
        else:
            for j in range(W):
                field[i][W-1-j] = color_seq[W*i + j]
    
    # output
    for i in range(H):
        print(*field[i], sep=" ")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9504
#include<stdio.h>

int main()
{
  int i,j,x;
  int n,u,k,v;
  int V[100][100]={0};

  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&u,&k);
      for(j=0;j<k;j++){
	scanf("%d",&v);
	V[i][v-1]=1;
      }
    }

  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  printf("%d",V[i][j]);
	  if(j!=n-1) printf(" ");
	}
      printf("\n");
    }
	         
  return 0;
}



Measured memory_bytes: 2112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int l[] = new int[N], r[] = new int[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
			ans += r[i] - l[i] + 1;
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 25700
mod = 10**9+7
n, X = map(int, input().split())
s = [int(x) for x in input().split()]
s = sorted(s)

dp = [[0 for _ in range(X+1)] for _ in range(n+1)]
inv = [pow(i, mod-2, mod) for i in range(n+1)]

for i in range(n+1):
    if i == 0:
        for x in range(X+1):
            dp[i][x] = x
    else:
        for x in range(X+1):
            dp[i][x] = dp[i-1][x % s[i-1]] * inv[i] + dp[i-1][x]*(1-inv[i])
            dp[i][x] %= mod

ans = dp[n][X]

for i in range(n):
    ans *= i+1
    ans %= mod

print(ans)


Measured memory_bytes: 257928
"""from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
"""
n=int(input())
print(n*n)

Measured memory_bytes: 2940
#include<cstdio>

#include<vector>
#include<map>
using namespace std;

vector<int> G[20000];
vector<int> rG[20000];
int id[20000];
int rid[20000];
int cid[20000];
void enume(int s, int &n) {
    if(id[s]) return;
    id[s] = -1;
    for(int t : G[s])
        enume(t, n);
    id[s] = ++n;
    rid[n] = s;
}
void dfs(int s, int n) {
    if(cid[s]) return;
    cid[s] = n;
    for(int t : rG[s])
        dfs(t, n);
}

int main(void) {
    int m,n;
    scanf("%d%d",&m,&n);
    for(int i=0; i<n; i++) {
        int s,t;
        scanf("%d%d",&s,&t);
        G[s].push_back(t);
        rG[t].push_back(s);
    }

    int k=0;
    for(int i=0; i<m; i++)
        enume(i, k);

    for(int i=m; i; i--)
        dfs(rid[i], i);

    int q;
    scanf("%d",&q);
    for(int i=0; i<q; i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        printf("%d\n",cid[u] == cid[v]);
    }
    return 0;
}

Measured memory_bytes: 4920
N=int(input())
s=input()
t=s[len(s)-1]
S=[s]
for i in range(N-1):
  s = input()
  if s in S:
    print("No")
    break
  elif t==s[0]:
    t=s[len(s)-1]
    S.append(s)
  else:
    print("No")
    break

if len(S)==N:
  print("Yes")

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

int main(void) {
    int A1, A2, A3;
    int sum = 0;
    
    cin >> A1 >> A2 >> A3;
    
    sum = A1 + A2 + A3;
    
    if (sum >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mkp make_pair
#define mod 1000000007
#define F first
#define S second
#define ld long double
#define f(i,l,f,n) for(i=(l); i<(n) && !(f); i++)
#define endl "\n"

int countt[100000+1][3], arr[100000+1][3];

int dp(int pos, int k)
{
    if(pos<0)
    return 0;
    else if(countt[pos][k]!=-1)
    return countt[pos][k];
    else
    {
        int p1 = dp(pos-1, (k+1)%3);
        int p2 = dp(pos-1, (k+2)%3);
        countt[pos][k] = arr[pos][k]+max(p1, p2);
    }
    return countt[pos][k];
}

void solve()
{
    int i, j, k, n;
    cin>>n;
    f(i,0,0,n)
    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    memset(countt, -1, sizeof(countt));
    int p1 = dp(n-1, 0);
    int p2 = dp(n-1, 1);
    int p3 = dp(n-1, 2);
    cout<<max(p1, max(p2, p3));
}


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

    int t=1, i=0;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<i++<<": "<<solve()<<endl;
        solve();
    }
}


Measured memory_bytes: 7296
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

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

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int k,x;cin>>k>>x;
  cout << (500*k>=x ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d,z=1;
    cin>>n>>p;
    for(i=2;i*i<=p;i++){
        l=0;
        if(n==1){
            cout<<p<<endl;
            return 0;
        }
        while(p%i==0)l++,p/=i;
        for(j=1;j*n<=l;j++) z*=i;
    }
    cout<<z<<endl;

    return EXIT_SUCCESS;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int n;
	cin>>n;
	long long int ar[n];
	for(int i=0;i<n;i++){
		cin>>ar[i];
	}
	long long int ans=0;
	long long int fr[n];
	fr[0]=ar[0];
	for(long int i=1;i<n;i++){
		fr[i]=fr[i-1]+ar[i];
		
	}
	for(long int i=0;i<n-1;i++){
		
		ans+=((fr[i]%1000000007)*ar[i+1])%1000000007;
	}
	ans=ans%1000000007;
	cout<<ans;
}


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

int main() {
  int64_t N,tmp=0;
  cin>>N;
  vector<int64_t> A(N);
  rep(i,N){
    int64_t a;
    cin>>a;
    A.at(i)=a;
    tmp=(tmp^a);
  }
  rep(i,N){
    int64_t k=(tmp^A.at(i));
    if(i!=N-1) cout<<k<<" ";
    else cout<<k;
  }
}

Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int n;
  cin >> n;
  vi a(n);
  REP(i,n) cin >> a[i];
  map<string,int> m;
  int any=0;
  REP(i,n) {
    if(a[i]<400) m["gray"]++;
    if(400<=a[i]&&a[i]<800) m["brown"]++;
    if(800<=a[i]&&a[i]<1200) m["green"]++;
    if(1200<=a[i]&&a[i]<1600) m["lightblue"]++;
    if(1600<=a[i]&&a[i]<2000) m["blue"]++;
    if(2000<=a[i]&&a[i]<2400) m["yellow"]++;
    if(2400<=a[i]&&a[i]<2800) m["orange"]++;
    if(2800<=a[i]&&a[i]<3200) m["red"]++;
    if(3200<=a[i]) any++;
  }
  if(m.size()==0) {
    cout << "1 " << any << endl;
    return 0;
  }
  cout << m.size() << " " << m.size()+any << endl;
  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
using namespace std;
signed main() 
{
    fast
    ll t=1;
  // cin>>t;
    while(t--)
    {
           ll n;
           cin>>n;
           ll a[n],dp[n]={0};
           for(ll i=0;i<n;i++){cin>>a[i];}
           ll p=10000000,q=10000000;
           for(ll i=1;i<n;i++)
           {
                if(i-1>=0) p=dp[i-1]+abs(a[i]-a[i-1]);
                if(i-2>=0) q=dp[i-2]+abs(a[i]-a[i-2]);
                dp[i]=min(p,q);
                
           }
           cout<<dp[n-1]<<"\n";
    }
}

Measured memory_bytes: 5184
import math
H = int(input())
W = int(input())

N = int(input())

ans1 = 0
ans2 = 0
# 横を塗る
tmp = 0
for i in range(H):
    tmp += W
    if tmp >= N:
        ans1 = i+1
        break        

tmp = 0
for i in range(W):
    tmp += H
    if tmp >= N:
        ans2 = i+1
        break        
        
print(min(ans1,ans2))

Measured memory_bytes: 3060
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: AC_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 51000

using namespace std;

#define debug(args...)(Debugger()) , args
class Debugger
{
  public:
  Debugger(const std::string& _separator=", ") :
  first(true),separator(_separator){}
  template<typename ObjectType>
  Debugger& operator,(const ObjectType& v)
  {
        if(!first)cerr<<separator;
        cerr<<v;
        first=false;
        return *this;
  }
  ~Debugger() {cerr<<endl;}
  private:
    bool first;
    string separator;
};

template <typename T1, typename T2>
inline ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
   return os<<"("<<p.first<<", "<<p.second<<")";
}
template<typename T>
inline ostream &operator<<(ostream & os,const vector<T>& v)
{
    bool first=true;
    os<<"[";
    for(unsigned ll i=0;i<v.size();i++)
    {
        if(!first)os<<", ";
        os<<v[i];
        first=false;
    }
        return os<<"]";
}
template<typename T>
inline ostream &operator<<(ostream & os,const set<T>&v)
{
    bool first=true;
    os<<"[";
    for(typename set<T>::const_iterator ii=v.begin();ii!=v.end();++ii)
    {
        if(!first)os<<", ";
        os<<*ii;
        first=false;
    }
    return os<<"]";
}
template<typename T1, typename T2>
inline ostream &operator<<(ostream & os,const map<T1, T2>&v)
{
        bool first=true;
        os<<"[";
        for(typename map<T1,T2>::const_iterator ii=v.begin(); ii!=v.end();++ii)
        {
            if(!first)os<<", ";
            os<<*ii;
            first=false;
        }
        return os<<"]";
}

ll a,b,c;
vector<ll>massiv;

int main(){
FAST_READ;
cin>>a>>b>>c;
massiv.pb(a);
massiv.pb(b);
massiv.pb(c);
sort(all(massiv));
ll cnt=0;
for(ll i=1;i<massiv.size();i++)
{
  cnt+=abs(massiv[i]-massiv[i-1]);
}
cout<<cnt<<endl;
return 0;
}


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

int main(void){
  int i,n = 0;
  char w[11], t[1001];

  scanf("%s", w);

  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }while(1);

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

  return 0;
}


Measured memory_bytes: 2028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = 0;
		int count = 0;
		while (sc.hasNext()) {
			x = sc.nextInt();
			if (isPrime(x))
				count++;
		}
		System.out.println(count);
	}

	public static boolean isPrime(int x) {
		if (x == 2) {
			return true;
		} else if (2 > x || x % 2 == 0) {
			return false;
		}
		int i = 3;
		while (i <= Math.sqrt(x)) {
			if (x % i == 0) {
				return false;
			}
			i = i + 2;
		}
		return true;
	}
}



Measured memory_bytes: 41728
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b,d,r;
  double f;
  cin>> a >> b;

  d = a / b;
  r = a % b;

  f = (double)a / b;

  printf("%d %d %.5f\n",d,r,f);
  return 0;
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
#define MAX_N 1000010
using ll = long long;

int n, bit[MAX_N+1];

void add(int a,int w){
  for(int x = a; x <= n; x += x & -x) bit[x] += w;
}

int sum(int a){
  int ret = 0;
  for(int x = a; x > 0; x -= x & -x) ret += bit[x];
  return ret;
}

int main(){
  int q; cin>>n>>q;
  rep(i,q){
    int c,x,y; cin>>c>>x>>y;
    if(c==0) add(x,y);
    else cout<<sum(y)-sum(x-1)<<endl;
  }
}



Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    int maxi=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        maxi=max(maxi,a[i]);
    }
    int p=a[0];
    for(int i=0;i<n;i++)
    {
        p=__gcd(p,a[i]);
    }
    if(k>maxi)
    cout<<"IMPOSSIBLE"<<endl;
    else if(k%p==0)
    {
        cout<<"POSSIBLE"<<endl;
    }
    else
    cout<<"IMPOSSIBLE"<<endl;
    
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N);

    REP(i, N){
        cin >> A[i];
    }

    sort(A.begin(), A.end());

    cout << A[N-1]-A[0] << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int a,b; cin >> a >> b;
    int ans = max(0,a-(2*b));
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    int x;
    for(int i=1;i<=N;i++){
        if(i%3==0){
            cout << " " << i;
        }
        else if(i%10==3){
            cout << " " << i;
        }
        else if((i/10)%10==3){
            cout << " " << i;
        }
        else if((i/100)%10==3){
            cout << " " << i;
        }
        else if((i/1000)%10==3){
            cout << " " << i;
        }
    }
    
    cout << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> p(100100); // 1e5

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

  int n;
  cin >> n;
  p.resize(n);
  rep(i,n) cin >> p[i];

  int ans = 0;
  int min = p[0];
  rep(i, n) {
    if (min >= p[i]) {
      ans++;
      min = p[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c,d,e=0,f=1,g;cin>>a>>b>>c>>d;
  e=max({a,b,c});
  g=e;
  f=a+b+c;
  rep(i,d)e*=2;
  cout<<f+e-g;
}



Measured memory_bytes: 27012
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;


int main() {
	int N;

	cin >> N;

	vector<int> A(N);

	for (int i = 0; i < N; i++)
		cin >> A[i];

	vector<vector<long>>	dp(2, vector<long>(N+1));

	dp[0][0] = 0;
	dp[1][0] = -9999999999;

	for (int i = 1; i <= N; i++) {
		dp[0][i] = max(dp[0][i - 1] + A[i-1], dp[1][i - 1] - A[i-1]);
		dp[1][i] = max(dp[0][i - 1] - A[i-1], dp[1][i - 1] + A[i-1]);
	}
	 
	cout << dp[0][N] <<	endl;


}

Measured memory_bytes: 2944
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int[][] g = new int[n+1][n+1];
        
        for (int i = 0; i < n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int v = sc.nextInt();
                g[u][v] = 1;
            }
        }
        
        int[] d = new int[n+1];
        for (int i = 0; i <= n; i++) {
            d[i] = -1;
        }
        Queue<Integer> que = new LinkedList<Integer>();
        que.add(1);
        d[1] = 0;
        while (!que.isEmpty()) {
            int top = que.poll();
            for (int j = 1; j <= n; j++) {
                if (g[top][j] == 1 && d[j] == -1) {
                    que.add(j);
                    d[j] = d[top] + 1;
                }
            }
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(i + " " + d[i]);
        }
    }
}



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

SP = {i+1: input().split() for i in range(N)}

for v in SP.values():
    v[1] = int(v[1])

# 降順
SP = sorted(SP.items(), key=lambda x: x[1][1], reverse=True)

# 昇順
SP = sorted(SP, key=lambda x: x[1][0])

for sp in SP:
    print(sp[0])


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

int main() {
    int N, T;
    cin >> N >> T;
    vector<long long> t(N);
    for (int i = 0; i < N; i++)
        cin >> t[i];
    vector<long long> diff(N - 1);
    for (int i = 0; i < N - 1; i++)
        diff[i] = t[i + 1] - t[i];

    long long res = 0;
    for (int i = 0; i < N - 1; i++) {
        if (diff[i] < T) {
            res += diff[i];
        } else {
            res += T;
        }
    }
    res += T;

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

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N = 2e5 + 50;
ll mod = 998244353;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937_64 mt(seed);
int fac[N],invf[N];
inline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
inline int sub(int x, int y) { return x - y >= 0 ? x - y : x - y + mod; }
inline int power(int x, int y, int res = 1) {
    for (; y; y >>= 1, x = 1ll * x * x % mod) {
        if (y & 1) { res = 1ll * res * x % mod; }
    } return res;
}
void initcombi(int n) {
    for (int i = fac[0] = 1; i <= n; i++) { fac[i] = 1ll * fac[i - 1] * i % mod; }
    invf[n] = power(fac[n], mod - 2);
    for (int i = n; i; i--) { invf[i - 1] = 1ll * invf[i] * i % mod; }
}
 
inline int NCR(int n, int m) {
    if (n < m) { return 0; }
    return 1ll * fac[n] * invf[m] % mod * invf[n - m] % mod;
}
bool ispal(string k) {
    for(int i = 0; i < k.size(); i++) {
        if(k[i] == k[k.size() - i - 1])
            continue;
        return false;
    }
    return true;
}
int main() {
    io();
    string s;
    cin >> s;
    s = "." + s;
    int n = s.size();
    if(ispal(s.substr(1)) and ispal(s.substr((n + 3) / 2)) and ispal(s.substr(1, (n - 1) / 2))) {
        cout << "Yes\n";
    }
    else {
        cout << "No";
    }



}


Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce

import numpy as np
import math
import bisect


def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    # M = [L[i] + L[j] for i in range(N) for j in range(i+1, N)]
    # M.sort()

    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            a = L[i]
            b = L[j]


            r = bisect.bisect_right(L, a+b-1) 

            ans += r - (j + 1)

    print(ans)


if __name__ == '__main__':
    main()


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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define REPR(i,a) for(int i = a; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

int gcd(int a, int b){ return b ? gcd(b, a % b) : a; }
template<typename A> void psn(A a){ cout << a << endl; }
template<typename A, typename... B> void psn(A a, B... b){ cout << a << ' '; psn(b...); }

int main(void){
    
    int N;
    cin >> N;
    
    vi a(N);
    REP(i, N) cin >> a[i];
    
    int count = 0;
    
    REP(i, N){
        if(a[i] == count + 1) count++;
    }
    
    if(count == 0) cout << "-1" << endl;
    else cout << N - count << endl;
}

Measured memory_bytes: 1024
// AOJ 1166 "迷図と命ず" (ICPC国内予選 2010 Problem B)
import java.util.Scanner;
import java.util.Queue;
import java.util.LinkedList;

public class Main {
    static int[][] field;
    static String[] wall;
    static int[] dx = {1, 0, -1, 0};
    static int[] dy = {0, 1, 0, -1};
    static int w, h;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            w = sc.nextInt();
            h = sc.nextInt();
            if (w == 0) {
                break;
            }
            field = new int[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    field[i][j] = 0;
                }
            }
            field[0][0] = 1;
            
            wall = new String[2*h-1];
            sc.nextLine();
            for (int i = 0; i < 2 * h - 1; i++) {
                wall[i] = sc.nextLine();
            }
            //debug();
            solve();
        }
    }
    
    public static void debug() {
        for (int i = 0; i < wall.length; i++) {
            System.out.println(wall[i]);
        }
    }
    
    public static void solve() {
        Queue<Field> que = new LinkedList<Field>();
        que.offer(new Field(0, 0));
        while (que.peek() != null) {
            Field tmp = que.poll();
            if (tmp.x == w - 1 && tmp.y == h - 1) {
                break;
            }
            for (int i = 0; i < 4; i++) {
                int nx = tmp.x + dx[i];
                int ny = tmp.y + dy[i];
                //System.out.println(tmp.x + " " + tmp.y + " " + nx + " " + ny + ": ");
                if (0 <= nx && nx < w && 0 <= ny && ny < h && !isWall(tmp.x, tmp.y, nx, ny) && field[ny][nx] == 0) {
                    que.offer(new Field(nx, ny));
                    field[ny][nx] = field[tmp.y][tmp.x] + 1;
                }
            }
        }
        System.out.println(field[h-1][w-1]);
    }
    
    // 隣接する2マスに壁があればtrue，そうでなければfalseを返すメソッド
    public static boolean isWall(int x1, int y1, int x2, int y2) {
        if (wall[y1+y2].charAt(x1 + x2) == '1') {
            return true;
        } else {
            return false;
        }
    }
}

class Field {
    int x;
    int y;
    Field(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 40172
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
            
        int a = sc.nextInt();
        int b = sc.nextInt();
        int C = sc.nextInt();
        
        double S = (a * b) / 2 * Math.sin(Math.toRadians(C));
        double c = Math.sqrt(a*a + b*b - 2 * a * b * Math.cos(Math.toRadians(C)));
        double h = b * Math.sin(Math.toRadians(C));
        
        System.out.println(S);
        System.out.println(a + b + c);
        System.out.println(h);
            
        sc.close();
    }
}


Measured memory_bytes: 26356
#include <iostream>
#include <cmath>
#include <cstdio>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#include <bitset>
#include <iomanip>
#include <map>
#include <queue>
#include <numeric>

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
using std::bitset;

#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define reps(i,s,e) for(int i=s; i<(int)e; i++)
#define coutd(i) cout << std::fixed << std::setprecision(i)
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

template<class T>
using Graph = vector<vector<T>>;

const int INT_BIG = 1<<28;

struct City {
    int cityNum;
    ll id;
    int prefNum;
    ll year;
};

int main() {
    int N, M;
    cin >> N >> M;
    vector<City> cityList(M);
    rep(i, M) {
        int p, y;
        cin >> p >> y;
        City c;
        c.cityNum = i;
        c.prefNum = p;
        c.year = y;
        cityList[i] = c;
    }

    auto func = [](City a, City b) {
        return ((a.prefNum == b.prefNum) ? a.year < b.year : a.prefNum < b.prefNum);
    };
    std::sort(cityList.begin(), cityList.end(), func);

    ll nowPref = 1;
    ll nowCity = 1;
    rep(i, M) {
        City &c = cityList[i];
        if (c.prefNum != nowPref) {
            nowPref = c.prefNum;
            nowCity = 1;
        }
        // cout << c.year << endl;
        // cout << nowPref * 1000000ll + nowCity << endl;
        c.id = nowPref * 1000000ll + nowCity;
        nowCity++;
    }

    auto func2 = [](City a, City b) {
        return a.cityNum < b.cityNum;
    };
    std::sort(cityList.begin(), cityList.end(), func2);
    rep(i, M) {
        char str[13];
        // cout << cityList[i].cityNum << endl;
        sprintf(str, "%012lld", cityList[i].id);
        cout << str << endl;
    }
}

Measured memory_bytes: 4608
#include <iostream>
#include <fstream>
#include <string.h>
#include <math.h>

using namespace std;

long long biggest_number(int a,int b){
    long long result = 1;
    for(int i = 2; i <= min(a,b);i++){
        if(a%i == 0 && b%i == 0) result = i;
    }
    return result;
}
int main(){
    long long a,b;
    cin >> a >> b;
    long long m = biggest_number(a,b);
    cout << a*b/m << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IL inline
#define _ 400005
#define ll long long
using namespace std ;
 
IL int gi(){
    int data = 0 , m = 1; char ch = 0;
    while(ch!='-' && (ch<'0'||ch>'9')) ch = getchar();
    if(ch == '-'){m = 0 ; ch = getchar() ; }
    while(ch >= '0' && ch <= '9'){data = (data<<1) + (data<<3) + (ch^48) ; ch = getchar(); }
    return (m) ? data : -data ; 
}
 
#define inf 2e18
 
int seqL[_] , seqR[_] , n , K , cov[_ << 2] , A[_] , B[_] , X[_] , xox , nL ;
ll Ans  , f[_] , SUM ; 

IL void PushDown(int o) {
	if(!cov[o]) return ;
	cov[o << 1] = cov[o] ; cov[o << 1 | 1] = cov[o] ; cov[o] = 0 ; return ;
}
void Insert(int o , int l , int r , int ql , int qr , int v) {
	if(ql > qr) return ;
	if(ql <= l && r <= qr) {cov[o] = v ; return ; }
	int mid = (l + r) >> 1 ;
	PushDown(o) ;
	if(ql <= mid) Insert(o << 1 , l , mid , ql , qr , v) ;
	if(qr  > mid) Insert(o << 1 | 1 , mid + 1 , r , ql , qr , v) ;
	return ; 	
}
int Query(int o , int l , int r , int ps) {
	if(l == r) return cov[o] ;
	int mid = (l + r) >> 1 ; PushDown(o) ;
	return ps <= mid ? Query(o << 1 , l , mid , ps) : Query(o << 1 | 1 , mid + 1 , r , ps) ;
}
 
IL void Init() {
	n = gi() ; K = gi() ;
	for(int i = 1; i <= n; i ++) A[i] = gi() , B[i] = gi() ;
	for(int i = 1; i <= n; i ++) if(2 * A[i] > K && B[i] == 1) {puts("-1") ; exit(0) ; } 
	for(int i = 1; i <= n; i ++) SUM += A[i] , A[i] = (A[i] + A[i - 1]) % K  ;
	nL = 0 ;
	for(int i = 1; i <= n; i ++)
		if(B[i] == 1) {
			seqL[i] = ((-2 * A[i - 1]) % K + K) % K ;
			seqR[i] = ((-2 * A[i]) % K + K) % K ; 
		}
		else seqL[i] = 0 , seqR[i] = K - 1 ; 
	for(int i = 1; i <= n; i ++) X[++xox] = seqL[i] , X[++xox] = seqR[i] ;
	sort(X + 1 , X + xox + 1) ; xox = unique(X + 1 , X + xox + 1) - X - 1 ;
	for(int i = 1; i <= n; i ++) {
		seqL[i] = lower_bound(X + 1 , X + xox + 1 , seqL[i]) - X ;
		seqR[i] = lower_bound(X + 1 , X + xox + 1 , seqR[i]) - X ; 
	}
	return ;
}
 
IL int Dist(int u , int v) {if(v >= u) return v - u ; else return v + K - u ; }
 
int main() {
	Init() ; 
	f[n + 1] = 0 ;
	seqL[n + 1] = seqL[n] ; 
	Insert(1 , 1 , xox , 1 , xox , n + 1) ;
	for(int i = n,v; i >= 1; i --) {
		f[i] = f[v = Query(1 , 1 , xox , seqL[i])] + 1ll * (v <= n) * Dist(X[seqL[i]] , X[seqL[v]]) ;
		if(seqL[i] > seqR[i])  Insert(1 , 1 , xox , seqR[i] + 1 , seqL[i] - 1 , i) ;
		else {
			Insert(1 , 1 , xox , 1 , seqL[i] - 1 , i) ;
			Insert(1 , 1 , xox , seqR[i] + 1 , xox , i) ; 
		} 
	}
	Ans = inf ;
	for(int i = 1,v; i <= xox; i ++) 
		Ans = min(Ans , f[v = Query(1 , 1 , xox , i)] +  1ll * (v <= n) * Dist(X[i] , X[seqL[v]])) ;
	Ans = Ans + 2ll * SUM ;
	cout << Ans << endl ; return 0 ; 
}


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	int N; SCD(N);
	static int p[20002];
	static int a[20002];
	static int b[20002];
	
	ARSCD1(p,N);
	int r[20002];
	FORq(i,1,N){
		r[p[i]] = i;
	}
	
	FORq(i,1,N){
		a[i] = 30000*i;
		b[i] = 30000*(N-i)+r[i];
	}
	
	FORq(i,1,N-1){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[N]);
	
	FORq(i,1,N-1){
		printf("%d ",b[i]);
	}
	printf("%d\n",b[N]);
	
	return 0;
}

Measured memory_bytes: 896