akhauriyash/Code-Regression huggingface dataset:
n=int(input())
if n%2==1:
  print(n-1+int((n-1)*(n-3)*0.5))
  for i in range(1,n):
    print(n,i)
  for i in range(1,n):
    for j in range(i+1,n):
      if i+j!=n:
        print(i,j)
else:
  print(int(n*(n-2)*0.5))
  for i in range(1,n+1):
    for j in range(i+1,n+1):
      if i+j!=n+1:
        print(i,j)

Measured memory_bytes: 3612
import copy
h,w,k=map(int, input().split())
s=[[0]*w for _ in range(h)]
for i in range(h):
    s[i]=list(input())

n=h+w
ans=0
for i in range(2**n):
    a=copy.deepcopy(s)
    for j in range(n):
        if ((i >> j) & 1):
            if j<h:
                for l in range(w):
                    a[j][l]='.'
            else:
                for l in range(h):
                    a[l][j-h]='.'
    cnt=0
    for j in range(h):
        for l in range(w):
            if a[j][l]=='#':
                cnt+=1
    if cnt==k:
        ans+=1
print(ans)

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
int64_t minll(int64_t a, int64_t b){
  if(a > b) return b;
  else return a;
}
int main(){
  int64_t l, r;
  cin >> l >> r;
  if(r/2019-l/2019 > 0 || l%2019 == 0)  cout << 0 << endl;
  else{
    l %= 2019;  r %= 2019;
    int64_t ans = 2019;
    for(int64_t i = l; i <= r; i++){
      for(int64_t j = i+1; j <= r; j++){
        ans = minll(ans,i*j%2019);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  ll Ans = 0;
  cin >> N;
  for(ll i = 2; i < 1000000; i++){
    if(N%i == 0) {
      int c = 0;
      while(N%i == 0){
        c++;
        N /= i;
      }
      for(ll t = 0; t < 50; t++){
        if(t*(t+1)/2 <= c) continue;
        Ans += t-1;
        break;
      }
    }
  }
  if(N > 1) Ans++;
  cout << Ans << endl;
      
      
  
}


Measured memory_bytes: 3640
#include <stdio.h>

int main()
{
	int A, B;
	scanf("%d %d", &A, &B);
	
	int x;
	for (x = B * 10 - 1; x <= B * 15 + 1; x++) {
		if (x * 2 / 25 == A && x / 10 == B) {
			printf("%d\n", x);
			break;
		}
	}
	if (x > B * 15 + 1) printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
xy = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for j in range(A):
        xy_ = tuple(map(int,input().split()))
        xy[i].append(xy_)

bN = 2**N
ans = 0
for b in range(bN):
    for n in range(N):
        if (b >> n) & 1:
            for x,y in xy[n]:
                if y != (b >> (x-1) & 1):
                    break
            else:
                continue
            break
    else:
        ans = max(ans,bin(b).count("1"))
print(ans)


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 10005;

/* ...o(^-^)o... */

int main(){
    ii(n);
    vector<lint> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    vector<lint> b, c; lint m = 0;
    if(a[0] >= 0){
        b.push_back(a[0]); m -= a[0];
        rep(i, n-1){
            c.push_back(a[i+1]); m += a[i+1];
        }
    }
    else if(a[n-1] <= 0){
        rep(i, n-1){
            b.push_back(a[i]); m -= a[i];
        }
        c.push_back(a[n-1]); m += a[n-1];
    }
    else{
        rep(i, n){
            if(a[i] <= 0){
                b.push_back(a[i]); m -= a[i];
            }
            else{
                c.push_back(a[i]); m += a[i];
            }
        }
    }
    out(m);

    int p = b.size(), q = c.size();
    lint tmp = b[0];
    rep(i, q-1){
        outs(tmp); outs(c[i]); out("");
        tmp -= c[i];
    }
    outs(c[q-1]); outs(tmp); out("");
    tmp = c[q-1] - tmp;
    rep(i, p-1){
        outs(tmp); outs(b[i+1]); out("");
        tmp -= b[i+1];
    }
}

Measured memory_bytes: 3700
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, M = list(map(int, input().split()))
L, R = zip(*[list(map(int, input().split())) for _ in range(M)])

ans = min(R) - max(L) + 1
print(max(0, ans))


Measured memory_bytes: 45164
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 210000;

const ll INF = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;

int n, m, s, t;

vector<pair<int, int> > eds[2][MAXN];

ll dd[2][MAXN];
set<pair<ll, int> > ss;
int go[2];
ll ans[MAXN];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> n >> m >> s >> t;
	--s, --t;
	for (int i = 0; i < m; ++i) {
		int a, b, x, y;
		cin >> a >> b >> x >> y;
		--a, --b;
		eds[0][a].emplace_back(b, x);
		eds[0][b].emplace_back(a, x);
		eds[1][a].emplace_back(b, y);
		eds[1][b].emplace_back(a, y);
	}
	go[0] = s, go[1] = t;
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < n; ++j)
			dd[i][j] = INF;
		dd[i][go[i]] = 0;
		ss.clear();
		ss.insert(make_pair(dd[i][go[i]], go[i]));
		while (!ss.empty()) {
			int x = ss.begin()->second;
			ss.erase(ss.begin());
			for (auto e: eds[i][x]) {
				int u = e.first;
				if (dd[i][u] > dd[i][x] + e.second) {
					ss.erase(make_pair(dd[i][u], u));
					dd[i][u] = dd[i][x] + e.second;
					ss.insert(make_pair(dd[i][u], u));
				}
			}
		}
	}
	for (int i = 0; i < n; ++i)
		ans[i] = dd[0][i] + dd[1][i];
	for (int i = n - 2; i >= 0; --i)
		ans[i] = min(ans[i], ans[i + 1]);
	for (int i = 0; i < n; ++i)
		cout << INF - ans[i] << "\n";
	return 0;
}




Measured memory_bytes: 25344
n = int(input())
b = list(map(int, input().split()))

l1 = []
l2 = []
for i, c in enumerate(b):
    if i%2 == 0:
        l1.append(c)
    else:
        l2.append(c)

l2.reverse()
answer = l2 + l1
if n%2 == 1:
    answer.reverse()
answer = list(map(str, answer))
print(' '.join(answer))

Measured memory_bytes: 35000
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

bool e[575][77];

signed main() {
  INIT;
	VAR(int, n, m);
  REP(i, m) {
		VAR(int, a, b);
		e[a][b] = e[b][a] = true;
	}
	
	int ans = 0;
	vector< int > p(n);
	iota(ALL(p), 1);
	
	do {
		if (p[0] > 1) break;
		bool ok = true;
		REP(i, n - 1) {
			ok &= e[p[i]][p[i + 1]];
		}
		if (ok) ans++;
	} while (next_permutation(ALL(p)));
	OUT(ans)BR;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
a = 1000
ans = 0

for i in range(N):
    tmp = abs(A - (T - H[i] * 0.006))
    if tmp < a:
        a = tmp
        ans = i + 1

print(ans)


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

#define say(a) cout<<a<<endl
#define say1(a,b) cout<<a<<" "<<b<<endl
#define loop(a,b) for(int i=a;i<b;i++)
//vector<int> v[200009];
int main()
{
    int n,i,mx1=1e9,mx2=1e9;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[i]=a[i];
    }sort(b,b+n);mx1=b[n-1];mx2=b[n-2];
    for(i=0;i<n;i++)
    {
        if(a[i]!=mx1) say(mx1);
        else if(a[i]==mx1) say(mx2);
    }
}




Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  ll k;
  cin >> n >> m;
  cin >> k;
  vl a(n),b(m);
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];

  vl sa(n+1,0),sb(m+1,0);
  rep(i,n)sa[i+1] = sa[i] + a[i];
  rep(i,m)sb[i+1] = sb[i] + b[i];

  ll ans = 0;
  rep(i,n){
    ll t = sa[i+1];
    if(t > k)continue;
    int num = upper_bound(rng(sb),k-t)-sb.begin();
    maxs(ans,(ll)(i+num));
  }
  rep(i,m){
    ll t = sb[i+1];
    if(t > k)continue;
    int num = upper_bound(rng(sa),k-t)-sa.begin();
    maxs(ans,(ll)(i+num));
  }

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

