akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

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

    string s;
    cin >> s;
    for (auto i = s.size() - 1; i >= 0; i--) {
        if (i % 2 != 0) {
            continue;
        }
        auto left = s.substr(0, i / 2);
        auto right = s.substr(i / 2, i / 2);
        if (left == right) {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}


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

#define PI acos(-1)
#define all(a) a.begin(), a.end()
#define full(a, n) a, a + n
#define ma(type, size) (type *)malloc(sizeof(type) * size)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define f0(i, n) for (i = 0; i < (n); i++)
#define f1(i, n) for (i = 1; i < (n); i++)
#define f1n(i, n) for (i = 1; i <= (n); i++)
#define fab(i, a, b) for (i = (a); i <= (b); i++)
#define fr(i, b, a) for (i = (b); i >= (a); i--)

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
	tree_order_statistics_node_update> indexed_set;
//*/
typedef long long int ll;
typedef long int lo;

typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

//* utility function
inline bool compare(ll i, ll j)
{
    return i < j;
}
//*/

//* function prototypes
template< typename T>
T gcd(T a, T b);
template< typename T>
T modpow(T number, T power, T mod_value);
//*/

//int row, column;
//int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//int dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
//int dx[4] = {1,  0, -1, 0};
//int dy[4] = {0, -1,  0, 1};
//ll p2[63] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904};
#ifdef DEBUG
#endif // DEBUG

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll number_of_test_case = 1, test_case;
    //cin >> number_of_test_case;
    for (test_case = 1; test_case <= number_of_test_case; test_case++)
    {
        ll a, b;
        cin >> a >> b;

        if (min(a, b) < 1 || max(a, b) > 9)cout << "-1\n";
        else cout << a * b << endl;
    	//cout << "Test #" << test_case << ": ";
    	//cout << "Case " << test_case << ": ";
    }
    return 0;
}


template< typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a%b);
}
template< typename T>
T modpow(T number, T power, T mod_value)
{
    if (power == 0)
        return 1%mod_value;
    ll u = modpow(number,power/2,mod_value);
    u = (u*u)%mod_value;
    if (power%2 == 1)
        u = (u*number)%mod_value;
    return u;
}


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


