akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

int main(void){
    int n,m,q; cin>>n>>m>>q;
    vector <pair<int,int>> data (m);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        data[i]= make_pair(a,b);
    }
    sort(data.begin(),data.end());
    vector <vector<int>> mark(510 ,vector <int>(510));
    vector <vector<int>> csum(510 ,vector <int>(510 ));
    for(int i=0;i<m;i++){
        mark[data[i].F][data[i].S]++;
    }
    for(int i=0;i<505;i++){
        for(int j=0;j<505;j++){
            csum[i][j+1]= csum[i][j]+ mark[i][j+1];
        }
    }
    for(int i=0;i<q;i++){
        int a,b; cin>>a>>b;
        //cout<<a<<' '<<b<<endl;
        int ans = 0;
        for(int i=a;i<=b;i++){
            ans+= csum[i][b];
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 4608
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define REP(i,n) for (int i = 1; i <= n; i++)
// mp::cpp_int



int solve( ){
  
int a,b;
cin>>a>>b;
if(b%a==0)cout<<a+b;
else
cout<<b-a;

return 0;
}
 

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
  
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=100010;
const ll mod=1e9+7;



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

  ll k = 1;
  while((1+k)*k/2<n){
    k++;
  }
  while(n>0){
    if(n>k){
      cout << k << ln;
      n -= k;
      k--;
    } else {
      cout << n << ln;
      n=0;
    }
  }

  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] letters = scanner.next().toCharArray();
		int[] exits = new int[26];
		Arrays.fill(exits, 0);
		
		for (int i = 0; i < letters.length; i++) {
			char c = letters[i];
			exits[c-'a']++;
		}
		String ans = "Yes";
		for (int i = 0; i < exits.length; i++) {
			if (exits[i]%2 != 0) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
		
		scanner.close();
	}
}


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

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

  const long long INF = 1LL << 60;
  long long dp[n+1];
  for (int i = 0; i < n + 1; i++) dp[i] = INF;

  long long in[n];
  for (int i = 0; i < n; i++) cin >> in[i];

  dp[0] = 0;
  for (int i = 0; i < (n - 1); i++) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(in[i] - in[i+1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(in[i] - in[i+2]));
  }

  cout << dp[n - 1];
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int t,n,ba=0;
	cin>>n;
	for(t=1;t<=n;t++)
	{
		string s=to_string(t);
		if(s.size()%2==1)
		{
			ba++;
		}
		//cout<<ba<<" ";
	}
	//string类型转化;
	cout<<ba;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	int n, m , p; 
  cin >> n >> m >> p;
  
	int a[5010], b[5010];
  
  long long c[5010] , dist[5010];
	
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
      
		c[i] = -c[i];
       c[i] += p;
		a[i]--, b[i]--;
	}
	
	
	dist[0] = 0;
  
  for(int i=1;i<n;i++){
    dist[i] = 1000000009;
  }
     
	for (int j = 0; j < n-1; j++) {
      
		for (int i = 0; i < m; i++) {
			if (dist[a[i]] == 1000000009) continue;
          
			if (dist[b[i]] > dist[a[i]] + c[i]) {
				dist[b[i]] = dist[a[i]] + c[i];
			}
		}
	}
  
	long long ans = dist[n-1];
 
	bool abc[5010];
  
  for(int i=0;i<n;i++){
    abc[i] = false;
  }
  
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < m; i++) {
			if (dist[a[i]] == 1000000009) continue;
			if (dist[b[i]] > dist[a[i]] + c[i]) {
				dist[b[i]] = dist[a[i]] + c[i];
              
				abc[b[i]] = true;
			}
			if (abc[a[i]]) abc[b[i]] = true;
		}
	}
 
	if (abc[n-1])
		cout << "-1" << endl;
	else
		cout << max((long long)0,-ans) << endl;
}


Measured memory_bytes: 384
fun main(args : Array<String>) {
    val (H, W) = readLine()!!.split(" ").map { it.toInt() }
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }

    val a = Array(H, { Array(W, { false })})

    (0..h-1).forEach {
        a[it].fill(true)
    }

    (0..w-1).forEach {ww ->
        (0..H-1).forEach { hh->
           a[hh][ww] = true
        }
    }


    var ans = 0
    (0..H-1).forEach { hh ->
        (0..W-1).forEach { ww ->
            if (a[hh][ww]) {
                ans++
            }
        }
    }

    println(H * W - ans)
}