Measured memory_bytes: 9600
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/12/20 20:48:37
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  string s; cin>>s;
  bool ok = false;
  for (auto c:s)
    if(c=='7')
      ok = true;

  cout << (ok ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void)
{
	int a; int b;
	scanf("%d %d", &a, &b);

	if (a < b) {
		printf("a < b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll x; cin >> x;

  ll result;
  if (x%11==0) result = x/11*2;
  else if (x%11<=6) result = x/11*2 + 1;
  else result = x/11*2 + 2;
  cout << result << endl;
  return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n+1);
    for(int i=1;i<=n;++i) {
        int u,k;
        cin >> u >> k;
        for(int j=0;j<k;++j) {
            int v;
            cin >> v;
            G[u].push_back(v);
        }
    }
    queue<int> q;
    vector<int> cnt(n+1,-1);
    cnt[1] = 0;
    q.push(1);
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int i:G[u]) {
            if(cnt[i] != -1) continue;
            cnt[i] = cnt[u] + 1;
            q.push(i);
        }
    }
    for(int i=1;i<=n;++i) cout << i << " " << cnt[i] << endl;
}



Measured memory_bytes: 3164
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String S =in.next();
		int count=0;
		boolean flag=S.matches("A[a-z][a-z,C][a-z,C]*[a-z]");
		for(int i=0;i<S.length();i++) {
			if(S.charAt(i)=='C') {
				count++;
			}
		}
		if(count>=2||count==0) {
			flag=false;
		}
		if(flag) {
			System.out.println("AC");
		}else {
			System.out.println("WA");
		}
 
	}
}