int main() {
  string s;
  cin >> s;
  int len = s.size();
  unordered_map<char,int> dict;
  for(int i = 0 ; i < len; ++i){
    if(dict.find(s[i]) == dict.end()) dict[s[i]] = 1;
    else ++dict[s[i]];
  }
  bool flag = true;
  for(auto element : dict){
    if(element.second % 2 != 0){
      flag = false;
      break;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 384
n, m = map(int, input().split())
p = list(map(int, input().split()))

par = {x:x for x in range(1, n+1)}

def root(node):
    if par[node] == node:
        return node
    par[node] = root(par[node])
    return par[node]

for _ in range(m):
    x, y  = map(int, input().split())
    par[root(x)] = root(y)
    
ans = 0
for i in range(1, n+1):
    if root(i) == root(p[i-1]):
        ans += 1

print(ans)

Measured memory_bytes: 20704
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld,lld> pi;
#define F first
#define S second
#define PB push_back
#define MOD 1000000007
#define MP make_pair
#define rep(i,a,b) for (lld i = a; i < b; i++)
lld b,c,d,e,f,g,i,j,k,l,m,n,o,p,q,r,s,t,x,y,z;string s1,s2,s3;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin>>x>>y;
  if(x%y
    ==0)
  {
    cout<<-1;return 0;
  }
  for(i=x;i<=1e18;i=i+x)
  {
    if(i%y!=0)
    {
        cout<<i;break;
    }
  }  

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

typedef long long ll;


int main(){

  int N;
  cin>>N;

  int ans;

  if((ans=1000-(N%1000))!=1000){
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }

}


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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a.at(i);}
  
  int64_t sum=0;
  for(int i=0;i<n;i++){
   sum+= a.at(i);}
  
  sort(a.begin(),a.end());
  
  cout<<a.at(0)<<" "<<a.at(n-1)<<" "<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3164
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    private static int[] dx = { 0, 1, 0, -1 };
    private static int[] dy = { 1, 0, -1, 0 };
    public static void Main()
    {
        int A = NextInt();
        int B = NextInt();
        int ans = A + B;
        ans = Math.Max(ans, A + A - 1);
        ans = Math.Max(ans, B + B - 1);
        Console.WriteLine(ans);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
def COMinit(N, mod):
    fac = [0] * N
    finv = [0] * N
    inv = [0] * N

    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1

    for i in range(2, N):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    
    return fac, finv, inv

def COM(n, r, mod, fac, finv, inv):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod

def solve():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    MOD = 10**9 + 7
    A.sort()

    fac, finv, inv = COMinit(N+1,MOD)
    max_sm = 0
    min_sm = 0
    for i in range(N):
        smallerNums = i
        largerNums = N - i - 1
        max_sm += A[i] * COM(smallerNums, K-1, MOD, fac, finv, inv) % MOD
        min_sm += A[i] * COM(largerNums, K-1, MOD, fac, finv, inv) % MOD
    
    print((max_sm % MOD - min_sm % MOD) % MOD)

if __name__ == '__main__':
    solve()

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

int main()
{
    double n,k,ans = 0;
    int f;
    cin >> n >> k;
    if(k==1)
    {
        cout << 1;
        return 0;
    }
    for (int i = 1; i <= n;++i)
    {
        if((int)(log(k / i) / log(2))<(log(k / i) / log(2)))
        {
            f=(int)(log(k / i) / log(2))+1;
        }
        else
        {
            f = (int)(log(k / i) / log(2));
        }
        ans += (1 / n) * pow(0.5,f);
        if(i==k-1)
        {
            break;
        }
    }
    if(n>=k)
    {
        ans += (n - k+1) / n;
    }
    cout << setprecision(12) << ans;
    return 0;
}

Measured memory_bytes: 256
main = do
  s <- getContents
  putStr . concat . map(++ "\n") . map rect2
    . takeWhile (/=[0,0]) . map (map (read :: String -> Int) . words) . lines $ s

rect2 :: [Int] -> String
rect2 [1,w] = row "#" w
rect2 [h,w] = (row "#" w) ++ (concat . take (h-2) . repeat $ (row "." w)) ++ (row "#" w)

row :: String -> Int -> String
row _ 1 = "#\n"
row t w = "#" ++ (concat . take (w-2) . repeat $ t) ++ "#\n"

Measured memory_bytes: 5284
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
char lst[Max][Max];
int ls[Max][Max];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			scanf(" %c", &lst[i][j]);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (lst[i][j] == '#')cout << "#";
			else
			{
				int sum = 0;
				if (lst[i + 1][j]=='#' && i + 1 <= n)sum++;
				if (lst[i - 1][j] == '#' && i - 1 >= 1)sum++;
				if (lst[i][j + 1] == '#' && j + 1 <= m)sum++;
				if (lst[i + 1][j+1] == '#' && i + 1 <= n&&j+1<=m)sum++;
				if (lst[i - 1][j-1] == '#' && i - 1 >= 1&&j-1>=1)sum++;
				if (lst[i][j - 1] == '#' && j - 1 >= 1)sum++;
				if (lst[i + 1][j - 1] == '#' && i + 1 <= n && j - 1 >= 1)sum++;
				if (lst[i - 1][j + 1] == '#' && i - 1 >= 1 && j + 1 <= m)sum++;
				cout << sum;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
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;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
#define P pair<int, int>
#define ll long long
const int MOD = 1000000007;
//bitset<64>(x).count()
//fixed << setprecision(15) << 

int main (){
  ll a[4];
  rep(i, 4)
    cin >> a[i];
  cout << max({a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3]}) << endl;
}


Measured memory_bytes: 3632
while true
  w,h = gets.chomp.split.map(&:to_i)

  break if w.zero? && h.zero?

  c = []
  h.times do |i|
    c[i] = gets.chomp.split.map(&:to_i)
  end

  reached = Array.new(h) { Array.new(w, false) }

  ans = 0
  h.times do |hh|
    w.times do |ww|
      next if c[hh][ww] == 0 || reached[hh][ww]
      ans += 1
      stack = [[hh,ww]]
      while !stack.empty?
        hhh,www = stack.pop
        reached[hhh][www] = true
        [-1,0,1].each do |hi|
          next if hi+hhh < 0
          next if hi+hhh > h-1
          [-1,0,1].each do |wi|
            next if wi+www < 0
            next if wi+www > w-1
            next if c[hi+hhh][wi+www] == 0 || reached[hi+hhh][wi+www]
            stack.push([hi+hhh,wi+www])
          end
        end
      end
    end
  end
  p ans
end



Measured memory_bytes: 6956
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cmath>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int first = atoi(S.substr(0, 2).c_str());
    int second = atoi(S.substr(2, 2).c_str());
    string ans = "NA";
    if(first > 0 && first < 13){
        if(second > 0 && second < 13){
            ans = "AMBIGUOUS";
        }else if(second > 12){
            ans = "MMYY";
        }else if (second == 0){
            ans = "MMYY";
        }
    }else if(first > 12){
        if(second >0 && second < 13){
            ans = "YYMM";
        }else if(second > 12){
            ans = "NA";
        }
    }else if(first == 0){
        if(second > 0 && second < 13){
            ans = "YYMM";
        }
    }else if(second == 0){
        if(first > 0 && first < 13){
            ans = "MMYY";
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int x,a,b;
		scanf("%d%d%d",&x,&a,&b);
		int disa = abs(x-a);
		int disb = abs(x-b);
		disa>disb? puts("B") : puts ("A");
		return 0;
}  

/*

*/


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String deck;
		int m,h;
		Scanner scan = new Scanner(System.in);
		while(true){
			deck=scan.next();
			if(deck.equals("-"))
				break;
			m=scan.nextInt();
			char[] cards = deck.toCharArray();
			char[] temp = new char[cards.length];
			for(int i=0;i<m;i++){
				h=scan.nextInt();
				for(int j=0;j<h;j++){
					temp[j]=cards[j];
				}
				for(int j=h;j<cards.length;j++){
					cards[j-h]=cards[j];
				}
				for(int j=0;j<h;j++){
					cards[j + (cards.length - h)] = temp[j];
				}
			}
			for(int i=0;i<cards.length;i++){
				System.out.print(cards[i]);
			}
			System.out.println();
		}
		scan.close();
	}
}


Measured memory_bytes: 26384
#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define repr(i,a,n) for(ll i = n-1;i >= a;i--)
#define LINF (ll)1e17
#define INF (int)1e9
#define MOD (ll)1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
	
}



signed main(){
	ll a,b,c,n,ans = LINF,cnt = 0;
	cin >> n >> a >> b >> c;
	ll l[n] = {};
	bool is_used[n] = {false};
	char s[n-3];
	
	rep(i,0,n) cin >> l[i];
	
	rep(i,0,n){
		rep(j,0,n)is_used[j] = false;
		
		is_used[i] = true;
		
		rep(j,0,n){
			if(!is_used[j]){
				
				is_used[j] = true;
				
				rep(k,0,n){
					if(!is_used[k]){
						
						is_used[k] = true;
						
						
						rep(m,0,pow(4,n-3)){
							cnt = 0;
							
							rep(q,0,n-3){
								s[q] = 'X';
							}
							
							ll memo = m;
							rep(q,0,n-3){
								s[q] = (char)('0' + (memo % 4));
								memo /= 4;
							}
							
							
							ll a_memo = l[i],b_memo = l[j],c_memo = l[k],index = 0;
							
							rep(q,0,n){
								
								if(!is_used[q]){
									
									if(s[index] == '1'){
										a_memo += l[q];
										cnt += 10;
									}
									else if(s[index] == '2'){
										b_memo += l[q];
										cnt += 10;
									}
									else if(s[index] == '3'){
										c_memo += l[q];
										cnt += 10;
									}
									
									index++;
								}
							}
							
							cnt += abs(a_memo - a);
							cnt += abs(b_memo - b);
							cnt += abs(c_memo - c);
							
							
							ans = min(cnt,ans);
							
							
							
						}
						
						is_used[k] = false;
					}
					
					
				}
				is_used[j] = false;
			}
			
			
		}
		
	}
	
	cout << ans << endl;
	
	
    return 0;
}

Measured memory_bytes: 256
// abc133_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll x = 0;
    REP(i, N){
        x += i % 2 == 0 ? A[i] : -A[i];
    }

    cout << x;
    REP(i, N-1){
        x = 2 * A[i] - x;
        cout << " " << x;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2176
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != 'B') {
      res += s[i];
    } else if (!res.empty()) {
      res.pop_back();
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))

