akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>
 
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;
 
//逆元をつかった二項係数
//----------------------------------------------
ll mx = 1000000;
vector<ll> fac(mx);
vector<ll> ifac(mx);

//modpow
ll mpow(ll x, ll n){
    ll ans = 1;
    while(n != 0){
        if(n & 1) ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

//二項係数を求める
ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0 || b < 0)return 0;
    ll tmp = ifac[a - b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

//facとifacの前処理
void pre_comb(ll n){
  fac[0] = 1;
  ifac[0] = 1;
    rep(i, n){
        fac[i + 1] = fac[i] * (i + 1) % MOD;
        ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
    }
}
//----------------------------------------------

int main(){
  ll n, k;
  cin >> n >> k;
  pre_comb(1000000);
  k = min(n - 1, k);

  ll res = 0, cnt = 0;
  for(int i = n - 1; i >= 1; i--){
    cnt++;
    if(cnt > k)break;
    res += (comb(n - 1, i - 1) * comb(n, i)) % MOD;
    res %= MOD;
    //cout << comb(n - 1, i - 1) << " " << comb(n, i) << endl;
  }
  cout << res + 1 << endl;
}
 

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

using namespace std;

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	long long x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	long long ans = 0, c = x / d;
	if (c >= k) {
		ans = abs(x - k * d);
	} else {
		k -= c;
		x -= c * d;
		if (k % 2) x -= d;
		ans = abs(x);
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3652
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = LIST()

L.sort()

print(sum(L[::2]))


Measured memory_bytes: 5328
n = gets.to_i
a = Array.new
 
n.times do
a << gets.to_i    
end
 
t = 0
answer = -1
b = 1
n.times do
    t = t + 1
    b = a[b-1]
    if b==2
        answer = t
        break
    end
end
 
puts answer

Measured memory_bytes: 5044
# DPL_1_B - 0,1ナップザック問題　
# 配るDPで解いてみる

import sys

N, C = map(int, sys.stdin.readline().strip().split())  # C: content 容量

v, w = [], []
for _ in range(N):
    i, j = map(int, sys.stdin.readline().strip().split())
    v.append(i)
    w.append(j)

# dp 配列の初期化
dp = [[0] * (C + 1) for _ in range(N + 1)]


for n in range(N):
    for c in range(C + 1):
        dp[n + 1][c] = max(dp[n + 1][c], dp[n][c])

        if c + w[n] <= C:
            dp[n + 1][c + w[n]] = max(dp[n][c] + v[n], dp[n + 1][c + w[n]])

# for i in range(len(dp)):
#     print(dp[i])

ans = dp[-1][-1]
print(ans)



Measured memory_bytes: 41892
#include<bits/stdc++.h>
using namespace std;
#define MAX 100001
#define MOD 1000000007
#define ll long long
#define ld long double
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main() {
	fast;
	int t = 1;
	// cin >> t;
	while(t--) {
		ll n;
		cin >> n;
		ll ans = 0;
		for(ll i=1;i<sqrt(n);i++) {
			ans += (n - 1 - i * i) / i;
		}
		ans = 2 * ans + (ll)sqrt(n);
		if((ll)sqrt(n) * (ll)sqrt(n) == n) ans--;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToList();
        var sx = line[0]; var sy = line[1];
        var tx = line[2]; var ty = line[3];
        Seek(sx, sy, tx, ty);
    }
    //U-up D-down R-right L-left
    static void Seek(int sx, int sy, int tx, int ty)
    {
        var go1 = new List<char>();
        var go2 = new List<char>();
        var back1 = new List<char>();
        var back2 = new List<char>();
        var mx = Math.Abs(tx - sx);
        var my = Math.Abs(ty - sy);
        back1.Add('U');
        back2.Add('R');
        for (var i = 0; mx > i; i++)
        {
            go1.Add('R');
            go2.Add('R');
            back1.Add('L');
            back2.Add('L');
        }
        back1.Add('L');
        back2.Add('L');

        for (var i = 0; my > i; i++)
        {
            go1.Add('U');
            go2.Insert(0, 'U');
            back1.Add('D');
            back2.Insert(1, 'D');
        }
        back1.Add('D');
        back1.Add('R');
        back2.Insert(1, 'D');
        back2.Add('U');

        Console.WriteLine($"{new String(go1.ToArray())}{new String(back1.ToArray())}{new String(go2.ToArray())}{new String(back2.ToArray())}");
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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




int main(){

    int n;
    cin >> n;
    string s[3];
    inrep(3,s);

    ll ans = 0;
   
    rep(i,0,n){
        set<char> c;
        rep(j,0,3){
            c.it(s[j][i]);
        }
        if(sz(c) >= 3){
            ans += 2;
        }else if(sz(c) >= 2){
            ans++;
        }
    }
    P(ans);
	return  0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k,total,h,a,b,x,y,n;
    	cin>>n;
    	ll p[n];
    	rep(i,0,n)
    	cin>>p[i];
    	m=p[0]; l=1;
    	rep(i,1,n)
    	{
    		if(m>p[i])
    		{
    			m=p[i]; l++;
			}
		}
    	cout<<l;
    } 
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
const int dx[4] = {1, 0, -1, 0} , dy[4] = {0, 1, 0, -1};
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

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

    int a,b; cin >> a >> b;
    string aa="" , bb="";
    REP(i,b) aa += to_string(a);
    REP(i,a) bb += to_string(b);
    out(min(aa,bb));

    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

n,m = map(int,input().split())

l = sorted([list(map(int,input().split())) for i in range(m)],key=itemgetter(1))



check = -1
count = 0
for a,b in l:
  if a > check:
    count += 1
    check = b-1

print(count)
            






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

#define ll long long int
#define pb push_back
#define MP make_pair
#define PLL pair<ll,ll>
#define fastio ios::sync_with_stdio(0);cin.tie(0);

ll arr[1000009];
int main()
{
  string s;
  ll k;
  cin >> k;
  cin >> s;

  if(s.length() > k)
   {
     for(ll i=0;i<k;i++)
     cout << s[i];
     cout <<"...";
   }
   else
   cout << s;

}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int ans = 0;
        if(a < c){
            if(b < c){
                ans = 0;
            }else{
                if(b < d){
                    ans = b -  c;
                }else{
                    ans = d - c;
                }
            }
        }else{
            if(d < a){
                ans = 0;
            }else{
                if(b < d){
                    ans = b -a;
                }else{
                    ans = d - a;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, N = 0, m = 0, maxy = 0, mini = 9999999999, mini2 = 9999999999, counter = 0, endp = 0, checker = 0;

std::vector <long long int> vec{}, vecsec{}, vecth{};
long long int iremono[100010], koware[100001];
long long  int iremono2[100001], check[100001], xpo[10000001], ypo[10000001], hei[1000001];
std::vector<std::string>kinds{}, kaku{};
char maze[1000];
int sx, sy;
int gx, gy;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
long long int dp[4][100003] ,ire[4][100003];
std::string input[103],one,two,three;
char re;

int H, W;//はんい
bool qw = false, er = false, ty = false, ui = false;
std::string code;
long long int gcd(long long int a, long long int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}

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

int main() {
	cin >> a >> b;
	if (b - a >= 2019) {
		cout << 0 << endl;
	}
	else {
		for (long long int i = a; i <= b;i++) {
			for (long long int j = i+1; j <= b; j++) {
				mini = min(mini,i*j % 2019);
			}
		}
		cout << mini << endl;
	}
}




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

using namespace std;
int dp[3001][3001];

int main()
{
	string s1,s2;
	cin>>s1>>s2;
	for (int i = 0; i < 3001; ++i)
	{
		dp[i][0]=0;
		dp[0][i]=0;
	}
	for (int i = 0; i < s1.length(); ++i)
	{
		for (int j = 0; j < s2.length(); ++j)
		{
			if(s1[i]==s2[j])
			{
				dp[i+1][j+1]=dp[i][j]+1;
			}
			else
			{
				dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
			}
		}
	}
	string s3;
	// cout<<dp[s1.length()][s2.length()]<<'\n';
	int j=s2.length(),i=s1.length();
	while(i!=0 || j!=0)
	{
		// cout<<i<<" "<<j<<'\n';
		if(s2[j-1]==s1[i-1])
		{
			s3.push_back(s2[j-1]);
			i--;
			j--;
		}
		else
		{
			if(i==0)
			{
				j--;
			}
			else if(j==0)
			{
				i--;
			}
			else if(dp[i][j-1]>=dp[i-1][j])
			{
				j--;
			}
			else
			{
				i--;
			}
		}
	}
	for (int i = s3.length()-1;i>=0; --i)
	{
		cout<<s3[i];
	}
	cout<<'\n';
}

Measured memory_bytes: 35456
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n = sc.nextInt();

        int d[]=sc.nextIntArray(5);
        int k=sc.nextInt();
        sort(d);
        
       
        out.println(abs(d[0]-d[4])<=k?"Yay!":":(");
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id,T;
//    P(int id, int T) {
//        this.id=id;
//        this.T=T;
//    }
//    public int compareTo(P p){
//        return id-p.id; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (int (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (int (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (int)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;
#define fi                  first
#define se                  second

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
// テーブルを作る前処理
const int MAX = 2e6;
long long fac[MAX], finv[MAX], inv[MAX];
void CombInit()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算(nCk)
long long CombExec(int n, int k)
{
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	ll n;
	cin >> n;
	n++;
	vector<int> a(n);
	vector<ll> idx(n, 0);
	int jufukuVal = 0;
	REP(i, n) {
		int val;
		cin >> val;
		a[i] = val;
		if (0 < idx[val]) {
			jufukuVal = val;
		}
		idx[val]++;
	};

	ll nokoriNum;
	{
		int edIdx = INF;
		int stIdx = INF;
		REP(i, n) {
			if (a[i] == jufukuVal) {
				if (stIdx == INF) stIdx = i;
				else edIdx = i;
			}
		}
		ll lNum = stIdx;
		ll rNum = n - edIdx - 1;
		nokoriNum = lNum + rNum;
	}

	CombInit();
	vector<ll> ans(n);
	REP(i, n) {
		int r = i + 1;
		ll cmbAll = CombExec(n, r);
		ll cmbPart = CombExec(nokoriNum, r - 1);
		ans[i] = (cmbAll - cmbPart);
		ans[i] = (ans[i] + MOD) % MOD;
	} 

	REP(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 50048
#include <stdio.h>

int main()
{
  int A,B,T;
  scanf("%d %d %d",&A,&B,&T);
  int cookies = 0;
  for(int i=1;i<=T;i++)
  {
    if(i % A == 0)
    {
      cookies += B;
    }
  }
  printf("%d\n",cookies);
}


Measured memory_bytes: 128
import math
from collections import Counter
n,p=map(int,input().split())

if n==1:
    s=p
else:
    l=[]
    k=2
    while k*k<=p:
        if p%k==0:
            l.append(k)
            p=p//k
        else:k+=1
    if p>0:l.append(p)

    c=Counter(l)
    s=1
    for key,value in c.items():
        s*=key**(value//n)
print(s)











Measured memory_bytes: 38512
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  lli n;
  cin>>n;
  if(n%10==2 or n%10==4 or n%10==5 or n%10==7 or n%10==9 )
  cout<<"hon"<<"\n";
  else if(n%10==0 or n%10==1 or n%10==6 or n%10==8)
  cout<<"pon"<<"\n";
  else
  cout<<"bon"<<"\n";
}

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

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

    vector<int> d(K);
    map<int, int> P;

    rep(i,K) {
        cin >> d.at(i);
        rep(j,d.at(i)) {
            int tmp = 0;
            cin >> tmp;
            if(P.count(tmp)){
                continue;
            } else {
                P[tmp] = 1;
            }
        }
    }

    int sum = 0;
    rep(i,N) {
        if(P.count(i+1)){
            continue;
        } else {
            sum += 1;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define FOR(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define FORN(i,b,a)for(int i=(b);_a=(a);i>=_a;i--)
#define REP(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
int main()
{
	vector<ll>v;
	ll a[100100],b[100100];
	int n;
	cin>>n;
	REP(i,n)cin>>a[i];
	REP(i,n)cin>>b[i];
	ll cnt1=0,cnt2=0;
	ll sum=0;
	ll ans=0;
	REP(i,n)
	{
		if(a[i]>b[i])v.pb(a[i]-b[i]);
		if(a[i]<b[i]){ans++;
		sum+=b[i]-a[i];
		}
		cnt1+=a[i];
		cnt2+=b[i];
	}
	if(cnt1<cnt2){
		cout<<-1<<endl;
		return 0;
	}
	sort(v.rbegin(),v.rend());
	REP(i,v.size())
	{
		if(sum>0)
		{
			sum-=v[i];
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 2428
local function gcd(a,b)if(a>b)then a,b=b,a end while(a~=0)do a,b=b%a,a end return b end
local function lcm(a,b)return a/gcd(a,b)*b end

A=io.read"*n"
B=io.read"*n"

print(lcm(A,B))

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = n % k;
    ans = min({ans, abs(k - ans), abs(ans - k)});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

const int MOD = 1000000000+7;

char field[1010][1010];
int dp[1010][1010];

int main(void) {
  int H, W;
  scanf("%d%d", &H, &W);
  REP(i, H) {
    scanf("%s", field[i]);
  }
  dp[0][0] = 1;
  REP(i, H) {
    REP(j, W) {
      if(field[i][j] == '#') {
        dp[i][j] = 0;
      } else {
        if(i > 0) {
          dp[i][j] += dp[i-1][j];
        }
        if(j > 0) {
          dp[i][j] += dp[i][j-1];
        }
        dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <set>

using namespace std;

const int MAX_N = 3e5 + 5;

set<int> taken;
int arr [MAX_N];

void put (int pos, int val) {
  arr[pos] = val;
  taken.erase(val);
}

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

  if (x == 1 || x == 2 * n - 1) {
    cout << "No" << '\n';
    return 0;
  }

  cout << "Yes" << '\n';

  if (n == 2) {
    cout << 1 << endl << 2 << endl << 3 << endl;
    return 0;
  }
  
  for (int i = 1; i <= 2 * n - 1; i++) {
    taken.insert(i);
  }

  if (x != 2) {
    put(n - 1, 1);
    put(n, x);
    put(n + 1, 2 * n - 1);
    put(n + 2, 2);
  } else {
    put(n - 1, 2 * n - 1);
    put(n, 2);
    put(n + 1, 1);
    put(n + 2, 2 * n - 2);
  }

  for (int i = 1; i <= 2 * n - 1; i++) {
    if (arr[i] == 0) {
      put(i, *taken.begin());
    }
    cout << arr[i] << '\n';
  }
}


Measured memory_bytes: 11648
#include <stdio.h>

#define MAX      500000
#define SENTINEL 1000000000

static int L[MAX / 2 + 1];
static int R[MAX / 2 + 1];
static int num_comparison;

void merge(int A[], int n, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;

    for ( int i = 0; i < n1; i++ ) {
        L[i] = A[left + i];
    }
    for ( int i = 0; i < n2; i++ ) {
        R[i] = A[mid + i];
    }
    L[n1] = R[n2] = SENTINEL;

    int i = 0, j = 0;
    for ( int k = left; k < right; k++ ) {
        num_comparison++;
        if ( L[i] <= R[j] ) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n,  int left, int right)
{
    if ( left + 1 < right ) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main ()
{
    int n;
    int A[MAX];

    scanf("%d", &n);
    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &A[i]);
    }

    mergeSort(A, n, 0, n);

    for ( int i = 0; i < n; i++ ) {
        if ( i > 0 ) {
            printf(" ");
        }
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", num_comparison);

    return 0;
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
const int maxc = 26;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
inline int read(){
    int f = 1,x = 0; char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-')f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - 48;ch = getchar();}
    return f * x;
}
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll qw(ll x,ll y){ll ans = 1;while(y){if(y&1) ans *= x;x *= x;y >>= 1;}return ans;}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool is_prime(ll x){if(x <= 1) return 0;for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;	}
ll x;
ll sq(ll k){
	return k * k * k * k * k;
}
void solve(){
	vector<ll> v;
	map<ll,ll> m;
	set<ll> s;
	for(int i = -5000;i <= 5000;i++){
		v.pb(sq(i));
		m[sq(i)] = i;
		s.insert(sq(i));
	}
	int sz = v.size();
	for(int i = 0;i <sz;i++){
		ll y = v[i] + x;
		if(s.count(y)){
//			cout << v[i] << " " << y << endl;
			cout << m[y] << " " << m[v[i]] << endl;
			break;
		}
	}
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> x;
	solve();	
	return 0;	
}

Measured memory_bytes: 4716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
   int a,b;
   cin >> a >> b;
   if (a%2 == 1 && b%2 == 1) cout << "Odd" << endl;
   else cout << "Even" << endl;
   
   return 0;
}



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

int main() {
  string a, b; cin >> a >> b;
  istringstream ab(a + b);
  int c;
  ab >> c;
  double sq = sqrt(c);
  cout << (sq == ceil(sq) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
using pl = pair<ll,ll>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;

const int M=10000;

int main(int argc,char* argv[])
{
    int s,i=0;
    cin>>s;
    if(s==1||s==2)cout<<4<<endl,exit(0);
    for(i=0;s!=1;i++){
        if(s%2) s=s*3+1;
        else s/=2;
    }
    cout<<i+2<<endl;
    
    return 0;
}




Measured memory_bytes: 256
package main

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

var (
	// ReadString returns a WORD string.
	ReadString func() string
)

func init() {
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
}

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt64() int64 {
	n, _ := strconv.ParseInt(ReadString(), 10, 64)
	return n
}

func readInt() int {
	return int(readInt64())
}

// 10 11 12 => [10, 11, 12]
func readIntSlice(size int) []int {
	a := make([]int, size)
	for i := 0; i < size; i++ {
		a[i] = readInt()
	}
	return a
}

func get2byte(size int) [][]byte {
	a := make([][]byte, size)
	for i := 0; i < size; i++ {
		var low string
		fmt.Scan(&low)
		a[i] = []byte(low)
	}
	return a
}

func transpose(a [][]int) {
	n := len(a)
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			a[i][j], a[j][i] = a[j][i], a[i][j]
		}
	}
}

func fact(n, m int) int {
	res := 1
	for i := m + 1; i <= n; i++ {
		res *= i
	}
	return res
}

func perm(n, r int) int {
	if r > n {
		return 0
	}
	return fact(n, n-r)
}

func comb(n, m int) int {
	if m > n {
		return 0
	}
	return fact(n, n-m) / fact(m, 0)
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

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

func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

func main() {
	n := readInt()
	var sum int64
	for i := 1; i <= n; i++ {
		m := n / i
		sum += int64(i * m * (m + 1) / 2)
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,x;
	cin>>N>>x;
	const int MAX=2*N-1;
	
	if (x==1||x==MAX){
		cout<<"No"<<endl;
		return 0;
	}
	vector<int> A(MAX,0);
	int i=N-1;
	if (x==2){
		A[i-1]=x+1;
		A[i]=x;
		A[i+1]=x-1;
		A[i+2]=x+2;
	}else{
		A[i-1]=x-1;
		A[i]=x;
		A[i+1]=x+1;
		A[i+2]=x-2;
	}
	int j;
	int k=1;
	for (j=0;j<N-2;j++){
		if (A[j]==0){
			while (k<=MAX){
				if (k!=A[i-1]&&k!=A[i]&&k!=A[i+1]&&k!=A[i+2]){
					A[j]=k++;
					break;
				}
				k++;
			}
		}
	}
	for (j=N+2;j<2*N-1;j++){
		if (A[j]==0){
			while (k<=MAX){
				if (k!=A[i-1]&&k!=A[i]&&k!=A[i+1]&&k!=A[i+2]){
					A[j]=k++;
					break;
				}
				k++;
			}			
		}
	}
	cout<<"Yes"<<endl;
	for (i=0;i<MAX;i++){
		cout<<A[i]<<endl;
	}
	A.clear();
	return 0;
}

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

bool	is_diag_queen(char (*grid)[8], int i, int j, int size)
{
	for (int k = max(-i, -j); k < min(size - i, size - j); ++k) {
		if (grid[i + k][j + k] == 'Q')
			return true;
	}
	for (int k = max(-i, j - size + 1); k < min(size - i, j + 1); ++k) {
		if (grid[i + k][j - k] == 'Q')
			return true;
	}
	return false;
}

bool	dfs(char (*grid)[8], bool in_row[], bool in_col[], int depth, int size)
{
	if (depth == size)
		return true;
	bool	found = false;
	for (int i = 0; i < size; ++i) {
		if (in_row[i]) continue;
		for (int j = 0; j < size; ++j) {
			if (in_col[j]) continue;
			if (is_diag_queen(grid, i, j, size)) continue;
			grid[i][j] = 'Q';
			in_row[i] = true;
			in_col[j] = true;	
			found = dfs(grid, in_row, in_col, depth + 1, size);
			if (found) break;
			grid[i][j] = '.';
			in_row[i] = false;
			in_col[j] = false;
		}
		if (found) break;
	}
	return found;
}

int	main()
{
	char	grid[8][8];
	bool	in_row[8], in_col[8];
	for (int i = 0; i < 8; ++i) {
		for (int j = 0; j < 8; ++j)
			grid[i][j] = '.';
	}
	for (int i = 0; i < 8; ++i) {
		in_row[i] = false;
		in_col[i] = false;
	}
	int	k, r, c;
	cin >> k;
	for (int i = 0; i < k; ++i) {
		cin >> r >> c;
		grid[r][c] = 'Q';
		in_row[r] = true;
		in_col[c] = true;
	}
	dfs(grid, in_row, in_col, k, 8);
	for (int i = 0; i < 8; ++i) {
		for (int j = 0; j < 8; ++j)
			cout << grid[i][j];
		cout << endl;
	}
}



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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k,x,sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>x;
		sum+=2*min(x,k-x);
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define MOD 1000000007
#define vi vector<int>
#define deb(n) cout<<#n<<" = "<<n<<endl;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const long long  MAX = 1e18;
int case_no=1;
#define w(x) int x; cin>>x; while(x--)

int solve(int x, vector<int> nums, int n) {
	if(n == 0) return x;
	for(int i=0; i<=n+1; i++) {
		if(nums[x-i] == 0) return x-i;
		if(nums[x+i] == 0) return x+i;
	}
	if(n % 2 != 0) {
		if(x >= n/2+1) return n+1;
		else return 0;
	}
	else {
		if(x <= n/2) return 0;
		else return n+1;
	}
	return 0;  
}
int main()
{
	FIO
	int x, n;
	cin >> x >> n;
	vector<int> nums(105);
	for(int i=0; i<n; i++) {
		int a; cin >> a;
		nums[a] = 1;
	}
	cout << solve(x, nums, n) << endl;
	return 0;
}

Measured memory_bytes: 3656
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        int[] T = new int[N];
        string[] str = Console.ReadLine().Split(' ');
        for(int i=0;i<N;i++){
            T[i] = int.Parse(str[i]); 
        }
        long sum = 0;
        for(int i=0;i<N;i++){
            sum += T[i];
        }
        int M = int.Parse(Console.ReadLine());
        for(int i=0;i<M;i++){
            str = Console.ReadLine().Split(' ');
            int P = int.Parse(str[0]);
            int X = int.Parse(str[1]);
            sb.Append((sum + X - T[P-1]) + "\n");
        }
    }
}

Measured memory_bytes: 2648
#53B A to Z String
s=list(input())
flag=0
for i in range(len(s)):
    if s[i]=="A":start=i;break
for j in range(len(s)-1,0,-1):
    if s[j]=="Z":finish=j;break
s2=len(s[start:finish+1])
print(s2)

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

int main() {
  int a,b,ans=0;
  cin >> a >> b;
  for(int i =0;i<2;i++){
    if(a>b){
      ans += a;
      a--;
    }
    else{
      ans += b;
      b--;
    }
  }
    cout << ans;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
	int n, m, d;
	scanf("%d %d %d", &n, &m, &d);	
	if (d > 0) printf("%.10Lf\n", (long double)(m - 1) * (n - d) * 2 / n / n);
	else printf("%.10Lf\n", (long double)(m - 1) * (n - d) / n / n);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1716
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
const int INF = 1 << 30;
typedef pair < int , int > Pi;
int n, m, mas[101][101], hoge[4][51][51];

bool isfind( const int& k, const int& y, const int& x, Pi& exitp)
{
  for(int i = 0 ; i < m ; i++ ){
    for(int j = 0 ; j < m ; j++ ){
      if( hoge[k][i][j] == -1) continue;
      if( mas[i + y][j + x] != hoge[k][i][j]) return false;
      if(exitp == Pi(-1,-1)) exitp = Pi(i + y + 1,j + x + 1);
    }
  }
  return true;
}

Pi solve()
{

  for(int i = 0 ; i <= n - m ; i++ ){
    for(int j = 0 ; j <= n - m ; j++ ){
      for(int k = 0 ; k < 4 ; k++ ){
        Pi p = Pi( -1, -1);
        if(isfind( k, i, j, p)) return p;
      }
    }
  }
  return Pi( INF, -1);
}
int main()
{
  while(cin >> n >> m, n){
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < n ; j++ ){
        cin >> mas[i][j];
      }
    }
    for(int i = 0 ; i < m ; i++ ){
      for(int j = 0 ; j < m ; j++ ){
        cin >> hoge[0][i][j];
      }
    }

    for(int k = 1 ; k < 4 ; k++ ){
      for(int i = 0 ; i < m ; i++ ){
        for(int j = 0 ; j < m ; j++ ){
          hoge[k][j][m - i - 1] = hoge[k - 1][i][j];
        }
      }
    }

    Pi pos = solve();
    if(pos.first == INF) cout << "NA" << endl;
    else cout << pos.second << " " << pos.first << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll n;
unordered_set<ll> s;

int main() {
    fast_io; cout_precision;
    cin >> n;
    for (ll i = 0, a; i < n; i++) {
        cin >> a;
        s.insert(a);
    }
    cout << s.size() - ((n ^ s.size()) & 1) << endl;
}

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

using ll = long long;
const int INF = 1e9 + 1;

int main(){

	bool dp[10001] = { false };
	dp[0] = true;

	int N, ma = 0;
	cin >> N;
	rep(i, N) {
		int s;
		cin >> s;
		ma += s;

		for (int j = ma; j >= 0; j--)
			if (dp[j])
				dp[j + s] = true;
	}

	for (int i = ma; i >= 0; i--) {
		if (dp[i]&&i % 10 != 0) {
			cout << i << endl;
			return 0;
		}
	}

	cout << 0 << endl;

	return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

void A_Beginner(void) {

	int N, R;
	cin >> N >> R;
	cout << ((N >= 10) ? R : R + 100 * (10 - N));
	return;
}

int main(void) {

	A_Beginner();
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;


int main() {
    int n;scanf("%d",&n);
    int a[n];for(int i=0;i<=n-1;i++)scanf("%d",&a[i]);
    long long int max=1,ans=a[0]-1;
    for(int i=1;i<=n-1;i++){
        if(a[i]<=max);
        else if(a[i]<=max+1)max=a[i];
        else ans+=(a[i]-1)/(max+1);
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

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

    ll X, Y;
    cin >> X >> Y;
    if(X % Y == 0) drop(-1);

    drop(X);

    return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = (int) s.length();
    int ans = n;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[i] != s[i + 1])
        {
            ans = min(ans, max(i + 1, n - 1 - i));
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int win = 0;
	rep(i,s.size()){
		if(s[i] =='o') win ++;
	}
	if((15 - s.size()) + win >= 8) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k *50 == x:
                count += 1

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define llu unsigned long long
#define U unsigned int
#define SIZE 1000002
#define pie 3.14159265358979323
#define minuss 1e-6
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    ll n;
    cin>>n;
    ll str[n+9];
    deque<ll>d;
    for(int i=0;i<n;i++)
    {
         cin>>str[i];
         if(i%2!=0)
            d.push_back(str[i]);
         else
            d.push_front(str[i]);
    }
    if(n%2==0)
        reverse(d.begin(),d.end());

    for(int i=0;i<d.size();i++)
        cout<<d[i]<<" ";

    cout<<endl;

}


Measured memory_bytes: 5376
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

m = 0
c = 0
for i in range(N):
    w = s[i]
    c = s.count(w)
    c -= t.count(w)
    if m < c:
        m = c
print(m)

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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[100000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    sort(A, A + N);
    int lb = -1, ub = N;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        int cur = 0;
        for (int i = 0; i <= mid; i++) {
            cur += A[i];
        }
        for (int i = mid + 1; i < N; i++) {
            if (A[i] <= 2 * cur) {
                cur += A[i];
            } else {
                goto check;
            }
        }
        ub = mid;
        continue;
check:
        lb = mid;
    }
    cout << N - ub << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        bool visible = true;
        for(int j = 0; j < i; j++){
            if(h.at(i) < h.at(j)) visible = false;
        }
        if(visible == true) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
N=int(input())
hk=list(input().split())
h=[int(s) for s in hk]
count=0
if N>2:
  for x in range(N):
    for y in range(N):
      for z in range(N):
        if h[x]!=h[y] and h[y]!=h[z] and h[z]!=h[x]:
          if h[x]+h[y]>h[z] and h[y]+h[z]>h[x] and h[z]+h[x]>h[y]:
            count+=1
count=count//6
print(count)

Measured memory_bytes: 9208