akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(num) scanf("%d",&num)
#define sff(num1,num2) scanf("%d %d",&num1,&num2)
#define sfff(num1,num2,num3) scanf("%d %d %d",&num1,&num2,&num3)
#define sl(num) scanf("%lld",&num)
#define sll(num1,num2) scanf("%lld %lld",&num1,&num2)
#define slll(num1,num2,num3) scanf("%lld %lld %lld",&num1,&num2,&num3)
#define rep(i,n) for(i=1;i<=n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define pb push_back
#define mpp make_pair
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define TIME cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<"s\n";
typedef long long int ll;
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(a=="Sunny")
        puts("Cloudy");
    else if(a=="Cloudy")
        puts("Rainy");
    else
        puts("Sunny");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    int x; cin >> x;
    if (x % 1000 > 0)
        cout << 1000 - x % 1000;
    else {
        cout << 0;
    }
    return 0;
}

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

 int main()
 {
     int a,b,i;

     cin>>a>>b;

     if(a>b){
        for(i=1;i<=a;i++){
            cout<<b;
        }
        cout<<endl;
     }
     else if(a<b){
        for(i=1;i<=b;i++){
            cout<<a;
        }
        cout<<endl;
     }
     else if(a==b){
        for(i=1;i<=b;i++){
            cout<<b;
        }
        cout<<endl;
     }

     return 0;
 }


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


#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

using namespace std;

vector<int> ans, usd(22), g[22];

void dfs(int s){
	if(usd[s]) return;
	usd[s]=1;
	for(auto v: g[s]) if(!usd[v]) dfs(v);
	ans.push_back(s);

}


int main()
{
	
	int n,m;
	cin >> m >> n;
	rep(i,n){
		int x,y; cin >>x >>y;
		g[x-1].push_back(y-1);
	}
	rep(i,m) dfs(i);
	for(int i=ans.size()-1;i>=0;i--) printf("%d\n",ans[i]+1);
	return 0;
}

Measured memory_bytes: 3212
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n,k,jt;
int dp[305][305];
int C[305][305];

int main(){
	cin>>n>>k>>jt;
	loop(i,n+1) C[i][0]=1;
	cont(i,n)cont(j,i) C[i][j]=(C[i-1][j]+C[i-1][j-1])%jt;
	loop(i,k+1) dp[0][i]=1;
	cont(i,n){
		dp[i][1]=1;
		cont(j,k){
			dp[i][j]=dp[i][j-1];
			cont(k,i) (dp[i][j]+=1ll*dp[k-1][j-1]*dp[i-k][j]%jt*C[i][k-1]%jt)%=jt;
		}
	}
	cout<<dp[n][k]<<endl;
	return 0;
}

Measured memory_bytes: 4300
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,M; cin>>N; cin>>M;
  vector<vector<int> > vv (N,vector<int>(3,0));
  int ANS = -1*INF;
  for (int i = 0; i < N; i++)
  {
    cin>>vv[i][0]>>vv[i][1]>>vv[i][2];
  }
  for (int b = 0; b < 8; b++)
  {
    vector<int> data(N,0);
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < 3; j++)
      {
        if(((b>>j)&1))
        {
          data[i] += vv[i][j];
        }
        else
        {
          data[i] -= vv[i][j];
        }
        // if(b == 7)DEBUG(data[i]);
      //  data[i] = abs(data[i]); 
      }
    }
    sort(ALL(data),greater<int>());
    int SUM = 0;
    for (int k = 0; k < M; k++)
    {
      SUM += data[k];
    }
    // DEBUG(data);
    //     DEBUG(b,SUM,"\n");
    chmax(ANS,SUM);
    // if(ANS == 747)
    // {
    //   DEBUG(b,"\n");
    //   DEBUG(data);
    // }
    
    
    
  }
  
  cout<<ANS<<endl;
  return;

}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}


Measured memory_bytes: 384
solve :: [Double] -> Int -> Int
solve a n = snd $ minimum $ fmap (\(v, i) -> (abs (v - ave), i)) $ zip a [0 .. n - 1]
  where
    ave = (foldl (+) 0 a) / (fromIntegral n)