char s[99] = {"0"};
int l = 1;

void next_lunlun(){
    int i = l-1;
    while(i>0 && (s[i-1] == s[i]-1 || s[i]=='9'))i--;
    if(s[0]=='9' && i == 0){
        s[l]='0';
        for(int j=l;j;j--){
            char tmp = s[j];
            s[j] = s[j-1];
            s[j-1] = tmp;
        }
        l++;
    }
    s[i]++;i++;
    for(int j=i;j<l;j++){
        s[j] = max('0', s[j-1]-1);
    }
    return;
}

main(x){
    scanf("%d", &x);
    while(x--)next_lunlun();
    printf("%s\n", s);
    return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{  
    int n;
    cin >> n;
    vector<int> w(n);
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }
    int ans = 1e9;
    for(int i = 1; i < n; i++){
        int l = 0, r = 0;
        for(int j = 0; j < i; j++) l += w[j];
        for(int j = i; j < n; j++) r += w[j];
        ans = min(ans, abs(l-r));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

vector<int> G[100001];
bool vsd[100001][3];
queue<int> que;

void dfs(int n, int cnt){
  //cout << "hoge" << endl;
  if(cnt == 3){
    que.push(n);
    return;
  }

  if(vsd[n][cnt]) return;

  for(int i = 0; i < G[n].size(); i++){
    dfs(G[n][i], cnt + 1);
  }
  vsd[n][cnt] = true;
  return;
}

int main(){
  int N, M;
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
  }
  int s, t;
  cin >> s >> t;
  s--;
  t--;

  for(int i = 0; i <= 100000; i++){
    for(int j = 0; j < 3; j++){
      vsd[i][j] = false;
    }
  }

  que.push(s);
  int cnt = 0;
  while(que.size()){
    int sz = que.size();
    for(int i = 0; i < sz; i++){
      int n = que.front();
      //cout << n << endl;
      que.pop();
      if(n == t){
        cout << cnt << endl;
        return 0;
      }
      dfs(n, 0);
    }
    cnt++;
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 6016
n = int(input())
a =list(map(int,input().split()))

ans = 1
now = a[0]
before = '-'
for i in range(1,n):
    if before == '-':
        if now > a[i]:
            before = 'D'
        elif now< a[i]:
            before = 'U'

    else:
        if before == 'U' and now > a[i]:
            ans += 1
            before = '-'
        elif before == 'D' and now < a[i]:
            ans += 1
            before = '-'
    now = a[i]

print(ans)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double x = ((h * 60 + m) * 0.5);
    while (x >= 360) x -= 360;
    double y = ((h * 60 + m) * 6);
    while (y >= 360) y -= 360;
    double ang = abs(x - y);
    if (ang > 180) ang = 360 - ang;
    double c_2 = a * a + b * b - 2 * a * b * cos((ang / 360) * 2 * M_PI);
    double c = sqrt(c_2);
    cout << fixed << setprecision(12) << c << endl; 
}

Measured memory_bytes: 4256
#include <stdio.h>

int main (){
 
 char N [100];
 int i;
 scanf("%c", &N);
 
 if(N[i] >= 'A' && N [i] <= 'Z'){
  puts("A");
 }
  else{
   puts("a");
  }
 
 return 0;
} 

Measured memory_bytes: 1596
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	seg := newSegment(n)
	for i := 0; i < q; i++ {
		c := getNextInt(scanner)
		s := getNextInt(scanner)
		t := getNextInt(scanner)
		switch c {
		case 0:
			x := getNextInt(scanner)
			seg.update(s, t+1, x, seg.min)
		case 1:
			fmt.Fprintln(writer, seg.query(s, t+1, math.MaxInt32, seg.min))
		}
	}
}

type lazy struct {
	v, w int
}

type segment [][]lazy

func newSegment(n int) segment {
	seg := make(segment, 0)
	for n > 1 {
		seg = append(seg, make([]lazy, n))
		n = (n + 1) >> 1
	}
	seg = append(seg, make([]lazy, 1))
	return seg
}
func (seg segment) up(h, i int, f func(x, y int) int) {
	for h = h + 1; h < len(seg); h++ {
		i >>= 1
		if i<<1+1 < len(seg[h-1]) {
			seg[h][i].v = f(seg.sum(h-1, i<<1), seg.sum(h-1, i<<1+1))
			continue
		}
		seg[h][i].v = seg.sum(h-1, i<<1)
	}
}
func (seg segment) down(h, i int) {
	if h >= len(seg) {
		return
	}
	seg.down(h+1, i>>1)
	seg[h][i].v += seg[h][i].w
	if h > 0 {
		seg[h-1][i<<1].w += seg[h][i].w
		if i<<1+1 < len(seg[h-1]) {
			seg[h-1][i<<1+1].w += seg[h][i].w
		}
	}
	seg[h][i].w = 0
}
func (seg segment) sum(h, i int) int {
	return seg[h][i].v + seg[h][i].w
}
func (seg segment) update(l, r int, v int, f func(x, y int) int) {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			seg[h][l].w += v
			seg.up(h, l, f)
			l++
		}
		l >>= 1
		if r&1 == 1 {
			seg[h][r-1].w += v
			seg.up(h, r-1, f)
		}
		r >>= 1
	}
}
func (seg segment) query(l, r int, s int, f func(x, y int) int) int {
	for h := 0; h < len(seg) && l < r; h++ {
		if l&1 == 1 {
			seg.down(h, l)
			s = f(s, seg.sum(h, l))
			l++
		}
		l >>= 1
		if r&1 == 1 {
			seg.down(h, r-1)
			s = f(s, seg.sum(h, r-1))
		}
		r >>= 1
	}
	return s
}

