akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int K, A, B;

  cin >> K;
  cin >> A >> B;

  bool ans = false;
  for (int i = A; i <= B; i++) {
    if (i % K == 0) {
      ans = true;
      cout << "OK" << endl;
      break;
    }
  }

  if (ans==false)
    cout << "NG" << endl;

  return 0;
}


Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

void findPrime(int N, vector<bool>& isPrime)
{
    isPrime.assign(N+1, true);
    isPrime[0] = isPrime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(isPrime[i]){
            for(int j=i; i*j<=N; j++){
                isPrime[i*j] = false;
            }
        }
    }
}

const int MAX = 55555;

int main()
{
    vector<bool> isPrime;
    findPrime(MAX, isPrime);

    int n;
    cin >> n;
    vector<int> ans;
    for(int i=6; ans.size()<n; i+=5){
        if(isPrime[i])
            ans.push_back(i);
    }

    cout << ans[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

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

#define CIN(x) int x;cin>>x;
#define COUT(x) cout<<(x)<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define P pair<int,int>
#define V vector<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    string a,b,c;
    cin>>a>>b>>c;
    string ans;
    ans+='A';
    ans+=b[0];
    ans+='C';
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
  val input = readLine()!!.toInt()
  var list = readLine()!!.split(" ")
  val tako = mutableListOf<Int>()
  
  for(i in 0..input-1){
    tako.add(list[i].toInt())
  }
  
  var bimi = 0
  
  for(i in 0..input-2){
    for(j in i+1..input-1){
        bimi += tako[i] * tako[j]
    }  
  }
  println(bimi)
}

Measured memory_bytes: 37908
// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d

#include "algorithm"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll N;
  cin >> N;
  string S;
  cin >> S;

  V<multiset<ll>> indices(10);

  rep(i, N) {
    auto c = S[i];
    auto cl = c - '0';
    indices[cl].insert(i);
  }

  ll res = 0;
  rep(f, 10) {
    auto fit = indices[f].lower_bound(0);
    auto f_i_i = distance(indices[f].begin(), fit);

    if (f_i_i == indices[f].size()) continue;
    ll f_i = *fit;

    rep(s, 10) {
      auto sit = indices[s].lower_bound(f_i + 1);
      auto s_i_i = distance(indices[s].begin(), sit);

      if (s_i_i == indices[s].size()) continue;
      auto s_i = *sit;

      rep(t, 10) {
        auto tit = indices[t].lower_bound(s_i + 1);
        auto t_i_i = distance(indices[t].begin(), tit);

        if (t_i_i == indices[t].size()) continue;
        auto t_i = *tit;

        res++;
      }
    }
  }

  cout << res << endl;
}

