akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
using namespace std;

struct uft{
    vector<ll> par;
    uft(ll n) {
        par.resize(n);
        rep(i,n)par[i]=i;
    }

    ll find(ll a){
        if(par[a]==a){
            return a;
        }else {
            return find(par[a]);
        }
    }

    void unite(ll a,ll b){
        par[find(a)]=find(b);
    }

    bool same(ll a,ll b){
        return find(a) == find(b);
    }
};

struct edge{
    ll s,t,w;
};

bool sortw(edge a,edge b) {
    return a.w < b.w;
}

int main() {
    const ll inf = 1e12;
    ll n;
    cin>>n;
    vector<vector<ll>> matrix(n,vector<ll>(n));
    rep(i,n){
        rep(j,n){
            if(i==j){
                matrix[i][j]=0;
            }else{
                matrix[i][j]=inf;
            }
        }
    }
    rep(i,n) {
        ll u,k;
        cin>>u>>k;
        rep(j,k){
            ll c,w;
            cin>>c>>w;
            matrix[u][c]=w;
        }
    }
    rep(k,n){
        rep(i,n){
            rep(j,n){
                if(matrix[i][k]<inf && matrix[k][j]<inf && matrix[i][j]>matrix[i][k]+matrix[k][j]){
                    matrix[i][j]=matrix[i][k]+matrix[k][j];
                }
            }
        }
    }
    rep(i,n){
        cout<<i<<" "<<matrix[0][i]<<endl;
    }
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<vector<int>> d(n*n+10);
    vector<int> dis(n*n+10);
    for(int i = 0; i < n*n+10; i++)
    {
        dis[i] = -1;
    }
    for(int i = 0; i < n; i++)
    {
        vector<int> tmp(n-1);
        for(int j = 0; j < n-1; j++)
        {
            cin >> tmp[j];
            tmp[j]--;
        }

        for(int j = 1; j <= n-2; j++)
        {
            int mi = min(i, tmp[j-1]);
            int ma = max(i, tmp[j-1]);
            int nmi = min(i, tmp[j]);
            int nma = max(i, tmp[j]);
            d[mi * n + ma].push_back(nmi * n + nma);
            if(dis[mi*n+ma] == -1) dis[mi*n+ma] = 0;
            if(dis[nmi*n+nma] == -1) dis[nmi*n+nma] = 0;
            dis[nmi*n+nma]++;
        }
    }
    queue<int> que;
    for(int i = 0; i < n*n+10; i++)
    {
        if(dis[i] == 0) que.push(i);
    }
    int ans = 0;
    int check = 0;
    while(que.size())
    {
        int size = que.size();
        check += size;
        while(size--)
        {
            int cand = que.front();
            que.pop();
            for(int next : d[cand])
            {
                dis[next]--;
                if(dis[next] == 0) que.push(next);
            }
        }
        ans++;
    }
    if(check != n * (n-1) / 2)
    {
        cout << -1 << endl;
    }
    else cout << ans << endl;
}


Measured memory_bytes: 43264
N = int(input())
A = {'M':0,'A':0,'R':0,'C':0,'H':0}
for i in range(N):
    s = input()
    if s[0] in A:
        A[s[0]] += 1
B = [A['M'],A['A'],A['R'],A['C'],A['H']]

ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += B[i] * B[j] * B[k]
print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int main()
{
	int n; string s;
	cin >> n >> s;
	map<ll,ll> mp;
	for(int i = 0; i < n; i++){
		mp[s[i]-'a']++;
	}
	ll ans = 1;
	for(auto x: mp){
		ans *= x.second+1;
		ans %= MOD;
	}
	cout << ans-1 << endl;
	return 0;
}

Measured memory_bytes: 512
n = int(input())
s = [input() for _ in range(n)]
s.sort()
if n == 1:
    print(s[0])
else:
    maximum = 1
    ans = [s[0]]
    count = 1
    for i in range(1, n):
        if s[i] == s[i-1]:
            count += 1
        else:
            count = 1
        if count == maximum:
            ans.append(s[i])
        elif count > maximum:
            ans = [s[i]]
            maximum = count
    for i in ans:
        print(i)

Measured memory_bytes: 20668
/* test code */
#include <iostream>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	int count[n+1]={};
	rep(i,n){
		cin>>a[i];
		count[a[i]]++;
	}
	ll ans[n+1]={};
	ll sum = 0;
	for(int i=1;i<n+1;i++){
		ll coun = count[i];
		ans[i] = coun*(coun-1)/2;
		sum+=ans[i];
	}
	for(int i=1;i<n+1;i++){
		ll coun = count[a[i-1]]-1;
		ll each = coun*(coun-1)/2;
		cout << sum - ans[a[i-1]] + each << endl;
	}
}


Measured memory_bytes: 5760
import java.math.BigInteger;
import java.util.*;



