akhauriyash/Code-Regression huggingface dataset:
package main

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

var (
	sc = bufio.NewScanner(os.Stdin)
	mod int = 1e9 + 7
)

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := getInt()
	var as []int
	var bs []int
	var cs []int

	for i := 0; i < n; i++ {
		as = append(as, getInt())
	}

	for i := 0; i < n; i++ {
		bs = append(bs, getInt())
	}

	for i := 0; i < n-1; i++ {
		cs = append(cs, getInt())
	}

	sum := 0
	for i, a := range as {
		sum += bs[a-1]

		if i > 0 {
			if a - as[i-1] == 1 {
				sum += cs[as[i-1]-1]
			}
		}
	}

	fmt.Println(sum)
}

func getInt() int {
	sc.Scan()
	str := sc.Text()
	value, _ := strconv.Atoi(str)
	return value
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    box = set()

    for i in range(N):
        num = N -i
        sum_num  = 0
        for j in range(1, N//num +1):
            if j*num in box:
                sum_num += 1

        if As[num-1] != sum_num % 2:
            box.add(num)

    print(len(box))

    for item in box:
        print(item)

if __name__ == "__main__":
    resolve()


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

using namespace std;

int a[15][15], d;

bool check(int x, int y)
{
    long long res = 0;
    for(int i = 0; i < d; i ++)
        res += 1ll * (a[x][i] - a[y][i]) * (a[x][i] - a[y][i]);
    long long tmp = sqrt(res);
    return res - tmp * tmp == 0;
}

int main()
{
    int n;
    scanf("%d%d", &n, &d);
    for(int i = 0; i < n; i ++)
    {
        for(int j = 0; j < d; j ++) scanf("%d", &a[i][j]);
    }
    int res = 0;
    for(int i = 0; i < n; i ++)
        for(int j = i + 1; j < n; j ++) res += check(i, j);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 256
import sys
n1,n2 = list( map(int, input().split()) )
s1 = input()
s2 = input()

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

t = gcd(n1,n2)

re = n1*n2//t

x1 = re//n1
x2 = re//n2

step = x1*x2 // gcd(x1,x2)

ii = 0
while ii <re:
    j1 = ii // x1 
    j2 = ii // x2
    if s1[j1]!= s2[j2]:
        print(-1)
        sys.exit()
    ii+=step
print(re)

    




Measured memory_bytes: 40176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using E = System.Linq.Enumerable;
class Program
{
    static void Main(string[] args)
    {
        string[] temp = System.Console.ReadLine().Split(' ');
        int N = int.Parse(temp[0]);
        int M = int.Parse(temp[1]);
        string[] temp1 = System.Console.ReadLine().Split(' ');
        int[] target = new int[M];
        for (int i = 0; i < M; i++)
        {
            target[i] = int.Parse(temp1[i]);
        }
        Array.Sort(target);
        int[] distance = new int[target.Length];
        for (int i = 1; i < target.Length; i++)
        {
            distance[i] = target[i] - target[i - 1];
        }
        var dsDesc = E.Range(0, distance.Length).ToArray();
        Array.Sort(distance.ToArray(), dsDesc);
        Array.Reverse(dsDesc);

        var k = target.Last() - target.First() - dsDesc.Take(N - 1).Sum(x => distance[x]);
        Console.WriteLine(k);
    }
}

Measured memory_bytes: 19552
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << min(a, b) + min(c, d) << endl;
  system("pause");
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M = 998244353;
const ll inf = 1e18+5;
const ll INF=INT_MAX;
using namespace std;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}
ll arr[500000],st[500000];
void buildtree(int si,int ss,int se){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	buildtree(2*si,ss,mid);
	buildtree(2*si+1,mid+1,se);
	st[si]=min(st[2*si],st[2*si+1]);
}
int query(int si,int ss,int se,int qs,int qe){
	if(qs>se || qe<ss) //completely outside
		return INF;
	if(ss>=qs && se<=qe)
		return st[si];
	int mid=ss+(se-ss)/2;
	int l=query(2*si,ss,mid,qs,qe);
	int r=query(2*si+1,mid+1,se,qs,qe);
	return min(l,r);
}
void update(int si,int ss,int se,int qi){
	if(ss==se){
		st[si]=arr[ss];
		return;
	}
	int mid=ss+(se-ss)/2;
	if(qi<=mid) update(2*si,ss,mid,qi);
	else update(2*si+1,mid+1,se,qi);
	st[si]=min(st[2*si],st[2*si+1]);
}
void solve(){
	ll a,b,x,count=0;
	cin>>a>>b>>x;
	for(ll i=a;i<=b;i++) if(i%x==0) count++;
	cout<<count<<"\n";
 }
int main(){
	fast();
	solve();
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define intt long long int
#define intu unsigned long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846 
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
long long bpow(long long a, long long b, long long m) 
{
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
void go()
{
#ifndef ONLINE_JUDGE
  freopen("in.txt","r",stdin);
  freopen("out.txt","w",stdout);
  #endif
}
template<typename P> struct Cmp
{
    bool operator()(const P &p1, const P &p2)
    {
        if(p1.ss <= p2.ss) return true;
        //if(p1.ss>p2.ss && p1.ff==p2.ff) return p1.ss < p2.ss;
        //if(p1.ss<p2.ss && p1.ff==p2.ff) return p1.ss < p2.ss;
        return false;
    }
};


int main()
{
  fast_io
  go();
  string str;cin>>str;
  cout << str.substr(0,3);
}










Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int n, z = 0, ans = 100000000, fz = -1000000;
  string s;
  vector<int> sum, maxi;
  cin >> s;
  n = s.size();
  sum.resize(s.size() + 10);
  maxi.resize(sum.size());
  sum[0] = 0;
  for (int i = 0; i < s.size(); i++) {
    sum[i + 1] = sum[i];
    if (s[i] == '1') {
      sum[i + 1]++;
    } else {
      sum[i + 1]--;
    }
    z = max(z, sum[i + 1]);
  }
  maxi[n] = z;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '1') {
      maxi[i] = maxi[i + 1] - 1;
    } else {
      maxi[i] = min(z, maxi[i + 1] + 1);
    }
  }
  int cnt = 0;
  int mini = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1' || s[i] == '?' && maxi[i + 1] >= cnt + 1) {
      cnt++;
    } else {
      cnt--;
    }
    mini = min(mini, cnt);
  }
  ans = z - mini;
  z++;
  maxi[n] = z;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '1') {
      maxi[i] = maxi[i + 1] - 1;
    } else {
      maxi[i] = min(z, maxi[i + 1] + 1);
    }
  }
  cnt = 0;
  mini = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1' || s[i] == '?' && maxi[i + 1] >= cnt + 1) {
      cnt++;
    } else {
      cnt--;
    }
    mini = min(mini, cnt);
  }
  ans = min(ans, z - mini);
  cout << ans << endl;
}