void solve2() {
  ll N;
  string S;
  cin >> N >> S;

  ll res = 0;

  rep(num, 1000) {
    VL cs = {num / 100, (num / 10) % 10, num % 10};
    ll i = 0;

    rep(j, N) {
      if (S[j] == ('0' + cs[i])) i++;
      if (i == 3) break;
    }

    if (i == 3) res++;
  }
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve2();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


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

int main(){
  int a,b,c,k;
  cin >>a >>b >>c >>k;
  int xa = min(a,k);
  k -= xa;
  int xb = min(b,k);
  k -= xb;
  int xc = k;
  cout << xa-xc << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define INPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in"
#define OUTPUT "/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

void solve()
{
    int n;
    cin >> n;
    int res = 0;
    for(int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        while(!(x & 1))
        {
            x >>= 1;
            res++;
        }
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0);
    //freopen(INPUT, "r", stdin);freopen(OUTPUT, "w", stdout);
    //freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


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

int64_t cnt[41][41];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		double x; cin >> x;
		int64_t a = x * 1e9 + 0.5;
		int c1 = 0, c2 = 0;
		while (a % 5 == 0) { c1++; a /= 5; }
		while (a % 2 == 0) { c2++; a /= 2; }
		cnt[c1][c2]++;
	}
	int64_t ans = 0;
	for (int i = 0; i < 41; i++) {
		for (int j = 0; j < 41; j++) {
			for (int x = max(18 - i, 0); x < 41; x++) {
				for (int y = max(18 - j, 0); y < 41; y++) {
					if (x == i && y == j) {
						ans += cnt[i][j] * (cnt[x][y] - 1);
					} else {
						ans += cnt[i][j] * cnt[x][y];
					}
				}
			}
		}
	}
	cout << ans / 2;
}

Measured memory_bytes: 3740
N = int(input())
ban = N if N%2 else N+1

ans = []
for i in range(1,N):
    for j in range(i+1,N+1):
        if i+j == ban: continue
        ans.append(str(i) + ' ' + str(j))

print(len(ans))
print(*ans, sep='\n')

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    long long n = s.length(), k;
    cin >> k;
    long long res = 0;
    if (k == 1) {
        if (n > 1) res = (n - 1) * 9;
        res += s[0] - '0';
    } else if (k == 2) {
        if (n > 2) res = (((n - 1) * (n - 2)) / 2) * 81;
        if (n > 1) {
            res += (s[0] - '0' - 1) * (n - 1) * 9;
            int i = 1;
            while (i < n) {
                if (s[i] == '0') {
                    i++;
                } else break;
            }
            if (i != n) {
                res += s[i] - '0';
                res += (n - 1 - i) * 9;
            }
        }
    } else {
        if (n > 3) res = (((n - 1) * (n - 2) * (n - 3)) / 6) * 729;
        if (n > 2) {
            // cout << res << " 1" << endl;
            res += (s[0] - '0' - 1) * (((n - 1) * (n - 2))/2) * 81;
            // cout << res << " 2" << endl;
            int i = 1;
            while (i < n) {
                if (s[i] == '0') {
                    i++;
                } else break;
            }
            if (i != n) {
                // res += (n - 1 - i) * 9;
                res += ((n - 1 - i) * (n - 2 - i) / 2) * 81;
                res += (s[i] - '0' - 1) * (n - 1 - i) * 9;
                i++;
                while (i < n) {
                    if (s[i] == '0') {
                        i++;
                    } else break;
                }
                if (i != n) {
                    res += s[i] - '0';
                    res += (n - 1 - i) * 9;
                }
                // cout << res << " 4" << endl;
            }
            // i++;
            // if (i < n) res += (s[i] - '0');
            // cout << res << " 5" << endl;
            // while (i < n) {
            //     if (s[i] == '0') {
            //         i++;
            //     } else break;
            // }
            // if (i < n) {
            //     // res += (n - 1 - i) * 9;
            //     res += (n - 1 - i) *9;
            //     cout << res << " 6" << endl;
            // }
        }
    }
    cout << res;
    return 0;
} 

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)

using namespace std;

static const int N=1001;
int lcs(string X,string Y){
	int c[N+1][N+1]; //二次元配列の作成
	int m=X.size();
	int n=Y.size();
	int maxl=0;
	X = ' '+X;
	Y = ' '+Y; //それぞれ文字列の先頭に空白を挿入
	rep(i,m) c[i][0]=0;
	rep(j,n) c[0][j]=0;

	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(X[i]==Y[j]){
				c[i][j]=c[i-1][j-1]+1;
			}
			else{
				c[i][j]=max(c[i-1][j],c[i][j-1]);
			}
			maxl=max(maxl,c[i][j]);
		}
	}
	return maxl;
}

int main(){
	cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
	// 追加２, 以降 cin の入力元が 'input.txt' になる
	//提出時に消す！！
	//td::ifstream in("sample.txt");
	//std::cin.rdbuf(in.rdbuf());

	int n;
	cin>>n;
	string s1,s2;
	rep(i,n){
		cin>>s1>>s2;
		cout<<lcs(s1,s2)<<endl;
	}
	return 0;
}



Measured memory_bytes: 7104
import fractions
a,b=map(int,input().split())
s=fractions.gcd(a,b)
cnt={1}
if s%2==0:
    cnt.add(2)
    while s%2==0:
      s//=2
for i in range(3,int(s**0.5)+1,2):
    if s%i==0:
        cnt.add(i)
        while s%i==0:
            s//=i
print(len(cnt)+(s>1))

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

int main()
{
  int n;
  cin >> n;
  int a[n],b[n];
  rep(i,n){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b,b + n);
  int k = 0;
  rep(i,n){
    if(a[i] != b[i]) k++;
  }
  cout << (k <= 2 ? "YES" : "NO") << endl;
  return 0;
}

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

int main(void)
{
    int n,k;
    char s[50];
    scanf("%d%d", &n, &k);
    scanf("%s", s);
    if(strncmp("A", &s[k-1], 1)==0) strncpy(&s[k-1], "a", 1);
    else if(strncmp("B", &s[k-1], 1)==0) strncpy(&s[k-1], "b", 1);
    else if(strncmp("C", &s[k-1], 1)==0) strncpy(&s[k-1], "c", 1);

    int i;
    for(i=0; i<n; i++) printf("%c", s[i]);
    return 0;

}