/**
 * Created by santa on 2016/10/16.
 */

public class Main {

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

        String a = scanner.next();

        System.out.println("ABC" + a);



    }


} // MainClass


Measured memory_bytes: 22728
N=int(input())
S = [''] * N
for i in range(N):
    S[i] = input()

S_sorted = sorted(list(set(S[0])))

ans = ''
for c in S_sorted:
    count = min(S[i].count(c) for i in range(N))
    ans += c * count
 
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
using namespace std;

namespace zyt
{
	const int N = 1e6 + 10;
	char str[N], s[N];
	int n, L[N], R[N], num[3], id[3], pos[3];
	int ctoi(char c)
	{
		return c - 'A';
	}
	char itoc(const int x)
	{
		return x + 'A';
	}
	bool cmp(const int i, const int j)
	{
		return num[i] < num[j];
	}
	void erase(const int i)
	{
		R[L[i]] = R[i];
		L[R[i]] = L[i];
		--num[ctoi(s[i])];
	}
	int work()
	{
		scanf("%s", str);
		id[0] = 0, id[1] = 1, id[2] = 2;
		for (int i = 0, len = strlen(str); i < len; i++)
			if (!i || str[i] != str[i - 1])
				s[++n] = str[i], num[ctoi(str[i])]++;
		sort(id, id + 3, cmp);
		sort(num, num + 3);
		for (int i = 0; i < 3; i++)
			pos[id[i]] = i;
		R[0] = 1, L[n + 1] = n;
		for (int i = 1; i <= n; i++)
			L[i] = i - 1, R[i] = i + 1, s[i] = itoc(pos[ctoi(s[i])]);
		for (int i = R[0]; i <= n && num[1] < num[2]; i = R[i])
			if (s[i] == 'C' && (L[i] == 0 || R[i] > n || s[L[i]] != s[R[i]]))
				erase(i);
		for (int i = R[0]; i <= n && num[1] < num[2]; i = R[i])
			if (s[i] == 'C' && s[L[i]] == 'A')
				erase(L[i]), erase(i);
		for (int i = R[0]; i <= n && num[0] < num[1]; i = R[i])
			if (((s[L[i]] == 'B' && s[i] == 'C') || (s[L[i]] == 'C' && s[i] == 'B')) &&
				(!L[L[i]] || R[i] > n || s[L[L[i]]] != s[R[i]]))
				erase(i), erase(L[i]);
		for (int i = R[0]; i <= n; i = R[i])
			putchar(itoc(id[ctoi(s[i])]));
		return 0;
	}
}
int main()
{
	return zyt::work();
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define repr(i,n) for(int i=0, i##_len=(n); i<i##_len; --i)
#define REP(i,m,n) for(int i=int(m), i##_len=(n); i<i##_len; ++i)
#define VV(T) vector<vector<T>>
#define co(P) cout << P << endl
#define ci(P) cin >> P
#define pb push_back
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;
using d = double;

int main(){
  unsigned long long A, C;
  d B;
  ci(A >> B);
  B *= 100;
  B = round(B);
  C = A * (unsigned long long)B;
  C /= 100;
  co(C);
}

Measured memory_bytes: 3708
#include "bits/stdc++.h"
using namespace std;

double n;

double dp[305][305][305];

double solve(int o, int t, int h) {
	if (dp[o][t][h] != -1) return dp[o][t][h];
	if (o == 0 && t == 0 && h == 0) return 0;
	double ans = n / (o + t + h);
	if (o > 0) ans += 1.0 * o / (o + t + h) * solve(o-1, t, h);
	if (t > 0) ans += 1.0 * t / (o + t + h) * solve(o+1, t-1, h);
	if (h > 0) ans +=  1.0 * h / (o + t + h) * solve(o, t+1, h-1);
	return dp[o][t][h] = ans;
}

signed main() {
    
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    for (int i=0; i<305; i++) {
		for (int j=0; j<305; j++) {
			for (int k=0; k<305; k++) {
				dp[i][j][k] = -1;
			}
		}
	}
    
	cin >> n;
	int a1 = 0, a2 = 0, a3 = 0;
	for (int i=0; i<n; i++) {
		int x;
		cin >> x;
		if (x == 1) a1++;
		if (x == 2) a2++;
		if (x == 3) a3++;
	}
	
	cout << setprecision(10) << fixed << solve(a1, a2, a3) << endl;
    
}


Measured memory_bytes: 221952
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define rcg(s) cout << s;exit(0)
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define all(s) s.begin(),s.end()
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,k,dp[1 << 17],x;

const int mod = 1e9 + 7;

int32_t main(){_
    //freopen("in","r",stdin);
    cin >> n >> k;
    dp[0] = 1;
    for(int i = 1;i <= n;i++)
    {
        cin >> x;
        for(int val = k;val >= 0;val--)
        {
            dp[val] = (mod + (dp[val] - (val - x - 1 >= 0 ? dp[val - x - 1] : 0))) % mod;
            dp[val] %= mod;
        }
        for(int val = 1;val <= k;val++)
        {
            dp[val] += dp[val - 1];
            dp[val] %= mod;
        }
    }
    rc(dp[k]);
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int N;
  int A[1001] = {0};
  int i, j;
  int tmp;
  unsigned long long int value = 1;
  scanf("%d", &N);

  for(i = N; i > 1; i--) {
    tmp = i;
    for(j = 2; j < tmp+1; j++) {
      while(tmp%j == 0) {
	tmp /= j;
	A[j]++;
      }
    }
  }
  for(i = 2; i < 1001; i++) {
    value *= (A[i]+1);
    value %= 1000000007;
  }

  printf("%llu\n", value);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>
using namespace std;

using INT=boost::multiprecision::cpp_int;

int main()
{
    INT LCM=1;
    int n; cin>>n;
    vector<int> a(n);
    for(auto& e: a) {
        cin>>e;
        LCM=boost::math::lcm(LCM, INT(e));
    }

    INT m=LCM-1, res=0;
    for(auto& e: a) res+=m%e;
    cout<<res<<endl;
}


Measured memory_bytes: 256
//
// Created by ryo on 2019/12/14.
//

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int numEdge;
map<pair<int,int>, int> mp;

// preは親、返す値はなし
void dfs(vector<vector<int>> const& G, int pre, int preColor) {
    int i = 1;
    for (auto it : G[pre]) {
        if (i == preColor) i++;
        auto edgePair = make_pair(pre, it);
        mp[edgePair] = i;
        dfs(G, it, i);
        chmax(numEdge, i++);
    }
}

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

    int n;
    cin >> n;
    vector<vector<int>> v(n);
    vector<pair<int,int>> pairs;
    rep(i, n - 1) {
        int a,b;
        cin >> a >> b;
        a--, b--;
        pairs.push_back(make_pair(a, b));
        mp[make_pair(a, b)] = -1;
        v[a].push_back(b);
    }

    dfs(v, 0, -1);
    cout << numEdge << endl;
    for (auto it : pairs) {
        cout << mp[it] << endl;
    }
}

Measured memory_bytes: 14968
/*
  	^_HAR HAR MAHADEV_^
    |Om namah shivaya|
*/

// AUTHOR : Harshil Mehta

#include <bits/stdc++.h>
//For ordered_set
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
//#include<boost/multiprecision/cpp_int.hpp>
#define mod 1000000007
#define init(arr,val) memset(arr,val,sizeof(arr))
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define pf push_front
#define F first
#define S second
#define fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define br "\n"
//using namespace boost::multiprecision;
using namespace std;
// For ordered_set
/*
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
ll findS(ll s) {
	return (sqrtl(8*s + 1) - 1)/2;
}
ll phi(ll n) {
	ll result = n;
	for (ll p = 2; p * p <= n; ++p) {
		if (n % p == 0) {
			while (n % p == 0)
				n /= p;
			result -= result / p;
		}
	}
	if (n > 1)
		result -= result / n;
	return result;
}
bool isPrime(ll a) {
	if(a==1)return false;
	if(a==2 || a==3)return true;
	if(a%2==0 ||a%3==0)return false;
	for(ll i=5; i<=sqrt(a); i+=6)
		if(a%i==0 || a%(i+2)==0)
			return false;
	return true;
}
ll power(ll x,ll y) {
	if (y == 0)
		return 1;
	ll p = power(x, y/2) % mod;
	p = (p * p) % mod;

	return (y%2 == 0)? p : (x * p) % mod;
}
ll nCr(ll n,ll k) {
	ll C[k+1];
	C[0] = 1;
	f(i,0,k+1)C[i]=0;
	for (ll i = 1; i <= n; i++) {
		for (ll j = min(i, k); j > 0; j--)
			C[j] = (C[j] + C[j-1])%mod;
	}
	return C[k];
}
ll LOGN(ll n , ll r) {
	return (n > r-1) ? (1 + LOGN(n / r , r)) : 0 ;
}
void dfs(vector<ll> v[], bool visited[], ll current_node) {
	visited[current_node]=true;
	for(ll nxt_node : v[current_node]) {
		if(visited[nxt_node]==false) {
			dfs(v , visited, nxt_node);
		}
	}
	return;
}
void solve() {
	string s;
	cin >> s;
	int n = s.size();
	vector<int> a(n+1, 0);
	int ten = 1 , p = 2019;
	for(int i = n-1; i >= 0; i--) {
		int ch = (s[i] - '0') * ten % p;
		a[i] = (a[i+1] + ch) % p;
		ten = (ten * 10) % p;
	}
	vector<int> cnt(p, 0);
	ll ans = 0;
	for(int i = n; i >= 0; i--) {
		ans += cnt[a[i]]++;
	}
	cout << ans << br ;
}
int main() {
	fast ;
	int t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 4280
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		while(true){
			var s=Console.ReadLine().Split(' ');
			if(s[0]=="0" && s[1]=="0")break;
			Sol mySol=new Sol(int.Parse(s[0]),int.Parse(s[1]));
			Console.WriteLine(mySol.Ans);
		}
	}
}

class Sol{
	int ans;
	public int Ans{
		get{return ans;}
	}
	
	public Sol(int n,int h){
		ans=n*n*n;
		List<String> In=new List<String>();
		
		for(int i=0;i<h;i++){
			var s=Console.ReadLine();
			if(!In.Contains(s))In.Add(s);
		}
		In.Sort((s,t)=>String.Compare(s,t));
		
		String[][] Command=new String[In.Count][];
		h=In.Count;
		for(int i=0;i<h;i++){
			Command[i]=In[i].Split(' ');
		}
		int xy=0;
		int xz=0;
		int yz=0;
		for(int i=0;i<h;i++){
			if(Command[i][0]=="xy")xy++;
			if(Command[i][0]=="xz")xz++;
			if(Command[i][0]=="yz")yz++;
		}
		//包除原理
		// xy,xz,yz
		for(int i=0;i<h;i++)ans-=n;
		
		// xy&xz,xy&xz,xy&xz
		//  xy&xz
		for(int i=0;i<xy;i++){
			for(int j=0;j<xz;j++){
				if(Command[i][1]==Command[j+xy][1])ans+=1;
			}
		}
		//  xy&yz
		for(int i=0;i<xy;i++){
			for(int j=0;j<yz;j++){
				if(Command[i][2]==Command[j+xy+xz][1])ans+=1;
			}
		}
		//  xz&yz
		for(int i=0;i<xz;i++){
			for(int j=0;j<yz;j++){
				if(Command[i+xy][2]==Command[j+xy+xz][2])ans+=1;
			}
		}
		// xy&xz&yz
		for(int i=0;i<xy;i++){
			for(int j=0;j<xz;j++){
				if(Command[i][1]==Command[j+xy][1]){
					for(int k=0;k<yz;k++){
						if(Command[i][2]==Command[k+xy+xz][1] && Command[j+xy][2]==Command[k+xy+xz][2] )ans-=1;
					}
				}
			}
		}

	}
}

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

class Main
{
    public static void main(String[] args) throws IOException{
        // Solution sol = new Solution();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int t = Integer.parseInt(st.nextToken());
        HashMap<String,Integer> hm = new HashMap();
        while(t--!=0) {
            String s = br.readLine();
            hm.put(s,hm.getOrDefault(s, 0)+1);
        }
        String[] sarr = new String[]{"AC","WA","TLE","RE"};

        for(String x: sarr) {
            System.out.println(x+" x "+hm.getOrDefault(x,0));
        }


    }

    


    

}

Measured memory_bytes: 44664
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
 
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
 
using namespace std;


int used[100500];
void solve(){
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    ll ans = 0;
    for(int i = 0; i < k; i++){
        if(t[i] == 'r'){
            used[i] = 3;
            ans += p;
        }
        if(t[i] == 's'){
            used[i] = 1;
            ans += r;
        }
        if(t[i] == 'p'){
            used[i] = 2;
            ans += s;
        }
    }
    for(int i = k; i < n; i++){
        if(t[i] == 'r' && used[i - k] != 3){
            used[i] = 3;
            ans += p;
        }
        if(t[i] == 's' && used[i - k] != 1){
            used[i] = 1;
            ans += r;
        }
        if(t[i] == 'p' && used[i - k] != 2){
            used[i] = 2;
            ans += s;
        }
    }
    cout << ans;
}

 
int main(){
    barsik;
    //freopen("file.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(ll i = 1; i <= q; i++){
        solve();
    }
}


Measured memory_bytes: 848
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
    long long n,m;
    cin>>n>>m;
    if (n == 1&&m == 1){
        cout<<1<<endl;
    }
    else if (n == 1){
        cout<<m-2<<endl;
    }
    else if( m == 1){
        cout<<n-2<<endl;
    }
    else{
        long long result = n*m -((n-2)*2+(m-2)*2+4);
        cout<<result<<endl;
    }
}


Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc176/tasks/abc176_c
// greedy
import std.algorithm;
import std.array;
import std.conv;
import std.stdio;
import std.string;

void main() {
    long n = readln.chomp.to!long;
    long[] a = readln.split.map!(to!long).array;

    long last = a[0];
    long ans = 0;

    for(int i = 1; i < n; i++)
        if(a[i] < last)
            ans += last - a[i];
        else
            last = a[i];

    ans.writeln;
}



Measured memory_bytes: 11616
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    double d;
    cin >> n >> d;
    int ans = 0;
    set<pair<int, int > > s;
    while(n--){
        int x, y;
        cin >> x >> y;
        s.insert({x, y});
        int point = x * x + y * y;
        double p = sqrt(point);
        if(p <= d) ans++;
    }
    cout << ans << endl;
}

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

int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    cout << A[N-1]-A[0] << endl;
}


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

int main()
{
    int N;
    int A[100005];
    bool flag[100005] = {};
    int ans = 0;

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

    flag[0] = true;
    int now = 0;
    while(now != 1) {
        now = A[now];
        if(flag[now]) { ans = -1; break; }
        flag[now] = true;
        ans++;
    }

    cout << ans << endl;

    return (0);
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#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; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    int n,a,b,x=1,ans=0;
    cin>>n>>b;
    red(i,n-1){
        cin>>a;
        if(a==b)x++;
        if(a!=b||i==0) ans+=x/2,x=1;
        b=a;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;

ll dp[2][21010]={};

int main(){
    ll a,b;
    cin>>a>>b;
    
  ll c=a/b;
  ll d=c*b;
  
    cout<<min(min(abs(a-d),abs(a-d-b)),min(abs(a-d-d),abs(a-b)))<<endl;;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
pic = [["#"]*(W+2) for i in range(H+2)]
for i in range(H):
    a = input()
    for j in range(W):
        pic[i+1][j+1] = a[j]

for i in range(H+2):
    for j in range(W+2):
        print(pic[i][j],end = '')
    print('')


Measured memory_bytes: 4468
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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 namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long,long>>;

int main() {
    int N,X,M; cin >> N >> M >> X;
    int cost_L = 0;
    int cost_R = 0;
    REP(i,M) {
        int a;
        cin >> a;
        if(a < X) cost_L++;
        else cost_R++;
    }
    //cout << cost_L << " " << cost_R << endl;
    cout << min(cost_L,cost_R) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
//#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
typedef long long ll;

signed main()
{
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,10){
        x=x*r-d;
        cout<<x<<endl;
    }

}


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

long long dp[101];

long long fib(long long n){
  
  dp[0] = 1;
  dp[1] = 1;

  for(int i=2;i<=n;++i) dp[i] = dp[i-1] + dp[i-2];

  return dp[n];
}

int main(){

  long long n;

  cin>>n;

  memset(dp,0,101);

  cout<<fib(n)<<endl;

  return EXIT_SUCCESS;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "YES"
#define FALSE__ "NO"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

int N, M;
vector<pair<int, int> > h;
vector<pair<int, int> > c;
ll dist[50][50];

signed main()
{
	cin >> N >> M;
	rep(i, N) {
		CIN(int, t);
		CIN(int, tt);
		h.PB(MP(t, tt));
	}
	rep(i, M) {
		CIN(int, t);
		CIN(int, tt);
		c.PB(MP(t, tt));
	}
	rep(i, N) {
		rep(j, M) {
			auto ph = h[i];
			auto pc = c[j];
			dist[i][j] = abs(ph.first-pc.first) + abs(ph.second-pc.second);
		}
	}
	rep(i, N) {
		ll mi = 1e18;
		rep(j, M) {
			mi = min(mi, dist[i][j]);
		}
		rep(j, M) {
			if (mi == dist[i][j]) {
				cout << j+1 << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

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

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

void dfs(vector<int> g[], int visited[], int u) {
	visited[u] = 1;
	for(auto it : g[u]) {
		if(!visited[it]) {
			dfs(g,visited,it);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		vector<int> g[n+1];
		f(i,m) {
			int u,v;
			cin>>u>>v;
			g[u].pb(v);
			g[v].pb(u);
		}
		int ans = 0;
		int visited[n+10] = {0};
		for(int i=1; i<=n; i++) {
			if(!visited[i]) {
				dfs(g,visited,i);
				ans++;
			}
		}
		cout<<ans-1<<"\n";
 	}
 	return 0;
}


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

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

  int n;
  cin >> n;
  long long a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    long long p, q;
    cin >> p >> q;
    if (i == 0) {
      a = p, b = q;
      continue;
    }
    long long lo = 1, hi = (1e18 + 100) / max(p, q);
    while (lo < hi) {
      long long mid = (lo + hi) / 2;
      if (a <= p * mid && b <= q * mid) {
        hi = mid;
      } else {
        lo = mid + 1;
      }
    }
    a = p * hi;
    b = q * hi;
  }

  cout << (a + b) << "\n";
  return 0;

}


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

int main() {
 ll n;
 string s;
  cin>>n>>s;
  ll ans=0; ll red=0; ll blue=0; ll green=0;
  rep(i,n){
    if(s[i]=='R') red++; 
    if(s[i]=='B') blue++; 
    if(s[i]=='G') green++;
  }
  ans+=red*blue*green;
  rep(i,n){
    rep2(j,1,(n-1-i)/2+1){
    if(s[i]=='R'&&s[i+j]=='B'&&s[i+2*j]=='G') ans--;
 else if(s[i]=='R'&&s[i+j]=='G'&&s[i+2*j]=='B') ans--;
 else if(s[i]=='B'&&s[i+j]=='R'&&s[i+2*j]=='G') ans--;
 else if(s[i]=='B'&&s[i+j]=='G'&&s[i+2*j]=='R') ans--;
 else if(s[i]=='G'&&s[i+j]=='B'&&s[i+2*j]=='R') ans--;
 else if(s[i]=='G'&&s[i+j]=='R'&&s[i+2*j]=='B') ans--;
    }
  }
    cout<<ans<<endl;
return 0;
}


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

int main() {
  string str1, str2;
  cin >> str1;
  cin>>str2;
  int s;
  s= str1.size();
  int a;
  a=0;
  for(int i=0;i<s;i++){
      if(str1.at(i)==str2.at(i)){
          a++;
      }
  }
if(a==s){
    cout<<"Yes"<<endl;
}
  else{
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3632
import Control.Applicative

import Control.Monad
    (when)
    
type Set = [Int]

type Problem = (Int, Int)

type Result = Int

enum :: Int -> Int -> Int -> Set -> [Set]

enum 1 f t c
    = [c ++ [x] | x <- [f..t]]
    
enum n f t c
    = concat [enum (n - 1) (x + 1) t (c ++ [x]) | x <- [f..t]]
    
solve :: Problem -> Result

solve (n, s)
    = length [x | x <- enum n 0 9 [], sum x == s]
    
main :: IO ()

main
    = do
        [n, s] <- map read <$> words <$> getLine
        when (n /= 0 || s /= 0) $ do
            print $ solve (n, s)
            main

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

ll ar[100000005],br[100000005]={0};
int main()
{
    ll a,b,c,i,j,cnt=0;


    cin>>a>>b;

    for(i=0;i<a;i++)
    {
        cin>>c;
        for(j=0;j<c;j++)
        {
            cin>>ar[j];
            br[ar[j]]++;
        }
    }
    for(i=0;i<=100000005;i++)
    {
        if(br[i]>=a)cnt++;
    }

    cout<<cnt<<endl;






    return 0;
}


Measured memory_bytes: 2304
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

k=int(input())
s=input()

if len(s)<=k:
    print(s)
else:
    print(s[:k]+"...")

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

int main(){
  long long N;
  long long sum = 0;
  cin >> N;
  long long cnt = N / 10;
  sum = cnt;
  if (N % 2)
    cout << '0' << endl;
  else {
    while (cnt != 0) {
      sum += cnt / 5;
      cnt /= 5;
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


a = input()
if a.lower() == a:
    print('a')
else:
    print('A')

Measured memory_bytes: 61892
#include "bits/stdc++.h"
using namespace std ;


int main(){

	int n ; 
	string s ;
	cin >> n >> s ;
	for( int i = 0 ; i < s.size() ; i++ ){
		char c = 'A'+(s[i]-'A' + n )% 26 ;
		cout << c ;
	}
	cout << endl ;

	return 0 ;
}

Measured memory_bytes: 256
K = int(input())
lun = [1, 2, 3, 4, 5, 6, 7, 8, 9]
cnt = 0

while(len(lun) < K):
  target = lun[cnt]
  num = target % 10
  if num != 0:
      lun.append(target * 10 + num - 1)
  lun.append(target * 10 + num)
  if num != 9:
      lun.append(target * 10 + num + 1)
  cnt += 1

print(lun[K-1])


Measured memory_bytes: 7140
#include <iostream>
using namespace std;
using ll = long long;

int N,a[100010],b[100010];
int main(){
    cin >> N;
    for(int i=0;i<N;++i) cin >> a[i];
    ll ans = 0;
    for(int i=0;i<N;++i){
        ++ans;
        while(i<N-1&&a[i]==a[i+1]) ++i;
        if(i==N-1) break;
        if(a[i]<a[i+1]){
            while(i<N-1&&a[i]<=a[i+1]) ++i;
        } else {
            while(i<N-1&&a[i]>=a[i+1]) ++i;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vll a(n);rep(i,n)cin>>a[i];
    sort(all(a));
    reverse(all(a));
    ll ans=a[0];
    int tmp;
    if(n%2)tmp=(n-3)/2;
    else tmp=(n-2)/2;
    rep2(i,1,tmp+1)ans+=2*a[i];
    if(n%2)ans+=a[(n-1)/2];
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=MAXL;
  REP(x,1,101) {
    ll sum=0;
    rep(i,n) sum+=(a[i]-x)*(a[i]-x);
    ans=min(ans,sum);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    #h0,w0h1,w1 = map(int, input().split())
    s=sys.stdin.read()
    chr_n=[0]*26
    for c in s:
        if c.isupper():c=c.lower()
        if not c.islower():continue
        chr_n[ord(c)-97]+=1
    for oc in range(26):
        print("{} : {}".format(chr(oc+97),chr_n[oc]))

main()



Measured memory_bytes: 5568
#include "bits/stdc++.h"
using namespace std;

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    ll a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 1) { cout << "IMPOSSIBLE" << endl; return 0; }
    cout << (a + b) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
s = str(input())
n = len(s)

for i in range(1, n):
    m = n - i
    if m % 2 != 0:
        continue
    #print(s[0:m//2], s[m//2:m])
    if s[0:m//2] == s[m//2:m]:
        break
print(m)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
 
int main(){
    int N, M, A[1001], B[1001], C[1001];
     
    cin >> N >> M;
     
    for(int i = 0;i < N;i++){
        cin >> A[i];
        C[i] = 0;
    }
     
    for(int i = 0;i < M;i++){
        cin >> B[i];
    }
     
    for(int i = 0;i < M;i++){
        for(int j = 0;j < N;j++){
            if(A[j] <= B[i]){
                C[j]++;
                break;
            }
        }
    }
     
    int index, num = -1;
    for(int i = 0;i < N;i++){
        if(C[i] > num){
            num = C[i];
            index = i + 1;
        }
    }
     
    cout << index << endl;
     
    return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
#include <stdlib.h>

long long int chmin(long long int a, long long int b)
{
	if (a > b)
		return b;
	else
		return a;
}

// long long int chmin_2(long long int a, long long int b)
// {
// 	if (a > b)
// 		return b;
// 	else return a;
// }

int main(int argc, char const *argv[])
{
	long long int n;
	scanf("%lld", &n);
	long long int *dp = malloc(n * sizeof(long long int));
	long long int *h = malloc(n * sizeof(long long int));
	for (int i = 0; i < n; i++)
	{
		dp[i] = 1000000;
		scanf("%lld", h+i);
	}
	dp[0] = 0;
	dp[1] = llabs(h[1] - h[0]);
	for (int i = 2; i < n; ++i)
		dp[i] = chmin(dp[i - 1] + llabs(h[i] - h[i-1]), dp[i - 2] + llabs(h[i] - h[i - 2]));
	// for (int i = 1; i < n; i++)
	// {
	// 	dp[i] = chmin_2(dp[i], dp[i - 1] + llabs(h[i] - h[i - 1]));
	// 	if(i > 1) dp[i] = chmin_2(dp[i], dp[i - 2] + llabs(h[i] - h[i - 2]));
	// }
	free(h);
	printf("%lld", dp[n-1]);
	free(dp);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
using namespace std;
int n, k, sum;
vector<int> a[2005];

int f(int p, int q, int r) {
	int i, s=1;
	if(r>k) return 0;
	for(i=0; i<a[p].size(); i++) {
		if(a[p][i]==q) continue;
		s += f(a[p][i], p, r+1);
	}
	return s;
}

int main() {
	int i, j, x, y;
	cin>>n>>k;
	for(i=0; i<n-1; i++) {
		cin>>x>>y;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	if(k%2) {
		k /= 2;
		for(i=1; i<=n; i++) for(j=0; j<a[i].size(); j++) {
			sum = max(sum, f(a[i][j], i, 0) + f(i, a[i][j], 0));
		}
	} else {
		k /= 2;
		for(i=1; i<=n; i++) sum = max(sum, f(i, -1, 0));
	}
	cout<<n-sum;
	return 0;
}

Measured memory_bytes: 384
#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; }

struct Edge {
    ll from, to, weight;
    Edge() : from(0), to(0), weight(0) {}
    Edge(ll f, ll t, ll w) : from(f), to(t), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &g, ll a, ll b, ll w = 1){
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}

void add_arrow(Graph &g, ll a, ll b, ll w = 1){
    g[a].emplace_back(a, b, w);
}

//ダイクストラ法
//グラフgの1点sからの最短距離をO((E + V) log V)で構築
vector<ll> dijkstra(Graph &g, ll s){
    vector<ll> dist(g.size(), INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    
    while(!que.empty()){
        ll cost, idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]){
            auto next_cost = cost + e.weight;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

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

    ll N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i, M){
        ll l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        add_arrow(G, l, r, d);
        add_arrow(G, r, l, -d);
    }

    vec d(N, INF);
    rep(i, N){
        if(d[i] != INF) continue;

        stack<P> sk;
        sk.push({i, 0});
        while(!sk.empty()){
            auto now = sk.top().first;
            auto dis = sk.top().second;
            sk.pop();
            if(d[now] != INF){
                if(d[now] != dis) drop("No");
                continue;
            }
            d[now] = dis;

            for(auto e : G[now]) sk.push({e.to, dis + e.weight});
        }
    }

    print("Yes");

    return 0;
}

Measured memory_bytes: 20736
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let s: Vec<char> = input::<String>().chars().collect();
    let n = s.len();

    let mut ok = s[0] == '1' && s[n - 1] == '0';
    for i in 0..n {
        let j = n - 2 - i;
        if i > j {
            break;
        }
        if s[i] != s[j] {
            ok = false;
            break;
        }
    }
    if !ok {
        println!("-1");
        return;
    }

    let mut ans = vec![];
    let mut zeros = vec![];
    let mut prev = n + 1;
    for i in 0..n {
        if i == n - 1 || s[i] == '1' {
            if prev <= n {
                ans.push((prev, i + 1));
                for &z in &zeros {
                    ans.push((i + 1, z));
                }
            }
            zeros.clear();
            prev = i + 1;
        } else {
            zeros.push(i + 1);
        }
    }

    with_stdout_lock(|mut w| {
        for (u, v) in ans {
            writeln!(w, "{} {}", u, v).unwrap();
        }
    });
}


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

/**
 * @author Tran Anh Tai
 * @template for CP codes
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }
    // main solver
    static class Task{
        static int MOD = 1000000007;
        public long pow(long x, long y){
            if (y == 0){
                return 1;
            }
            else{
                long au = pow(x, y / 2);
                au = (au * au) % MOD;
                if (y % 2 == 0){
                    return au;
                }
                else{
                    return (au * x)% MOD;
                }
            }
        }
        public void solve(InputReader in, PrintWriter out){
            int k = in.nextInt();
            String s = in.nextToken();
            int n = s.length();
            long cur = pow(26, k);
            long total = cur;
            for (int last = n + 1; last <= n + k; last++){
                cur = (cur * 25) % MOD;
                cur = (cur * (last -  1)) % MOD;
                cur = (cur * pow(26, MOD - 2)) % MOD;
                cur = (cur * pow(last - n, MOD - 2)) % MOD;
                total = (total + cur) % MOD;
            }
            out.println(total);
        }
    }
    // fast input reader class;
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (line == null) {
                    return null;
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        public long nextLong(){
            return Long.parseLong(nextToken());
        }
    }
}

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

#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 REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#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 ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    ll n, ans = 0;
    map<ll, ll> mp;

    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> wa(n), sa(n);
    REP(i, n) {
        wa[i] = a[i] + i;
        sa[i] = i - a[i];
    }
    sort(ALL(wa));
    sort(ALL(sa));


    REP(i, n) mp[wa[i]]++;
    REP(i, n) ans += mp[sa[i]];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 30532
def Qa():
    k = int(input())
    a, b = map(int, input().split())

    lis = range(a, b + 1)
    ans = 'NG'
    for v in lis:
        if v % k == 0:
            ans = 'OK'
    print(ans)

if __name__ == '__main__':
    Qa()


Measured memory_bytes: 9008
n, _w = gets.split.map(&:to_i)
 
dp = Array.new(_w + 1, 0)
n.times do
  w, v = gets.split.map(&:to_i)
  _w.downto(w) do |nw|
    nv = dp[nw - w] + v
    dp[nw] = nv if nv > dp[nw]
  end
end

puts dp[_w]



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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    long long a,b;
    cin>>n>>a>>b;
    
    vector<int> sp(n+1);
    for(int i=1; i<=n; i++){
        int x;
        cin>>x;
        sp[x]=i;
    }
    
    vector<long long> dpCur(2*n+1), dpPrev(2*n+1);
    
    for(int i=0; i<=2*n; i++){
        long long c=0;
        int goal=2*sp[1]-1;
        if(i!=goal){
            c=i<goal?b:a;
        }
        dpPrev[i]=c;
        if(i) dpPrev[i]=min(dpPrev[i],dpPrev[i-1]);
    }
    for(int i=2; i<=n; i++){
        for(int j=0; j<=2*n; j++){
            long long c=0;
            int goal=2*sp[i]-1;
            if(j!=goal){
                c=j<goal?b:a;
            }
            dpCur[j]=(j%2?dpPrev[j-1]:dpPrev[j])+c;
            if(j) dpCur[j]=min(dpCur[j],dpCur[j-1]);
        }
        dpPrev=dpCur;
    }
    cout<<dpCur[2*n];
    
    
    
    
    
    
    
    
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
#print(N,A)

sort_A = sorted(A,reverse=True)
#print(sort_A)

Alice = 0
Bob = 0
for i in range(N):
  if i % 2 == 0:
    Alice += sort_A[i]
  else:
    Bob += sort_A[i]

print(Alice - Bob)

Measured memory_bytes: 61828