akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N := sc.nextInt()
	pfs := make(map[int]int)
	for i := 1; i <= N; i++ {
		pfs = primeFactors(i, pfs)
	}
	var n3, n5, n15, n25, n75 int
	for _, num := range pfs {
		num++
		if 75 <= num {
			n75++
		} else if 25 <= num {
			n25++
		} else if 15 <= num {
			n15++
		} else if 5 <= num {
			n5++
		} else if 3 <= num {
			n3++
		}
	}
	sum := n75 + n25 + n15 + n5 + n3
	var ans int
	ans += n75
	ans += (n75 + n25) * (sum - 1)
	ans += (n75 + n25 + n15) * (sum - n3 - 1)
	ans += ((sum - n3) * (sum - n3 - 1) / 2) * (sum - 2)

	fmt.Fprintln(wtr, ans)
}

func primeFactors(n int, pfs map[int]int) map[int]int {
	for n%2 == 0 {
		pfs[2]++
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i]++
			n = n / i
		}
	}
	if n > 2 {
		pfs[n]++
	}

	return pfs
}


Measured memory_bytes: 640
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N, M = IL()
s = S()[::-1]

ans = []

now = 0
while True:
  if 0 <= now + M <= N:
    for num in range(1,M+1)[::-1]:
      if s[now + num] == "1":
        continue
      else:
        ans.append(num)
        now += num
        break
    else:
      print(-1)
      exit()
    continue
  else:
    if N - now == 0:
      pass
    else:
      ans.append(N - now)
    break

print(*ans[::-1])

Measured memory_bytes: 50416
import copy
A = []
N = int(input())
for i in range(N):
  A.append(int(input()))
l1 = copy.copy(A)
l1.sort()
for i in range(N):
  if A[i] == l1[N-1]:
    print(l1[N-2])
  else:
    print(l1[N-1])

Measured memory_bytes: 14560
N,K=map(int,input().split())
P=list(map(int,input().split()))
total=sum(P[:K])
maximum=sum(P[:K])
num=0
for i in range(N-K):
    m=total-P[i]+P[i+K]
    if m>=maximum:
        num=i+1
        maximum=m
    total=m
print(sum([1+(p-1)*0.5 for p in P[num:num+K]]))


Measured memory_bytes: 25060
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
int cx[105],cy[105],cr[105];
int vx[105],vy[105];
//
//initialization finish


// your function is here
//

//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
	int ans = 0;
	if(a + b < c*2) //a,bのみで構築
	{
		ans = a*x + b*y;
	}
	else
	{
		int cc = min(x,y);
		ans = c*cc*2;

		if(x == cc)
		{
			if(b < 2*c)
			{
				ans += b*(y-cc);
			}
			else
			{
				ans += c*(y-cc)*2;
			}
		}
		else
		{
			if(a < 2*c)
			{
				ans += a*(x-cc);
			}
			else
			{
				ans += c*(x-cc)*2;
			}
		}
	}

	Print(ans);
	//
	// your code finished


	return 0;
}

Measured memory_bytes: 256
def prison():
    N, M = (int(i) for i in input().split())
    L_max = 0
    R_min = float("inf")
    for _ in range(M):
        L, R = (int(i) for i in input().split())
        L_max = max(L, L_max)
        R_min = min(R, R_min)
        result = max(R_min - L_max + 1, 0)
    return result


print(prison())