Measured memory_bytes: 37836
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PUTS(x) cout << (x) << endl;
const auto MOD = 1000000007LL;
constexpr Int L = 2002;
int main() {
    Int n, k;
    cin >> n >> k;
    Int count[L] = {0};
    Int a[L] = {0};
    Int base = 0;
    rep(i, n) {
        Int x;
        cin >> x;
        a[i] = x;
        count[x]++;
        rep(j, i) {
            if (a[j] > x) base++;
        }
    }
    Int yoridai[L] = {0};
    for (Int i = L - 1; i >= 0; i--) {
        for (Int j = i + 1; j < L; j++) {
            yoridai[i] += count[j];
        }
    }
    Int ans = 0;
    rep(i, n) {
        ans += yoridai[a[i]];
        ans %= MOD;
    }
    ans *= (k * (k - 1) / 2) % MOD;
    ans %= MOD;
    ans += base * k % MOD;
    ans %= MOD;
    PUTS(ans);
}


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

int main(){
	char c;
	const int N = 26;
	int num[N] = {0};
	while(cin >> c){
		if(c >= 'A' && c <= 'Z')
			num[c-'A']++;
		else if(c >= 'a' && c <= 'z')
			num[c-'a']++;
	}
	for(int i = 0; i < N; i++){
		cout << (char)('a'+i) << " : " << num[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する


int main() {
    map<int,int> mp;
    int n;
    cin >> n;
    rep(i,0,n){
        int in;
        cin >> in;
        mp[in]++;
    }
    ll ans = 0;
    for(auto it = mp.begin(); it != mp.end(); it++){
        int a = it->first;
        int b = it->second;
        if(a <= b){
            ans += 1LL*(b-a);
        }else{
            ans += 1LL * b;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main(void)
{
    int a,b,c;
    int i,n;
    
    scanf("%d %d %d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0)
            n=n+1;
    }
    printf("%d\n",n);
    
    return 0;
}


Measured memory_bytes: 2108
#A問題
S=list(str(input()))
aflag = 0
kflag = 0
flag = 0
for s in S:
    if s == "A":
        if aflag == 0:
            aflag = 1
            pass
        else:
            flag = 1
            break
    else:
        if s == "K":
            if kflag == 0:
                aflag = 1
                kflag+=1
            else:
                flag = 1
                break
        elif s == "I":
            if kflag == 1:
                kflag+=1
            else:
                flag = 1
                break
        elif s == "H":
            if kflag == 2:
                kflag+=1
                aflag = 0
            else:
                flag = 1
                break
        elif s == "B":
            if kflag == 3:
                kflag+=1
                aflag = 0
            else:
                flag = 1
                break
        elif s == "R":
            if kflag == 4:
                kflag+=1
                aflag = 0
            else:
                flag = 1
                break
        else:
            flag = 1
            break

if flag == 0 and kflag == 5:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

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


	    int N=gi();
	    int[] A=new int[N];
	    LinkedList<Integer> l = new LinkedList<Integer>();

        for (int i=0; i<N; i++) {
            A[i]=gi();
            if(i%2==0) {
            	l.addFirst(A[i]);
            } else {
            	l.addLast(A[i]);
            }
        }

        if(N%2==0)Collections.reverse(l);

        Iterator it=l.listIterator();
        boolean f=false;
        while(it.hasNext()) {
        	if(f) {
        		System.out.print(" ");
        	} else {
        		f=true;
        	}
        	System.out.print(it.next());
        }



        //System.out.println(Math.min(mp[N], pm[N]));

//        if(ans==0) {
//
//		    System.out.println("Yes");
//        } else {
//        	System.out.println("No");
//
//        }
	}


	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n = 0;
    cin >> n;
    vector<int> v(n);

    for (int &x : v) {
        cin >> x;
    }

    int tmp = v[0];
    lld ans = 0;
    for (int i = 1; i < (int) v.size(); i++) {
        if (v[i] < tmp) {
            ans += (tmp - v[i]);
        } 
        tmp = max(tmp, v[i]);
    }
    cout << ans << '\n';

    return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Measured memory_bytes: 3984
import java.util.*;
import java.io.*;
import java.lang.*;

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

        int k = sc.nextInt();
        int x = sc.nextInt();

        int from;
        int to;

        if (x-(k-1) >= -1000000)
            from = x-(k-1);
        else
            from = -1000000;
        if (x+(k-1) <= 1000000)
            to = x+(k-1);
        else
            to = 1000000;
        for (int i = from; i<=to; i++)
            System.out.print(i + " ");
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  
  ll ans = 100;
  REP1(i, (int)sqrt(n)+1){
    ll j = n/i;
    if(i*j == n){
      ll f = max((int)log10(i), (int)log10(j));
      ans = min(ans, f+1);
    }


  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
int main() {
	int mod,val;
	cin >> mod;
	val = 7%mod;
	int ans = -1;
	for (int i = 1; i <= 1e7; i++) {
		if (val == 0) {
			ans = i;
			break;
		}
		val = ((val*10%mod)+7%mod)%mod;
	}
	cout << ans;
	return 0;
}

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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll n; std::cin >> n;
  n--;
  std::cout << (n+1) * n / 2 << "\n";
}


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

int main(){
  int N;
  cin >> N;
  
  int ans= INT_MAX;
  for(int bufA=1; 2*bufA <= N; bufA++){
    int A= bufA;
    int B= N- A;
    int digitsum= 0;
    while(B > 0){
      digitsum+= A%10+ B%10;
      A/= 10;
      B/= 10;
    }

    ans= min(ans, digitsum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const double EPS = 1e-9;    // 許容誤差。問題によって変える
//typedef complex<double> P;  // Point
//typedef vector<P> VP; //単純多角形
//#define X real()
//#define Y imag()
//#define LE(n,m) ((n) < (m) + EPS)
//#define GE(n,m) ((n) + EPS > (m))
//#define EQ(n,m) (abs((n)-(m)) < EPS)
//namespace std{
//    bool operator < (const P a, const P b){
//        return a.X != b.X ? a.X <b.X : a.Y < b.Y;
//    }
//}
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
//外積cross(a,b) = |a||b|sinθ
//double cross(const P& a, const P& b) {
 // return imag(conj(a)*b);
//}
//内積dot(a,b) = |a||b|cosθ
//double dot(const P& a, const P& b) {
  //return real(conj(a)*b);
//}
//Line
//struct L : public vector<P> {
  //L(const P &a, const P &b) {
    //push_back(a); push_back(b);
  //}
//};
//円
//struct C{
//  P p; double r;
//  C(const P &p, double r) : p(p), r(r) { }
//};
int main(){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    return 0;
}


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

const int64_t INF = 1LL << 60;

int N;
int64_t K;
vector<int64_t> A;

int solve(int i, int64_t x) {
    int l = i, r = N;
    while(r - l > 1) {
        int c = (l + r) / 2;
        (A[i] * A[c] <= x) ^ (A[i] > 0) ? r = c : l = c;
    }
    return A[i] > 0 ? l - i : N - r;
}

int main() {
    cin >> N >> K;
    A.resize(N);
    for(auto &e : A) cin >> e;
    sort(A.begin(), A.end());
    auto OK = [&](int64_t x) {
        int64_t cnt = 0;
        for(int i = 0; i < N; ++i) {
            if(A[i] == 0) cnt += (x >= 0 ? N - i - 1 : 0);
            else cnt += solve(i, x);
        }
        return cnt < K;
    };
    int64_t l = -INF, r = INF;
    while(r - l > 1) {
        int64_t c = (l + r) / 2;
        OK(c) ? l = c : r = c;
    }
    cout << r << '\n';
    return 0;
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353
#define Graph vector<vector<int>>

int main() {
    vector<int> x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x.at(i);
        if (x.at(i) == 0) cout << i + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3588
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		String s = sc.next();
		int n = parseInt(sc.next());
		StringBuffer pre = new StringBuffer();
		StringBuffer post = new StringBuffer();
		int rev = 0;
		for (i = 0; i < n; i++) {
			if(sc.next().equals("1")) {
				rev++;
			} else {
				int pp = (parseInt(sc.next())+rev)%2;
				if(pp==1) {
					pre.append(sc.next());
				} else {
					post.append(sc.next());
				}
			}
		}
		StringBuffer ans = pre.reverse().append(s).append(post);
		if(rev%2==1) ans = ans.reverse();
		out.println(ans.toString());
	}
}


Measured memory_bytes: 91188
from sys import stdin, stdout
import sys
import bisect
INF=1e9
def get_int(): return int(stdin.readline().strip())
def get_ints(): return map(int,stdin.readline().strip().split()) 
def get_array(): return list(map(int,stdin.readline().strip().split()))
def get_string(): return stdin.readline().strip()
def op(c): return stdout.write(c)
#from collections import defaultdict 
#for _ in range(int(stdin.readline())):
x=get_array()
for i in range(len(x)):
    if x[i]==0:
        print(i+1)

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

using namespace std;

int n, y[300005], z[300005], ans = INT_MAX;
char x[300005];

int main() {
	scanf("%d%s", &n, x);
	for (int i = 0; i < n; i++) {
		y[i + 1] = y[i] + (x[i] == 'W');
		z[i + 1] = z[i] + (x[i] == 'E');
	}
	for (int i = 0; i < n; i++)
		ans = min(ans, y[i] + z[n] - z[i + 1]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2944
alf = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'

N = int(input())
S = input()
S = list(S.lower())

for i in range(len(S)):
    for j in range(26):
        if S[i] == alf[j]:
            S[i] = alf[j + N]
            break

ans = ''.join(S)

print(ans.upper())

Measured memory_bytes: 3064
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; string s;
    cin >> n >> s;
    rep(i,0,s.size()){
        if(s[i]>'Z'-n) s[i]-=26;
        cout << char(s[i]+n);
    }
    cout ENDL;
    
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
using namespace std;
const int nmax=200;
const int INF=1000000000;

struct Node{
	vector<int> to;
	vector<int> cost;
};
struct node{
	int cost;
	bool visited;
};

int operate();

int dist[nmax][nmax];

Node nodes[nmax];

int N,M,R;
int r[8]={};
int patern[8]={};
long long Ans=INF;
bool checked[8];

long long min(long long x,long long y){
	if (x<y){
		return x;
	}else{
		return y;
	}
}

void dijkstra(int x,int y){
	if(dist[x][y] != INF)return;
	int TargetNode = x;
	int cost[nmax];
	for(int i=0;i<nmax;i++){
		cost[i] = INF;
	}
	node otherNodes[nmax];
	for(int i=0;i<nmax;i++){
		otherNodes[i].cost = INF;
		otherNodes[i].visited = false;
	}
	cost[TargetNode] = 0;
	otherNodes[TargetNode].cost = 0;
	otherNodes[TargetNode].visited = true;
	
	while(true){
		for(int i=0;i<nodes[TargetNode].to.size();i++){
			int now = nodes[TargetNode].to[i];
			if(otherNodes[now].visited)continue;
			otherNodes[now].cost = min(otherNodes[now].cost,cost[TargetNode] + nodes[TargetNode].cost[i]);
		}
		int Min=INF;
		int thenNode=-1;
		for(int i=0;i<nmax;i++){
			if(otherNodes[i].visited)continue;
			if(otherNodes[i].cost < Min){
				Min = min(otherNodes[i].cost,Min);
				thenNode = i;
			}
		}
		
		if(thenNode == -1)break;
		TargetNode = thenNode;
		otherNodes[TargetNode].visited = true;
		cost[TargetNode] = otherNodes[TargetNode].cost;
		
		if(thenNode == y)break;
		
	}
	dist[x][y] = cost[y];
	dist[y][x] = cost[y];
	
}

void kumiawase(int I,int junban){
	patern[junban]=r[I];
	if(junban == R-1){
		Ans = min(Ans,operate());
	}else{
		for(int i=0;i<R;i++){
			if(checked[i])continue;
			checked[i] = true;
			kumiawase(i,junban+1);
			checked[i] = false;
		}
	}
}
				  
int operate(){
	int ret=0;
	for(int i=0;i<R-1;i++){
		dijkstra(patern[i],patern[i+1]);
		ret = ret + dist[patern[i]][patern[i+1]];
	}
	return ret;
}

int main(){
	
	
	cin >> N >> M >> R;
	for(int i=0;i<R;i++){
		cin >> r[i];
		r[i]--;
	}
	for(int i=0;i<nmax;i++){
		for(int j=0;j<nmax;j++){
			if(i==j){
				dist[i][j] = 0;
			}else{
				dist[i][j] = INF;
			}
		}
	}
	for(int i=0;i<8;i++){
		checked[i] = false;
	}
	
	int A,B,C;
	for(int i=0;i<M;i++){
		cin >> A >> B >> C;
		A--;
		B--;
		nodes[A].to.push_back(B);
		nodes[A].cost.push_back(C);
		nodes[B].to.push_back(A);
		nodes[B].cost.push_back(C);
	}
	
	for(int i=0;i<R;i++){
		checked[i] = true;
		kumiawase(i,0);
		checked[i] = false;
		for(int j=0;j<R;j++){
			patern[j] = -1;
		}
	}
	
	cout << Ans << endl;
	
	return 0;
}

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(intl i=0;i<(intl)(n);i++)
#define Rep1(i,n) for(intl i=1;i<(intl)(n)+1;i++)
#define vec vector
#define fi first
#define se second
#define pushb push_back
#define popb pop_back
#define SortA(v) sort(v.begin(), v.end())
#define SortD(v) sort(v.rbegin(), v.rend())
using intl = int64_t;
using vi = vec<intl>;
using vvi = vec<vi>;
vec<intl> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<intl> dy = {1, 0, -1, 0, 1, -1, 1, -1};

intl pow(intl a,intl n){
  intl ans=1;
  Rep(i,n) ans *=a;
  return ans;
}

int main(){
  intl N,K;
  cin >>K>>N;
  set<intl> distance;
  vi A(N);
  Rep(i,N) cin >> A.at(i);
  Rep(i,N-1) distance.insert(A.at(i+1) - A.at(i));
  distance.insert(A.at(0) + K - A.at(N-1));
  cout << K-*distance.rbegin();
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;
const int MX = 100005;

int main(){
    int N;
    long long A;
    long long Q;
    int B,C;
    long long sum;
    long long num;

    cin >> N;
    vector<long long> x(MX);

    for(int i = 1 ; i <= N ; i++){
        cin >> A;
        x[A]++;
        sum += A;
    }

    cin >> Q;

    long long calc;

    while(Q--){
        cin >> B >> C;
        /**
        sum-=B*x[B];
        sum+=C*x[B];
        x[C]+=x[B];
        x[B]=0;
        cout << sum << endl;
        **/
        
        num = C - B;
        calc = num * x[B] + sum;
        sum = calc;
        x[C] = x[C] + x[B];
        x[B] = 0;
        cout << calc << endl;
    }

    return 0;
}


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

typedef long long ll;

ll h, w;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w;
    if (h % 3 == 0 || w % 3 == 0) {
        cout << 0 << endl;
        exit(0);
    }
    // 12
    // 13
    ll ans = min(h, w);
    for (int i = 1; i < w; ++i) {
        ll left = i * h;
        ll right1 = (w - i) * (h / 2);
        ll right2 = (w - i) * ((h + 1) / 2);
        vector<ll> v = {left, right1, right2};
        sort(v.begin(), v.end());
        ans = min(ans, v[2] - v[0]);
    }
    for (int i = 1; i < h; ++i) {
        ll up = i * w;
        ll right1 = (h - i) * (w / 2);
        ll right2 = (h - i) * ((w + 1) / 2);
        vector<ll> v = {up, right1, right2};
        sort(v.begin(), v.end());
        ans = min(ans, v[2] - v[0]);
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char x,y;cin >> x >> y;
	if(x>y) cout << '>' << endl;
	else if(x<y) cout << '<' << endl;
	else cout << '=' << endl;
}

Measured memory_bytes: 256
import math

def main():
    a, b, n = map(int, input().split())

    if n >= b:
        print(math.floor(a * (b-1) / b) - a * math.floor((b-1) / b))
    else:
        print(math.floor(a * n / b) - a * math.floor(n / b))

main()

Measured memory_bytes: 9188
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	ll A, B, C, K;
	cin >> A >> B >> C >> K;
	if (K % 2 == 0) cout << A - B << endl;
	else cout << B - A << endl;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;


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

	cin >> N >> M;
	multimap<pair<int, int>, pair<pair<int, int>, int>>edge;
	map<pair<int, int>, int>dis;
	priority_queue<pair<int, pair<int,int>>, vector<pair<int, pair<int,int>>>, greater<pair<int, pair<int,int>>>>PQ;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> K;
		edge.insert({ { L,K },{ { R,K },0 } });
		edge.insert({ { R,K },{ { L,K },0 } });
		edge.insert({ { L,0 },{ { L,K },1 } });
		edge.insert({ { R,0 },{ { R,K },1 } });
		edge.insert({ { R,K },{ { R,0 },0 } });
		edge.insert({ { L,K },{ { L,0 },0 } });
	}
	dis[{1,0}] = 0;
	PQ.push({ 0,{1,0} });
	while (!PQ.empty()) {
		auto cn = PQ.top().second;
		int c = PQ.top().first;
		PQ.pop();
		//cout << cn.first << " " << cn.second << " " << c << endl;
		if (c > dis[cn])continue;
		auto m = edge.equal_range(cn);
		for (auto i = m.first; i != m.second;++i) {
			if (dis.find(i->second.first) == dis.end()) {
				dis[i->second.first] = dis[cn] + i->second.second;
				PQ.push({ dis[i->second.first], i->second.first });
			}
			else if (dis[i->second.first] > dis[cn]+i->second.second) {
				dis[i->second.first] = dis[cn] + i->second.second;
				PQ.push({ dis[i->second.first], i->second.first });
			}
		}
	}
	if (dis.find({N,0})==dis.end()) {
		cout << "-1\n";
	}
	else {
		cout << dis[{N, 0}] << endl;
	}
	return 0;
}

Measured memory_bytes: 108080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}


int main() {
	int n;
	cin >> n;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 15; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())
A = []

for s in range(n + 1):
    count = 0
    t = n - s
    while s > 0:
        count += s % 6
        s //= 6
    while t > 0:
        count += t % 9
        t //= 9
    A.append(count)
    
print(min(A))

Measured memory_bytes: 3864
#include <bits/stdc++.h>
 
using namespace std;
 
double P,E,T;
 
double solve(double L,double R,int K){
    double H = (L + R) / 2.0;
    if(K == 0){
	if(T-E <= H && H <= T+E){
	    return 1;
	}else{
	    return 0;
	}
    }
 
    if(T-E <= L && L <= T+E &&
       T-E <= R && R <= T+E){
	return 1;
    }
 
    if(T-E > L || T+E < R){
	return 0;
    }
 
    double res = 0;
    if(H < T){
	res += solve(L,H,K-1)*(1-P);
	res += solve(H,R,K-1)*P;
    }else{
	res += solve(H,R,K-1)*(1-P);
	res += solve(L,H,K-1)*P;
    }
    return res;
}
 
int main(){
    int K;
    double R,L;
    cin >> K >> R >> L >> P >> E >> T;
    printf("%.8f\n",solve(L,R,K));
    return 0;
}

Measured memory_bytes: 3264
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T[]readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?e[1..$]:[];return tp;}}
struct Stack(T){T[]e;auto push(T t){e~=t;}auto push(T[]ts){e~=ts;}T pop(){T tp=e[$-1];e=e.length>1?e[0..$-1]:[];return tp;}}
//END OF TEMPLATE

void main(){
    long n;
    n.scan;
    iota(1,n+1).filter!(i=>i%3!=0&&i%5!=0).fold!"a+b".writeln;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(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 RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

// int M[10000][10000]; // max of [L][R]
// int X[10000][10000]; 

// void solve() {
//   int N; cin >> N;
//   REP0(i, N){
//     int p; cin >> p;
//     X[i][i] = p;
//     REP0(j, i+1) { // 0 ~ i-1 行 までの上△を埋める
//       FOR(k, j+1, i+1) { // j 行目を k = j+1 - i まで
//         if (k==j+1) {
//           X[j][k] = min(X[j][k-1], X[j+1][k]);
//           M[j][k] = max(X[j][k-1], X[j+1][k]);
//           } else {
//           if (M[j][k-1] <= X[k][k]) X[j][k] = M[j][k-1];
//           else if ((M[j][k-1] > X[k][k]) and (X[k][k] >= X[j][k-1])) X[j][k] = X[k][k];
//           else X[j][k] = X[j][k-1];
//         } 
//       }
//     }
//   }
//   int ans=0;
//   REP1(i, N) FOR(j, i+1, N+2) ans += X[i][j];
//   cout << ans << endl;
// }

void solve()
{
  // multiset<int> S; // 0<=j < i   s.t. P_i < P_j 
  // multiset<int> T; // i< j <=N+1 s.t. P_i < P_j
  // X_LR=P_i となるのは
  // ① w < L ≤ x < i ≤ R < y < z のときと
  // ② w < x ≤ L < i < y ≤ R < z のときのみ
  // つまり, P_iより大きい要素の添え字を範囲内にひとつ（x xor y）しか持たないときで
  // ①のケース数は (x-w)*(y-i); L,r が w < L ≤ x, i ≤ R < y でそれぞれ自由に動く
  // ②のケース数は (i-x)*(z-y) でカウントする
  ULL ans = 0;
  int N; cin >> N;

  map<int, int> P_index;
  REP1(i, N) {
    int p; cin >> p;
    P_index.insert(make_pair(p, i));
  }
  multiset<int> checked_ind;
  checked_ind.insert(0); checked_ind.insert(0);
  checked_ind.insert(N+1); checked_ind.insert(N+1);

  decltype(checked_ind)::iterator ptr_x;
  decltype(checked_ind)::iterator ptr_y;

  RREP1(P_i, N){
    int i = P_index.at(P_i);
    ptr_y = checked_ind.upper_bound(i);
    // lower_bound は条件を満たす *最初の要素* を指すので
    // set に対して使うと最小値を取ってきてしまう
    ptr_x = prev(ptr_y);
    LL cnt = (*ptr_x - *prev(ptr_x)) * (*ptr_y - i);
    cnt += (i - *ptr_x) * (*next(ptr_y) - *ptr_y);
    ans += cnt * P_i;
    checked_ind.insert(i);
  }

  cout << ans << endl;

}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> board(h);
    rep(y, h) {
        string s;
        cin >> s;
        board[y] = s;
    }

    rep(y, h) {
        rep(x, w) {

            if(board[y][x] == '#') {
                continue;
            }

            int bomb = 0;
            rep(i, 8) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                
                if(nx < 0 || w <= nx || ny < 0 || h <= ny) {
                    continue;
                } 

                if(board[ny][nx] == '#') {
                    bomb++;
                }
            }

            board[y][x] = (char)(bomb + '0');
        }
    }

    rep(y, h) {
        rep(x, w) {
            cout << board[y][x];
        }
        cout << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lucasr
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		CSumOfProductOfPairs solver = new CSumOfProductOfPairs();
		solver.solve(1, in, out);
		out.close();
	}

	static class CSumOfProductOfPairs {
		static final long MOD = 1000000007;

		public void solve(int testNumber, MyScanner sc, PrintWriter out) {
			int N = sc.nextInt();
			long[] vals = sc.nextLongArray(N);
			long sum = 0, sq = 0;
			for (int i = 0; i < N; i++) {
				sum += vals[i];
				sum %= MOD;
				sq += vals[i] * vals[i];
				sq %= MOD;
			}
			long ans = ((sum * sum) - sq) % MOD;
			ans *= 500000004L;
			ans %= MOD;
			out.println(ans);
		}

	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

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

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = nextLong();
			}
			return ret;
		}

	}
}



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

int main(void){
  int n;
  while(cin >> n){
    int nums[n];
    int prime=0;
    for(int i=1;i<=n;i++){
      nums[i]=i;
    }
    for(int i=1;i<=n;i++){
      if(nums[i]>1){
	prime++;
	for(int j=2;nums[i]*j<=n;j++){
	  nums[nums[i]*j]=1;
	}
      }
    }
    cout << prime << endl;
  }
  
  return 0;
}

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

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

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

  ll sum = 0;

  for (int i = 1; i <= k; i++)
  {

    for (int j = 1; j <= k; j++)
    {
      for (int l = 1; l <= k; l++)
      {
        ll tmp = gcd(i, j);
        sum += gcd(tmp, l);
      }
    }
  }
  cout << sum;
}


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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int b;
        cin >> b;
        v.push_back(b);
    }
    vector<int> ans;
    while(v.size() > 0){
        bool flag = false;
        for(int i=v.size()-1;i>=0;--i){
            if(v[i] == i+1){
                ans.push_back(i+1);
                v.erase(v.begin()+i);
                flag = true;
                break;
            }
        }
        if(!flag){
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    if(ans.size() == n){
        for(auto e : ans){
            cout << e << endl;
        }
    }else{
        cout << -1 << endl;
    }

    return 0;
}


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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
        return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
        return a / gcd(a, b) * b;
}

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

int main()
{
        int d;
        ci >> d;

        if(d == 25) co << "Christmas" << en;
        if(d == 24) co << "Christmas Eve" << en;
        if(d == 23) co << "Christmas Eve Eve" << en;
        if(d == 22) co << "Christmas Eve Eve Eve" << en;

        return 0;
}

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

int main(){
   // 制約見て！！！デカかったらlong longにすること！
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(k>a+b) printf("%d\n",a-(k-(a+b)));
    else if(k>a) printf("%d\n",a);
    else printf("%d\n",k);
}


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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n, h;
  cin >> n >> h;
  vector<int> a(n);
  vector<int> b(n);
  int ma = 0;
  rep(i, n) {
    int aa, bb;
    cin >> aa >> bb;
    a.at(i) = aa;
    b.at(i) = bb;
    ma = max(ma, aa);
  }
  sort(b.rbegin(), b.rend());
  int bi = 0;
  int cnt = 0;
  while (h > 0) {
    int v;
    if (bi == n) {
      v = ma;
    } else if (b.at(bi) > ma) {
      v = b.at(bi);
      bi++;
    } else {
      v = ma;
    }
    h -= v;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))

#%%
A = [0] + A
A.append(0)

diff = [abs(A[i] - A[i+1]) for i in range(len(A)-1)]
diff2 = [abs(A[i] - A[i+2]) for i in range(len(A)-2)]
total = sum(diff)

for i in range(n):
    ans = total - (diff[i] + diff[i+1]) + diff2[i]
    print(ans)

Measured memory_bytes: 20584
#include<bits/stdc++.h>
using namespace std;
int main()
{
	bool fu = false;
	int n;
	cin>>n;
	int l;
	cin>>l;
	int mi=10000000,he =0;
	for(int i=1;i<=n;i++)
	{
		int no = i+l-1;
		he+=no;
		int k = abs(no);
		if(no <0)
			fu = true;
		mi = min(k,mi);
	}
	if(fu)
		cout<<he+mi<<endl;
	else
		cout<<he-mi<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, fd[6];
    double h;

    for (int i = 0; i < 6; i++)
        fd[i] = 0;

    cin >> n;
    while (n--) {
        cin >> h;
        if (h >= 185)
            fd[5]++;
        else if (h >= 180)
            fd[4]++;
        else if (h >= 175)
            fd[3]++;
        else if (h >= 170)
            fd[2]++;
        else if (h >= 165)
            fd[1]++;
        else
            fd[0]++;
    }

    for (int i = 0; i < 6; i++) {
        cout << i + 1 << ":";
        for (int j = 0; j < fd[i]; j++)
            cout << "*";
        cout << endl;
    }

    return 0;
}

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

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    
    string s;
    cin >> s;
    for (int i = 0; i < sz(s); i++) {
        if (s[i] == '7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <deque>
#include <list>
using namespace std;
int main(){
	int n;
	cin >> n;
	deque<int>deq;
	bool f = true;
	if(n%2 == 0){
		f = true;
	}else{
		f = false;
	}
	for(int i=0; i<n; ++i){
		int tmp;
		cin >> tmp;
		if(f){
			deq.push_back(tmp);
		}else{
			deq.push_front(tmp);
		}
        if(f) f=0;
        else f=1;
	}
    for(auto itr = deq.begin(); itr !=deq.end(); ++itr){
        cout << deq.front() << " ";
        deq.pop_front();
    }
	cout << endl;
    return 0;
}

Measured memory_bytes: 4456
#include <stdio.h>

int main(void) {
	int n;
	int A[1000];
	int v = 0;
	int i, j, k;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	
	for(i = 0; i < n; i++) {
		v = A[i];
		j = i - 1;
		
		while(j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
		}
		
		A[j + 1] = v;
		
		for(k = 0; k < n; k++) {
			printf("%d", A[k]);
				
			if(k != n - 1) {
				printf(" ");
			}
		}
		
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 604
from collections import Counter

import sys

readline = sys.stdin.buffer.readline

N = int(readline())
A = list(map(int, readline().split()))

Q = int(readline())
BC = [list(map(int, readline().split())) for _ in range(Q)]

d = Counter(A)

sub_s = sum(A)

for b, c in BC:
    sub_s += d[b] * (c - b)
    d[c] += d[b]
    d[b] = 0

    print(sub_s)


Measured memory_bytes: 40428
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

LL t[1100];

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	vector<int> v1,v2,vs;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		t[i]=a;
	}
	b=0;
	for(i=0;i<2;i++){
		a=0,v1.clear();
		for(j=0;2*j+i<n;j++){
			if(t[2*j+i]>0)v1.push_back(2*j+i),a+=t[2*j+i];
		}
		if(b<a){
			b=a,v2=v1;
		}
	}
	if(v2.empty()){
		for(i=0,j=0;i<n;i++){
			if(t[i]>t[j])j=i;
		}
		v2.push_back(j);
		b=t[j];
	}
	cout<<b<<endl;
	for(i=n;i>v2.back()+1;i--){
		vs.push_back(i);
	}
	for(i=0;i<v2[0];i++){
		vs.push_back(1);
	}
	for(i=0;i+1<v2.size();i++){
		for(j=(v2[i+1]-v2[i])/2;j>1;j--){
			vs.push_back(3);
		}
		vs.push_back(2);
	}
	cout<<vs.size()<<endl;
	for(auto num:vs){
		cout<<num<<endl;
	}
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc169/tasks/abc169_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)

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

  ll ans = 1;
  REP(i, N) {
    ll a;
    cin >> a;
    if (ans == 0 || a == 0) {
      cout << 0;
      return 0;
    }
    if (ans > ll(2e18) / a) {
      ans = 2e18;
    } else
      ans *= a;
  }
  if (ans > ll(1e18)) {
    cout << -1;
    return 0;
  }
  cout << ans;
}


Measured memory_bytes: 3632