func (seg segment) min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func (seg segment) max(x, y int) int {
	return -seg.min(-x, -y)
}



Measured memory_bytes: 7704
n = [0] + list(map(int, input())) + [0]
n = n[::-1]
#print(n)

b0 = [0]*len(n)
b1 = [0]*len(n)
b1[0] = 1
for i in range(1, len(n)):
  num = n[i]
  b0[i] = min(b0[i-1]+num, b1[i-1]+num+1)
  b1[i] = min(b0[i-1]+10-num, b1[i-1]+10-(num+1))

print(min(b0[-1], b1[-1]))
#print(b0[-1], b1[-1])

Measured memory_bytes: 89956
n,m,v,p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

def solve(ind):
    if a[ind]+m < a[-p]:
        return False
    thr = a[ind] + m
    votes=[]
    for i in range(n):
        if i<=ind or i>n-p:
            votes.append(m)
        else:
            votes.append(thr-a[i])
    sm = sum(votes)
    return sm >= m*v

ok=n-1
ng=-1
while abs(ng - ok) > 1:
    mid = (ng + ok)//2
    if solve(mid):
        ok = mid
    else:
        ng = mid

print(n-ok)

Measured memory_bytes: 171636
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC 9(10).
01 num        PIC 9(10).
01 qt         PIC 9(10).
01 rm         PIC 9(10).
01 ans        PIC 9(10).
01 zs         PIC Z(9)9.

