akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int k;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        k = sc.nextInt();
        int ans = 1;

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

        System.out.println(ans);
    }

    int plusOrTimes(int num){
        int plus = num + k;
        int times = num * 2;

        if(plus > times){
            return times;
        } else {
            return plus;
        }
    }
}

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

#define Pair make_pair
#define Push push_back
typedef long long lli;
typedef pair<lli,lli> pll;
typedef vector<lli> vcL;
typedef vector<pll> vPL;


void solve() {
	lli a, b;
	cin >> a >> b;
	
	if ( a >= 13 ) cout << b << '\n';
	else if ( a >= 6 ) cout << b/2 << '\n';
	else cout << 0 << '\n';
	
	return;
}

int main() {
	int t = 1;
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
def main():
    a, b, c = map(int, input().split())

    count = 0
    while True:
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            print(count)
            break
        elif a == b == c:
            print(-1)
            break
        count += 1
        i, j, k = a / 2, b / 2, c / 2
        a, b, c = j + k, k + i, i + j


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[]) {
	int a=0;
	int b=0;
	while(scanf("%d%d", &a, &b)!=EOF){ 
	int init_a = a;
	int init_b = b;
	int gcd=0;
	int i=0;
	int temp;
	for(i=0; i<init_a+init_b; i++){
		temp = b;
		b = a%b;
		a = temp;
		if(b == 0){
			gcd = a;
			break;
		}
	}
	int lcm = init_a/gcd*init_b;
	printf("%d %d\n", gcd, lcm);
} 
	return 0;
}


Measured memory_bytes: 1976
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,m,lim;
ll a[15][15],b[15],c[15];

ll solve(int sta)
{
    ll ans=0;
    rep(i,1,m) b[i]=0;
    rep(i,1,n)
    {
        if ((sta>>(i-1))&1)
        {
            ans+=c[i];
            rep(j,1,m) b[j]+=a[i][j];
        }
    }
    rep(i,1,m)
        if (b[i]<lim) return 1e18;
    return ans;
}

int main()
{
    n=read();m=read();
    lim=read();
    rep(i,1,n) 
    {
        c[i]=read();
        rep(j,1,m) a[i][j]=read();
    }
    ll ans=1e18;
    rep(i,0,(1<<n)-1)
        ans=min(ans,solve(i));
    if (ans>=1e18) ans=-1;
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	int M = sqrt(N * 2);
	if ((2 * N) % M == 0 && 2 * N / M == M + 1) {
		cout << "Yes" << endl;
		cout << M + 1 << endl;
		vector<vector<int>> Ans(M + 1, vector<int>(M));
		for (int i = 0; i < M; i++) Ans[0][i] = i + 1;
		int last = M + 1;
		for (int i = 1; i < M + 1; i++) {
			for (int j = 0; j < i; j++) Ans[i][j] = Ans[j][i - 1];
			for (int j = i; j < M; j++) {
				Ans[i][j] = last;
				last++;
			}
		}
		for (int i = 0; i < M + 1; i++) {
			cout << M << " ";
			for (int j = 0; j < M; j++) cout << Ans[i][j] << (j < M - 1 ? " " : "\n");
		}
	}
	else cout << "No" << endl;

}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;

inline ll read()
{
	int x = 0,w = 1;char c = getchar();
	while (c < '0' || c > '9'){if (c == '-') w = -1;c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0',c = getchar();
	return x * w;
}

ll x,y;

int main() 
{
	x = read(),y = read();
	if (x % y == 0)
	{
		printf("-1");
		return 0;
	}
	for (int i = 1; i * x <= 1000000000000000000; ++i)
		if (i * x % y)
		{
			printf("%lld",i * x);
			return 0;
		}
	printf("-1");
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
	
		MyScanner sc = new MyScanner();
		int n=sc.nextInt();
		int m=sc.nextInt();
		int x[]=new int[m];
		for(int i=0;i<m;i++) {
			x[i]=sc.nextInt();
		}
		int ans=0;
		if(n<m) {
			Arrays.sort(x);
			int dx[]=new int[m-1];
			for (int j=0;j<m-1;j++) {
				dx[j]=x[j+1]-x[j];
			}
			Arrays.sort(dx);
			for(int l=0;l<m-n;l++) {
				
				ans+=dx[l];
			}
		}
		System.out.println(ans);
	}
	
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

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

	}
	

}