Measured memory_bytes: 22356
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

ll ar[10000005];
 
int main()
{
	cio;
	ll n;
	cin >> n;
 
	ll tot = 0;
	for (ll i = 1; i <= n; i++)
	{
		ll pos = n / i;
 
		tot += i * (pos * (pos + 1) / 2);
	}
 
	cout << tot;
}

Measured memory_bytes: 3136
#include<iostream>
#include<cstring>
using namespace std;
long long n,m,k,l,f;
string a,b,c;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='C') f=1;
		if(a[i]=='F'&&f==1) 
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
N = gets.to_i
t0, x0, y0 = 0, 0, 0
 
readlines.each do |line|
  t, x, y = line.split(" ").map(&:to_i)
  dx = (x - x0).abs
  dy = (y - y0).abs
  if t - t0 - dx - dy >= 0 && (t - t0 - dx - dy) % 2 == 0
    t0, x0, y0 = t, x, y
  else
    puts "No"
    exit
  end
end
puts "Yes"

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  int A,B;
  cin>>A>>B;
  string s;
  int res=0;
  FOR(i,A,B+1){
    s=std::to_string(i);

    if(s[0]==s[4]&&s[1]==s[3]){
      res++;
    }

  }
  cout<<res<<endl;
  //cout<<s<<endl;
}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/12/20 07:29:17
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
  vector<int> dp(f+1, -1);
  dp[0] = 0;
  for (int i = 1; i*a*100 <= f; i++) {
    dp[i*a*100] = 0;
  }
  for (int m = f; m >= 0; m--) {
    if (dp[m] == -1) continue;
    for (int i = 1; m+i*b*100 <= f; i++) {
      dp[m+i*b*100] = 0;
    }
  }
  for (int m = f; m >= 0; m--) {
    if (dp[m] == -1) continue;
    for (int i = 1; m+i*c <= f and i*c <= m/100*e; i++) {
      dp[m+i*c] = i*c;
    }
  }
  for (int m = f; m >= 0; m--) {
    if (dp[m] == -1) continue;
    for (int i = 1; m+i*d <= f; i++) {
      auto t = m+i*d;
      auto s = dp[m+(i-1)*d]+d;
      if (s > (t-s)/100*e) break;
      dp[t] = max(dp[t], s);
    }
  }
  double max_n = 0;
  int ans_m = 0;
  for (int m = 1; m <= f; m++) {
    if (dp[m] == -1) continue;
    double n = (double)dp[m]/m;
    if (n > max_n) {
      max_n = n;
      ans_m = m;
    }
  }
  if (ans_m == 0)
    ans_m = a*100;
  cout << ans_m << " " << dp[ans_m] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int n, k; cin >> n >> k;
  vector<int> p(n);
  for(int i=0; i<n; i++) cin >> p[i];
  sort(all(p));
  int ans = 0;
  for(int i=0; i<k; i++) ans += p[i];
  cout << ans << endl;

  return 0;
}

// EOF

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