Measured memory_bytes: 128
import java.util.*;
class Main{
	 public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int[] s = new int[N];
      	for(int i = 0; i<N-1; i++){
          	int j = sc.nextInt();
        	s[j-1] += 1;
        }
      	for(int i=0; i<N; i++ ) System.out.println(s[i]);
    
    }

}

Measured memory_bytes: 60192
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <cassert>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<ll, int, int> T;

struct Dice {
	int d[3];
	Dice(int a, int b) {
		for (int i = 0; i < 3; i++) {
			d[i] = (a+i)%3+a/3*3;
		}
		while (d[1] != b) rot(1);
	}
	int get(int dir) {
		if (dir < 2) {
			return d[dir];
		} else {
			dir -= 2;
			return 5-d[dir];
		}
	}
	void rot(int dir) {
		int t = d[2];
		if (dir < 2) {
			d[2] = 5-d[dir];
			d[dir] = t;
		} else {
			dir -= 2;
			d[2] = d[dir];
			d[dir] = 5-t;
		}
	}
};

int di[4][2] = {
    {0, 1},
    {1, 0},
    {0, -1},
    {-1, 0}
};
int main() {
    while (true) {
        int n;
        cin >> n;
        if (!n) break;
        int rank[300][300] = {};
        int up[300][300] = {};
        for (int i = 0; i < n; i++) {
            int a, b;
            cin >> a >> b; a--; b--;
            Dice d = Dice(b, a);
            d.rot(3);
            int x = 150, y = 150;
            while (true) {
 
                bool f = false;
                int mm = 0, md = 0;
                for (int k = 0; k < 4; k++) {
                    int xx = x+di[k][0], yy = y+di[k][1];
                    if (rank[x][y] > rank[xx][yy]) {
                        if (d.get(k) >= 3) {
                            f = true;
                            if (d.get(k) > mm) {
                                mm = d.get(k);
                                md = k;
                            }
                        }
                    }
                }
 				
                if (!f) break;
                d.rot(md);
                x += di[md][0];
                y += di[md][1];
                //printf("rot %d %d %d\n", md, d.first, d.second);
            }
            rank[x][y]++;
            up[x][y] = d.d[2];
        }
        int d[6] = {};
        for (int x = 0; x < 300; x++) {
            for (int y = 0; y < 300; y++) {
                if (rank[x][y]) {
                    d[up[x][y]]++;
                }
            }
        }
        for (int i = 0; i < 5; i++) {
            printf("%d ", d[i]);
        }
        printf("%d\n", d[5]);
    }
 
    return 0;
}

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