Measured memory_bytes: 12136
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	long x=sc.nextLong();
boolean loop=true;
long i=1;
long now=0;
while(loop){
	now+=i;
i++;

	if(now>=x){
		loop=false;
	}
}
i--;
System.out.println(i);

	}}

Measured memory_bytes: 23124
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());
//		int[] a = new int[N-1];
//		int[] b = new int[N-1];
//		int[] p = new int[Q];
//		int[] x = new int[Q];
		int a,b,p,x;
		int idx;

		// 親-子リストのマップ
		HashMap<Integer, ArrayList<Integer>> pMap = new HashMap<Integer, ArrayList<Integer>>();
		// 値のマップ
		int[] value = new int[N+1];
		int[] counter = new int[N+1];

		ArrayList<Integer> childs;
		for (idx = 0; idx < N-1; idx++) {
			a = Integer.parseInt(sc.next());
			b = Integer.parseInt(sc.next());

			childs = pMap.get(a);
			if (childs == null) {
				childs = new ArrayList<Integer>();
				pMap.put(a, childs);
			}
			childs.add(b);
		}
		for (idx = 0; idx < Q; idx++) {
			p = Integer.parseInt(sc.next());
			x = Integer.parseInt(sc.next());
			counter[p] += x;
		}

		// 処理するノード、親の1をスタート
//		LinkedList<Integer> nodes = new LinkedList<Integer>();
//		nodes.add(1);
		int[] nodes = new int[N];
		nodes[0] = 1;

		int node;
		int pos = 0;
		int tailpos = 1;

		while(true) {
			node = nodes[pos++];
			// 自身のカウンター足す
			value[node] += counter[node];
			// 子を取得
			childs = pMap.get(node);
			if (childs != null) {
				// 子に親の合計を足す
				for (int ch : childs) {
					value[ch] += value[node];
					nodes[tailpos++] = ch;
				}
			}

			if (pos >= N) {
				break;
			}
		}

		for (idx = 1; idx < N+1; idx++) {
			System.out.print(value[idx] + " ");
		}

	}

}