#define ll long long 
#define sci(n) scanf("%d",&n)
#define scii(a,b) scanf("%d%d",&a,&b)
#define scl(a) scanf("%lld",&a)
#define F(i,a,b) for(int i =a;i<b;i++)
#define vi vector<int> 
#define vpi vector<pair<int,int>> 
#define vvi vector<vector<int>>
#define pii pair<int,int> 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define w(t)  int t;cin>>t;while(t--)
#define mod 1000000007



int main(){
	string s,t;
	cin>>s>>t;
	int a = s.length();
	int b = t.length();
	int ans = 5000;
	for(int i = 0;i<=a-b;i++){
		int ans_ = 0;
		for(int j = 0;j<b;j++){
			if(s[i+j] != t[j]) ans_++;
		}
		ans = min(ans , ans_);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define int long long int
#define MOD (ll) (1e9+7)
#define in_arr(ar) for(int i=0;i<sizeof(ar)/sizeof(ar[0]);i++)cin>>ar[i];
#define val(x) cout<<"Value of "<<(#x)<<" is "<<x<<endl;




//ll bigmod(ll a, ll e)
//{
//    ll ret = 1LL;
//    while (e>0)
//    {
//        if (e%2==1) ret = ret * a % MOD;
//        a = a*a % MOD;
//        e/=2;
//    }
//    return ret;
//}

int vis[1000000];

int solve()
{
    int n;
    cin>>n;
    int ar[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
        vis[ar[i]]++;
        sum+=ar[i];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int a,b;
        cin>>a>>b;
        sum-= a*vis[a];
        sum+=b*vis[a];
        vis[b]=vis[a]+vis[b];
        vis[a]=0;
        cout<<sum<<endl;

    }

    return 0;
}


main()
{
    int t=1;
//    cin>>t;
    while(t--)
    {
        int x = solve();
    }
//    return 0;
}


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

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

    rep(i, s.size()){
        s[i] = s[i]+n <= 90 ? s[i]+n : s[i]+n -26;
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 384
n,k,q = map(int,input().split())
kaitou = [0 for i in range(n)]
for i in range(q):
    a = int(input())
    kaitou[a-1] += 1
kaitou = [k-(q-i) for i in kaitou]
for i in kaitou:
    if i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 52384
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Set<Integer> set = new HashSet<>();
			IntStream.range(0, n).forEach(i -> set.add(scanner.nextInt()));
			System.out.println(set.size());
		}
	}
}


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

int main()
{

	int x, a, b, la, lb;

	while(cin >> x >> a >> b){
	}

	la = a - x;
	lb = b - x;

	la > 0 ? la = la * 1 : la = -1 * la;
	lb > 0 ? lb = lb * 1 : lb = -1 * lb;

	la < lb ? cout << "A" << endl : cout << "B" << endl;

	return 0;
}

Measured memory_bytes: 256
p[8],d,r,i,s,m;char*C="4 1 4 1 2 1 2 1 4 1 4 1 2 1 2",*P="GKCOIMEA";main(b){for(;~scanf("%d",p+d);)if(++d==8){m=0;for(r=8;r--;s<m||(m=s,b=P[r]-65))for(s=0,i=8;i--;s+=p[i]<d?p[i]:d)d=C[P[r]-65+i*2]-48;printf("%.15s\n",C+b);d=0;}}

Measured memory_bytes: 0
import sys
MOD = 1000000007


def main():
    h, w, k = [int(x) for x in input().split()]
    fibonacci = [1, 2]
    for i in range(w - 2):
        fibonacci.append(fibonacci[i] + fibonacci[i + 1])
    pattern = [0 for _ in range(w)]
    pattern[0] = 1
    for _ in range(h):
        nextp = [0 for _ in range(w)]
        for i in range(w):
            nextp[i] = (pattern[i] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i > 0:
                nextp[i] += (pattern[i - 1] * (fibonacci[max(0, i - 2)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i < w - 1:
                nextp[i] += (pattern[i + 1] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 3))])) % MOD
            nextp[i] %= MOD
        pattern = nextp
    print(pattern[k-1])