PROCEDURE DIVISION.
  ACCEPT N.
  DIVIDE N BY 1000 GIVING qt REMAINDER rm.
  COMPUTE num = 1000 - rm.
  DIVIDE num BY 1000 GIVING qt REMAINDER ans.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
int main() {
	vector<int> a(5);
  	int minimam = 10;
    int sums = 0;
    for (int i=0;i<5;i++){
      cin>>a[i];
      if (a[i]%10 > 0){
        minimam = min(minimam,a[i]%10);
      }
      sums += 10 * ceil(float(a[i])/10.0);
    }
    sums = sums - 10 + minimam;
    cout << sums << endl;
	return 0;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

ll gcf(ll a, ll b){
    if(b == 0) return a;
    return gcf(b, a%b);
}

ll lcm(ll a, ll b){
    ll g = gcf(a, b);
    return a/g * b;
}
int main(void){
    double N; cin >> N;
    vector<double> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    
    double bunbo = 0;
    for(int i = 0; i < N; i++){
        bunbo += 1/A[i];
    }
    double ans = 1/bunbo;
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

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

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

  string s;
  cin >> s;
  int ans = 0;
  for(int i = 1; i < s.length()/2; i++){
    bool ok = true;
    for(int j = 0; j < i; j++){
      if(s[j] != s[j+i]){
        ok = false;
      }
    }
    if(ok){
      chmax(ans, i);
    }
  }

  cout << ans * 2 << endl;



  return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let q: usize = read();

    for _ in 0..q {
        let k: usize = read();
        let mut d: i64 = 0;
        let mut m: i64 = 0;
        let mut dm: i64 = 0;
        let mut ans: i64 = 0;
        for j in 0..n {
            match s[j] {
                'D' => d += 1,
                'M' => {
                    m += 1;
                    dm += d;
                }
                'C' => ans += dm,
                _ => {}
            }
            if j >= k - 1 {
                let l = j + 1 - k;
                match s[l] {
                    'D' => {
                        d -= 1;
                        dm -= m
                    }
                    'M' => m -= 1,
                    _ => {}
                }
            }
        }
        println!("{}", ans);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


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

int main(){
  int N;
  cin >> N;
  vector<string> A(N);
  vector<int> B(N);
  int sum=0,subsum=0;
  for(int i=0;i<N;i++){
    cin >> A.at(i) >> B.at(i);
    sum+=B.at(i);
  }
  string E;
  cin >> E;
  for(int i=0;i<N;i++){
    subsum+=B.at(i);
    if(A.at(i)==E){
      break;
    }
  }
  cout << sum-subsum << endl;
}
      
    

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
long long a,b,c;
int main(){
	cin>>a>>b>>c;
	if(a<b)swap(a,b);
	if(a<c)swap(a,c);
	if(b<c)swap(b,c);
	
	if(a%2==0)cout<<0<<endl;
	else cout<<b*c<<endl;
	
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<double, double>;

int main()
{
    int n;
    cin >> n;
    vector<pii> a;
    rep(i, 0, n)
    {
        double x, y;
        cin >> x >> y;
        a.emplace_back(x, y);
    }
    auto comp = [=](pii xy1, pii xy2){
        return atan2(xy1.first, xy1.second) < atan2(xy2.first, xy2.second);
    };
    sort(a.begin(), a.end(), comp);

    vector<pii> vecs;
    vecs.emplace_back(0, 0);
    for (auto aa: a)
    {
        double x, y;
        tie(x, y) = vecs.back();
        vecs.emplace_back(x + aa.first, y + aa.second);
    }
    for (auto aa: a)
    {
        double x, y;
        tie(x, y) = vecs.back();
        vecs.emplace_back(x + aa.first, y + aa.second);
    }

    double ans = 0;
    rep(i, 0, n)
    rep(j, i, i + n)
    {
        double x, y;
        x = vecs[j + 1].first - vecs[i].first;
        y = vecs[j + 1].second - vecs[i].second;
        
        ans = max(ans, x * x + y * y);
    }

    double answer = sqrt((double)ans);
    printf("%.20f\n", answer);
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());

		if(h+w>=10) {
			System.out.println("error");
		}else {
			System.out.println(h+w);
		}
	}
}




Measured memory_bytes: 21844
MOD = 1000000007
N,K = map(int,input().split())
A = list(map(int,input().split()))
def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt
def sigma(k):
    return int(k*(k+1)//2)
C = []
for k in range(2):
    C.extend(A)
cnt = bubble_sort(A)
diff = bubble_sort(C) - 2 * cnt
a = (K*cnt)
b = (diff*sigma(K-1))
print ((a+b)%MOD)


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vl divisor(ll k){
	vl c;
	for(ll i=1; i*i<=k; i++){
		if(k % i == 0){
			c.push_back(i);
			if((k / i) != i){
				c.push_back(k/i);
			}
		}
	}
	sort(c.rbegin(), c.rend());
	return c;
}

int main(){
	ll n,k; cin >> n >> k;
	vl a(n); rep(i,n) cin >> a[i];
	ll sum = 0;
	rep(i,n) sum += a[i];
	vl div = divisor(sum);
	for(auto v : div){
		vl up, down;
		rep(i,n){
			if(a[i] % v == 0) continue;
			down.push_back(a[i] % v);
		}
		if(down.empty()){
			cout << v << endl;
			return 0;
		}
		sort(all(down));
		ll siz = down.size();
		vl acc(siz+1,0);
		for(ll i=siz-1; i>=0; i--){
			acc[i] = acc[i+1] + v - down[i];
		}
		ll cnt = 0;
		rep(i,siz-1){
			if(cnt == acc[i]) break;
			cnt += down[i];
		}
		if(cnt <= k){
			cout << v << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	ll ans = 1;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans;
	return 0;
}

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define pi 3.141592653589793238

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double theta,ans;
    
    theta = h*pi/6 + m*pi/360 - m*pi/30;
    ans = sqrt(a*a + b*b - 2*a*b*cos(theta));
    cout << fixed << setprecision(10);
    cout << ans;
}

Measured memory_bytes: 4148
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	ll res = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			res += a[i] * a[j];
		}
	}

	println(res);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>
#include <deque>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

struct edge {
    LL to;
    LL cost;
};

/*
 LL V;

 cin >> V;

 vector<edge> G[V];

 rep(i,0,V){
 	 LL e;

 	 cin >> e;

 	 rep(j,0,e){
 	 	 LL to,cost;
 	 	 cin >> to >> cost;

 	 	 G[j].insert(new edge(to,cost));
 	 }
 }

 */

void dijkstra(LL s,LL V,vector<edge> G[],LL d[]) {
    priority_queue<pLL, vector<pLL>, greater<pLL> > que;
    fill(d, d+V, INT_MAX);
    d[s] = 0;
    que.push(pLL(0, s));

    while (!que.empty()) {
        pLL p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pLL(d[e.to], e.to));
            }
        }
    }
}