int main(){
    int N, K, H[100000];
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> H[i];
    sort(H, H+N);
    
    int ans = 2e9;
    for(int i=0; i<=N-K; i++) ans = min(ans, H[i+K-1] - H[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4012
s = input()
t = input()

if(s == t):
  print("No")
  
else:
  cnt = "No"
  #まずsを辞書順で一番小さくなるよう並べ替える
  #(単純ソート)
  s_sort = sorted(s)
  
  #tは辞書順で一番大きくなるように並べ替え
  #(逆ソート)
  t_sort_rev = sorted(t, reverse=True)
  
  min_len = min( len(s), len(t) )
  if( len(s) < len(t) ):
    #特に追加処理はいらない
    s_more_length = False
  elif( len(s) > len(t) ):
    #こっちの場合が面倒
    s_more_length = True
  
  #-----
  for i in range ( min_len ):
    if( ord(s_sort[i]) < ord(t_sort_rev[i]) ):
      cnt = "Yes"
      break
    elif( ord(s_sort[i]) == ord(t_sort_rev[i])):
      #全文字が同じだった時の、文字数で辞書順を判定する処理
      if( i == min_len-1 and s_more_length == False ):
        cnt = "Yes"
      elif( i == min_len-1 and s_more_length == True ):
        continue
      continue
    else:
      break
  #-----
  
  print(cnt)

Measured memory_bytes: 3064
S = input()
if S[0] == '0' or S[-1] == '1':
    print(-1)
    exit()
flag = True
for i in range((len(S)-1)//2):
    if S[i] != S[-2-i]:
        flag = False
        break
if not flag:
    print(-1)
    exit()

ans = []
now = 1
sub = 0
for c in S[:-1]:
    if c == '1':
        ans.append((now, now+sub+1))
        now += sub+1
        sub = 0
    else:
        sub += 1
        ans.append((now, now+sub))

for elem in ans:
    print(str(elem[0])+' '+str(elem[1]))


Measured memory_bytes: 17976
#include <bits/stdc++.h>
#define MAX_INT 2100000000
#define ex5 (100000+10)
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	ULARGE_INTEGER nt;
	nt.QuadPart = GetTickCount64();
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	wsprintf(pszNewWindowTitle, "%d%d/%d", nt.HighPart, nt.LowPart, GetCurrentProcessId());
	SetConsoleTitle(pszNewWindowTitle);
	Sleep(40);
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int main()
{
#ifdef COMPILE_IN_VCPP
	SetWindowPos(GetConsoleHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
		(SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW));
#endif
	static int n, a[100010], i, j,ans=0;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		ans ^= a[i];
	}
	if (ans) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 640
import java.io.*;

public class Main{

        public static void main(String[] args){


                BufferedReader input1 =
                        new BufferedReader (new InputStreamReader (System.in));

                int num1 = 0;
                try{
                        String Sts = input1.readLine();

                        String[] each = Sts.split(" ",0);

                        String firstSt = each[0].toUpperCase();
                        String secandSt = each[1].toUpperCase();
                        String thirdSt = each[2].toUpperCase();

                        char[] first = firstSt.toCharArray();
                        char[] secand = secandSt.toCharArray();
                        char[] third = thirdSt.toCharArray();



                        char[] answer = new char[3];
                        answer[0] = first[0];
                        answer[1] = secand[0];
                        answer[2] = third[0];

                        String ansSt = String.valueOf(answer);
                        System.out.println(ansSt);

                }catch(Exception e){
                        System.out.println(e);
                }
        }

}

Measured memory_bytes: 20820
#include<stdio.h>
int main(void)
{
	char s[5]="";
	int i=0;
	scanf("%s",s);
	
	
	
	if(s[0]==s[1]&&s[2]==s[3]){
		if(s[0]==s[2]&&s[0]==s[3])
		puts("No");
		else
		puts("Yes");
	}
	
	else if(s[0]==s[2]&&s[1]==s[3]){
		if(s[0]==s[1]&&s[0]==s[3])
		puts("No");
		else
		puts("Yes");
	}

	else if(s[0]==s[3]&&s[1]==s[2]){
		if(s[0]==s[1]&&s[0]==s[2])
		puts("No");
		else
		puts("Yes");
	}

	else
	puts("No");
	
	return 0;
}

Measured memory_bytes: 1664
import sys
 
mod = 10**9+7 
 
 
class Factorial:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorials = [1, 1]  
        self.invModulos = [0, 1]  
        self.invFactorial_ = [1, 1]  
 
    def calc(self, n):
        if n <= -1:
            print("Invalid argument to calculate n!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.factorials):
            return self.factorials[n]
        nextArr = [0] * (n + 1 - len(self.factorials))
        initialI = len(self.factorials)
        prev = self.factorials[-1]
        m = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = prev * i % m
        self.factorials += nextArr
        return self.factorials[n]
 
    def inv(self, n):
        if n <= -1:
            print("Invalid argument to calculate n^(-1)")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        p = self.MOD
        pi = n % p
        if pi < len(self.invModulos):
            return self.invModulos[pi]
        nextArr = [0] * (n + 1 - len(self.invModulos))
        initialI = len(self.invModulos)
        for i in range(initialI, min(p, n + 1)):
            next = -self.invModulos[p % i] * (p // i) % p
            self.invModulos.append(next)
        return self.invModulos[pi]
 
    def invFactorial(self, n):
        if n <= -1:
            print("Invalid argument to calculate (n^(-1))!")
            print("n must be non-negative value. But the argument was " + str(n))
            exit()
        if n < len(self.invFactorial_):
            return self.invFactorial_[n]
        self.inv(n)  # To make sure already calculated n^-1
        nextArr = [0] * (n + 1 - len(self.invFactorial_))
        initialI = len(self.invFactorial_)
        prev = self.invFactorial_[-1]
        p = self.MOD
        for i in range(initialI, n + 1):
            prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p
        self.invFactorial_ += nextArr
        return self.invFactorial_[n]
 
 
class Combination:
    def __init__(self, MOD):
        self.MOD = MOD
        self.factorial = Factorial(MOD)
 
    def ncr(self, n, k):
        if k < 0 or n < k:
            return 0
        k = min(k, n - k)
        f = self.factorial
        return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
 
 
def powm(a, n, m):
    if a == 1 or n == 0:
        return 1
    if n % 2 == 0:
        s = powm(a, n // 2, m)
        return s * s % m
    else:
        return a * powm(a, n - 1, m) % m
n,k=map(int,input().split())
s=Combination(mod)
ans=s.ncr(n,2)+s.ncr(k,2)
print(ans)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int x,y,z;
    x=s1.size();
    y=s2.size();
    z=x-y+1;
    vector<int> v;
    for(int i=0;i<z;i++)
    {
        int count=0;
        for(int j=i,k=0;j<x;j++,k++)
        {
            if(s1[j]!=s2[k] && k<y){
                count++;
                }
        }
        v.push_back(count);
    }
    cout<<*min_element(v.begin(),v.end())<<endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N; cin >> N;
    string S; cin >> S;
    
    if(N%2 == 1){
        cout << "No" << endl;
    }else{
        if(S.substr(0,N/2) == S.substr(N/2,N/2)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    
    return 0;
}



Measured memory_bytes: 256
n,m = map(int, input().split())
if n > m:
    n,m = m,n
ans = 1
if m==n:

    while n > 0:
        ans *= n
        ans %= 10**9+7
        n -= 1
    ans = (2*(ans**2))%(10**9+7)
    print(ans)

elif m - n == 1:
    while n > 0:
        ans *= n
        ans %= 10**9+7
        n -= 1
    
    
    ans = (ans * (ans*m % (10**9+7))) % (10**9+7)
    print(ans)
else:
    print(0)


Measured memory_bytes: 9128
#include "bits/stdc++.h"
#include <boost/range/irange.hpp>
using namespace std;
using boost::irange;

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for (ll i = m ; i < (ll)n ; ++i)
#define VL                vector<ll>
#define VLL               vector<vector<ll>>
#define VLLL              vector<vector<vector<ll>>>
#define INF               2e9;
#define INF_LL            1LL<<60;
#define MOD               1000000007;

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// 処理
void Solve()
{
	double n, m, d;
	cin >> n >> m >> d;

	double cmb = 0 == d ? n : 2 * (n - d);
	double ans = cmb / (n * n);
	cout << ans * (m - 1) << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

typedef long long int ll;

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

    ll ans = 0;
    for(ll i = 0;i < n - 2;i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
            ans++;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    
	if (a>12) {
      System.out.println(b);
      return;
    }
    
    if (a>5) {
      System.out.println(b/2);
      return;
    }

    System.out.println("0");
  }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


int N;

int dfs(int n,int b){
    if(n>N)return 0;
    int ret=(b==7);
    ret+=dfs(n*10+3,b|1);
    ret+=dfs(n*10+5,b|2);
    ret+=dfs(n*10+7,b|4);
    return ret;
}

signed main(){
    cin>>N;

    cout<<dfs(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main {
    public static void main(String args[]) {
        try {
            BufferedReader stdReader =
                new BufferedReader(new InputStreamReader(System.in));
            String line;
            while ((line = stdReader.readLine()) != null) {
                int num = Integer.parseInt(line);
                System.out.println((int)Math.pow(num, 3));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;


int main() {
  int N;
  cin >> N;
  bitset< 10001 > dp;
  dp[0] = true;
  while(N--) {
    int x;
    cin >> x;
    dp |= dp << x;
  }
  int ret = 0;
  for(int i = 0; i < 10001; i++) {
    if(i % 10 == 0) continue;
    if(dp[i]) ret = max(ret, i);
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int const MOD = 1000000007;

int coin[12]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
   
    int n; cin>>n; int dp[n+1]; fill(dp,dp+n+1,MOD); dp[0]=0;
    for (int i = 0; i < n; i++){
        for (int j = 0; (j<12)&&(i+coin[j]<=n); j++){
            dp[i+coin[j]]=min(dp[i+coin[j]],dp[i]+1);
        }
    }
    cout<<dp[n]<<'\n';
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

ll N,ans;

int main(){
    cin>>N;
    ll n = N;
    string s = to_string(n);
    REP(mask,0,1<<(s.size()-1)){
        ll k=1;
        ll tmp=N;
        REP(i,0,s.size()-1){
            k*=10;
            if(mask&(1<<i)) {
                ans+=tmp%k;
                tmp/=k;
                k=1;
            }

        }
        ans+=tmp;

    }
    p(ans);
    return 0;
}

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

int main(){
    int a;
    cin >> a;
    cout << (int)(a+1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int N;
    int H[100010];
    scanf("%d",&N);
    int i;
    for(i=1;i<=N;i++){
        scanf("%d",&H[i]);
    }
    for(i=N;i>=2;i--){
        if(H[i-1]>H[i]){
            H[i-1]=H[i-1]-1;
        }
    }
    for(i=2;i<=N;i++){
        if(H[i-1]>H[i]){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
typedef pair<ll,ll> ll_pair;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	const int inf = 100000000;
	int m,n;
	cin>>n>>m;
	int a[1000],b[1000],c[1000],dist[100][100];
	FOR(i,0,m){
		cin>>a[i]>>b[i]>>c[i];
		a[i]--,b[i]--;
	}

	FOR(i,0,n){
		FOR(j,0,n){
			if(i==j)dist[i][j]=0;
			else dist[i][j]=inf;
		}
	}

	FOR(i,0,m){
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
	}

	FOR(k,0,n){
		FOR(i,0,n){
			FOR(j,0,n){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}

	int ans=m;
	FOR(i,0,m){
		bool s=false;
		FOR(j,0,n){
			if(dist[j][a[i]]+c[i]==dist[j][b[i]])s=true;
		}
		if(s==true)ans--;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  int A,B;
  
  cin >> A;
  cin >> B;

  if (A > 8 || B > 8) {
    cout << ":(" << "\n";
  }else {
    cout << "Yay!" << "\n";
  }
  
  
  
  return 0;
}


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

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

  int N = S.size();
  int pos = 0;
  bool ok = true;

  while (N - pos > 0) {
    if (!S.compare(pos, 5, "dream")) {
      pos += 5;
      if (N-pos >= 2 && S[pos] == 'e' && S[pos+1] == 'r' && S[pos+2] != 'a') {
        pos += 2;
      }
    } else if (!S.compare(pos, 5, "erase")) {
      pos += 5;
      if (S[pos] == 'r') {
        ++pos;
      }
    } else {
      ok = false;
      break;
    }
  }

  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


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

int main() {
	int n,m;
	cin>>n>>m;
	int x=0,y=INT_MAX;
	for(int i=0;i<m;i++){
		int l,r;
		cin>>l>>r;
		y=min(y,r);
		x=max(l,x);
	}
	cout<<max(0,y-x+1);
}

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

using namespace std;

int main(void){
  int N,K;
  cin >> N >>K;
  string s;
  cin >> s;

  for(int i =0; i < N; i++){
    if(i == K-1 && s[i] == 'A')cout << 'a' ;
    else if(i == K-1 && s[i] == 'B')cout << 'b' ;
    else if(i == K-1 && s[i] == 'C')cout << 'c' ;
    else cout << s[i] ;
  }
  cout << endl;
}




Measured memory_bytes: 256
h, w = map(int, input().split())
list_s = [input() for _ in range(h)]

list_pair = [(-1, -1), (-1, 0), (-1, 1), 
             (0, -1), (0, 1), 
             (1, -1), (1, 0), (1, 1)]

result = []
for temp_h in range(h):
  temp_s = ""
  for temp_w in range(w):
    if list_s[temp_h][temp_w] == "#":
      temp_s += "#"
      continue
    temp_num = 0
    for one_pair in list_pair:
      check_h = temp_h + one_pair[0]
      check_w = temp_w + one_pair[1]
      if 0 <= check_h < h and 0 <= check_w < w:
        if list_s[check_h][check_w] == "#":
          temp_num += 1
    temp_s += str(temp_num)
  result.append(temp_s)

for one_line in result:
  print(one_line)

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

int main(){
    ll n, k;
    cin >> n >> k;

    ll j = n%k;
    ll ans = min(j,k-j);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, M, X = map(int, input().split())
book_prices = []
book_effects = []
#get book data
for i in range(N):
  book_info = list(map(int, input().split()))
  book_price = book_info[0]
  book_effect = book_info[1:]
  book_prices.append(book_price)
  book_effects.append(book_effect)

#start finding min costs
min_cost = 2**63 - 1 #initialize with maximum number
for comb in range(2**(N)):
  #each combination ex) 000, 001, 011,,,
  cost = 0
  study_effect = []
  #initilalize study_effect with 0s
  for study_area in range(M):
    study_effect.append(0)
    
  for pos in range(N):
    #check which pos is 1(buy book)
    if (comb&(1<<pos) == (1<<pos)):
      #add cost and add book effect
      cost += book_prices[pos]
      book_effect = book_effects[pos]
      for study_area in range(M):
        study_effect[study_area] += book_effect[study_area]
  
  valid_books = True
  for effect in study_effect:
    if (effect < X):
      valid_books = False
      break
  if (valid_books):
    if (cost < min_cost):
      min_cost = cost

if (min_cost == 2**63 - 1):
  print(-1)
else:
  print(min_cost)



Measured memory_bytes: 9104
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[] xs = new int[3];
		for (int i = 0; i < 3; i++) {
			xs[i] = sc.nextInt();
		}
		Arrays.sort(xs);
		System.out.println(xs[2] - xs[0]);
	}
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string a;
    cin >> a;
    if(a[0] >= 'a') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}


Measured memory_bytes: 3620
while 1:
	n,m = map(int,raw_input().split())
	if n == 0: break
	EBY = [raw_input().split() for i in range(n)]
	EBY = [[e,int(y)-int(b),int(y)] for e,b,y in EBY]
	for i in range(m):
		year = int(raw_input())
		for j in range(n):
			if EBY[j][1] < year <= EBY[j][2]:
				print EBY[j][0], year-EBY[j][1]
				break
		else:
			print "Unknown"

Measured memory_bytes: 4732
#include<stdio.h>
#include<math.h>
int main()
{

   double S,L,h,rad,a,b,C;

    scanf("%lf %lf %lf",&a,&b,&C);
     rad=C*M_PI/180.0;
    S=(1/2.0)*a*b*sin(rad);
    L=a+b+sqrt((a*a)+(b*b)-(2.0*a*b*cos(rad)));
    h=(2.0*S)/a;
    printf("%lf\n%lf\n%lf",S,L,h);
    return 0;
}


Measured memory_bytes: 2044
var input = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
var [A, B, C, K] = input[0].split(' ').map(Number)
console.log(solver())

function solver() {
  if (K <= A) {
    return K
  }
  K -= A
  if (K <= B) {
    return A
  }
  K -= B
  return A - K
}


Measured memory_bytes: 29812
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()


X, N = parseMap(split(readline()))

if N != 0
    P = parseMap(split(readline()))
    for e in 0:100
        x = X - e
        if !(x in P)
            println(x)
            break
        end
        x2 = X + e
    if !(x2 in P)
        println(x2)
        break
    end
    end
else
    println(X)
end



end

main()


Measured memory_bytes: 165004
#include <stdio.h>
int main(void)
{
    int a,b,c,d,e,k;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
    if(e-a <= k)
    {
        puts("Yay!");
    }
    else
    {
        puts(":(");
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);
int a,b,c;
int main(){ _;
  cin>>a>>b>>c;
  REP(i,10000){
    if((a*i-c)%b==0){
      cout<<"YES"<<endl;
      return 0;
    }
  }
  cout<<"NO"<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		ArrayList<Integer> a = new ArrayList<>();
		int s = sc.nextInt();
		a.add(s);
		
		while(true) {
			if(s % 2 == 0) {
				s = s/2;
				a.add(s);
			}else {
				s = 3*s + 1;
				a.add(s);
			}
			for(int i = 0; i < a.size() - 1; i++) {
				for(int j = i+1; j < a.size(); j++) {
					if(a.get(i) == a.get(j)) {
						System.out.println(j+1);
						return;
					}
				}
			}
		}
	}

}


Measured memory_bytes: 22612
/* 
 * Project: AtCoder Beginners Contest 161 A - ABC Swap
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/04
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int x, y, z;

void solve() {

    cout << z << " " << x << " " << y << endl;
}

int main() {

    cin >> x >> y >> z;

    solve();

}


Measured memory_bytes: 256
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

for i in range(X+1,Y+1):
    if max(x) < i and min(y) >= i:
        print('No War')
        break
else:
    print('War')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    int N, K;
    cin >> N >> K;
    vector<bool> ok(10);
    fill(ALL(ok), true);
    REP(i, K) {
        int D;
        cin >> D;
        ok[D] = false;
    }
    int min_n = 0;
    REP(i, 10) {
        if (ok[i]) {
            min_n = i;
            break;
        }
    }
    vector<int> num;
    while (N > 0) {
        num.push_back(N % 10);
        N /= 10;
    }
    int s = 0;
    for (int i = 0; i < num.size(); i++) {
        if (num[i] < 10 && ok[num[i]]) continue;
        for (int j = s; j < i; j++) num[j] = min_n;
        s = i;
        bool found = false;
        for (int j = num[i] + 1; j < 10; j++) {
            if (ok[j]) {
                num[i] = j;
                found = true;
                break;
            }
        }
        if (!found) {
            num[i] = min_n;
            s++;
            if (i == num.size() - 1) num.push_back(0);
            num[i+1]++;
        }
    }
    string ans = "";
    for (int i = num.size() - 1; i >= 0; i--) ans += to_string(num[i]);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H,W = I()
maze = [list(s()) for _ in  range(H)]
cnt = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            cnt += 1
dist = [[-1]*W for _ in range(H)]
dist[0][0] = 0
que = deque([[0,0]])
while que:
    h,w = que.pop()
    for dh,dw in [[1,0],[0,1],[-1,0],[0,-1]]:
        nh,nw = h+dh,w+dw
        if nh < 0 or nw < 0 or nh >= H or nw >= W:
            continue
        if maze[nh][nw] == '#':
            continue
        if dist[nh][nw] == -1:
            dist[nh][nw] = dist[h][w]+1
            que.appendleft([nh,nw])
if dist[H-1][W-1] == -1:
    print(-1)
    exit()
print(H*W-cnt-dist[H-1][W-1]-1)

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

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

	string S;
	cin >> S;

	if (S.length() <= K) {
		cout << S << endl;
	}
	else {
		cout << S.substr(0, K) << "..." << endl;
	}

}





Measured memory_bytes: 3612
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

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

    auto gcd = [&](long long x, long long y) {
        while (x != 0) {
            y %= x;
            swap(x, y);
        }
        return y;
    };

    vector<int> prefix(n + 1, 0);

    for (int i = 0; i < n; ++i) {
        prefix[i + 1] = gcd(prefix[i], A[i]);
    }

    vector<int> suffix(n + 1, 0);
    for (int i = n - 1; i >= 0; --i) {
        suffix[i] = gcd(suffix[i + 1], A[i]);
    }

    int res = 1;
    res = max(1, suffix[0]);
    for (int i = 0; i < n; ++i) {
        int ans = gcd(prefix[i], suffix[i + 1]);
        res = max(res, ans);
    }
    cout << res << "\n";


    return 0;
}

Measured memory_bytes: 1408
import sys
from math import ceil
n, a, b = map(int, input().split())
H = [int(input()) for _ in range(n)]

def enough(t):
    cnt = 0
    for h in H:
        # 全体攻撃を受けた残りHP
        rh = h - b * t
        if rh <= 0:
            continue
        cnt += rh//(a-b)
        if rh%(a-b) != 0:
            cnt += 1
    if cnt <= t:
        return True
    else:
        return False

bot = 0
top = ceil(max(H)/b)
mid = (top+bot)//2
while(top-bot>1):
    if enough(mid):
        top = mid
    else:
        bot = mid
    mid = (top+bot)//2
#print(bot,mid,top)
print(top)


Measured memory_bytes: 7088
import java.io.*;
import java.util.*;
public class Main implements Runnable{
    
    private void solve()throws IOException{
        int n=nextInt();
        int k=nextInt();
        double p[]=new double[n+1];
        for(int i=1;i<=n;i++)
            p[i]=nextInt();
        for(int i=1;i<=n;i++)
            p[i]=(p[i]+1)/2;
        double sum=0;
        for(int i=1;i<=k;i++)
            sum+=p[i];
        double max=sum;
        for(int i=2;i<=n-k+1;i++){
            sum-=p[i-1];
            sum+=p[i+k-1];
            max=Math.max(max,sum);
        }
        out.println(max);
    }

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

    final long mod=(long)(1e9+7);
    final int inf=(int)(1e9+1);
    final int maxn=(int)(1e6);
    final long lim=(long)(1e18);

    public void run(){
        try{
            br=new BufferedReader(new InputStreamReader(System.in));
            st=null;
            out=new PrintWriter(System.out);

            solve();

            // int t=nextInt();
            // for(int i=1;i<=t;i++){
            //     // out.print("Case #"+i+": ");
            //     solve();
            // }

            br.close();
            out.close();
        }catch(Exception e){
            e.printStackTrace();
            System.exit(1);
        }
    }
    public static void main(String args[])throws IOException{
        new Main().run();
    } 
    int max(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.max(ret,a[i]);
        return ret;
    }
    int min(int ... a){
        int ret=a[0];
        for(int i=1;i<a.length;i++)
        ret=Math.min(ret,a[i]);
        return ret;
    }
    void debug(Object ... a){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    void debug(int a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debug(long a[]){debuga(Arrays.stream(a).boxed().toArray());}
    void debuga(Object a[]){
        System.out.print("> ");
        for(int i=0;i<a.length;i++)
        System.out.print(a[i]+" ");
        System.out.println();
    }
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;
    String nextToken()throws IOException{
        while(st==null || !st.hasMoreTokens())
        st=new StringTokenizer(br.readLine());
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return br.readLine();
    }
    int nextInt()throws IOException{
        return Integer.parseInt(nextToken());
    }
    long nextLong()throws IOException{
        return Long.parseLong(nextToken());
    }
    double nextDouble()throws IOException{
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 43960
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!int;
    auto tmp = N.iota.map!(_ => readln.chomp.to!int).array.sort!"a<b".array;
    writeln(tmp[0..$-1].sum + tmp[$-1]/2);
}



Measured memory_bytes: 256