main()


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<ccomplex>
#include<vector>
#include<map>
#include<string>
#include<set>
using namespace std;
#define fl(i,n)             for(int i=0;i<n;i++)
#define fit(it,x)           for(auto it=x.begin();it!=x.end();it++)
#define fll(j,n)            for(int j=n-1;j>=0;j--)
#define pb                  push_back
#define mp                  make_pair
#define f                   first
#define s                   second
#define all(x)              x.begin(),x.end()
typedef vector<int>         vi;
typedef vector<double>      vd;
typedef vector<char>        vc;
typedef vector<string>      vs;
typedef map<int, int>       mii;
typedef map<string, int>    msi;
typedef pair<int, int>      pii;
typedef set<int>            si;
typedef long long ll;
const int mod = 1000000007;
int sum = 0, max = 0, min = 0;
void solve() {
    int a; cin >> a;
    cout << a + pow(a, 2) + pow(a, 3);
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int test_case = 1;
    //cin >> test_case;
    for (int i = 1; i <= test_case; i++) {
        solve();
        cout << endl;
    }
}


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

int main()
{
  int N, Max=0;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  rep(i,N) cin >> A.at(i);
  rep(i,N) B.at(i)=A.at(i);
  sort(A.begin(), A.end());
  rep(i,N){
    if(B.at(i)==A.at(A.size()-1)){
      cout << A.at(A.size()-2) << endl;
    }
    else{
      cout << A.at(A.size()-1) << endl;
    }
  }
}

Measured memory_bytes: 3200
import sys
input = sys.stdin.readline

from collections import deque

def main(): 
    H,W = map(int,input().split())
    S = [input().split() for _ in range(H)]
    for i in range(H):
        S[i]=list(S[i][0])
    grid = [[0]*W for _ in range(H)]
    
    for i in range(H):
        l=0
        for j in range(W):
            if S[i][j] == "#":
                for k in range(1,l+1):
                    grid[i][j-k]+=l
                l=0
            else:
                l+=1
        for k in range(1,l+1):
                    grid[i][W-k]+=l
    max=0
    for j in range(W):
        l=0
        for i in range(H):
            if S[i][j] == "#":
                for k in range(1,l+1):
                    grid[i-k][j]+=l
                    if grid[i-k][j] > max:
                        max = grid[i-k][j]
                l=0
            else:
                l+=1
        for k in range(1,l+1):
            grid[H-k][j]+=l
            if grid[H-k][j] > max:
                        max = grid[H-k][j]
    print(max-1)
if __name__ == "__main__":
    main()
    

Measured memory_bytes: 218120
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <random>
#include <iterator>
#include <cstring>
#include <deque>

//#include <bits/stdc++h>

#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int k, n;
    cin >> k >> n;
    vector <int> a(n, 0);
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int m = 0;
    for (int i = 0; i < n - 1; i ++) {
        m = max(m, a[i + 1] - a[i]);
    }
    m = max(a[0] + k - a[n - 1], m);
    cout << k - m;
    return 0;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
a=[]
b=[]
for _ in range(n):
    a.append(input())
for _ in range(m):
    b.append(input())
for i in range(n-m+1):
    for j in range(n-m+1):
        if [k[j:m + j] for k in a[i:m + i]] == b:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
n = int(input())
a = int(n**0.5)+1

if n == 1:
    print(0)
    exit()
ans = 0


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def waru(n, s, ans):
    a = int(n**0.5)+1
    for i in range(s, a+1):
        j = 1
        frag = 0
        while 1:
            if n % pow(i, j) == 0:
                frag = 1
                n = n//pow(i, j)
                ans += 1
                j += 1
            elif frag == 1:
                return (n, i, ans)
            else:
                break


a = prime_factorize(n)
c = set(a)
b = int(n**0.5)+1
ans = 0
for i in c:
    s = a.count(i)
    j = 1
    while 1:
        if s-j >= 0:
            ans += 1
            s = s-j
            j = j+1
        else:
            break
if ans == 0:
    print(1)
    exit()
print(ans)


Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a,b,c,n,v,count=0,sum=0,flag=0;
	string s;
	vector<int> ve(10000,0);
	cin>>s;
	a=s.size();
    for(int i=0;i<a;i++){
        if((i+1)%2==1){
            if(s[i]=='R' || s[i]=='U' || s[i]=='D'){
            }
            else{
                flag=1;
            }
        }
        if((i+1)%2==0){
            if(s[i]=='L' || s[i]=='U' || s[i]=='D'){
            }
            else{
                flag=1;
            }
        }
    }
    if(flag==0){
        cout<<"Yes"<<'\n';
    }
    else{
        cout<<"No"<<'\n';
    }
	return 0;
}


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