int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


LL gcd(LL i,LL j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

LL A(){
	LL K,A,B;

	cin >> K >> A >> B;

	rep(i,A,B+1){
		if(i % K == 0) {
			printf("OK");
			return 0;
		}
	}

	printf("NG");

	return 0;
}

LL B(){
	return 0;
}

LL C(){
	return 0;
}

LL D(){
	return 0;
}


signed main() {
	A();
	return 0;
}

Measured memory_bytes: 3728
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
    int tmp;
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b>=c) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	int A, B;
	A = sc.nextInt();
	B = sc.nextInt();

	if (A > 9 || B > 9)
	    System.out.println(-1);
	else
	    System.out.println(A * B);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

template<typename T> T gcd(T a, T b) {
	if (a < b) return gcd(b, a);
	T r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
template<typename T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

signed main() {
	LL a, b, c, d;
	cin >> a >> b >> c >> d;

	LL cd = lcm(c, d);
	LL ans = b - a + 1 - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / cd - (a - 1) / cd);
	col(ans);
	return 0;
}

Measured memory_bytes: 3608
import math
import sys

sys.setrecursionlimit(10**8)

N = int(input())

A = list(map(int,input().split()))

B = []
sum = 0

for i in range(N):
	aa = A[i] - i - 1
	B.append(aa)
	