Measured memory_bytes: 168544
#include <iostream>
#include <vector>
using ll = long long;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> C(N);
  for (int i = 0; i < N - 1; i++) {
    int a;
    std::cin >> a;
    C[a - 1]++;
  }
  for (auto&& v : C) std::cout << v << std::endl;

  return 0;
}

Measured memory_bytes: 3984
N = int(input())
S =input()

dic = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans = ''

for i in range(len(S)):
    ans += dic[(dic.index(S[i])+N)%26]

print(ans)

Measured memory_bytes: 40540
#include <iostream>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	string s,s1="",s2="";
	cin>>s;
	if(n%2==1){
		cout<<"No";
		return 0;
	}
	for(i=0;i<n/2;i++)s1+=s[i];
	for(i=n/2;i<n;i++)s2+=s[i];
	if(s1==s2)cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int q = sc.nextInt();

		Queue<Process> Q = new ArrayDeque<>();

		for (int i=0; i<n; i++) {
			Q.add(new Process(sc.next(), sc.nextInt()));
		}

		int t = 0;
		while (!Q.isEmpty()) {
			Process p = Q.poll();
			if (p.time<=q) {
				t += p.time;
				System.out.println(p.name + " " + t);
			} else {
				t += q;
				p.time -= q;
				Q.add(p);
			}
		}

		sc.close();
	}

	static class Process {
		String name;
		int time;
		public Process(String name, int time) {
			this.name = name;
			this.time = time;
		}
	}

}

Measured memory_bytes: 74400
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}


int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        if (a[i] % 2 == 1) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    int ans = 0;
    int flag = 1;
    while (flag) {
        rep(i,n) {
            a[i] /= 2;
            if (a[i] % 2 == 1) {
                flag = 0;
            }
        }
        ans++;
    }

    cout << ans << endl;
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int count=0, best=0;
	bool counting = false;
	for (char c: s){
		if (c == 'A' && !counting) {counting = true;}
		if (counting) {
			if (c == 'Z') { count++;best = count;}
			else count++;
			}
		}
	cout << best;
 }


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

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

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

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

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

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

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

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

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

using Data = pair<ll, vector<ll>>;