int main() {
    int r, c;
    cin >> r >> c;
    int t[r][c] = {0}, a[r] = {0}, b[c] = {0}, all = 0;
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> t[i][j];
        }
    }
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            a[i] += t[i][j];
        }
    }
    for(int i = 0; i < c; i++){
        for(int j = 0; j < r; j++){
            b[i] += t[j][i];
        }
    }
    for(int i = 0; i < r; i++){
        all += a[i];
    }

    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            if(j > 0) cout << " ";
            cout << t[i][j];
        }
        cout << " " << a[i] << endl;
    }
    for(int i = 0; i < c; i++){
        if(i > 0) cout << " ";
        cout << b[i];
    }
    cout << " " << all << endl;
    return 0;
}


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

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int> l(m), r(m);
	for (int i = 0; i < m; i++) cin >> l[i] >> r[i];

	int a = 0, b = 100001;

	for (int i = 0; i < m; i++) {
		a = max(a, l[i]);
		b = min(b, r[i]);
	}

	if (b - a + 1 <= 0) cout << 0 << endl;
	else cout << b - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    ll res = LONG_LONG_MAX;
    for(ll i = 1;i*i <= n;i++){
        if(n%i == 0){
            res = min(res,max(ll(to_string(i).length()),ll(to_string(n/i).length())));
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication51
{
    class Program
    {
        static void Main()
        {
            int a = int.Parse(Console.ReadLine());
            while (true)
            {
                switch (Console.ReadLine()) {
                    case "+":a+=int.Parse(Console.ReadLine()); break;
                    case "-": a -= int.Parse(Console.ReadLine()); break;
                    case "*": a *= int.Parse(Console.ReadLine()); break;
                    case "/": a /= int.Parse(Console.ReadLine()); break;
                    default:Console.WriteLine(a);goto k;
                }
            }
        k:;
        }
    }
}

Measured memory_bytes: 9244
#include<iostream>
using namespace std;
void insertionsort(int a[],int n)
{
	 
   for(int i=1;i<n;i++)
   {
       
   	int v=a[i];
   	int j=i-1;
   	while(j>=0&&a[j]>v)
   	{
   		a[j+1]=a[j];
   		j--;
	   }
	   a[j+1]=v;
	   for(int q=0;q<n;q++)
	   if(q!=n-1)
	   cout<<a[q]<<" ";
	   else
	   cout<<a[q];
	   cout<<endl;
   }
   
   return ;
}
int main()
{
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	if(i!=n-1)
	cout<<a[i]<<" ";
	else
	cout<<a[i];
	cout<<endl;
	insertionsort(a,n);
	return 0;
 } 


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

int N;
string S;

int ans[100000];

int main(){
    cin>>S;
    N=S.size();
    S+='R';

    int L=0,R=0;
    int index=0;
    char before='R';
    rep(i,N+1){
        if(before=='L' && S[i]=='R'){
            ans[index+R-1]=ceil(R/2.0)+L/2;
            ans[index+R]=ceil(L/2.0)+R/2;
            index+=L+R;
            L=0;
            R=0;
        }
        if(S[i]=='L') L++;
        if(S[i]=='R') R++;
        before=S[i];
    }

    rep(i,N){
        cout<<ans[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctime>
using namespace std;

int a,b,c,d,e,f; 
void input()
{
    cin >> a >> b >> c >> d >> e >> f;
}

void solve()
{
    vector<int> water(31,0),sugar(3001,0);
    water[a] = 1, water[b] = 1;
    sugar[0] = 1;
    for (int i = 0; i < 31; ++i) {
        if(water[i] == 1){
            if(i+a<31) water[i+a] = 1;
            if(i+b<31) water[i+b] = 1;
        }
    }
    for (int i = 0; i < 3001; ++i) {
        if(sugar[i] == 1){
            if(i+c<3001) sugar[i+c] = 1;
            if(i+d<3001) sugar[i+d] = 1;
        }
    }

    int ans[2]; 
    ans[0] = a*100, ans[1] = 0;
    for (int i = 1; i < 31; ++i) {
        if (water[i] == 0) continue;
        for (int j = 0; j < 3001; ++j) {
            if (sugar[j] == 0) continue;
            if (i * e < j) continue;
            if (i * 100 + j > f) continue;

            if ((i * 100 + j) * ans[1] < j * ans[0]){
                ans[0] = i * 100 + j, ans[1] = j;
            }
        }
    }
    cout << ans[0] << " " << ans[1] << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3640
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

vector<vector<itn> > g;
vector<itn> a;
vector<itn> ans;
vector<int> dp;

void dfs(int v,int p=-1){
  auto itr=lower_bound(dp.begin(),dp.end(),a[v])-dp.begin();
  int old=dp[itr];
  dp[itr]=a[v];
  ans[v]=itr;
  ans[v]=lower_bound(dp.begin(),dp.end(),inf)-dp.begin()-1;
  for(auto nv:g[v]){
    if(nv==p) continue;
    dfs(nv,v);
  }
  dp[itr]=old;
  return;
}

int main(){
  int n; cin >> n;
  g.resize(n);
  dp.resize(n+1);
  rep(i,n+1) dp[i]=inf;
  dp[0]=-inf;
  a.resize(n);
  ans.resize(n);
  rep(i,n) cin >> a[i];
  rep(i,n-1){
    int u,v;
    cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0);
  for(auto v:ans){
    cout << v << endl;
  }
}

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

using namespace std;
typedef long long ll;

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

int main() {
  string n;
  cin >> n;
  ll ans=0;
  int size = n.length();
  rep(i,0,size){
    ans += ctoi(n[i]);
  }
  if(ans%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int main() {
   int N;
   cin >> N;
   int total = 0;
   vector<int> A(N), B(N), C(N);
   for(int i=0; i<N; i++) cin >> A[i];
   for(int i=0; i<N; i++) cin >> B[i];
   for(int i=0; i<N-1; i++) cin >> C[i];

   for(int i=0; i<N; i++) {
      int x = A[i];
      total += B[x-1];
      if(i < N-1 && A[i] + 1 == A[i+1]) total += C[x-1];
   }
   cout << total << endl;
}

Measured memory_bytes: 3640
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  ll x; cin >> x;
  for (ll a = -200; a<=200; a++) {
    for (ll b = -200; b<=200; b++) {
      if (a*a*a*a*a - b*b*b*b*b == x) {
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  assert(x == 0);
  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int N;
string S;
int dp[101010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> S;
    rep(i, N) {
        chmax(dp[i+1], dp[i]);
        if (i + 1 < N && S[i] != S[i+1]) chmax(dp[i+2], dp[i] + 1);
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s;
    cin>>s;
    int x1=0,x2=0,x3=0,x4=0;
    rep(i,s.size()){
        if(s[i]=='N')x1++;
        if(s[i]=='E')x2++;
        if(s[i]=='S')x3++;
        if(s[i]=='W')x4++;
    }
    if((x1!=0&&x3==0)||(x2!=0&&x4==0)||(x1==0&&x3!=0)||(x2==0&&x4!=0)){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
n = int(input())


def divisor_count(n):
    i = 1
    count = 0

    while(i * i <= n):
        if n % i == 0:
            count += 1
            if n != i * i:
                count += 1
        i += 1

    return count

result = 0
for i in range(1, n + 1):
    if i % 2 == 1 and divisor_count(i) == 8:
        result += 1

print(result)



Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL (1LL<<62) // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, k, ans = INFLL;
    cin >> n >> k;
    vi x(n), y(n);
    vector<pair<ll, ll>> xy(n), yx(n);
    rep(i, n){
        cin >> x[i] >> y[i];
        xy[i] = make_pair(x[i], y[i]);
        yx[i] = make_pair(y[i], x[i]);
    }
    sort(all(xy));
    sort(all(yx));

    for(ll sx=0; sx<n; sx++){
        for(ll sy=0; sy<n; sy++){
            for(ll gx=sx; gx<n; gx++){
                for(ll gy=sy; gy<n; gy++){
                    ll cnt = 0;
                    for(ll i=0; i<n; i++){
                        if(xy[sx].first <= x[i] && x[i] <= xy[gx].first && yx[sy].first <= y[i] && y[i] <= yx[gy].first) cnt++;
                    }
                    if(cnt >= k) chmin(ans, (xy[gx].first-xy[sx].first)*(yx[gy].first-yx[sy].first));
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
n,m = (int(i) for i in input().split())
x =[]
checkpoint =[]
for i in range(n):
  tmp =list(int(i) for i in input().split())
  x.append(tmp)
for j in range(m):
  tmp = list(int(i) for i in input().split())
  checkpoint.append(tmp)

for i in range(n):
  destrange = []
  for j in range(m):
    #各学生とチェックポイントとの距離をだす
    rang = abs(x[i][0]-checkpoint[j][0])+abs(x[i][1]-checkpoint[j][1])
    destrange.append(rang)
  print(destrange.index(min(destrange))+1)


Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Created by shaoq on 2016/10/23.
 */
public class Main {
    public static String getCF(String s) {
        s = s.replace("Q","");
        s = s.replace("A","");
        s = s.replace("Z","");
        s = s.replace("W","");
        s = s.replace("S","");
        s = s.replace("X","");
        s = s.replace("E","");
        s = s.replace("D","");
        s = s.replace("R","");
        s = s.replace("V","");
        s = s.replace("T","");
        s = s.replace("G","");
        s = s.replace("B","");
        s = s.replace("Y","");
        s = s.replace("H","");
        s = s.replace("N","");
        s = s.replace("U","");
        s = s.replace("J","");
        s = s.replace("M","");
        s = s.replace("I","");
        s = s.replace("K","");
        s = s.replace("O","");
        s = s.replace("L","");
        s = s.replace("P","");
        if (s.contains("CF")) {
            return "Yes";
        } else {
            return "No";
        }
    }
    
    public static void main(String ... args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        System.out.println(getCF(s));
    }
}


Measured memory_bytes: 10068
#include<stdio.h>

double power(long long int x,long long int n){
    long long int M=1000000007,tmp;
    
    if(n==0) return 1;
    tmp=power(x*x%M,n/2);
    if(n%2==1){
        tmp=tmp*x%M;
    }    
    return tmp;
}

int main(void){
long long int m,n,x;
scanf("%lld %lld",&m,&n);
x=power(m,n);
printf("%lld\n",x);

return(0);
}




Measured memory_bytes: 2052
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
  string s;
  int k;
  
  cin >> k;
  cin >> s;
  
  if ( (int)(s.length()) > k ) {
    for (int i = 0; i < k; ++i ) {
      cout << s[i];
    }
    cout << "..." << endl;
  }
  else {
    cout << s << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3524
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 100005
#define mod 1000000007
int arr[MX],dp[MX];
int main()
{
    int n,k;
    sci(n),sci(k);
    for(int i=0;i<n;i++)
    {
        sci(arr[i]);
    }
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k&&i-j>=0;j++)
        {
            dp[i]=min(dp[i],abs(arr[i]-arr[i-j])+dp[i-j]);
        }
    }
    printf("%d\n",dp[n-1]);
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  string s;cin >> s;
  int t = stoi(s);
  int ans = 0;
  for(auto&i:s){
    int k=i-'0';
    ans += k;
  }
  cout << (t%ans==0?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main(){
    int h,w;
    cin >> h >> w;
    char field[1010][1010];
    rep(i,h){
        rep(j,w){
            cin >> field[i][j];
        }
    }
    mint dp[1010][1010];
    rep(i,h){
        rep(j,w){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            if(field[i][j]=='#')continue;
            if(i==0&&j==0)continue;
            if(i==0)dp[i][j]=dp[i][j-1];
            if(j==0)dp[i][j]=dp[i-1][j];
            else{
                dp[i][j]=dp[i-1][j]+dp[i][j-1];
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 9216
while True:
    try:
        N = int(input())
        count = 0
        for a in range(10):
            for b in range( 10):
                for c in range(10):
                    for d in range(10):
                        if a + b + c + d == N:
                            count += 1
        print(count)
    except EOFError:
        break



Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <set>

using namespace std;
typedef long long ll;

int main(){
    int A,B;
    cin >> A >> B;
    if(A<=5) cout << 0 << endl;
    else if(A<13) cout << B/2 << endl;
    else cout << B << endl;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}

fn main() {
    let s     = read_line().into_bytes();
    let n = s.len() as i64;
    let mut freq = vec![0 as i64 ; 26];
    for b in s {
        freq[(b - ('a' as u8)) as usize] += 1;
    }

    let mut tot = n * (n - 1)/ 2 + 1;
    for f in freq {
        tot -= f * (f - 1) / 2;
    }

    println!("{}", tot);

}


Measured memory_bytes: 4352
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

li = [a1, b1, a2, b2, a3, b3]

s = 0
t = 0
for i in range(len(li)):
    if li[i] == 2:
        s += 1
    if li[i] == 3:
        t += 1
if s == 2 and t == 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060