Measured memory_bytes: 35188
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll t=0,b=0,c=0,d=0,n,min=100000000000,k,ans=0;
    string s,s2;
    cin >> n;
    for(int i=1;i<10;i++){
        if(n<=111*i){
            cout << 111*i <<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define len(array) (sizeof(array) / sizeof(array[0]))
#define asort(array) sort(array, array + len(array))

int main() {
  int n,m;cin>>n>>m;
  vector<int> an(n,0), bn(n,0);
  int a,b;
  rep(i,m) {
    cin>>a>>b;
    if (a>b) swap(a,b);
    if (a == 1) an[b-1]=1;
    else if (b==n) bn[a-1]=1;
  }
  rep(i,n) {
    if (an[i]==1 && bn[i]==1) {
      cout<<"POSSIBLE";
      return 0;
    }
  }
  cout<<"IMPOSSIBLE";
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
#ifdef BOOST_RANGE_ALGORITHM_FOR_EACH_HPP_INCLUDED
  boost::for_each(vc, [&os](T value) {
#else
  std::for_each(vc.begin(), vc.end(), [&os](T value) {
#endif
    os << value << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;
  ui N{}; cin >> N;
  auto K = (ll)log10(N);
  assert(K <= 5);

  ull ans = K % 2 ? 0 : (N - (ull)std::pow(10, K) + 1);
  rep_sl_down(K - 1, -1)
  {
    if (i % 2 == 0)
    {
      ans += 9ULL * (ull)(std::pow(10, i));
    }
  }

  using std::cout;
  cout << ans << '\n';
  return;
}

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

  solve();

  return 0;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  
  int ans;
  if (A < 0 or B < 0 or A > 9 or B > 9){
  	ans = -1;
  } else {
  	ans = A * B;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,sum=0;
    cin>>n;
    lli a[n];
    for (int i=0;i<n;i++)
    cin>>a[i];
    for (int i=0;i<n-2;i++)
    {
        for (int j=i+1;j<n-1;j++)
        {
            if (a[i]==a[j])
            continue;
            for (int k=j+1;k<n;k++)
            {
                if (a[k]==a[j]||a[i]==a[k])
                continue;
                if (a[i]+a[j]<=a[k])
                continue;
                if (a[i]+a[k]<=a[j])
                continue;
                if (a[j]+a[k]<=a[i])
                continue;
                //cout<<i<<" "<<j<<" "<<k<<"\n";
                sum++;
            }
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3704
h,w=[int(i) for i in input().split()]
s=[]

for i in range(h):
    s.append(input())

aaaaa=0
for i in range(h):
  for j in range(w):
     count=0

     if s[i][j]=="#":
        try:
            if s[i][j+1]=="#":
                count=1
        except: pass

        try:
            if s[i+1][j]=="#":
                count=1
        except: pass

        try:
            if s[i-1][j]=="#":
                count=1
        except: pass

        try:
            if s[i][j-1]=="#":
                count=1
        except: pass

        if count==0: aaaaa=1

if aaaaa==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
n,m=map(int,input().split())
IN,OUT={},{}
for _ in range(m):
    a,b=map(int,input().split())
    if a==1:
        if b in OUT:
            print("POSSIBLE")
            exit()
        else:IN[b]=1
    if b==n:
        if a in IN:
            print("POSSIBLE")
            exit()
        else:OUT[a]=1
print("IMPOSSIBLE")

Measured memory_bytes: 24176
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <limits>
#include <set>

int main()
{
    long long n{};
    std::cin >> n;
    std::cout << (n + 1) / 2 << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> s(H, vector<char> (W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> s.at(i).at(j);
        }
    }
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (s.at(i).at(j) == '.') {
                continue;
            }

            if (i - 1 >= 0 && s.at(i - 1).at(j) == '#') {
                continue;
            }  
            if (i + 1 < H && s.at(i + 1).at(j) == '#') {
                continue;
            }
            if (j - 1 >= 0 && s.at(i).at(j - 1) == '#') {
                continue;
            }
            if (j + 1 < W && s.at(i).at(j + 1) == '#') {
                continue;
            }
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
// 6/14 リアルタイム参加
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p[i];

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

    int res = 0;
    rep(i, K) {
        res += p[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 3624
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion

K = ri()
if K % 2 == 0:
    print((K // 2) ** 2)
else:
    print((K // 2) * (K // 2 + 1))

Measured memory_bytes: 65644
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
    int h,n;
    cin >> h >> n;
    int a[n];
    for(int i=0;i<n;++i) cin >> a[i];
    int sum=0;
    for(int i=0;i<n;++i) {
        sum+=a[i];
    }
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 640
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <algorithm>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define mod 1000000007
#define pii pair <int, int>
#define all(x) x.begin(), x.end()
#define FOR(i, x, y) for (int i = x; i <= y; i++)

using namespace std;

int n;
int v[5][150];
int main()
{
	cin >> n;
	
	FOR (i, 1, 2)
	FOR (h, 1, n)
	cin >> v[i][h];
	
	FOR (i, 1, 2) {
		FOR (h, 1, n)
			v[i][h] += max(v[i-1][h], v[i][h-1]);
	}
	
	cout << v[2][n];
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {
  static final Scanner in = new Scanner(System.in);
  static int N, K;

  static int[] a;
  static boolean dp[];

  public static void main(String[] args) throws Exception {
    N = in.nextInt();
    K = in.nextInt();
    a = new int[N];
    dp = new boolean[K + 1];

    for (int i = 0; i < N; i++) a[i] = in.nextInt();
    F();
    if (dp[K]) System.out.println("First"); else System.out.println("Second");
  }

  static boolean F(int k) {
    if (k < a[0]) return false;

    boolean win_state = false;
    for (int i = 0; i < N; i++) {
      if (k < a[i]) break;
      if (!F(k - a[i])) win_state = true;
    }

    return win_state;
  }

  static void F() {
    for (int k = 1; k <= a[0] && k <= K; k++) {
      dp[k] = false;
    }

    for (int k = a[0]; k <= K; k++) {
      boolean win_state = false;
      for (int i = 0; i < N; i++) {
        if(k < a[i])
          break;
        if (!dp[k - a[i]]) win_state = true;
      }
      dp[k] = win_state;
    }
  }
}


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

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n = 0;
    cin >> n;
    const int max = 2e5 + 5;
    int arr[max];
    memset(arr, 0, sizeof(arr));
    ll temp = 0;
    for(int i = 0; i < n -1; i++) {
        cin >> temp;
        arr[temp]++;
    }

    for(int i = 0; i < n - 1; i++) {
        cout << arr[i + 1] << endl;
        arr[i + 0] = 0;
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 4440
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 21
int w,h;
char map[MAX][MAX];
int dx[]={ 0, 1, 0,-1};
int dy[]={ 1, 0,-1, 0};
int count;
void search(int y,int x){
	//cout<<"now:("<<x<<","<<y<<")"<<endl;
	map[y][x]='#';
	for(int i=0;i<4;i++){
		int nextX=x+dx[i];
		int nextY=y+dy[i];
		//cout<<"next:("<<nextX<<","<<nextY<<")"<<endl;
		if(nextY<0||nextX<0||nextY>=h||nextX>=w || map[nextY][nextX]=='#')continue;
		++count;
		search(nextY,nextX);
	}
	return;
}
int main(){
	while(cin>>w>>h && (w||h)){
		int st_w,st_h;
		memset(map,' ',sizeof(map));
		for(int i=0;i<h;i++){
			cin>>map[i];
			for(int j=0;j<w;j++){
				if(map[i][j]=='@'){
					st_w=j;st_h=i;
				}
			}
		}
		count=1;
		search(st_h,st_w);
		cout<<count<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
struct Node{
  int key;
  struct Node *right, *left, *parent;
};
 
struct Node *root,*NIL;
 
void insert(int);
void inorder(struct Node *);
void preorder(struct Node *);
 
int main(){
  int comnum,i,z;
  char s[10];
  scanf("%d",&comnum);
 
  for(i=0; i<comnum; i++){
    scanf("%s",s);
    if(strcmp(s,"insert") == 0){
      scanf("%d",&z);
      insert(z);
    }
    else if(strcmp(s,"print") == 0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
 
void insert(int k){
  // x の親
  struct Node *y = NIL;
  //x = 'T の根'
  struct Node *x = root;
  struct Node *z;
 
  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while( x != NIL){
    y = x;// 親を設定
    if(z->key < x->key) 
      x = x->left;// 左の子へ移動
    
    else
      x = x->right;// 右の子へ移動
  } 
  
  z->parent = y;
  if(y == NIL)// T が空の場合
    root = z;
  else
    if(z->key < y->key )
      y->left = z;
    else 
      y->right = z;
  
}
 
void inorder(struct Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
 
void preorder(struct Node *u){
  if(u == NIL) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}



Measured memory_bytes: 25116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
constexpr ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    bool ok = 0;
    ll num = 0;
    REP(i,10000){
        if(i*(i-1) == 2*N){
            ok = 1;
            num = i;
        }
    }
    if(ok){
        vector<vector<ll>> A(num,vector<ll>(num-1));
        ll nu = 1;
        REP(i,num-1){
            REP(l,num-1-i){
                A[i][l+i] = nu+l;
            }
            REP(l,num-1-i){
                A[i+l+1][i] = nu+l;
            }
            nu += num-1-i;
        }
        cout << "Yes" << "\n";
        cout << num << "\n";
        REP(i,num){
            cout << num - 1 << " ";
            REP(l,num - 1)cout << A[i][l] << (l == num -2?"\n":" ");
        }
    }else{
        cout << "No" << "\n";
    }
}

Measured memory_bytes: 4696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int num;
  cin >> num;
  if(num == 0){
    cout << 0 << endl;
    return 0;
  }
  string ans = "";
  while(num != 0){
    int r = num % (-2);
    if(r < 0) r += 2;
    num = (num-r) / (-2);
    ans += (char)('0' + r);
  }
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}
    
  

Measured memory_bytes: 3580
#include <iostream>

using namespace std;

int main(void) {
    int A = 0;
    int B = 0;
    int result = 0;

    cin >> A >> B;

    if (13 <= A) {
        result = B;
    } else if (6 <= A && A <= 12) {
        result = B/2;
    } else {
        result = 0;
    }

    cout << result;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,i,count;
  scanf("%d %d %d",&a,&b,&c);
  for(i=a;i<=b;i++){
    if(c%i==0){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2080
def d_fennec_vs_snuke():
    from collections import deque
    N = int(input())
    Edges = [[int(i) for i in input().split()] for j in range(N - 1)]

    graph = [[] for _ in range(N)]
    for a, b in Edges:
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)

    def bfs(start, tree_size=N, tree=graph):
        """木のある頂点 start からの距離を求める (start は 0-origin)"""
        dist = [0] * tree_size
        is_visited = [False] * tree_size
        is_visited[start] = True

        queue = deque([start])
        while queue:
            current = queue.pop()
            for child in tree[current]:
                if is_visited[child]:
                    continue
                is_visited[child] = True
                dist[child] = dist[current] + 1
                queue.appendleft(child)
        return dist

    fennec_dist, snuke_dist = bfs(0), bfs(N - 1)
    fennec_point, snuke_point = 0, 0  # 各々が色を塗れたマスの数

    for fennec, snuke in zip(fennec_dist, snuke_dist):
        if fennec <= snuke:
            fennec_point += 1
        else:
            snuke_point += 1
    return 'Fennec' if fennec_point > snuke_point else 'Snuke'

print(d_fennec_vs_snuke())

Measured memory_bytes: 48272
n,k = map(int,input().split())
raw = list(map(int,input().split()))
num = 2**(n-1).bit_length()
seg1 = [0]*2*num
seg2 = [n]*2*num

def build(raw):
    for i in range(n):
        seg1[i+num-1] = raw[i]
        seg2[i+num-1] = raw[i]
    for i in range(num-2,-1,-1):
        seg1[i] = max(seg1[2*i+1],seg1[2*i+2])
        seg2[i] = min(seg2[2*i+1],seg2[2*i+2])
    return True

build(raw)
cnt = n-k+1

def query(seg,ele,segf,p,q):
    if q <= p:
        return False
    p += num - 1
    q += num - 2
    res = ele
    while q-p > 1:
        if not p%2:
            res = segf(res,seg[p])
        if q%2:
            res = segf(res,seg[q])
            q -= 1
        p //= 2
        q = (q-1)//2
    if p == q:
        res = segf(res,seg[p])
    else:
        res = segf(res,seg[p],seg[q])
    return res

def check(i):
    #print(i,query(seg1,0,max,i,i+k+1),query(seg2,n+1,min,i,i+k+1))
    return query(seg1,0,max,i,i+k+1) == raw[i+k] and query(seg2,n+1,min,i,i+k+1) == raw[i]

t = [0]*n
f = -1
c = -1
for i in range(n):
    if raw[i] > c:
        f += 1
    else:
        f = 0
    c = raw[i]
    t[i] = f

c2 = -1
for i in range(n-k):
    if t[i+k-1] - t[i] == k-1:
        c2 += 1
    elif check(i):
        cnt -= 1
if t[n-1] - t[n-k] == k-1:
    c2 += 1
if c2 >= 0:
    cnt -= c2
print(cnt)

Measured memory_bytes: 96288
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	
	int n = scan.nextInt();
	int m = scan.nextInt();
	int c = scan.nextInt();
	int[] b = new int[m];
	for(int i = 0; i < m; i++){
	    b[i] = scan.nextInt();
	}
	int[][] a = new int[n][m];
	for(int i = 0; i < n; i++){
	    for(int j = 0; j < m; j++){
		a[i][j] = scan.nextInt();
	    }
	}

	int count = 0;
	for(int i = 0; i < n; i++){
	    int sum = 0;
	    for(int j = 0; j < m; j++){
		sum += a[i][j]*b[j];
	    }
	    sum += c;
	    if(sum > 0){
		count++;
	    }else{
		//何もしない
	    }
	}

	System.out.println(count);
    }
}


Measured memory_bytes: 24276
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    double A = Math.log(N) / Math.log(K);
    for(int n = 0;n <= A ;n++){
      if(A < n+1 ){System.out.println( n+1 );};
    };
  }
}

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

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

	int n;
	cin >> n;

	vector<vector<int>> v(n, vector<int>(n));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> v[i][j];

	int M = (1 << n);
	vector<long long> cost(M);
	for(int i = 0; i < M; i++)
	{
		for(int j = 0; j < n; j++)
		{
			if(i & (1 << j))
			{
				for(int k = 0; k < j; k++)
				{
					if(i & (1 << k))
						cost[i] += v[j][k];
				}
			}
		}
	}

	vector<long long> dp(M);

	for(int i = 0; i < M; i++)
	{
		for(int j = i; j > 0; j = (j - 1) & i)
			dp[i] = max(dp[i], dp[i - j] + cost[j]);
	}

	cout << dp[M - 1] << "\n";
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

string a,b;
bool ok = true;

int main()
{

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

    cin >> a >> b;
    if( a.size()+1!=b.size() ){
        cout << "No";
        return 0;
    }
    for(ll i=0; i<a.size(); i++) ok&=( a[i]==b[i] );
    if( ok ){
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int n, k;
int a[200000], fn[300000], f[200000];

void md(int x) {
  while(x <= n + n + 1){
    fn[x]++;
    x = (x | (x - 1)) + 1;
  }
}

int sum(int x) {
  int s = 0;
  while (x >= 1) {
    s += fn[x];
    x = (x & (x - 1));
  }
  return s;
}

LL calc(int x) {
  for (int i=1; i<=n; i++) {
    if (a[i] <= x) f[i] = f[i-1] + 1;
    else f[i] = f[i-1] - 1;
  }
  for (int i=1; i<=n + n + 1; i++) fn[i] = 0;
  LL c = 0;
  md(f[0] + n + 1);
  for (int i=1; i<=n; i++) {
    c += sum(f[i] + n);
    md(f[i] + n + 1);
  }
  return c;
}

int main() {
  cin >> n;
  for (int i=1; i<=n; i++) cin >> a[i];
  LL all = 1ll * n * (n + 1) / 2;
  int l = 1, r = 1e9;
  while (r - l > 0) {
    int mid = (l + r) / 2;
    LL k = calc(mid);
    if (k < all /2 + 1) l = mid + 1;
    else r = mid;
  }
  cout << l << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#define INF 1e+9
using namespace std;

int main(){
	int n,a[100],b[100];
	int dp[100][100];
	cin >> n;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++) dp[i][j] = INF;
	}
	for(int i = 0;i < n;i++) {
		cin >> a[i] >> b[i];
		dp[i][i] = 0;
	}
	for(int i = 1;i < n;i++){
		for(int j = 0;j < n - i;j++){
			for(int k = 0;k < i;k++){
				dp[j][j + i] = min(dp[j][j + i],dp[j][j + k] + dp[j + k + 1][j + i] + a[j] * b[j + k] * a[j + k + 1] * b[j + i]);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep2(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i,0,n)
#define rep1(i, n) rep1(i,1,n+1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend() //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }


void func(long long A, long long B){
    rep(i, 10000) {
        if(i * 8/ 100 == A && i / 10 == B) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);

    long long A;
    std::cin >> A;
    long long B;
    std::cin >> B;
    func(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, l, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int n;
    cin >> n;
    vector<P> a(n);
    rep(i,n) cin >> a[i].first >> a[i].second;
    sort(a);
    double sum = 0;
    do{
        srep(i,0,n-1){
            double dis = 0;
            dis += sqrt(pow(a[i+1].first - a[i].first, 2) + pow(a[i+1].second - a[i].second, 2));
            sum += dis;
        }
    }while(next_permutation(a.begin(), a.end()));
    double p = 1;
    for(int i = n ; i >= 1 ; i--){
        p *= i;
    }
    cout << fixed << setprecision(15) << sum / p << endl;
 
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    var a = IntArray(100010)
    repeat(m){
        val (l,r) = readLine()!!.split(" ").map{it.toInt()}
        a[l]++
        a[r + 1]--
    }
    for(i in 1 .. n){
        a[i] += a[i - 1]
    }
    var ans = 0
    for(i in 1 .. n){
        if(a[i] == m) ans++
    }
    println(ans)
}


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

int main(){

    string s; cin >> s;
    if(s.size() == 2){
        if(s[0] == s[1]) cout << 1 << " " << 2 << endl;
        else cout << "-1 -1" << endl;
    }else{

        for(int i = 0; i < (int)s.size() - 2; i++){
            
            if(s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }

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

    }
    return 0;
}


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

long long A, B, C, D, ans;

inline long long gcd(int aa, int bb) {
	return bb ? gcd(bb, aa % bb) : aa;
}

int main() {
	cin >> A >> B >> C >> D;
	--A;
	ans += B / C + B / D - B / (C * D / gcd(C, D));
	ans -= A / C + A / D - A / (C * D / gcd(C, D));
	ans = (B - A) - ans;
	cout << ans << endl;
	return 0;
}

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

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine() ;
            if (S.Contains("a") && S.Contains("b") && S.Contains("c")) Console.WriteLine("Yes");
            else Console.WriteLine("No");
            
        }
    }
}


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

int main(void){
  int N,M,count=0;
  cin>>N>>M;
  vector<int>check;
  check.resize(M);
  for(int q=0;q<M;q++)check[q]=0;
  int x[31];

  //行列の作成
  vector<vector<int>>vvc;
  vvc = vector<vector<int>>(N,vector<int>(M,0));

  //行列に値を代入
  for(int i=0;i<N;i++){
    cin>>x[i];
    for(int t=0;t<x[i];t++){
      cin>>vvc[i][t];
    }
  }

  //checkの0~M-1に値を代入
  for(int k=1;k<=M;k++){
    for(int s=0;s<N;s++){
      for(int l=0;l<M;l++){
        if(vvc[s][l]==k)check[k-1]++;
      }
    }
  }

  //最終確認
  for(int w=0;w<M;w++){
    if(check[w]==N)count++;
  }
  cout<<count;
}


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

const int N = 310;
int tot;
vector<pair<int, int> > ans[2][2];

void dfs(int c[N * 2][N * 2], int x, int y, int n, int d, int col) {
	if (x > n || y > n || x < 0 || y < 0 || c[x][y] != -1) return;
	c[x][y] = col;
	for (int i = 0; i * i <= d && i <= n; i++) {
		int j = sqrt(d + 0.0 - i * i);
		while (j * j <= d - i * i) j++;
		j--;
		if (i * i + j * j != d) continue;
		dfs(c, x + i, y + j, n, d, col ^ 1);
		dfs(c, x + i, y - j, n, d, col ^ 1);
		dfs(c, x - i, y + j, n, d, col ^ 1);
		dfs(c, x - i, y - j, n, d, col ^ 1);
	}
}

int c[2][N * 2][N * 2];
void solve(int n, int d, int t) {
	for (int i = 0; i < n * 2; i++)
		for (int j = 0; j < n * 2; j++)
			if (c[t][i][j] == -1) dfs(c[t], i, j, n * 2 - 1, d, 0);
}

int main()
{
	int n, d1, d2;
	scanf("%d%d%d", &n, &d1, &d2);
    memset(c, -1, sizeof(c));
	solve(n, d1, 0);
	solve(n, d2, 1);
	for (int i = 0; i < 2 * n; i++)
		for (int j = 0; j < 2 * n; j++) {
			ans[c[0][i][j]][c[1][i][j]].push_back(make_pair(i, j));
		}
	tot = n * n;
	int maxn = 0, x = 0, y = 0;
    for (int i = 0; i < 2; i++)
		for (int j = 0; j < 2; j++)
            if (ans[i][j].size() > maxn) maxn = ans[i][j].size(), x = i, y = j;
	for (int i = 0; i < ans[x][y].size() && i < tot; i++)
		printf("%d %d\n", ans[x][y][i].first, ans[x][y][i].second);
	return 0;
}


Measured memory_bytes: 40664
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();
        int ans=0;
        
        for(int i=0; i<n; i++){
            if(s.charAt(k-1)==s.charAt(i)){
                System.out.print(s.charAt(i));
            }else{
                System.out.print('*');
            }
        }
		
	}
}


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

const ll p = 1e9+7;
const ll M = 3005;

ll n, m, tot;
ll dp[M][M];

int main() {
	cin >> n >> m;
	//want sequences of m-1 things that stay within range n-1
	for (int i = 0; i < n; ++i)
		dp[0][i] = 1;
	for (int j = 0; j <= m-2; ++j)
		for (int i = 0; i < n; ++i) {
			dp[j+1][i] = (dp[j+1][i] + 2*dp[j][i])%p;
			if (i > 0)
				dp[j+1][i-1] = (dp[j+1][i-1] + dp[j][i])%p;
			if (i < n-1)
				dp[j+1][i+1] = (dp[j+1][i+1] + dp[j][i])%p;
		}

	for (int i = 0; i < n; ++i)
		tot = (tot + dp[m-1][i])%p;
	n--;
	memset(dp, 0, sizeof(dp));
	
	for (int i = 0; i < n; ++i)
		dp[0][i] = 1;
	for (int j = 0; j <= m-2; ++j)
		for (int i = 0; i < n; ++i) {
			dp[j+1][i] = (dp[j+1][i] + 2*dp[j][i])%p;
			if (i > 0)
				dp[j+1][i-1] = (dp[j+1][i-1] + dp[j][i])%p;
			if (i < n-1)
				dp[j+1][i+1] = (dp[j+1][i+1] + dp[j][i])%p;
		}

	for (int i = 0; i < n; ++i)
		tot = (tot + p - dp[m-1][i])%p;

	cout << 4*tot%p << endl;
}

Measured memory_bytes: 70784
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s.at(0)==s.at(2))cout<<"No";
    else if(s.at(0)==s.at(1) && s.at(2)==s.at(3))cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N, M, K;
    cin >> N >> M >> K;
 
    for( int i = 0; i <= N; ++i )
    {
        for( int j = 0; j <= M; ++j )
        {
            if( i * j + ( N - i ) * ( M - j ) == K )
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<string>
#include<string.h>
#include<map>
#include<math.h>
using namespace std;

#define ll long long

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

template<class S, class T> inline void chmax(S &a, T b){ if (a < b)a = b; }
template<class S, class T> inline void chmin(S &a, T b){ if (a > b)a = b; }

int main(){
	int i, j;
	string s;
	cin >> s;
	string ans;
	int slen(0);
	for (int i = 0; i < s.size(); i++){
		if (s[i] == '0'){
			ans.push_back('0');
			slen++;
		}
		else if (s[i] == '1')
		{
			ans.push_back('1');
			slen++;
		}
		else if (slen>=1&&s[i] == 'B'){
			ans.pop_back();
			slen--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const x = input[0].split(" ").map(n => parseInt(n));
    for(let i = 0; i<5; i++){
        if(x[i] == 0) console.log(i+1)
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 29576
import numpy as np
n, m, q = input().split()
n, m, q = int(n), int(m), int(q)
s = np.zeros((501, 501))
 
for _ in range(m):
    l, r = input().split()
    l, r = int(l), int(r)
    s[l, r] += 1
    
"""
     1 2 3
    --------
1 | 1 2 3
2 | 1 0 1
"""
    
for i in range(1, n+1):
    for j in range(1, n+1):
        s[i, j] += s[i, j-1]
        
"""
     1 2 3
    --------
1 | 1 3 6
2 | 1 1 2
"""
        
for j in range(1, n+1):
    for i in range(1, n+1):
        s[i, j] += s[i-1, j]
        
"""
     1 2 3
    --------
1 | 1 3 6
2 | 2 4 8
"""
 
for _ in range(q):
    l, r = input().split()
    l, r = int(l), int(r)
    print(int(s[r, r] - s[r, l-1] - s[l-1, r] + s[l-1, l-1]))

Measured memory_bytes: 21124
#include<bits/stdc++.h>
using namespace std;
int main()
  {
     int k,l=0;
     string s;
     cin>>k;
     cin>>s;
     if(s.size()<=k)
     cout<<s;
     else
     for(int i=0;i<k;++i)
     {
         cout<<s[i];
         l=1;
     }
     if(l==1)
     cout<<"...";
     return 0;
  }

Measured memory_bytes: 3624
class A:

    def solve(self):
        s1 = input()
        s2 = input()
        print("Yes" if s1 == s2[:-1] else "No")

class B:

    def solve(self):
        A, B, C, K = tuple(map(int, input().split(" ")))
        sum = min(A, K)
        K -= A
        K -= B
        sum -= max(min(K, C), 0)
        print(sum)

B().solve()


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

int main(){
  int n;
  int red =0;
  int blue =0;
  string s;
  
  cin >> n;
  cin >> s;
  
  for(int i = 0; i < n; i++){
  	if(s[i] == 'R'){
      red = red + 1;
    }
    else{
      blue = blue + 1;
    }
  }
  
  if(red > blue){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}
  

Measured memory_bytes: 256
class UnionFind(object):
  def __init__(self, n=1):
    self.par = [i for i in range(n)]
    self.rank = [0 for _ in range(n)]
    self.size = [1 for _ in range(n)]
  def find(self, x):
    if self.par[x] == x:
      return x
    else:
      self.par[x] = self.find(self.par[x])
      return self.par[x]
  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)
    if x != y:
      if self.rank[x] < self.rank[y]:
        x, y = y, x
      if self.rank[x] == self.rank[y]:
        self.rank[x] += 1
      self.par[y] = x
      self.size[x] += self.size[y]
  def is_same(self, x, y):
    return self.find(x) == self.find(y)
  def get_size(self, x):
    x = self.find(x)
    return self.size[x]

import sys
input = sys.stdin.readline

from heapq import heapify, heappop, heappush

N = int(input())
X = []; Y = []
for i in range(N):
  x,y = map(int,input().split())
  X.append((x,i));Y.append((y,i))
X.sort();Y.sort()
dx = [];dy =[]
for i in range(N-1):
  tx = X[i+1][0]-X[i][0]
  dx.append((tx,(X[i+1][1],X[i][1])))
  ty = Y[i+1][0]-Y[i][0]
  dy.append((ty,(Y[i+1][1],Y[i][1])))
heapify(dx);heapify(dy)
#print(dx,dy)
visited = set([])
ans = 0
uf = UnionFind(N)
while uf.get_size(0) < N:
  if not dy or dx[0] <= dy[0]:
    cost, loc = heappop(dx)
  else:
    cost, loc = heappop(dy)
  if uf.is_same(loc[0],loc[1]): #すでに接続済みのところはスキップ
    continue
  ans += cost
  #print(cost)
  uf.union(loc[0],loc[1])
print(ans)

Measured memory_bytes: 131980
#!/usr/bin/perl

use strict;
use warnings;

my $n = <STDIN>;
my $s = <STDIN>;

my $ans = 0;
for (my $i=0; $i<10; $i++) {
    my $a = index($s, $i);
    next if $a<0 || $a>=length($s)-2; 
    for (my $j=0; $j<10; $j++) {
        my $b = index(substr($s, $a+1), $j);
        next if $b<0 || $b>=length(substr($s, $a+1))-1; 
        for (my $k=0; $k<10; $k++) {
            my $c = index(substr(substr($s, $a+1), $b+1), $k);
            next if $c<0 || $c>=length(substr(substr($s, $a+1), $b+1)); 
            $ans++;
        }
    }
}

print "$ans\n";

Measured memory_bytes: 1024
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;


int main(void){
    // Your code here!
    int n;
    cin >> n;
    
    vector<int> v(n);
    vector<int> c(n);
    
    FOR(i,0,n) cin >> v[i];
    FOR(i,0,n) cin >> c[i];
    
    int ans = 0;
    FOR(i,0,n){
        if (v[i] - c[i] > 0) ans += v[i] - c[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x;
		for(int i=3; i<=n; i++){ 
		x = i;
		if(x%3==0){
		System.out.print(" " + i);
		continue;}             
		while(x!=0){
		if(x%10==3){
		System.out.print(" " + i);
		break;}
		x /= 10;}}
		System.out.println();
	}
}

Measured memory_bytes: 24272
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(ll n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
     mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint 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];
}
int main(){
  int n;
  cin>>n;
  V<ll> a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(all(a));
  mint ans=0;
  for(int i=0;i<n;i++){
    int r=n-i-1;
    mint d=mint(2).pow(r);
    if(i!=n-1)d+=mint(2).pow(r-1)*mint(r);
    d*=mint(2).pow(i);
    ans+=d*mint(a[i]);
  }
  ans*=mint(2).pow(n);
  cout<<ans<<"\n";
}

Measured memory_bytes: 48640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long power = 1;
		long a = 1000000007;
		for(int i = 1; i <= n; i++) {
			power = (power * i) % a;
		}
		System.out.println(power);
	}
}

Measured memory_bytes: 21844