int main()
{
    cout << fixed << setprecision(15);
    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;

    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    
    REP(i, X){
        cin >> A[i];
    }
    REP(i, Y){
        cin >> B[i];
    }
    REP(i, Z){
        cin >> C[i];
    }

    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    
    priority_queue<Data> que;
    set<Data> se;

    que.push(Data(A[0] + B[0] + C[0], vector<ll>({0, 0, 0})));

    for(ll k=0; k<K; k++){
        auto c = que.top();que.pop();
        cout << c.first << endl;
        // cout << c.second[0] << " " << c.second[1] << " " << c.second[2] << endl;

        ll a1 = c.second[0];
        ll b1 = c.second[1];
        ll c1 = c.second[2];
        if(a1+1 < X){
            ll sum = c.first - A[a1] + A[a1+1];
            auto num = c.second;
            num[0]++;
            auto d = Data(sum, num);
            
            // すでに push されたもの以外
            if (!se.count(d)) se.insert(d), que.push(d);
        }
        if(b1+1 < Y){
            ll sum = c.first - B[b1] + B[b1+1];
            auto num = c.second;
            num[1]++;
            auto d = Data(sum, num);
            
            // すでに push されたもの以外
            if (!se.count(d)) se.insert(d), que.push(d);
        }
        if(c1+1 < Z){
            ll sum = c.first - C[c1] + C[c1+1];
            auto num = c.second;
            num[2]++;
            auto d = Data(sum, num);
            
            // すでに push されたもの以外
            if (!se.count(d)) se.insert(d), que.push(d);
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
using namespace std;
int Sum[2][2005][2005];
int N, K;
void solve(int a, int b, int &num1, int &num2,int i,int j	)
{
	num1 = Sum[a][i - 1][2 * K] - Sum[a][i - 1][j] + Sum[a][i - 1][j - K] + Sum[a][2 * K][j - K] - Sum[a][i + K - 1][j - K] + Sum[a][2 * K][2 * K] - Sum[a][i + K - 1][2*K] - Sum[a][2 * K][j] + Sum[a][i + K - 1][j] + Sum[a][i + K - 1][j] - Sum[a][i - 1][j] - Sum[a][i + K - 1][j - K] + Sum[a][i - 1][j - K];
	num2 = Sum[b][i - 1][j] - Sum[b][i - 1][j - K] + Sum[b][i + K - 1][j - K] - Sum[b][i - 1][j - K] + Sum[b][2 * K][j] - Sum[b][i + K - 1][j] - Sum[b][2 * K][j - K] + Sum[b][i + K - 1][j - K] + Sum[b][i + K - 1][2 * K] - Sum[b][i - 1][2 * K] - Sum[b][i + K - 1][j] + Sum[b][i - 1][j];
}

int main()
{
	
	scanf("%d %d", &N, &K);
	int x, y;
	char s[3];
	for (int i = 1;i <= N;i++)
	{
		scanf("%d %d %s", &x, &y, s);
		x = x % (2 * K), y = y % (2 * K);
		x++, y++;
		if (s[0] == 'B')
			Sum[0][x][y]++;
		else
			Sum[1][x][y]++;
	}
	for(int i=1;i<=2*K;i++)
		for (int j = 1;j <= 2 * K;j++)
		{
			Sum[0][i][j] += Sum[0][i - 1][j] + Sum[0][i][j - 1] - Sum[0][i - 1][j - 1];
		}
	for(int i=1;i<=2*K;i++)
		for (int j = 1;j <= 2 * K;j++)
		{
			Sum[1][i][j] += Sum[1][i - 1][j] + Sum[1][i][j - 1] - Sum[1][i - 1][j - 1];
		}
	int maxans = -1;
	for(int i=1;i<=2*K;i ++)
		for (int j = 1;j <= 2 * K;j++)
		{
		
			int ans = 0;
			int num1 = 0, num2 = 0;
			if (i <= K + 1 && j >= K)
				solve(0, 1, num1, num2, i, j);
			else if (i > K + 1 && j >= K)
				solve(1, 0, num2, num1, i - K, j);
			else if (i <= K + 1 && j < K)
				solve(1, 0, num2, num1, i, j + K);
			else
				solve(1, 0, num2, num1, i - K, j + K);
			ans = num1 + num2;
			maxans = max(ans, maxans);
		}
	cout << maxans << endl;

}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

int n, a[N];

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i ++ ) scanf("%d", &a[i]);
	sort(a, a + n);
	
	int t = a[n - 1];
	int x, v = 0x3f3f3f3f;
	for (int i = 0; i < n; i ++ )
		if (abs(t / 2 - a[i]) < v)
		{
			v = abs(t / 2 - a[i]);
			x = a[i];
		}
		else if (abs((t + 1) / 2 - a[i]) < v)
		{
			v = abs((t + 1) / 2 - a[i]);
			x = a[i];
		}
		
	printf("%d %d\n", t, x);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long h;
    cin >> h;
    long long waruni = 0;
    while(h != 1){
        h = ceil(h/2);
        waruni += 1;
    }
    long long ans = 0;
    for(int i = 0; i <= waruni; i++){
        ans += pow(2, i);
    }
    cout << ans;
}


Measured memory_bytes: 256
from sys import stdin
inf = 10**3
n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
point = 0
for i in range(m):
    d = [[inf for i in range(n)]for j in range(n)]
    lin = li[:i]+li[i+1:]
    for j in range(m-1):
        d[lin[j][0]-1][lin[j][1]-1] = 1
        d[lin[j][1]-1][lin[j][0]-1] = 1
    for k in range(n):
        d[k][k] = 0
    lis = warshall_floyd(d)
    for i in lis:
        i.sort()
        if i[-1] == inf:
            point += 1
            break
print(point)

Measured memory_bytes: 44016
#include <bits/stdc++.h>
using namespace std;
# define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll K,A,B;

    cin>>K>>A>>B;
    string ans = "NG";
    rep(i,B-A+1){
        if((A+i)%K==0){
            ans = "OK";
        }
    }

    cout<<ans<<"\n";
	
	return 0;
}


Measured memory_bytes: 3624
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

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

int main() {
    ll n;
    cin >> n;
    n--;
    int keta = 1;
    ll now = 0;
    ll power = 26;
    while(now + power <= n){
        now += power;
        power *= 26;
        keta++;
    }
    n -= now;
    vector<int> ord(keta, 0);
    REP(i, keta){
        ord[i] = n % 26;
        n /= 26;
    }
    string ans(keta, ' ');
    REP(i, keta){
        ans[i] = ord[keta-i-1] + 'a';
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;
public class Main{
	static int getK(int a,int b) {  
		int i,k=0;
		  i=a+b;
		    k=i/2;
		  return k ;
  } 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int a,b,i,k=1;
	Scanner scan=new Scanner(System.in);
	 a=scan.nextInt();
	 b=scan.nextInt();
    i=a+b;
    if(i%2==0) {
    System.out.println(getK(a,b));
   }
   else { 
   System.out.println("IMPOSSIBLE");
   }
	   }
	
	 }

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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int n;
	sf("%d", &n);
	int a[] = {2, 4, 5, 7, 9};
	if (n % 10 == 3) {
		puts("bon");
		return 0;
	}
	else {
		for (int i = 0; i < 5; ++i) {
			if (a[i] == n % 10) {
				puts("hon");
				return 0;
			}
		}
	}
	puts("pon");

	return 0;
}