B.sort()

if N%2 == 0:
	best = (B[N//2] + B[N//2-1])//2
else:
	best = B[N//2]

ans = 0
	
for i in range(N):
	ans += abs(B[i]-best)
	

print(ans)

Measured memory_bytes: 26404
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int N;
int main() {
	cin >> N;
	if (N == 100000000) cout << "Yes";
	else {
		int d[8];
		d[0] = 0;
		int x = N;
		rep1(i, 8) {
			d[i] = x % 10;
			x = (x - d[i]) / 10;
		}
		int disum = 0;
		rep1(i, 8) disum += d[i];

		if (N%disum == 0)cout << "Yes";
		else cout << "No";
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

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

    string s; cin >> s;
    int ans = 0;
    int now = 0;
    rep(i,3) {
        if (s[i] == 'R') ++now;
        else now = 0;
        ans = max(ans,now);
    }
    cout << ans << '\n';
    return 0;
}

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

int main()
{
		int n;
		int p[30];
		int count = 0;

		cin >> n;
		for (int i = 0; i < n; i++)
		{
			cin >> p[i];
		}

		for (int j = 0; j < n - 2; j++)
		{
			if (p[j] < p[j + 2])
			{
				if (p[j] < p[j + 1] && p[j + 1] < p[j + 2])
				{
					count++;
				}
			}
			else
			{
				if (p[j] > p[j + 1] && p[j + 1] > p[j + 2])
				{
					count++;
				}
			}
		}
		cout << count << endl;
	
	return 0;
}

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

using namespace std;

struct Dsu {
    int n;
    vector<int> p;
    
    Dsu(int _n) { n = _n; p.resize(n); init(); }
    inline void init() {
        for (int i = 0; i < n; i++) {
            p[i] = i;
        }
    }
    inline int find(int x) {
        return p[x] == x ? x: p[x] = find(p[x]);
    }
    inline bool join(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        p[y] = x; return true;
    }
    inline bool check(int x, int y) {
        return find(x) == find(y);
    }
};

template <typename T=int>
struct Slider {
    vector<T> a;
    int n, d;
    deque<int> mi, mx;

    vector<int> lid, hid;

    Slider(vector<T> _a, int _d) : a(_a), d(_d) {
        n = a.size();
        lid.resize(n + d);
        hid.resize(n + d);
        build();
    }
    void build() {
        for (int i = 0; i < n+d-1; i++) {
            while (i < n && !mi.empty() && a[mi.back()] >= a[i]) {
                mi.pop_back();
            }
            mi.push_back(i);
            lid[i+1] = mi.front();
            if (i-d+1 >= 0 && i-d+1 == mi.front()) {
                mi.pop_front();
            }

            while (i < n && !mx.empty() && a[mx.back()] <= a[i]) {
                mx.pop_back();
            }
            mx.push_back(i);
            hid[i+1] = mx.front();
            if (i-d+1 >= 0 && i-d+1 == mx.front()) {
                mx.pop_front();
            }
        }
    }
    
    int min_id(int l, int r) {
        assert(1 <= r-l && r-l <= d);
        if (r-l < d) assert(l == 0 || r == n);
        return r < n ? lid[r] : lid[l+d];
    }
    T get_min(int l, int r) {
        return a[min_id(l,r)];
    }
    int max_id(int l, int r) {
        assert(1 <= r-l && r-l <= d);
        if (r-l < d) assert(l == 0 || r == n);
        return r < n ? hid[r] : hid[l+d];
    }
    T get_max(int l, int r) {
        return a[max_id(l,r)];
    }
};

void solve() {
    int n,K;
    cin >> n >> K;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    if (K == n) {
        cout << 1; return;
    }
    Dsu d(n-K+1);
    Slider<> s(a, K+1);
    for (int i = 0; i+K+1 <= n; i++) {
        if (s.min_id(i, i+K+1) == i && s.max_id(i, i+K+1) == i+K) {
            d.join(i, i+1);
        }
    }

    vector<int> len(n);
    len[0] = 1;
    for (int i = 1; i < n; i++) {
        if (a[i-1] < a[i]) len[i] = len[i-1] + 1;
        else len[i] = 1;
    }
    int id = -1;
    for (int i = 0; i+K <= n; i++) {
        if (len[i+K-1] >= K) {
            if (id == -1) id = i;
            else d.join(i, id);
        }
    }
    set<int> equiv;
    for (int i = 0; i+K <= n; i++) {
        equiv.insert(d.find(i));
    }
    cout << equiv.size();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

string S, T;

int main() {
    cin >> S >> T;
    int i;
    bool restorable;
    for (i = S.size() - T.size(); i >= 0; i--) {
        restorable = true;
        for (int j = 0; j < T.size(); j++) {
            if (S.at(i+j) != T.at(j) && S.at(i+j) != '?') {
                restorable = false;
            }
        }
        if (restorable) break;
    }
    string ans;
    if (restorable) {
        for (int j = 0; j < i; j++) {
            if (S.at(j) == '?') ans.push_back('a');
            else ans.push_back(S.at(j));
        }
        for (int j = 0; j < T.size(); j++) ans.push_back(T.at(j));
        for (int j = i + T.size(); j < S.size(); j++) {
            if (S.at(j) == '?') ans.push_back('a');
            else ans.push_back(S.at(j));
        }
    }
    else ans = "UNRESTORABLE";
    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 k = sc.nextInt();
        sc.close();

        if(n == 1) {
            System.out.println(k);
        } else {
            System.out.println(k * (int)Math.pow(k-1, n-1));
        }
    }
}


Measured memory_bytes: 21844