main :: IO ()
main = do
  n <- readLn :: IO Int
  a <- (fmap (\x -> read x :: Double)) . words <$> getLine
  print $ solve a n



Measured memory_bytes: 1020
a,b,c=input().split(" ")
nums=[]
ans=0
b=int(b)
c=int(c)
a=int(a)
for i in range(a+1):
  nums.append(sum(list(map(int,str(i)))))
for j,n in enumerate(nums):
  if b<=n and n<=c:
    ans+=j
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  int sum = n*(n+1)/2;
  cout<<sum<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const double PI = acos(-1.0);

int main()
{
	int n, m, a;
	cin >> n >> m;
	vector<ll> f(n+1, 0);
	f[0] = f[1] = 1;
	for(int i = 2; i <= n; i++) {
		f[i] = f[i-1] + f[i-2];
		f[i] %= 1000000007;
	}

	int p = 0;
	ll res = 1;
	for(int i = 0; i <= m; i++) {
		if(i == m) {
			a = n+1;
		} else {
			cin >> a;
		}

		if(a == p) {
			cout << 0 << endl;
			return 0;
		}

		if(a - 1 != p) {
			res *= f[a-1-p];
		}

		res %= 1000000007;
		p = a+1;
	}


	cout << res << endl;

    return 0;
}


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

const int M = 105;
int n,a[M];
bool ans = true;

int main(){
    scanf("%d",&n);
    for(int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        if(a[i] % 2) continue;
        if(a[i] % 3 != 0 && a[i] % 5 != 0){ans = false; break;}
    }
    if(ans) printf("APPROVED\n");
    else printf("DENIED\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    long long n, a[200000];
    long long c[200000] = {0};
    long long d1[200001] = {0};
    long long d2[200001] = {0};

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        c[a[i]]++;
    }
    long long ans = 0;
    for (int j = 1; j <= n; j++) {
        d1[j] = c[j] * (c[j] - 1) / 2;
        d2[j] = (c[j] - 1) * (c[j] - 2) / 2;
        ans += d1[j];
    }
    
    for (int i = 0; i < n; i++) {
        cout << ans - d1[a[i]] + d2[a[i]] << endl;
    }    
    return 0;
}