Measured memory_bytes: 47848
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
    //cout << fixed << setprecision(8);
   
    double A, B, T; cin >> A >> B >> T;
    
    int a=0;
    for(int i=1; A*i<=T+0.5; i++){
        a += B;
    }
    cout << a << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    
    for(int i = 0;i < (1 << n);++i){
        cout << i << ":";
        for(long j = 0;j < n;++j){
            if(i & (1 << j)){
                cout << " " << j;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3104
#include <cstdio>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;
int main() {
    int n, m; scanf("%d%d", &n, &m);
    vector<vector<int> > g(n);
    repeat (i,m) {
        int a, b; scanf("%d%d", &a, &b); -- a; -- b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    bool result = true;
    repeat (i,n) {
        if (g[i].size() % 2 == 1) {
            result = false;
        }
    }
    printf("%s\n", result ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int d;
  cin>>d;
  vector<int> c(26);
  for (int i = 0; i < 26; ++i)
  {
    cin>>c[i];
  }
  vector<vector<int>> s(d,vector<int>(26));
  for (int i = 0; i < d; ++i)
  {
    for (int j = 0; j < 26; ++j)
    {
      cin>>s[i][j];
    }
  }
  vector<int> last(26,0);
  for (int i = 0; i < d; ++i)
  {
    vector<int> diff(26,0);
    for (int tmp = 0; tmp < 26; ++tmp)
    {
      last[tmp]=i+1;
      diff[tmp]=s[i][tmp];
      for (int j = 0; j < 26; ++j)
      {
         diff[tmp]-=c[j]*(i+1-last[j]);
      }
    }
    for (int j = 0; j < 26; ++j)
    {
      if(diff[j]==*max_element(diff.begin(), diff.end()))
      {
        cout<<j+1<<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 3680
#include<cstdio>
#define MAX(x,y) ((x>y)? x:y)
#define MIN(x,y) ((x<y)? x:y)

long long int a,b,g,h;

int f(long long int x,long long int y)
{
	if(y==0) return x;
	else return f(y,x%y);
}

int main()
{
	while(scanf("%ld%ld",&a,&b)!=EOF)
	{
		g = f(MAX(a,b),MIN(a,b)); 
		h = (a/g)*b;
		printf("%ld ",g);
		printf("%ld\n",h);
	}
	return 0;
}

Measured memory_bytes: 0
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

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

const ld PI = 3.14159265358979323846;

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

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 3e5+5;
int dp[2][N];
class CAttention {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in>>n;
		string s; in>>s;
        dp[0][0] = dp[1][0] = 0;
        // 1 -> West, 0->East
        rep(i, 1, n){
            dp[0][i] = dp[0][i-1];
            dp[1][i] = dp[1][i-1];
            if(s[i-1]=='E') ++dp[0][i];
            else ++dp[1][i];
        }
        int res = n-1;
        f(i, n){
            int change = dp[1][i] + dp[0][n] - dp[0][i+1];
            res = min(res, change);
        }
        out<<res;
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	CAttention solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef DEBUG
    //    freopen("solution.out", "w", stdout);
        freopen("1.in", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    set<int> snukes;
    int d, snuke;
    for (int i = 0; i < 2 * k; ++i) {
        cin >> d;
        for (int j = 0; j < d; ++j) {
            cin >> snuke;
            snukes.insert(snuke);
        }
    }
    int solution = 0;
    for (int i = 1; i < n + 1; ++i) {
        if (!snukes.count(i)) {
            ++solution;
        }
    }
    cout << solution
    << "\n";
}


Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<list>
#include<deque>
#include<cmath>
#include<unordered_map>
#include<unordered_set>
#include<numeric>

using namespace std;

using ll = int64_t;

/// <summary>
/// 単純なcoutの時に使う
/// </summary>
#define co(a) cout<<a<<"\n"


/// <summary>
/// [beg, end)の範囲を，添え字indexでループするfor文に置換します
/// </summary>
#define rep(i,a) for(ll i=0; i<a; ++i)
#define reps(i, a, b) for(ll i = a; i < b; ++i)

/// <summary>
/// 迷路等で使う方向のベクトル
/// </summary>
const vector<ll> dx = { 0, 1, 0, -1 }, dy = { 1, 0, -1, 0 };

/// <summary>
/// デバッグ時に使う
/// </summary>
#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

///////////////////////////////////////////////////////////////////////////

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

	ll L, R;
	cin >> L >> R;

	ll ans = 2*1e9;

	if (R % 2019 == 0 || L + 2019 <= R) {
		cout << 0 << endl;
		return 0;
	}

	L %= 2019, R %= 2019;

	if (L >= R) {
		cout << 0 << endl;
		return 0;
	}
	
	for (ll i = L; i <= R - 1; ++i) {
		for (ll j = i + 1; j <= R; ++j) {
			ll hoge = i * j;
			hoge %= 2019;
			if (hoge < ans) {
				ans = hoge;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define ABS(x) (((x)<(0))?(-(x)):(x))

int main(void){
  int N,t,x,y,nx=0,ny=0,nt=0;
  int i,j,k,tmp;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d%d%d",&t,&x,&y);
    tmp=t-nt-(ABS(x-nx)+ABS(y-ny));
      if(tmp<0 || tmp%2){
	puts("No");
	return 0;
      }
  }
  puts("Yes");
  return 0;
}


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

int main() {
 
  int n;
  cin >> n;
  
  n %= 100;
  n %= 10;
  
  if (n == 3) cout << "bon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8)
    cout << "pon" << endl;
  else cout << "hon" << endl;
}


Measured memory_bytes: 3584
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int x, y, s;
	int chess[14][14]={0};
	while(scanf("%d,%d,%d", &x, &y, &s)!=EOF){
		x=x+2;
		y=y+2;
		if(s==1){
			chess[x][y]++;
			chess[x+1][y]++;
			chess[x-1][y]++;
			chess[x][y+1]++;
			chess[x][y-1]++;
		}
		else if(s==2){
			for(int i=x-1; i<=x+1; i++){
				for(int j=y-1; j<=y+1; j++)
					chess[i][j]++;
			}
		}
		else if(s==3){
			for(int i=x-1; i<=x+1; i++){
				for(int j=y-1; j<=y+1; j++)
					chess[i][j]++;
			}
			chess[x][y-2]++;
			chess[x][y+2]++;
			chess[x+2][y]++;
			chess[x-2][y]++;
		}
	}
	int c=0, m=0;
	for(int i=2; i<12; i++){
		for(int j=2; j<12; j++){
			if(chess[i][j]==0)
				c++;
			else{
				m=max(m, chess[i][j]);
			}
		}
	}
	printf("%d\n%d\n", c, m);
	return 0;
}


Measured memory_bytes: 2696
import Data.List
import Control.Monad

main = do
    [h,w,a,b] <- map read . words <$> getLine :: IO [Int]
    let ans1 = replicate a '0' ++ replicate (w-a) '1'
    let ans2 = replicate a '1' ++ replicate (w-a) '0'
    replicateM_ b $ putStrLn ans1
    replicateM_ (h-b) $ putStrLn ans2

Measured memory_bytes: 4876
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,k;
	cin>>n>>k;
	int r[500000][2];
	int x=0;
	int la;
	vector<int> v;
	for(int i=1;i*i<=n;++i)
	{
		r[x][0]=i;
		r[x][1]=i;
		++x;
		la=i;
		v.push_back(1);
	}
	// cout<<"!"<<endl;;
	++la;
	while(la<=n)
	{
		r[x][0]=la;
		int va=n/la;
		if(va==1)
		{
			r[x][1]=n;
			la=n+1;
		}
		else
		{
			r[x][1]=n/(va);
			la=n/(va)+1;
		}
		v.push_back(1);
		++x;
	}
	int mo=1000000007;
	for(int i=0;i<x;++i)
	{
		// cout<<r[i][0]<<" "<<r[i][1]<<"\n";
	}
	for(int i=2;i<=k;++i)
	{
		for(int j=1;j<v.size();++j)
		{
			v[j]=(v[j]*(r[j][1]-r[j][0]+1))%mo+v[j-1];
			v[j]%=mo;
		}
		reverse(v.begin(), v.end());
	}
	int ans=0;
	for(int i=0;i<x;++i)
	{
		ans+=(v[i]*(r[i][1]-r[i][0]+1))%mo;
		ans%=mo;
		// cout<<r[i]
		// cout<<ans<<"\n";
		// ans%=mo;
	}
	cout<<ans;
}

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

#define INF 1e9
using namespace std;

int main() {

    int A, B; cin >> A >> B;

    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        puts("IMPOSSIBLE");
    }
}

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

Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int a,b;
    cin >> a >> b;
    vector<string> vec;
    for(int i=0; i<a; i++){
        string s;
        cin >> s;
        vec.push_back(s);
    }
    for(int i =0; i<vec.size(); i++){
        cout << vec[i] <<endl;
        cout << vec[i] <<endl;
    }
}

Measured memory_bytes: 3620
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int w;
  while (cin >> w) {
    vi v(1, 1);
    int s = 1;
    for (int i = 1; s < w;) {
      i *= 3;
      s += i;
      v.pb(i);
    }
    cout << '+';
    for (int i = v.size() - 2; i >= 0; i--) {
      int x = v[i];
      if (s - x * 2 >= w) {
        s -= x * 2;
        cout << '-';
        continue;
      }
      if (s - x >= w) {
        cout << '0';
        s -= x;
        continue;
      }
      cout << '+';
    }
    cout << endl;
  }
}

Measured memory_bytes: 3168
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner scanner = new Scanner(System.in);
        long m = scanner.nextLong();
        long n = scanner.nextLong();
        int mod = 1000000007;

        System.out.println(pow(m, n, mod));
    }

    //return a^b mod M O(logB)
    private static long pow(long a, long b, int M) {
        long ret = 1;
        long tmp = a;
        while (b > 0) {
            if ((b & 1) == 1) ret = (ret * tmp) % M;
            tmp = (tmp * tmp) % M;
            b = b >> 1;
        }
        return ret;
    }
}


Measured memory_bytes: 26220
#include <iostream>
#include <algorithm>
#include <string>
#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
int main()
{
    string S;
    cin >> S;
    int H[100010];
    int N = S.length();
    int ki=0;
    int gu=0;
    rep(i, 0, N)
    {
        if (S[i] == '1')
        {
            if(i%2==0){ki++;}
            if(i%2!=0){gu++;}
        }
        else
        {
            if(i%2==0){gu++;}
            if(i%2!=0){ki++;}
        }
    }
    cout<<min(ki,gu)<<endl;
}

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

int N;
int h[100005];
int dp[100005];

int solve() {
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= N; i++) {
        dp[i] = min(
            dp[i-2] + abs(h[i] - h[i-2]),
            dp[i-1] + abs(h[i] - h[i-1])
        );
    }
    return dp[N];
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys

(n, m, l) = sys.stdin.readline().rstrip('\r\n').split(' ')
n = int(n)
m = int(m)
l = int(l)

a = []
b = []
c = []
for ii in range(n):
  a.append([int(x) for x in input().rstrip('\r\n').split(' ')])

for ii in range(m):
  b.append([int(x) for x in input().rstrip('\r\n').split(' ')])

for ii in range(n):
  c.append([])
  for jj in range(l):
    c[ii].append(0)
    for kk in range(m):
      c[ii][jj] += a[ii][kk] * b[kk][jj]
    c[ii][jj] = str(c[ii][jj])
  print(' '.join(c[ii]))



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

int main()
{
    int N;
    cin >> N;
    vector<int> bars(N);
    for (int i = 0; i < N; i++)
    {
        int L;
        cin >> L;
        bars.at(i) = L;
    }
    sort(bars.begin(), bars.end());
    ll answer = 0;
    for (int i = 0; i < N - 2; i++)
    {
        for (int j = i + 1; j < N - 1; j++)
        {
            int doubleLength = bars.at(i) + bars.at(j);
            auto ite = lower_bound(bars.begin(), bars.end(), doubleLength);
            if(ite == bars.end()){
                ite--;
            }
            while(*ite >= doubleLength){
                ite--;
            }
            int index = distance(bars.begin(), ite);
            answer += max(0, index - j);
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

vector<ll> dp;

int main(void) {
   ll N;
   cin>>N;
   ll h[N];
   rep(i,N) cin>>h[i];
   dp.resize(N,0);
   dp[0] = 0;
   dp[1] = abs(h[1]-h[0]);
   for (int i = 2; i < N;i++) {
      dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
   }
   // rep(i,N) cout<<dp[i]<<endl;
   cout<<dp[N-1]<<endl;





   return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    char a;
    cin >> a;
    if(a=='T'){
        a = 'A';
    }else if(a=='A'){
        a = 'T';
    }else if(a=='C'){
        a = 'G';
    }else{
        a = 'C';
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

x = input().split()
n = int(x[0])
m = int(x[1])

d = {}

ac = 0
pe = 0

c = Counter()

for i in range(m):
    k = input().split()
    pi = int(k[0])
    s = k[1]
    if pi in d:
        continue
    if s == "AC":
        ac += 1
        d[pi] = True
        pe += c[pi]
    else:
        c[pi] += 1

print("{} {}".format(ac, pe))

Measured memory_bytes: 15456
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
ll MOD=1e9+7;
#define INF 2*1e9
#define N 1000010
#define MAX_V 900010
using namespace std;
ll int inv[N],comb[N],prd[N],invprd[N];
void calc_inv(){
    inv[1]=1;
    rep2(i,2,N){
        inv[i]=((-(MOD/i)*inv[MOD%i])%MOD+MOD)%MOD;
    }
    return;
}
void calc_comb(ll int n){
    comb[0]=1;
    rep2(i,1,n){
        comb[i]=comb[i-1]*(n+1-i)*inv[i]%MOD;
    }
    return;
}
void calc_product(){
    prd[0]=prd[1]=1;
    invprd[0]=invprd[1]=1;
    rep2(i,2,N){
        prd[i]=i*prd[i-1]%MOD;
        invprd[i]=inv[i]*invprd[i-1]%MOD;
    }
    return ;
}
ll cmb(int a,int b){
    return prd[a]*invprd[b]%MOD*invprd[a-b]%MOD;
}
ll modpow(ll x,ll n){
    if(n==0) return 1;
    ll res=modpow(x*x%MOD,n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
main(){
    int n,m,x,y;
    cin>>n>>m>>x;
    cout<<max({10*x+n+m,n*10+m+x,n+10*m+x});
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int num;
  cin >> num;
  int* arg;
  arg = new int[num];
  for (int i=0; i<num; i++) {
    cin >> arg[i];
  }
  bool allEven = true;
  int counter = 0;
  while(allEven){
    for (int i=0; i<num; i++){
      if(arg[i] % 2 != 0){
        allEven = false;
        cout << counter;
        break;
      }else{
        arg[i] = arg[i] / 2;
      }
    }
    counter++;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
int main() {
	int n, k;
	int ans = 0;
	cin >> n >> k;
	int dis = 0;
	int d;
	rep(i, k) {
		cin >> d;
		dis |= (1 << d);
	}
	clog << bitset<10>(dis)<<endl;
	int cnt;
	bool can = true;
	for (; can == true; n++) {
		cnt = n;
		can = false;
		// clog << n << endl;
		while (cnt != 0) {
			can |= (dis & (1 << (cnt % 10)));
			cnt /= 10;
		}
		if (can == false) {
			cout << n << endl;
			return 0;
		}
	}
	//	cout <<n-1 << endl;
}

Measured memory_bytes: 3476
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#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 rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;
int table[10][10];


int main(){
	int n;
	while(cin >> n && n != 0){
		for(int i = 0; i < 10; i++){
			fill(table[i], table[i]+10, 10000000);
			table[i][i] = 0;
		}
		for(int i = 0; i < n; i++){
			int node1, node2;
			cin >> node1 >> node2;
			cin >> table[node1][node2];
			table[node2][node1] = table[node1][node2];
		}
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				for(int k = 0; k < 10; k++){
					table[j][k] = min(table[j][k], table[j][i] + table[i][k]);
				}
			}
		}
		int index = -1;
		int min = 1000000;
		for(int i = 0; i < 10; i++){
			if(table[i][0] == 10000000) break;
			int sum = 0;
			for(int j = 0; j < 10; j++){
				if(table[i][j] == 10000000) break;
				sum += table[i][j];
			}
			if(sum<min){
				min = sum;
				index = i;
			}
		}
		cout << index << " " << min << endl;
	}

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repc(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1001001001;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

//------------------------------------------------------//

int main(){
  int n, wmax;
  cin >> n >> wmax;
  vec<int> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  ll dp[n+1][wmax+1];
  rep(i, n+1){
    rep(j, wmax+1){
      dp[i][j] = 0;
    }
  }

  repc(i, 0, n-1){
    repc(j, 0, wmax){
      if(j-w[i] >= 0) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
      else dp[i+1][j] = dp[i][j];
    }
  }

  cout << dp[n][wmax] << endl;

  return 0;
}

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

const int MOD = 1000000007;
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a;}
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b;}

int main(){
    string s;
    cin >> s;

    int a=0,b=0;
    rep(i,s.length()){
        if(s[i]=='0')a++;
        else b++;
    }

    if(a>b)cout << b*2 << endl;
    else cout << a*2 << endl;

    return 0;
    
}






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

using namespace std ;
using namespace __gnu_pbds;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

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

const int N = 1e6 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;

int n, m ;
int dp[N] ;
string s  ;

int t[N*4] ;

void update(int v, int i, int j, int x, int y)
{
    if(i == j and j == x) { t[v] = y ; return ; }
    if(x < i or x > j) return ;
    int mid = i+j >> 1 ;
    update(v*2, i, mid, x, y); update(v*2 + 1, mid + 1, j, x, y);
    t[v] = min(t[v*2], t[v*2 + 1]);
}

int get(int v, int i, int j, int l, int r)
{
    if(i > r or j < l) return 1e9;
    if(i >= l and j <= r) return t[v] ;
    int mid = i+j  >> 1 ;
    return min(get(v*2, i, mid, l, r), get(v*2 + 1, mid + 1, j, l, r));
}

int main()
{
    fastio; cin >> n >> m ;
    cin >> s ;
    dp[n+1] = 0 ; for(int i = 1; i < N; i++) t[i] = 1e9 ; // update(1, 1, n+m, i, 1e9);
    // update(1, 1, n+m+1, n+1, 0);

    multiset < int > ms ; ms.insert(0);

    for(int i = n; i > 0; i--)
    {
        if(s[i-1] == '1') dp[i] = 1e9 ;
        else dp[i] = 1 + *ms.begin(); // get(1, 1, n+m+1, i+1, i + m);
        ms.insert(dp[i]); // update(1, 1, n+m+1, i, dp[i]);
        if((i+m) <= (n+1)) ms.erase(ms.find(dp[i+m]));
    }
    if(dp[1] >= N) {
        cout << -1 ;
        return 0 ;
    }
    int cnt = dp[1] - 1 ; int now = 1 ;
    for(int i = 1; i <= n+1; i++)
    {
        if(dp[i] == cnt) {
            cout << i - now << " " ;
            now = i ;
            cnt-- ;
        }
    }
}



Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  vector<long> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  long x = a.at(n-1);
  long comp = 0;
  long y;
  rep(i,n-1){
    long tmp = min(a.at(i),x - a.at(i));
    if(comp < tmp){
      comp = tmp;
      y = a.at(i);
    }
  }
  cout << x << " " << y << endl;
}


Measured memory_bytes: 1024
//HOW YOU DOI'N........................JT
//Could this code be more bad..........CB
//I know...............................MG
//Hii..................................RG
//Noooooooo............................RG
//I wish I could but I don't want to...PB

//That's what she said.................MS


#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vvl vector<vector<ll>>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(v.begin(),v.end())
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;

ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll min(ll a,ll b){if(a>=b)return b;return a;}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
ll nsum(ll n){return (1ll * n * (n + 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}

#define MAX_SIZE 100005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
			for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
	for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};





// Lets start ...


void solve(){
    string s,t;
    cin>>s>>t;
    ll mx=sz(s);
    fi(i,0,sz(s)-sz(t)+1){
        ll cur=0;
        fi(j,0,sz(t)){
            if(t[j]!=s[i+j])cur++;
        }
        mx=min(mx,cur);
    }
    cout<<mx;
    
}

int main(){
    //vector<int> primes;
    //Sieve(primes);
    
    fast
    ll tests=1,cnt=0;
    //cin>>tests;
    while(tests--){
        solve();
    }
    

    return 0;
    }

// Done:)




Measured memory_bytes: 3648
# -*- coding:utf-8 -*-
import sys
from fractions import gcd
from collections import Counter
def prime_factorization(n):
    """nを素因数分解する
    Return d(dict):
        素因数をキー、素因数の指数部を値とするディクショナリを返す
    Example:
        n=140 -> d = {2: 2, 5: 1, 7: 1}
    """
    d = Counter()
    m = 2
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
        m = m + 1 if m == 2 else m + 2  # m=3からは、m+=2する（偶数は明らかに素数ではないので）
    if n > 1:
        d[n] += 1
    return d

def solve():
    A, B = list(map(int, sys.stdin.readline().split()))
    cd = gcd(A, B)
    if cd == 1:  # コーナーケース
        print(1)
        return
    # (素因数分解の素因数の個数)+1が答え
    prime_d = prime_factorization(cd)
    print(len(prime_d)+1)
if __name__ == "__main__":
    solve()

Measured memory_bytes: 5076
#include<iostream>
#include<vector>
#include<string>
#include<utility>
using namespace std;
int main(){
  int n,k,leng,bp=-1,max=0,cnt=0,sum=0;
  char c;
  vector<pair<int,char>> group;
  string s;
  cin >> n >> k;
  cin >> s;
  c = s[0];
  leng=0;
  for(int i=0;i<s.length();i++){
    if(c!=s[i]){
      group.push_back(make_pair(leng,c));
      leng=1;
      c=s[i];
    }else{
      leng++;
    }
  }
  group.push_back(make_pair(leng,c));
  for(int i=0;i<group.size();i++){
    if(cnt==k&&group[i].second=='0'){
      bp=i;
      break;
    }
    sum+=group[i].first;
    if(group[i].second=='0'){
      cnt++;
    }
  }
  if(bp!=-1){
    max = sum;
    int up,down;
    for(int i=bp;i<group.size();i+=2){
      down = group[i-2*k].first;
      if((i-2*k-1)>=0) down+=group[i-2*k-1].first;
      up = group[i].first;
      if(i!=group.size()-1) up+=group[i+1].first;
      sum = sum + up - down;
      if(sum>max) max = sum;
    }
  }else{
    max = n;
  }
  cout << max << endl;
}



Measured memory_bytes: 1528
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >>n;

    unordered_set<string> hmap;
    rep(i, 0, n)
    {
        string s, ch;
        cin >> s >> ch; 
        if (s == "insert")
            hmap.insert(ch);
        else if (s == "find")
        {
            if (hmap.find(ch) != hmap.end())
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
    }

    return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

int main(){
  vector<int> p(2); cin >> p[0] >> p[1];

  int ans = 0;
  rep(i,2){
    if(p[i] == 1) ans += 300000;
    else if(p[i] == 2) ans += 200000;
    else if(p[i] == 3) ans += 100000;
  }

  if(p[0] == 1 && p[1] == 1) ans += 400000;

  cout << ans << endl;
}

Measured memory_bytes: 256
'''
Created on 2020/09/08

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  X,Y,Z,K=map(int,pin().split())
  A=list(map(int,pin().split()))
  B=list(map(int,pin().split()))
  C=list(map(int,pin().split()))
#   A.sort(reverse=True)
#   B.sort(reverse=True)
#   C.sort(reverse=True)

  d=[]
  for i in A:
    for j in B:
      d.append(i+j)
  d.sort(reverse=True)
  d=d[:K]
  ans=[]
  for k in d:
    for l in C:
      ans.append(k+l)
  ans.sort(reverse=True)
  for m in range(K):
    print(ans[m])
  return
main()



Measured memory_bytes: 217728
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    int K, A, B;
    cin >> K >> A >> B;
    FOR(i, A, B + 1){
        if(i % K == 0){
            PRINT("OK");
            return 0;
        }
    }
    PRINT("NG");
    return 0;

}

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

int main()
{
    long int a, b, gcd, lcm, amari, wara, wari;
 
    while(cin>>a>>b){
        wara=0;
        wari=0;
        amari=0;
        gcd=0;
        lcm=0;

        if (a > b){
            wara = a;
            wari = b;
        }
        else{
            wara = b;
            wari = a;
        }
        amari = wara % wari;
        while (amari != 0)
        {
            wara = wari;
            wari = amari;
            amari= wara % wari;
        }
        gcd = wari;
        lcm = a * b / gcd;
        cout<<gcd<<" "<<lcm<<endl;
    }
}

Measured memory_bytes: 3028
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  print((n+1)/2);
}


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

using namespace std;

int main() {

	int N;

	cin >> N;

	vector<string> a(N);

	for (auto &x : a)
		cin >> x;

	string T;
	cin >> T;

	a.push_back(T);

	vector<string> z(a);

	for(auto &x:a){
		string::size_type pos = x.find('?');
		while (pos != string::npos) {
			x.replace(pos, 1, "a");
			pos = x.find('?', pos + 1);
		}
	}

	for (auto &x : z) {
		string::size_type pos = x.find('?');
		while (pos != string::npos) {
			x.replace(pos, 1, "z");
			pos = x.find('?', pos + 1);
		}
	}

	sort(a.begin(), a.end());
	sort(z.begin(), z.end());

	int nz = find_first_of(z.begin(), z.end(), &T, &T + 1) - z.begin();
	int na = find_end(a.begin(), a.end(), &T, &T + 1) - a.begin();

	for (int i = nz; i <= na; i++) {
		cout << i + 1;
		if (i != na)
			cout << ' ';
	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
    int a,b,c,d,ans1,ans2;
    cin>>a>>b>>c>>d;
    if (a>b) ans1=b;
    else
    ans1=a;
    if (c>d) ans2=d;
    else
    ans2=c;
    int ans=ans1+ans2;
    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 ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;
		
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			if (s.equals("AC")) ac++;
			else if (s.equals("WA")) wa++;
			else if (s.equals("TLE")) tle++;
			else if (s.equals("RE")) re++;
		}
		
		System.out.println("AC x " + ac);
		System.out.println("WA x " + wa);
		System.out.println("TLE x " + tle);
		System.out.println("RE x " + re);

	}

}

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

int main(){

    long long int A,B,C,D;
    cin >> A >> B >> C >> D;

    long long int U,nC,nD,nCD,nCnD;
    U=B-A+1;
    nC = B/C-(A-1)/C;
    nD = B/D-(A-1)/D;
    nCD = B/(C/__gcd(C,D)*D)-(A-1)/(C/__gcd(C,D)*D);
    nCnD = nC+nD-nCD;

    cout << U - nCnD <<endl;

    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


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

    is_ok = True
    for i, b in enumerate(B, 1):
        if i < b:
            is_ok = False
    if not is_ok:
        print(-1)
        exit()

    ans = []
    for _ in range(N):
        for i in reversed(range(len(B))):
            if B[i] == i + 1:
                break
        ans.append(B[i])
        del B[i]

    ans = ans[::-1]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9160
#include <iostream>
#include <string>

using namespace std;

int main(){
  int n;
  string str1,str2;
  int t1=0,t2=0;

  while(cin>>n){
    for(int i=0;i<n; i++){
      cin>>str1>>str2;
      if(str1==str2){
	t1+=1;
	t2+=1;
      }
      //ato
      else if(str1<str2){
	t2+=3;
      }
      else if(str1>str2){
	t1+=3;
      }

    }
    cout <<t1<<" "<<t2<<endl;    
  }

  
  return 0;
}



Measured memory_bytes: 3192
N, K = map(int, input().split())
# セグメント木(min, max)
N += 1
N0 = 2**(N-1).bit_length()
INF = float('inf')
minST = [INF]*(2*N0)
def update_min(k, x):
  k += N0-1
  minST[k] = x
  while k >= 0:
    k = (k - 1) // 2
    minST[k] = min(minST[2*k+1], minST[2*k+2])
def query_min(l, r):
  L = l + N0; R = r + N0
  s = INF
  while L < R:
    if R & 1:
      R -= 1
      s = min(s, minST[R-1])
    if L & 1:
      s = min(s, minST[L-1])
      L += 1
    L >>= 1; R >>= 1
  return s

MINF = float('-inf')
maxST = [MINF]*(2*N0)
def update_max(k, x):
  k += N0-1
  maxST[k] = x
  while k >= 0:
    k = (k - 1) // 2
    maxST[k] = max(maxST[2*k+1], maxST[2*k+2])

def query_max(l, r):
  L = l + N0; R = r + N0
  s = MINF
  while L < R:
    if R & 1:
      R -= 1
      s = max(s, maxST[R-1])
    if L & 1:
      s = max(s, maxST[L-1])
      L += 1
    L >>= 1; R >>= 1
  return s

Ps = list(map(int, input().split())) + [-1]
sorted_lens = []
tmp = 0
prev = -1
for i, p in enumerate(Ps):
  update_min(i, p)
  update_max(i, p)
  if prev > p:
    tmp = 0
  tmp += 1
  sorted_lens.append(tmp)
  prev = p

ans = N-K
flag = False
for i in range(N-K):
  smin = query_min(i, i+K+1)
  smax = query_max(i, i+K+1)
  if (smin == Ps[i] and smax == Ps[i+K]) or (flag and sorted_lens[i+K] >= K):
    ans -= 1
  if sorted_lens[i+K-1] == K:
    flag = True

print(ans)

Measured memory_bytes: 131252
m=10**9+7
f=max
r=range
for _ in r(int(input())):
	x,y=sorted(map(int,input().split()))
	s=-1
	i=j=1
	while j<=x and i+j<=y:
		i,j=j,i+j
		s+=1
	if x==1 or y<3:print(1,x*y%m)
	else:
		a=max(0,(y-j)//i+1)+f(0,(x-j)//i+1)
		i=j=1
		for c in r(s):
			k,l=j,i+j*2
			for _ in r(s-c):k,l=l,k+l
			if x>=k:a+=f(0,(y-l)//k+1)
			if y>=k:a+=f(0,(x-l)//k+1)
			i,j=j,i+j
		print(s+1,a%m)

Measured memory_bytes: 80792
import collections

N = int(input())
a = list(map(int,input().split()))
su = sum(a)

Q = int(input())

c = collections.Counter(a)

for i in range(Q):
    arr = list(map(int,input().split()))
    B = arr[0]
    C = arr[1]

    if(C not in c):
        c[C] = 0

    num_B = c[B] # 配列に含まれるBの個数
    c[B] = 0
    c[C] += num_B
    # c[C] += c[B]
    # del c[B]

    # for key, cnt in c.items():
    #     sum -= items():
    #     sum += key*cnt

    su -= num_B * B # bのやつを減らす
    su += num_B * C # cのやつを増やすitems():

    print(su)

Measured memory_bytes: 94232