Measured memory_bytes: 3804
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> A(9);
  for(int i = 0; i < 9; i++){
    cin >> A[i];
  }
  int N,b;
  cin >> N;
  for (int i = 0; i < N; i++){
    cin >> b;
    for(int i = 0; i < 9; i++){
      if(A[i] == b){
        A[i] = -1;
      }
    }
  }
  bool c = false;
  if(A[1] == A[2] && A[2] == A[0])
    c = true;
  if(A[4] == A[5] && A[5] == A[3])
    c = true;
  if(A[7] == A[8] && A[8] == A[6])
    c = true;
  if(A[1] == A[4] && A[4] == A[7])
    c = true;
  if(A[2] == A[5] && A[5] == A[8])
    c = true;
  if(A[3] == A[6] && A[6] == A[0])
    c = true;
  if(A[0] == A[4] && A[4] == A[8])
    c = true;
  if(A[2] == A[4] && A[4] == A[6])
    c = true;
  if (c)
    cout << "Yes";
  else
    cout << "No";  
}

Measured memory_bytes: 256
import sys

MOD = 10**9 + 7

def main():
    N = int(sys.stdin.readline().rstrip())
    A = [int(x) for x in sys.stdin.readline().rstrip().split()]

    Asum = sum(A)
    ans = 0
    for i in range(N-1):
        Asum -= A[i]
        Asum %= MOD
        ans += A[i] * Asum
        ans %= MOD
    
    print(ans)


main()

Measured memory_bytes: 31528
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;
 
 
int main()
{
  int a,b,c,d;
    scf(a),scf(b),scf(c),scf(d);


    for(int i=0;i<1e8;i++)
    {
      if(i%2==0)
      c-=b;

      if(c<=0)
      {
        printf("Yes\n");
        break;

      }  

      if(i&1)
      a-=d;

      if(a<=0)
      { 
       printf("No\n"); 
       break;
     } 

    }
 
      
}

Measured memory_bytes: 3684
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

int main() {
	int n; cin >> n;
	vector<int> a(n); for (int i = 0; i < n; ++ i) cin >> a[i];
	sort(a.begin(), a.end());
	long long ret = 0;
	int cur = a[0];
	int count = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] == cur) {
			count++;
		} else {
			if (count > cur) {
				ret += count - cur;
			} else if (count < cur) {
				ret += count;
			}
			cur = a[i];
			count = 1;
		}
	}
	if (count > cur) {
		ret += count - cur;
	} else if (count < cur) {
		ret += count;
	}

	cout << ret << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = 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 vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, T;
    cin >> n >> T;
    vll t(n);
    rep(i, n){
        cin >> t[i];
    }
    ll c = 0;
    ll ans = 0;
    rep(i, n){
        ans += T;
        if(c > t[i]){
            ans -= c - t[i];
        }
        c = t[i] + T;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
def solve():
  n = int(input())
  s = input()
  dp = [[] for _ in range(4)]

  for i in range(n):
    number = s[i]
    

    for k in dp[2]:
      dp[3].append(k+number)
    for l in dp[1]:
      dp[2].append(l+number)  
    dp[1].append(number)
    
    for i in range(4):
      dp[i] = list(set(dp[i]))
  print(len(dp[3]))
    
      
solve()

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int x = nextInt();
		int a = nextInt();
		int b = nextInt();

		String ans ="A";
		if(Math.abs(x-a)>Math.abs(x-b)){
			ans="B";
		}

		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21332
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String s=sc.next();int f=0;
for(int i=0;i<3;i++)
{
if(s.charAt(i)==s.charAt(i+1))
{
f=1;
break;
}
}
if(f==1)
System.out.println("Bad");
else
System.out.println("Good");
}}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
#define     infn            INT_MIN
const int sz=1e5+9;
string s,t;
int dp[3009][3009];

void lcs(int i,int j){
    if(i>=s.size()|| j>=t.size())return;
    if(dp[i][j]!=-1)return;
    if(s[i]==t[j]){
        lcs(i+1,j+1);
        dp[i][j]=1+max(0,dp[i+1][j+1]);

    }else{
        lcs(i+1,j);
        lcs(i,j+1);
        dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
        dp[i][j]=max(0,dp[i][j]);
    }
    return;
}