Measured memory_bytes: 8832
#include<stdio.h>
main (){
  int i,l,a[256],b;
  for(i=0;i<10;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<9;i++){
    for(l=9;l>i;l--){
      if(a[l]>a[l-1]){
    b=a[l];
    a[l]=a[l-1];
    a[l-1]=b;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,m;
    cin>>n>>m;
    ll height[n+1];
    for(ll i=1;i<=n;i++){
        cin>>height[i];
    }
    vector<ll> arr[n+1];
    for(ll i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        arr[a].pb(b);
        arr[b].pb(a);
    }
    ll count=0;
    for(ll i=1;i<=n;i++){
        int ans=1;
        for(ll j=0;j<arr[i].size();j++){
            if(height[arr[i][j]]>=height[i]){
                ans=0;
                break;
            }
        }
        if(ans==1){
            count+=1;
        }
    }
    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 10268
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
    set<int>s;
    int n;
    cin>>n;
    while(n--)
    {
        int m;
        cin>>m;
        if(s.count(m)) s.erase (m);
        else s.insert(m);

    }
cout<<s.size()<<endl;
}


Measured memory_bytes: 4864
#include <iostream>
#include <cstring>
#include <queue>

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

using namespace std;

int n[1000001];

int main()
{
	memset(n,0,sizeof(n));
	int num,q;
	cin >> num >> q;

	priority_queue< pair<int,int> > p;
	rep(i,q)
	{
		int a, v;
		cin >> a >> v;
		n[a-1] += v;
		
		p.push(make_pair(n[a-1],-(a-1)));

		while(true)
		{
			int team = -p.top().second;
			if(n[team] == p.top().first)
			{
				cout << team+1 << " " << p.top().first << endl;
				break;
			}
			p.pop();
		}
	}
	
	

	return 0;
}

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

 
public class Main {
 
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n  = sc.nextInt();
		int k  = sc.nextInt();
		int r  = sc.nextInt();
		int s  = sc.nextInt();
		int p  = sc.nextInt();
		char[] tArray = sc.next().toCharArray(); 
        int ans = 0;
        
        for(int i = 0; i < n; i++) {
        	if(i < k) {
            	if(tArray[i] == 's') {
            		ans += r;
            	}else if(tArray[i] == 'p') {
            		ans += s;
            	}else if(tArray[i] == 'r') {
            		ans += p;
            	}
        	}else {
        		if(tArray[i] != tArray[i - k]){
                	if(tArray[i] == 's') {
                		ans += r;
                	}else if(tArray[i] == 'p') {
                		ans += s;
                	}else if(tArray[i] == 'r') {
                		ans += p;
                	}
        		}else {
        			tArray[i] = '0';
        		}
        	}
        }

		System.out.println(ans);
		sc.close();
	}

}

Measured memory_bytes: 39768
#!/usr/bin/env python3
def main():
    N, M = map(int, input().split())
    num = [-1] * N
    for _ in [0] * M:
        s, c = map(int, input().split())
        if num[s - 1] == -1 or num[s - 1] == c:
            num[s - 1] = c
        else:
            print(-1)
            return
    if num[0] == 0 and len(num) != 1:
        print(-1)
        return
    if num[0] == -1 and len(num) != 1:
        num[0] = 1
    for x in num:
        print(0 if x == -1 else x, end='')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

int cmp (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

i32 calc (const i32 v, const i32 *a, const i32 *b, const i32 n) {
  i32 cnt = 0;
  i32 j = n - 1;
  for (i32 i = 0; i < n; ++i) {
    while (j >= 0 && a[i] + b[j] >= v) j--;
    cnt += (n - 1 - j) & 1;
  }
  return cnt & 1;
}

void sub_and_sort (const i32 sub, i32 *a, const i32 n, i32 *tmp) {
  i32 j = 0;
  for (; j < n && a[j] < sub; ++j);
  const i32 m = j;
  i32 i = 0;
  i32 k = 0;
  while (i < m && j < n) {
    if (a[i] <= a[j] - sub) {
      tmp[k++] = a[i++];
    } else {
      tmp[k++] = a[j++] - sub;
    }
  }
  while (i < m) tmp[k++] = a[i++];
  while (j < n) a[j++] -= sub;
  for (i = 0; i < k; ++i) {
    a[i] = tmp[i];
  }
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *a = (i32 *) calloc (2 * n, sizeof (i32));
  i32 *b = a + n;
  for (i32 i = 0; i < 2 * n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  qsort (a, n, sizeof (i32), cmp);
  qsort (b, n, sizeof (i32), cmp);
  i32 *tmp = (i32 *) calloc (n, sizeof (i32));
  i32 ans = 0;
  for (i32 bit = 28; bit >= 0; bit--) {
    ans |= (calc (1 << bit, a, b, n) ^ calc (2 << bit, a, b, n) ^ calc (3 << bit, a, b, n)) << bit;
    sub_and_sort (1 << bit, a, n, tmp);
    sub_and_sort (1 << bit, b, n, tmp);
  }
  printf ("%" PRIi32 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 3000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
#define INF 1000000
const int MAX = 1000000;
const int MOD = 1000000007;

int main(){
	string s;
    cin>>s;
    bool f=true;
    REP(i,SZ(s)/2){
        if(s[i]!=s[SZ(s)-1-i]){
            f=false;
        }
    }
    REP(i,SZ(s)/4){
        if(s[i]!=s[SZ(s)/2-1-i]){
            f=false;
        }
    }
    for(int i=SZ(s)/2+1;i<3*SZ(s)/4;i++){
        if(s[i]!=s[SZ(s)-1-i]){
            f=false;
        }
    }
    if(f) OUT("Yes");
    else OUT("No");
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

void clr(auto &a,int n){
  a.clear();
  a.resize(n);
}

void unq(auto &a){
  sort(all(a));
  a.resize(unique(all(a))-a.begin());
}

const int N=200005;

struct SegTree{
  vector<int>t;
  int _=1e9+100;
  int merge(int x,int y){
    return min(x,y);
  }
  SegTree(int n){
    t.resize(4*n);
    for(auto &i:t){
      i=_;
    }
  }
  
  int query(int v, int tl, int tr, int l, int r) {
    if (l > r) 
      return _;
    if (l == tl && r == tr) {
      return t[v];
    }
    int tm = (tl + tr) / 2;
    return merge(query(v*2, tl, tm, l, min(r, tm))
		 ,query(v*2+1, tm+1, tr, max(l, tm+1), r));
  }
  
  void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
      t[v] = new_val;
    } else {
      int tm = (tl + tr) / 2;
      if (pos <= tm)
	update(v*2, tl, tm, pos, new_val);
      else
	update(v*2+1, tm+1, tr, pos, new_val);
      t[v] = merge(t[v*2],t[v*2+1]);
    }
  }
}; 

void solve(){
  int n,x;
  cin>>n>>x;
  vi a(n);
  cin>>a;
  if(n==1){
    cout<<a[0];
    return;
  }
  SegTree st(n);
  for(int i=0;i<n;i++){
    st.update(1,0,n-1,i,a[i]);
  }
  ll ans=1e18;
  for(int op=0;op<=n;op++){
    ll val=op*1ll*x;
    for(int i=0;i<n;i++){
      int mn=a[i];
      mn=min(mn,st.query(1,0,n-1,max(0,i-op),i));
      if(i-op<0){
	mn=min(mn,st.query(1,0,n-1,n+i-op,n-1));
      }			  
      val+=mn;
    }
    ans=min(ans,val);
  }
  cout<<ans;
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int N,L=1;
long long Sum=0,Ans,A[200005];;
int main()
{
	scanf("%d",&N);
	for (int i=1;i<=N;i++){
		scanf("%lld",&A[i]);
		while ((Sum^A[i])!=Sum+A[i]) Sum^=A[L++];
		Sum^=A[i];Ans+=i-L+1;
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1, y1, x2, y2, X;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	X = (x2 - x1)*(x2 - x1)+(y2 - y1)*(y2 - y1);
	printf("%lf\n", sqrt(X));
	return 0;
}

Measured memory_bytes: 652
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define lpton(i,n) for(int i=0;i<(int)n;i++)
#define lpto0(i,n) for(int i=n;i>-1;i--)
#define lpmn(i,m,n) for(int i=m;i<n;i++)
#define lpmnd(i,m,n) for(int i=m;i>n;i--)
#define ms(l,n,s) memset(l,n,s)
#define m(l,n) (l*)malloc(n*sizeof(l))
void print(int*,int);
void maxset(int*,int,int);
void structs(int*,int);
void swap(int*,int);
int main(){
  int n,v;
  int *heap;
  scanf("%d",&n);
  heap=m(int,(n+2));
  *(heap)=INT_MIN;
  *(heap+(n+1))=INT_MIN;
  lpmn(i,1,n+1){
    scanf("%d",&v);
    *(heap+i)=v;
  }
  structs(heap,n);
  print(heap,n);
  free(heap);
  return 0;
}
void print(int *heap,int n){
  lpmn(i,1,n+1){
    printf(" %d",*(heap+i));
  }
  printf("\n");
}
void maxset(int *heap,int i,int n){
  int tmp,tmpi;
  int left=2*i;
  int right=2*i+1;
  if(left>n)return;
  tmp=*(heap+left)>*(heap+right)?*(heap+left):*(heap+right);
  tmpi=*(heap+left)>*(heap+right)?left:right;
  if(tmp>*(heap+i)){
    swap(heap,tmpi);
    maxset(heap,tmpi,n);
  }
}
void swap(int *heap,int i){
int tmp;
tmp=*(heap+i);
*(heap+i)=*(heap+(i/2));
*(heap+(i/2))=tmp;
}
void structs(int *heap,int n){
  int m=n;
  lpmnd(i,m/2,0){
    maxset(heap,i,n);
  }
}



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

using namespace std;

typedef long long LL;

const int N = 1000010;

int a[5];

bool cmp(int a, int b)
{
    return (a - 1) % 10 > (b - 1) % 10;
}

int main()
{
    for(int i = 0; i < 5; i++) cin >> a[i];
    sort(a, a + 5, cmp);

    int res = 0;
    for(int i = 0; i < 5; i++)
    {
        res += a[i];
        if(i != 4 && a[i] % 10 != 0) res += 10 - a[i] % 10;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int alice , bob;
    cin >> alice >> bob;
    if (alice == 1 && bob != 1) cout << "Alice";
    else if (bob == 1 && alice != 1) cout << "Bob";
    else if (alice > bob) cout << "Alice";
    else if (bob > alice) cout << "Bob";
    else if (bob == alice) cout << "Draw";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    string s,t;
    cin >> s;
    t=s;
    reverse(all(t));
    int ans=0;
    repi(i,1,n){
        int exist[26];
        int ctr=0;
        fill(exist,exist+26,0);
        rp(j,i) exist[s[j]-'a']=1;
        rp(j,n-i){
            if(exist[t[j]-'a']) {
                ctr++;
                exist[t[j]-'a']=0;
            }
        }
        chmax(ans,ctr);
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int N;
vector<vector<int>> to(200005);
mint ans;

int dfs(int v, int p = -1) {
  int res = 1;
  vector<int> ts;
  for (int u : to[v]) {
    if (u == p) continue;
    int t = dfs(u, v);
    res += t;
    ts.push_back(t);
  }
  if (p != -1) {
    ts.push_back(N - res);
  }
  mint now = mint(2).pow(N - 1) - 1;
  for (int t : ts) {
    now -= mint(2).pow(t) - 1;
  }
  ans += now;
  return res;
}

void solve() {
  dfs(0);
  ans /= mint(2).pow(N);
  cout << ans.x << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  scanf("%d", &N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d", &a);
    scanf("%d", &b);
    --a;
    --b;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  solve();
  return 0;
}


Measured memory_bytes: 32168
N, K=map(int, input().split())
R, S, P=map(int, input().split())
T=input()
dp=[[0 for _ in range(N)] for _ in range(3)]
for i in range(N):
  if i>=K:
    dp[0][i]+=max(dp[1][i-K], dp[2][i-K])
    dp[1][i]+=max(dp[0][i-K], dp[2][i-K])
    dp[2][i]+=max(dp[0][i-K], dp[1][i-K])
  dp[0][i]+=R if T[i]=='s' else 0
  dp[1][i]+=S if T[i]=='p' else 0
  dp[2][i]+=P if T[i]=='r' else 0
ans=0
for i in range(N-K, N):
  ans+=max(dp[0][i], dp[1][i], dp[2][i])
print(ans)

Measured memory_bytes: 58224
#include <bits/stdc++.h>
using namespace std;
int a[3];
void solve()
{
    sort(a,a+3);
    if (a[0]%2==0&&a[1]%2==0&&a[2]%2==0)
    {
        //2 4 6
        cout<<(a[2]-a[0])/2+(a[2]-a[1])/2;
    }
    else if (a[0]%2&&a[1]%2==0&&a[2]%2==0)
    {
        //1 4 6
        cout<<1+(a[2]+1-a[0])/2+(a[2]-a[1])/2;
    }
    else if (a[0]%2==0&&a[1]%2&&a[2]%2==0)
    {
        //2 3 6
        cout<<1+(a[2]-a[0])/2+(a[2]+1-a[1])/2;
    }
    else if (a[0]%2==0&&a[1]%2==0&&a[2]%2)
    {
        //2 4 5
        cout<<1+(a[2]-a[0]-1)/2+(a[2]-a[1]-1)/2;
    }
    else if (a[0]%2&&a[1]%2&&a[2]%2==0)
    {
        //1 3 4
        cout<<1+(a[2]-a[1]-1)/2+(a[2]-a[0]-1)/2;
    }
    else if (a[0]%2&&a[1]%2==0&&a[2]%2)
    {
        //1 4 5
        cout<<1+(a[2]+1-a[1])/2+(a[2]-a[0])/2;
    }
    else if (a[0]%2==0&&a[1]%2&&a[2]%2)
    {
        //2 3 5
        cout<<1+(a[2]+1-a[0])/2+(a[2]-a[1])/2;
    }
    else if (a[0]%2&&a[1]%2&&a[2]%2)
    {
        //1 3 5
        cout<<(a[2]-a[0])/2+(a[2]-a[1])/2;
    }
    cout<<endl;
}
int main()
{
    while(cin>>a[0]>>a[1]>>a[2])
        solve();
}

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

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		long N = Long.parseLong(W);

		String ans = ":(";

		for(int i=1;i<50000;i++){
			if(N==(long)(i*1.08)){
				ans = String.valueOf(i);
				break;
			}
		}



		System.out.println(ans);



	}


}


Measured memory_bytes: 21332
N = int(input())
ans = 0
import math
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
for i in make_divisors(N):
    tmp = (N - i) // i
    if tmp == 0:
        continue
    if N // tmp == N % tmp:
        ans += tmp
print(ans)

Measured memory_bytes: 3268
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int i;

    int a = 0;
   
    char s[7];
   
      
    scanf("%s", s );
   
    for( i = 0 ; i < 6 ; i = i + 1 ){
   
         if( s[i] == '1' ) a += 1;

         }
   

    printf("%d\n", a );


    return 0;
                                                          
}

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

int main() {

        int d;

        std::cin >> d;

        switch(d) {
                case 22:
                        std::cout << "Christmas Eve Eve Eve";
                        break;
                case 23:
                        std::cout << "Christmas Eve Eve";
                        break;
                case 24:
                        std::cout << "Christmas Eve";
                        break;
                case 25:
                        std::cout << "Christmas";
                        break;
        }

        std::cout << std::endl;

        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    string S;
    cin>>S;
    ll K;
    cin>>K;
    set<string> M;
    ll Sz=S.size();
    rep(i, Sz){
        ll W=Sz-i;
      	if(W>5)W=5;
        string T="";
        rep(j, W){
            T+=S.at(i+j);
            M.insert(T);
        }
    }
    auto itr=M.begin();
    for(int i = 0;i < K-1; ++i)++itr;
    cout<<*itr<<endl;


}



Measured memory_bytes: 1664
nums = [int(item) for item in input().split()]
nums.sort()

a, b, c = nums
count = 0

while True:
  if b - a >= 2:
    a += 2
    count += 1
  elif c - b >=1:
    a += 1
    b += 1
    count += 1
  else:
    break
    
if a != b:
  count += 2
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>

using namespace std;

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
        for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
        res[i][S[i]-'0'] = i;
    }
    return res;
}

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


    // 前処理配列
    vector<vector<int> > next = calcNext(s);

    // DP
    vector<vector<long long>> dp(4, vector<long long> (n+1, 0));
    dp[0][0] = 1; // 初期化、空文字列 "" に対応
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (next[i][j] >= n) continue; // 次の文字 j がもうない場合はスルー
            for (int k=0; k<3; k++)
                dp[k+1][next[i][j] + 1] += dp[k][i];
        }
    }

    // 集計
    long long res = 0;
    for (int i = 0; i <= n; ++i) res += dp[3][i];

    cout << res << endl;
    return 0;
}

//int main() {
//    int n;
//    string s;
//    map<string,bool> mp;
//    cin >> n >> s;
//
//    for (int i=0; i<(1<<n); i++) {
//        string t = "";
//        for (int j=n-1; j>=0; j--) {
//            if (t.size() >= 3) break;
//            if ((i>>j)&1) {
//                t += s[n-j-1];
//            }
//        }
//        if (t.size() == 3)
//            mp[t] = true;
//    }
//    for (auto p : mp) {
//        cout << p.first << " " << p.second << endl;
//    }
//    cout << mp.size() << endl;
//    return 0;
//}
/*
 * 123123
 * 112
 */


Measured memory_bytes: 3584
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c, d, tmp, m, h, w, x, y, sum, k, q;
U_MAP mpa, mpb;
ll suma[ohara], sumb[ohara];

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

  cin >> n >> m;
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  sort(a, a + n);
  sort(b, b + m);
  reverse(a, a + n);
  reverse(b, b + m);
  rep(i, n - 1) {
    mpa[a[i]]++;
    suma[a[i]]++;
    if (a[i] == a[i + 1]) {
      Cout(0);
      return 0;
    }
  }
  rep(i, m - 1) {
    mpb[b[i]]++;
    sumb[b[i]]++;
    if (b[i] == b[i + 1]) {
      Cout(0);
      return 0;
    }
  }
  mpa[a[n - 1]]++;
  suma[a[n - 1]]++;
  mpb[b[m - 1]]++;
  sumb[b[m - 1]]++;
  if (!(a[0] == b[0] && a[0] == n * m)) {
    Cout(0);
    return 0;
  }
  ans = 1;
  rrrep(i, ohara - 2, 0) {
    suma[i] += suma[i + 1];
    sumb[i] += sumb[i + 1];
  }
  rrrep(i, n * m, 1) {
    if (mpa[i] + mpb[i] == 2) continue;
    ll val;
    if (mpa[i] == 1)
      val = sumb[i];
    else if (mpb[i] == 1)
      val = suma[i];
    else {
      val = suma[i] * sumb[i];
      val -= n * m - i;
      if (val < 0) {
        Cout(0);
        return 0;
      }
    }
    val %= MOD;
    ans *= val;
    ans %= MOD;
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 97712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,ans = 0;
    cin >> n;
    int l[n];
    rep(i, n)cin >> l[i];
    qsort(l, n, sizeof(int), asc);
    rep(i, n - 2){
        nfor(j, i + 1, n - 1){
            nfor(k, j + 1, n){
                if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i]) {
                    ++ans;
                }
                if (l[i] + l[j] < l[k]) {
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main(void){
    int x,y,a,b,r;
    std::cin>>x>>y>>a>>b>>r;
    if(a-r>=0&&a+r<=x&&b-r>=0&&b+r<=y){
        std::cout<<"Yes"<<std::endl;
    }else{
        std::cout<<"No"<<std::endl;
    }
    return 0;
}



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

ll p = 1e9 + 7;

ll mod(ll n, ll x){
    if(x == 1) return n % p;
    if(x % 2 == 0){
        ll t = mod(n, x/2);
        return (t * t) % p;
    }else{
        return (mod(n, x-1) * n) % p;
    }
}
 
int main() {
    int n, k;
    cin >> n >> k;
    
    ll count[k];
    
    ll res = 0;
    for(ll i = k; i >= 1; --i){
        ll num = k / i;
        ll t = mod(num, n);
        for(ll j = 2; i * j <= k; ++j){
            t -= count[i * j - 1];
            t %= p;
        }
        count[i-1] = t;
        // cout << t << endl;
        ll x = (i * t) % p;
        // cout << x << endl;
        res = (res + x) % p;
    }
    
    if(res < 0) res += p;
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


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

	int s = x - k + 1;
	int e = x + k - 1;
	for (int i = s; i <= e; ++i) {
		cout << i << " ";
	}
	cout << endl;



		return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


ll N, K;
string s;

int main(void) {
  cin >> N >> K;
  cin >> s;
  ll f=0;
  if(s[0]=='0') {
    s='1'+s;
    N++;
    f=1;
  }
  ll i;
  vector<ll> v;
  
  for(i=0; i<N;) {
    if(s[i]=='0') {
      ll cnt=0;
      while(i<N && s[i]=='0') {
        cnt++;
        i++;
      }
      v.pb(cnt);
    }else if(s[i]=='1') {
      ll cnt=0;
      while(i<N && s[i]=='1') {
        cnt++;
        i++;
      }
      v.pb(cnt);
    }
  }
  
  if(v.size()<=K*2+1) {
    if(f) N--;
    pt(N);
    return 0;
  }
  
  ll ans=0;
  ll t=0;
  for(i=0; i<K*2+1; i++) t+=v[i];
  if(f) ans=t-1;
  else ans=t;
  
  for(i=K*2+1; i<v.size(); i+=2) {
    t-=v[i-K*2-1];
    t-=v[i-K*2];
    if(i+1<v.size()) t+=v[i+1];
    t+=v[i];
    
    chmax(ans, t);
  }
  
  pt(ans);
}


Measured memory_bytes: 1528
def get_input():
    while True:
        try:
            yield ''.join(raw_input())
        except EOFError:
            break

ar = [0] * 51

for i in range(10):
	for j in range(10):
		for k in range(10):
			for l in range(10):
				ar[i + j + k + l] += 1

for a in list(get_input()):

	print ar[int(a)]

Measured memory_bytes: 4212
#include <cstdio>
#include <cstring>
int n, m; char e[261], f, g;
int main() {
	while(scanf("%d\n", &n), n) {
		for(int i = 0; i < 256; i++) e[i] = i;
		for(int i = 0; i < n; i++) scanf("%c %c\n", &f, &g), e[f] = g;
		scanf("%d\n", &m);
		for(int i = 0; i < m; i++) scanf("%c\n", &f), printf("%c", e[f]);
		printf("\n");
	}
}

Measured memory_bytes: 2608
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,i;
  cin >> n;
  string s1,s2;
  int t=0,h=0;
  
  for(i=0;i<n;i++){
    cin >> s1 >> s2;
    if(s1.compare(s2)==0) {
      t++;h++;
    }else if(s1.compare(s2)>0) t+=3;
    else h+=3;
  }
  cout << t << " " << h << endl;
}



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

int dp[2][110];

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

    dp[0][0] = 0;
    dp[1][0] = 0;
    rep2(i,1,n+1){
        dp[0][i] = dp[0][i-1] + a[i-1];
    }
    rep2(i,1,n+1){
        dp[1][i] = max(dp[0][i], dp[1][i-1]) + b[i-1];
    }

    cout << dp[1][n] << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import deque
a=deque(list(input()))
b=deque(list(input()))
c=deque(list(input()))
tmp=a.popleft()
while 1:
    if tmp=='a':
        if not len(a):
            print('A')
            break
        tmp=a.popleft()
    elif tmp=='b':
        if not len(b):
            print('B')
            break
        tmp=b.popleft()
    else:
        if not len(c):
            print('C')
            break
        tmp=c.popleft()


Measured memory_bytes: 3316
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    S = input().strip()
    T = input().strip()

    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    cnt = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            cnt += 1

    print(cnt)


resolve()

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

typedef long long ll;

ll n, m, d;

int main(void) {
  cin >> n >> m >> d;
  double p = 0;
  double res = 0;
  if(d == 0) {
    // res = m * 1.0 / n;
    res += n*1.0;
    res = res * (m-1) / n / n;
  } else if(d > n/2) {
    // p += (n-d)*2.0/n * 1;
    // p += (n-(n-d)*2.0)/n * 0;
    // res = pow(p, m-1);
    res += (n-d)*2*1.0;
    res += (n-(n-d)*2)*0;
    res = res * (m-1) / n / n;
  } else {
    // p += d*2.0/n * 1;
    // p += (n-d*2.0)/n * 2;
    // res = pow(p, m-1);
    res += d*2*1.0;
    res += (n-d*2)*2;
    res = res * (m-1) / n / n;
  }
  printf("%.10f\n", res);
  
  return 0;
}


Measured memory_bytes: 256