void solve(){
    reset(dp,-1);
     getline(cin,s);
     getline(cin,t);
     lcs(0,0);
     //cout<<dp[0][0];
  /*   for(int i=0;i<=s.size();i++){
        for(int j=0;j<=t.size();j++){
            cout<<dp[i][j]<<tab;
        }
        cout<<endl;
     }*/
     int i=0,j=0,temp=dp[i][j];
     if(temp==0){
        cout<<"\n\n";return;
     }
     while(true){

        if(dp[i][j+1]==temp){
            j++;continue;
        }
        if(dp[i+1][j]==temp){
            i++;continue;
        }
        if(temp==1){
            cout<<s[i];
            break;
        }
        if(dp[i+1][j+1]==temp-1){
            cout<<s[i];
            temp--,i++,j++;
            continue;
        }
     }
     cout<<"\n";
}



int main(){
/*    FasterIO;
    #ifndef ONLINE_JUDGE
        freopen("1.txt","r",stdin);
    #endif
    */
   // int t;
//  cin>>t;
 //   while(t--)
        solve();
}



Measured memory_bytes: 35968
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[213456];

signed main() {
	int n, k, b = 0, ans = 0; cin >> n >> k;
	int a = k - 1;
	for (int h = 0; h < n; h++) {
		cin >> test[h];
	}
	sort(test, test + n);
	vector<vector<long long>>aa(k, vector<long long>(2));
	for (int h = 0; h < k; h++) {
		cin >> aa[h][1] >> aa[h][0];
	}
	sort(aa.begin(), aa.end());
	for (int h = 0; h < n; h++) {
		if (b != 0 && test[h] < aa[a][0]) {
			test[h] = aa[a][0]; b--;
			if (a == 0 && b == 0) { break; }
			if (b == 0) { a--; }
		}
		if (b == 0 && test[h] < aa[a][0]) {
			test[h] = aa[a][0]; b = aa[a][1] - 1;
			if (a == 0 && b == 0) { break; }
			if (b == 0) { a--; }
		}
	}
	for (int h = 0; h < n; h++) {
		ans += test[h];
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a, b;
    while(cin >> a >> b && !cin.eof()) {
        if(b > a) swap(a, b);
        while(b) {
            int tmp = a % b;
            a = b;
            b = tmp;
        }
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	ll* l = new ll[n];
	rep(i, n) cin >> l[i];
	sort(l, l + n);

	int ans = 0;
	rep(i, n) {
		REP(j, i + 1, n) {
			if (l[j] == l[i]) continue;
			REP(k, j + 1, n) {
				if (l[j] != l[k] && l[k] < l[j]+l[i]) {
					++ans;
				}
			}
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

struct tuple {
    int x;
    int y;
};

int asc(const void *a, const void *b) {
    return ((struct tuple *)a)->y - ((struct tuple *)b)->y;
}


int main(void){
    int N;
    int x,l;
    scanf("%d", &N);
    struct tuple A[100000+10];
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &x, &l);
        A[i].x = x - l;
        A[i].y = x + l;
    }
    qsort(A,N,sizeof (struct tuple), asc);
    int now = -1100000000;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (now <= A[i].x) {
            now = A[i].y;
            cnt++;
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 3092
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <limits>
#include <numeric>
#include <string>
#include <type_traits>
#include <vector>
using namespace std;
int main() {
  string s;
  cin>>s;
  if(s=="ABC"){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"ABC"<<endl;
  }
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a =sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int ab=b-a;
        int bc=c-b;
        int ac=c-a;

        int rab=Math.abs(ab);
        int rbc=Math.abs(bc);
        int rac=Math.abs(ac);

        if((rac<=d)||(rab<=d&&rbc<=d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
    }
}

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

int main(){
    int a,b,c,d,e,sum=0,hitoketa=0;
    cin >> a >> b >> c >> d >> e;
    if(a%10!=0){hitoketa=max(hitoketa,10-(a%10));a = (a/10)*10+10;}
    else{hitoketa=max(0,hitoketa);}
    //cout << hitoketa << endl;
    if(b%10!=0){hitoketa=max(hitoketa,10-(b%10));b = (b/10)*10+10;}
    else{hitoketa=max(0,hitoketa);}
    //cout << hitoketa << endl;
    if(c%10!=0){hitoketa=max(hitoketa,10-(c%10));c = (c/10)*10+10;}
    else{hitoketa=max(0,hitoketa);}
    //cout << hitoketa << endl;
    if(d%10!=0){hitoketa=max(hitoketa,10-(d%10));d = (d/10)*10+10;}
    else{hitoketa=max(0,hitoketa);}
    //cout << hitoketa << endl;
    if(e%10!=0){hitoketa=max(hitoketa,10-(e%10));e = (e/10)*10+10;}
    else{hitoketa=max(0,hitoketa);}
    //cout << hitoketa << endl;
    cout << a+b+c+d+e-hitoketa << endl;
    return 0;
}

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

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

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

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

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

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

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

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

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

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

    cout << ll(pow(2,M) * ((1900*M) + (100*(N-M)))) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main (args:Array<String>) {
    val material = readLine()!!.toInt()
    val valueList = readLine()!!.split(" ").map(String::toDouble).sortedDescending()
    var stack = Stack<Double>()
    for (value in valueList){
        stack.push(value)
    }
    while (stack.size > 1){
        val a = stack.pop()
        val b = stack.pop()
        stack.push((a + b) / 2)
    }
    print(stack.pop())
}

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

bool is_match(vector<int> &s,vector<int>& t)
{
    rep(i,s.size())
    {
        if(s[i]!=t[i]) return false;
    }
    return true;
}

int main()
{
    int n;
    cin>>n;
    vector<int> p(n),q(n),z(n);
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    rep(i,n) z[i]=i+1;

    int a=0,b=0,now=1;
    do
    {
        if(is_match(p,z))a=now;
        if(is_match(q,z))b=now;
        now++;
    } while (next_permutation(z.begin(),z.end()));
    cout<<abs(a-b)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    std::deque<int> deq(n,-1);
    int m,s,c,flag=0;
    cin>>m;
    for (int i=0;i<m;i++) {
        cin>>s>>c;
        if (deq[s-1]==-1||deq[s-1]==c) {
            deq[s-1]=c;
            if (s-1!=0&&c!=0) {
                flag=2;
            }
        } else {
            flag=1;
            break;
        }
    }
    if (flag==1) {
        cout<<-1<<endl;
    } else if (flag==2) {
        if (n==1) {
            cout<<deq[0]<<endl;
        } else {
            if (deq[0]==0) {
                cout<<-1<<endl;
            } else {
                for (int j=0;j<n;j++) {
                    if (j==0&&deq[0]==-1) {
                        cout<<1;
                    } else if (deq[j]==-1) {
                        cout<<0;
                    } else {
                        cout<<deq[j];
                    }
                }
                cout<<endl;
            }
        }
    } else {
        if (n==1) {
            if (deq[0]!=-1) {
                cout<<deq[0]<<endl;
            } else {
                cout<<0<<endl;
            }
        } else {
            if (deq[0]==0) {
                cout<<-1<<endl;
            } else {
                for (int k=0;k<n;k++) {
                    if (k==0&&deq[k]==-1) {
                        cout<<1;
                    } else if (deq[k]==-1) {
                        cout<<0;
                    } else {
                        cout<<deq[k];
                    }
                }
                cout<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()



ll factorial(ll x, ll n){
  
  if (n==0){
    return 1;
  }
  
  else if (n==1){
    return x%MOD;
  }
  else if (n%2==0){
    return (factorial(x,n/2)*factorial(x,n/2))%MOD;
  }
  
  else {
    return (((factorial(x,(n-1)/2)*factorial(x,(n-1)/2))%MOD)*x)%MOD;
  }

}
  



int main(){
  

  int n,k;
  cin>>n>>k;
  
  vector<ll> com1(n-k+2);
  vector<ll> com2(k);
  
  com1.at(0)=1;
  com2.at(0)=1;
  
  for (int i=1;i<=n-k+1;i++){
    com1.at(i)=(((com1.at(i-1)*(n-k-i+2))%MOD)*factorial(i,MOD-2))%MOD;
  }
  
  for (int i=1;i<=k-1;i++){
    com2.at(i)=(((com2.at(i-1)*(k-i))%MOD)*factorial(i,MOD-2))%MOD;
  }
  
  for (int i=1;i<=k;i++){
    if (i<=n-k+1){
      cout<<(com1.at(i)*com2.at(i-1))%MOD<<endl;
    }
    else {
      cout<<0<<endl;
    }
  }
  


}












Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define ft first
#define sd second
#define elif else if
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mp make_pair
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
const int MOD = 1e9+7;
const ll INF =1e18;

int main(){
    ll n;cin>> n;
    vl h(n);
    fr(i,n) cin>>h[i];
    vl dp(n+1);
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    fr(i,n){
        dp[i+2] = min(dp[i+1]+abs(h[i+2]-h[i+1]), dp[i]+abs(h[i+2]-h[i]));
    }

    cout << dp[n-1]<< endl;
}

Measured memory_bytes: 1792
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P, i) P[(i) % P.size()]
#define next(P, i) P[(i+1) % P.size()]
#define prev(P, i) P[(i+P.size()-1) % P.size()]

using namespace std;

double EPS = 1e-10;
const double PI = acos(-1);

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator + (point p){
    return point(add(x,p.x), add(y,p.y));
  }

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }

  point operator * (double d){
    return point(x*d,y*d);
  }
};

double areaPol(vector<point> t){
  double area=0;
  for(int i=0;i<t.size();i++)
    area+=(curr(t,i).x-next(t,i).x)*(curr(t,i).y+next(t,i).y);

  return abs(area)/2.0;
}

int main(void){
  int n;
  cin >> n;
  vector<point>pol(n);

  for(int i=0;i<n;i++)cin >> pol[i].x >> pol[i].y;

  printf("%.1f\n",areaPol(pol));

  return 0;
}

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

using namespace std;

const int nmax=8;
bool graph[nmax][nmax];


int dfs(int v, int N, bool visited[nmax]){
	bool all_visited = true;
	int ret = 0;

	for(int i=0;i<N;++i){
		if(visited[i] == false) all_visited=false;
	}
	if(all_visited){
		return 1;
	}
	for(int i=0;i<N;++i){
		if(visited[i] == false){
			if(graph[v][i] == true){
				visited[i] = true;
				ret = ret + dfs(i, N, visited);
				visited[i] = false;
			}
		}
	}
	return ret;
}


int main(void){

	int N, M;
	cin >> N >> M;
	for(int i=0;i<M;++i){
		int A, B;
		cin >> A >> B;
		graph[A-1][B-1] = graph[B-1][A-1]=true;
	}
	int path_num=0;
	bool visited[nmax];

	for(int i=0;i<nmax;++i){
		visited[i] = false;
	}
	visited[0] = true;
	path_num = dfs(0, N, visited);

	cout << path_num << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  ll X[N];
  for(int i=0;i<N;++i) cin>>X[i];
  ll ans = 0;
  for(int i=1;i<N;++i) {
    if((X[i]-X[i-1])*A>B) ans += B;
    else ans += (X[i]-X[i-1])*A;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 4376
N = int(input())
D = []
for n in range(N):
    D.append(int(input()))

num = []
for length in range(len(D)):
    count = 0
    if length == 0:
        num.append(D[length])
    else:
        for nu in range(len(num)):
            if D[length] == num[nu]:
                count += 1
                break
        if count == 0:
            num.append(D[length])
print(len(num))

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, K = map(int, input().split())
    A_lsit = list(map(int, input().split()))

    answer_list = []
    for i in range(N-K):
        if A_lsit[i+K] > A_lsit[i]:
            answer_list.append("Yes")
        else:
            answer_list.append("No")
    for answer in answer_list:
        print(answer)

if __name__ == "__main__":
    main()



Measured memory_bytes: 31572
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;

typedef pair<int, int> P;

vector<vector<int>> a(100000);
vector<int> comp(100000, 0);

void dfs(int s, int id) {
	stack<int> st;
	st.push(s);
	comp[s] = id;
	while (!st.empty()) {
		int i = st.top();
		int k = a[i].size();
		REP(j, k + 1) {
			if (j < k) {
				int t = a[i][j];
				if (comp[t] != id) {
					comp[t] = id;
					st.push(t);
					break;
				}
			}
			else st.pop();
		}
	}
}

void divide(int size) {
	int s = 0;
	int id = 1;
	while (1) {
		dfs(s, id);
		while (s < size && comp[s]>0) s++;
		if (s == size) break;
		id++;
	}
	return;
}

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

	int n, m;
	scanf("%d %d", &n, &m);
	//cin >> n >> m;
	REP(i, m) {
		int s, t;
		scanf("%d %d", &s, &t);
		//cin >> s >> t;
		a[s].push_back(t);
		a[t].push_back(s);
	}
	int q;
	cin >> q;
	divide(n);
	REP(i, q) {
		int s, t;
		scanf("%d %d", &s, &t);
		//cin >> s >> t;
		if (comp[s] == comp[t]) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}






Measured memory_bytes: 9320
M, D = map(int, input().split())

ans = 0
for m in range(1, M+1):
    for d in range(1, D+1):
        if d >= 10 and d % 10 >= 2 and d//10 >= 2 and (d % 10) * (d//10) == m:
            ans += 1

print(ans)

Measured memory_bytes: 3060