akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


vector<ll>pa(51,0), ba(51,0);
ll n, x;


ll func(ll n, ll x) {

	if (n == 0) {
		return 1;
	}
	else if (x == 1) {
		return 0;
	}
	else if (x>1 && x <= ba[n-1] + 1) {
		return func(n - 1, x  - 1);
	}
	else if (x == ba[n-1]+2) {
		return pa[n - 1] + 1;
	}
	else if (x > ba[n - 1] + 2 && x < ba[n] ) {
		return pa[n-1] + 1 + func(n - 1, x - ba[n - 1] - 2);
	}
	else if (x == ba[n]) {
		return pa[n];
	}

	return 0;
}


signed main() {
	int i, j;

	cin >> n >> x;

	pa[0] = 1;
	ba[0] = 1;

	for (i = 1; i <= n; i++) {
		pa[i] = pa[i - 1] * 2 + 1;
	}

	for (i = 1; i <= n; i++) {
		ba[i] = ba[i - 1] * 2 + 3;
	}

	cout << func(n, x) << endl;




	getchar();
	getchar();
	return 0;
}

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

void print(int i, int d, vector<pair<string, vector<int>>> const& v) {
    for(int j=0; j<d; ++j) {
        cout << '.';
    }
    cout << v[i].first << endl;

    for(int j=0; j<v[i].second.size(); ++j) {
        print(v[i].second[j], d+1, v);
    }
}

int main() {
    int n;
    cin >> n;
    vector<pair<string, vector<int>>> v(n);
    for(int i=0; i<n; ++i) {
        int k;
        cin >> k;
        cin >> v[i].first;
        if(k != 0) {
            v[k-1].second.push_back(i);
        }
    }
    print(0, 0, v);
}


Measured memory_bytes: 3428
yearformat s
  | month s && month s100 = "AMBIGUOUS"
  | month s = "YYMM"
  | month s100 = "MMYY"
  | otherwise = "NA"
  where
    s100 = s `div` 100
    month i = 1 <= i `mod` 100 && i `mod` 100 <= 12

main = do
  s <- readLn
  putStrLn $ yearformat s

Measured memory_bytes: 508
#include<stdio.h>

int main(void){
    int a,b,c,d,e=0;
    scanf("%d",&a);
    b=a%10;
    c=(a%100)/10;
    d=a/100;
    if(b==7){
        e=1;
    }
     if(c==7){
        e=1;
    }
     if(d==7){
        e=1;
    }
    if(e==1){
        printf("Yes");
    }
    else{
        printf("No");
    }
}

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


 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  
  int a,b;
  cin >> a >> b;
  
  int add,sub,mul;
  add=a+b;
  sub=a-b;
  mul=a*b;
  int c;
  if(add>sub){
  	c=add;
  }else{
  	c=sub;
  }
  
  if(c<mul){
    c=mul;
  }
  cout << c << endl;

}

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

fn main() {
    let n: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let a: Vec<i64> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };

    let mut dp = vec![vec![-(1 << 60); 2]; 3];
    dp[0][0] = 0;
    for i in 0..n {
        for j in (0..3).rev() {
            dp[j].swap(0, 1);
            if j > 0 {
                dp[j][0] = max(dp[j][0], dp[j - 1][0]);
            }
            dp[j][1] += a[i];
        }
    }
    println!("{}", max(dp[n % 2][0], dp[n % 2 + 1][1]));
}

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

using namespace std;

main(){
    string s[4];

    for(int i = 0 ; i < 3 ; i ++){
        cin >> s[i];
        reverse(s[i].begin() , s[i].end());
    }

    int i = 0;
    while( true ){
        if(s[i].length() == 0){
            printf("%c" , char(i + 'A'));
            return 0;
        }

        int j = int(s[i].back() - 'a');
        s[i].pop_back();
        i = j;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll A[n + 1];
    A[0] = 0;
    ll ans = 0;
    REP(i, n){
        cin >> A[i];
        if(A[i] < A[i - 1]){
            ans += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5196
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
f = [int("".join(ls()), 2) for _ in range(n)]      
p = [list(li()) for _ in range(n)]

def dfs(cur:int, depth:int):
    if depth == 10:
        if cur == 0:
            return -float("inf")
        else:
            return sum([p[i][bin(cur&fi).count("1")] for i, fi in enumerate(f)])
    
    else:
        return max(dfs(cur+(1<<depth), depth+1),
                   dfs(cur, depth+1))
        
print(dfs(0,0))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdint>

int64_t calc(int64_t x) {
    return x * x;
}

int main() {
    int N, K;
    std::cin >> N >> K;
    
    int ans = 1;
    while(N > 0) {
        if ((ans*2 > ans+K))
            ans += K;
        else
            ans *= 2;
        N--;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
	int n;
	int a,b;
	int B;
	scanf("%d%d%d",&n,&a,&b);
	B=n*a;
	if(B>=b)
		printf("%d",b);
	if(B<b)
		printf("%d",B);
	return 0;
}

	

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

using namespace std;

int main()
{

    int row,c;
    scanf("%d%d",&row,&c);

    vector <char> v[row];

    int i,j;
    char ch1,ch2;

     for(i=0;i<row;i++)
     {

         v[i].push_back('*');

         for(j=0;j<c;j++)
         {
             cin>>ch1;

             v[i].push_back(ch1);

         }

        v[i].push_back('*');
     }


     for(i=0;i<row;i++)
     {
         for(j=0;j<c;j++)
      {
          ch2= v[i][j];

          if(i==0 && ch2=='#')
         {

          if(v[i+1][j]=='#' ||v[i][j+1]=='#' ||v[i][j-1]=='#')
          {

          }

          else
          {
              printf("No\n");
              return 0;

          }

         }

         else if(i==(row-1) && ch2=='#')
         {
             if(v[i-1][j]=='#' ||v[i][j+1]=='#' ||v[i][j-1]=='#')
          {

          }

          else
          {
              printf("No\n");
              return 0;

          }

         }

         else if(ch2=='#')
         {
             if(v[i-1][j]=='#' ||v[i+1][j]=='#' ||v[i][j+1]=='#' ||v[i][j-1]=='#')
          {

          }

          else
          {
              printf("No\n");
              return 0;

          }


         }

      }

     }

    printf("Yes\n");

    return 0;
}



Measured memory_bytes: 256
#include <set>
#include <map>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <climits>

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

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

struct Edge{
  int cap; // capacity
  int to;
  int rev; // reverse edge id

  Edge(){}
  Edge(int c, int t, int r) :
    cap(c), to(t), rev(r){}
};

template<class E> // Edge type
class Graph{
public:
  typedef std::vector<std::vector<E> > G;

private:
  G g;

public:
  Graph(int n) : g(G(n)) {}

  void addEdge(int from, int to, int cap){
    g[from].push_back(E(cap, to, g[to].size()));
    g[to].push_back(E(0, from, g[from].size() - 1));
  }

  void addEdge(int from, int to, int cap, int cost){
    g[from].push_back(E(cap, to, cost, g[to].size()));
    g[to].push_back(E(0, from, -cost, g[from].size() - 1));
  }

  G &getRowGraph(){
    return g;
  }
};

template<class E>
class Dinic{
  typedef typename Graph<E>::G G;
  G &g;
  std::size_t n; // size of graph

  std::vector<int> level;
  std::vector<int> iter;

  // other utilities

  // search length of shortest path from s
  void bfs(int s){
    std::queue<int> que;
    level = std::vector<int>(n, -1);

    level[s] = 0;
    que.push(s);

    while(!que.empty()){
      int v = que.front(); que.pop();
      for(int i = 0; i < (int)g[v].size(); i++){
        E &e = g[v][i];
        if(e.cap > 0 && level[e.to] < 0){
          level[e.to] = level[v] + 1;
          que.push(e.to);
        }
      }
    }
  }

  // search path
  int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i = iter[v]; i < (int)g[v].size(); i++){
      E &e = g[v][i];
      if(e.cap > 0 && level[v] < level[e.to]){
        int d = dfs(e.to, t, min(f, e.cap));
        if(d > 0){
          e.cap -= d;
          g[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

public:
  Dinic(Graph<E> &graph) : g(graph.getRowGraph()){
    n = g.size();
  }

  // Max flow of the flow from s to t.
  int solve(int s, int t){
    int flow = 0;
    while(true){
      int f;
      bfs(s);
      if(level[t] < 0) return flow;
      iter  = std::vector<int>(n, 0);
      while((f = dfs(s, t, INT_MAX)) > 0){
        flow += f;
      }
    }
  }
};

template<class E>
int dinic(Graph<E> &g, int s, int d){
  return Dinic<E>(g).solve(s, d);
}

template<class T>
class IdMaker{
public:
  std::map<T,int> _m;
  int getId(const T &v){
    if(_m.find(v) == _m.end()){
      int next = _m.size();
      return _m[v] = next;
    }
    return _m[v];
  }
};

int main(){
  while(int n = getInt()){
    map<int, int> my;

    const int m = getInt();
    const int s = m + n;
    const int e = m + n + 1;
    Graph<Edge> f(2 + m + n);

    REP(i,m){
      my[getInt()] = i;
      f.addEdge(s, i, 1);
    }

    REP(i,n){
      int mm = getInt();
      f.addEdge(m + i, e, 1);
      REP(j,mm){
        int p = getInt();
        if(my.count(p))
          f.addEdge(my[p], m + i, 1);
      }
    }

    printf("%d\n", dinic(f, s, e));
  }
  return 0;
}

Measured memory_bytes: 1144
import sys
from operator import itemgetter as ITEM
input = sys.stdin.readline
N = int(input())
mG = [tuple(map(int, input().split())) for _ in range(N)]

mG.sort(key=ITEM(1), reverse=True)
mG.sort(key=ITEM(0))

INF = 1000100100

vA1 = []
L = -1
R = INF
for l,r in mG[:-1]:
    L = max(L, l)
    R = min(R, r)
    vA1.append(R-L+1)

vA2 = []
L = -1
R = INF
for l,r in mG[:0:-1]:
    L = max(L, l)
    R = min(R, r)
    vA2.append(R-L+1)

M1 = max(a+b for a,b in zip(vA1, vA2[::-1]))

# pick max1
# and all others to 2
k = 0
idm = -1
for i,(l,r) in enumerate(mG):
    d = r-l+1
    if d > k:
        k = d
        idm = i

L = -1
R = INF
for i,(l,r) in enumerate(mG):
    if i==idm:
        continue
    L = max(L, l)
    R = min(R, r)

M2 = k + max(0, R-L+1)

print(max(M1,M2))


Measured memory_bytes: 27788
def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,l):
    lmax=max(l)
    if lmax*2<sum(l):
        return 'Yes'
    else:
        return 'No'

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)


Measured memory_bytes: 9164
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
    //cin.tie(nullptr);
    //ios::sync_with_stdio(false);
    int n; cin >> n;
    if(n==0)printf("1\n");
    else if(n==1)printf("2\n");
    else if(n==2)printf("1\n");
    else printf("0\n");
}



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

int main(){
    int N;
    int i;
    cin >> N;
    int A[N];
    for(i=0;i<N;i++)cin >> A[i];
    int flag = 0;
    for(i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0)flag++;
        }
    }
    if(flag>0)cout << "DENIED" << endl;
    else{cout << "APPROVED" << endl;}
}


Measured memory_bytes: 256
S = gets.chomp.split("").sort.uniq
S_size = S.size
if S_size == 26 then
  print("None")
else
  S_size.times do |n|
    if S[n] != (n+97).chr then
      print("#{(n+97).chr}")
      exit
    end
  end
  print("#{(97+S_size).chr}")
end

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

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

  for(int X = 1; X <= N; ++X) {
    if((int) (1.08 * X) == N) {
      std::cout << X << '\n';
      return 0;
    }
  }

  std::cout << ":(" << '\n';
}


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

int main() {
  int a[5],b[5];
  for(int i; i<5; ++i) cin >> a[i];

  for(int i; i<5; ++i){
    b[i] = a[i]%10;
  }


  int c[5];
  for(int i; i<5; ++i){
    if(b[i]!=0) c[i] = a[i]-b[i] + 10;
    else c[i] = a[i];
  }


  if(b[0]==0&&b[1]==0&&b[2]==0&&b[3]==0&&b[4]==0){
     for(int i; i<5;++i) b[i] = 10;
  }

  for(int i; i<5; ++i){
    if(b[i]==0) b[i] = 9;
  }



  b[0] = min({b[0],b[1],b[2],b[3],b[4]});

  int ans = c[0]+c[1]+c[2]+c[3]+c[4]-10+b[0];
  cout << ans << endl;
  //cout << b[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n],sq=0;
    for (int i=1;i<=n;i++)
    {
        cin >>a[i];
        if (a[i]%2==1&&i%2==1)
            sq++;
    }
    cout << sq;
    return 0;
}


Measured memory_bytes: 3148
#include<stdio.h>
#include<stdlib.h>
 
#define MAX 1000000
 
typedef struct{
  int parent;
  int left;
  int right;
}Node;
 
void RootedTree(int);
Node T[MAX];
 
int main(){
  int n,i,j;
  int k,id,child,x,depth;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    T[i].parent=-1;
    T[i].left=-1;
    T[i].right=-1;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d",&id, &k);
    for(j=0;j<k;j++){
      scanf("%d",&child);
      T[child].parent=id;
      if(j==0) T[id].left=child;
      else if(j>0) T[x].right=child;
      x=child;
    }
  }
 
  for(i=0;i<n;i++) RootedTree(i);
  return 0;
}
 
void RootedTree(int n){
  int i=T[n].parent;
  int depth=0;
 
  while(i!=-1){
    i = T[i].parent;
    depth++;
  }
 
  if(depth == 0) printf("node %d: parent = %d, depth = %d, root, ",n ,T[n].parent, depth);
  else if(T[n].left == -1) printf("node %d: parent = %d, depth = %d, leaf, ",n ,T[n].parent, depth);
  else printf("node %d: parent = %d, depth = %d, internal node, ",n ,T[n].parent, depth);
 
  i=T[n].left;
  printf("[");
  if(i!=-1) printf("%d",i);
 
  while(i!=-1){
    i=T[i].right;
    if(i!=-1) printf(", %d",i);
  }
  printf("]\n");
}


Measured memory_bytes: 2912
import math

def main():
    N, K = [int(n) for n in input().split()]
    needed = (math.log2(K))

    nex = 2
    res = 0
    for i in range(1, N+1):
        if i >= K:
            res += 1
            continue
        res += math.pow(0.5, math.ceil(needed-math.log2(i)))
        # print(math.pow(0.5, math.ceil(needed-math.log2(i))))
    res /= N * 1.
    print(res)
main()

Measured memory_bytes: 3060
n, t = map(int,input().split())

lis = []
for _ in range(n):
    lis.append(list(map(int, input().split())))

ans = 1001001001
for i in lis:
    if i[1] <= t:
        ans = min(ans, i[0])
        

if ans == 1001001001:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
constexpr double pi = M_PI;

#define int long long

signed main()
{
    //TODO
    //1d input template
    int n;
    cin >> n;
    int a[n];
    int x[n][n];
    bool y[n][n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        for (int j = 0; j < a[i]; j++) {
            cin >> x[i][j] >> y[i][j];
            x[i][j] -= 1;
        }
    }

    int M = pow(2, n);
    int ans = 0;
    int ans_pattern = -1;
    for (int i = 0; i < M; i++) {
        bool h[n];
        int p = 1;
        int h_num = 0;
        for (int j = 0; j < n; j++) {
            h[j] = static_cast<bool>(i & p);
            h_num += h[j];
            p *= 2;
        }
        bool ok = true;
        for (int j = 0; j < n; j++) {
            if (h[j]) {
                for (int k = 0; k < a[j]; k++) {
                    ok &= !(h[x[j][k]] ^ y[j][k]);
                }
            }
        }
        if (ok) {
            if (h_num > ans) {
                ans = h_num;
                ans_pattern = i;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(c<=a-b)
	{
		cout<<"0";
	}
	else
	{
		int d=c-a+b;
		cout<<d;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

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

if n != 0:
    p = list(map(int, input().split()))

    ll = [x]
    lu = [x]
    i = 1
    for _ in range(2*n):
        if ll[-1] not in p:
            print(ll[-1])
            break
        elif lu[-1] not in p:
            print(lu[-1])
            break
        ll.append(ll[-1]-i)
        lu.append(lu[-1]+i)
else:
    print(x)

Measured memory_bytes: 9212
#include <stdio.h>

int main(void){
  int n;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int a;
    int age[7];
    for(int i=0;i<7;i++){
      age[i]=0;
    }
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      if(a>=60){
        age[6]+=1;
      }
      else{
        age[a/10]+=1;
      }
    }
    for(int i=0;i<7;i++){
      printf("%d\n",age[i]);
    }
  }
  return 0;
}



Measured memory_bytes: 2048
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        n: u64,
        m: u64,
        q:[(u64, String);m]
    }
    let mut ch = vec![(false, 0); n as usize];
    let mut c: u64 = 0;
    let mut sum:u64 = 0;
    for i in q {
        if !ch[(i.0 - 1)as usize].0 {
            if i.1 == "AC".to_string(){
                c += 1;
                ch[(i.0 - 1)as usize].0 = true;
                sum += ch[(i.0 - 1)as usize].1;
            }
            else {
                ch[(i.0 - 1)as usize].1 += 1;
            }
        }
    }
    println!("{} {}", c, sum)
}


Measured memory_bytes: 10492
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


mod=10**9+7
n, k=map(int, input().split())
for i in range(1, k+1):
    if i<=n-k+1:
        print(((cmb(k-1, i-1)%mod)*(cmb(n-k+1, i)%mod))%mod)
    else:
        print(0)


Measured memory_bytes: 50652
def examC():
    N, M = LI()
    A = [I() for _ in range(M)]
    A.append(N+1)
    fib = [1]*(N+2)
    for i in range(1,N):
        fib[i+2] = fib[i+1] + fib[i]
    fib[0] = 0
#    print(fib)
    ans = fib[A[0]]%mod
    for i in range(M):
        ans *= fib[A[i+1]-A[i]-1]
        ans %=mod
    print(ans)
    return

def examD():
    H, W = LI()
    S = [SI() for _ in range(H)]
    width = [[0]*W for _ in range(H)]
    height = [[0]*W for _ in range(H)]
    for i in range(H):
        cur = 0; keep = []
        for j in range(W):
            if S[i][j]==".":
                cur +=1
                keep.append(j)
            else:
                for k in keep:
                    width[i][k] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                width[i][k] = cur
    for j in range(W):
        cur = 0; keep = []
        for i in range(H):
            if S[i][j]==".":
                cur +=1
                keep.append(i)
            else:
                for k in keep:
                    height[k][j] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                height[k][j] = cur
    ans = 0
    for i in range(H):
        for j in range(W):
            cur = width[i][j] + height[i][j]
            if ans<cur:
                ans = cur
    print(ans-1)
    return

def examE():
    L = SI()
    N = len(L)
    Loc0 = [-1]*N; cur = 0
    for i in range(N):
        if L[i]=="0":
            Loc0[i] = cur
            cur +=1
    ans = pow(3,N,mod)
#    print(Loc0)
    for i in range(N):
        if Loc0[i]>=0:
            now = pow(2,(i-Loc0[i]+1),mod)*pow(3,(N-i-1),mod)
            ans -=now%mod
            if ans<0:
                ans +=mod
    print(ans)
#    examE2(L)
    return

def examE2(L):
#    L = SI()
    N = int(L,2)
    ans = 0
    for a in range(N+1):
        for b in range(N+1):
            cur = a^b
            if cur!=a+b:
                continue
            if cur>N:
                continue
            ans +=1
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examE()


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;
using pll = pair<ll, ll>;


int main() {
#ifdef LOCAL
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(12);
    string s;
    cin >> s;
    int n = s.length();
    int ans = n;
    for (int i = 0; i < n; i++) {
        int cnt = 0;
        string cur = s;
        for (;;) {
            bool ok = true;
            for (int j = 0; j < (int)cur.length(); j++)
                if (cur[j] != s[i])
                    ok = false;
            if (ok)
                break;
            cnt++;
            string t;
            for (int j = 0; j + 1 < cur.length(); j++)
                if (cur[j + 1] == s[i])
                    t += cur[j + 1];
                else
                    t += cur[j];
            cur = t;
        }
        ans = min(ans, cnt);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

ll INF = (ll)1e18+1;

int main(){
  int n; ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n)cin >> a[i];
  sort(a.begin(),a.end(),[](int a,int b){return a<b;});
  //rep(i,n)cout << a[i] << endl;
  ll ok = -INF, ng = INF;
  while(ok+1<ng){
    ll x = (ok+ng)/2;
    ll tot = 0;
    rep(i,n){
      int l=-1,r=n;
      if(a[i]>0){
        while(l+1<r){
          int m = (l+r)/2;
          if(a[i]*a[m]<x)l=m; else r=m;
        }
        tot += r;
      }else{
        while(l+1<r){
          int m = (l+r)/2;
          if(a[i]*a[m]<x)r=m; else l=m;
        }
        tot += n-r;
      }
      if(a[i]*a[i]<x)tot--;
    }
    tot /= 2;
    if(tot<k)ok=x; else ng = x;
  }
  cout << ok << endl;
}

Measured memory_bytes: 1792
while True:
    a, op, b = input().split()
    a, b = int(a), int(b)

    if op == '?':
        break

    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    else:
        print(a // b)



Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int main(){
	double a,b,c,d,e,f;
	while(~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)){
		double x = (c*e - b*f) / (a*e - b*d) ;
		double y = (a*f - d*c) / (a*e - d*b) ; 
		printf("%.3lf %.3lf\n",x+EPS,y+EPS);
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

value = 0
tmp = A[0]
for i in A[1:]:
    if (tmp+1 == i):
        value += C[tmp-1]
    tmp = i
    

value += sum(B)
print(value)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"sort"
)

type item struct {
	weight int
	value int
}

func main() {
	var N, W int
	_, _ = fmt.Scan(&N, &W)
	items := make([]item, N)
	for i := 0; i < N; i++{
		_, _ = fmt.Scan(&items[i].weight, &items[i].value)
	}
	C := make([][]int, 4)
	base := items[0].weight
	for i := 0; i < N; i++ {
		C[items[i].weight-base] = append(C[items[i].weight-base], items[i].value)
	}
	for i := 0; i < 4; i++ {
		if C[i] == nil {
			C[i] = append(C[i], 0)
		} else {
			C[i] = append(C[i], C[i][0])
			C[i][0] = 0
			sort.Sort(sort.Reverse(sort.IntSlice(C[i][1:])))
			for j := 1; j < len(C[i]); j++ {
				C[i][j] += C[i][j-1]
			}
		}
	}
	ans := 0
	for i := 0; i < len(C[0]); i++ {
		for j := 0; j < len(C[1]); j++ {
			for k := 0; k < len(C[2]); k++ {
				cost := int64(i)*int64(base+0)+int64(j)*int64(base+1)+int64(k)*int64(base+2)
				if cost <= int64(W) {
					ans = max(ans, C[0][i]+C[1][j]+C[2][k]+C[3][min((W-int(cost))/(base+3), len(C[3])-1)])
				}
			}
		}
	}
	fmt.Printf("%d\n", ans)
}

func min(nums ...int) int {
	res := nums[0]
	for i := 1; i < len(nums); i++ {
		if nums[i] < res {
			res = nums[i]
		}
	}
	return res
}

func max(nums ...int) int {
	res := nums[0]
	for i := 1; i < len(nums); i++ {
		if nums[i] > res {
			res = nums[i]
		}
	}
	return res
}

Measured memory_bytes: 512
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int PMAX=55555,NMAX=55,LIM=1e6;
int n,seq[NMAX],premiers[PMAX],nbPremier=0;
bool premier[PMAX+1];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
		
	cin >> n;
	premier[0]=false;
	premier[1]=false;
	for(int i=2;i<=PMAX;i++) premier[i]=true;
	
	for(int i=2;i<=PMAX;i++){
		if(premier[i]){
			premiers[nbPremier]=i;
			nbPremier++;
			for(int j=2*i;j<=PMAX;j+=i){
				premier[j]=false;
			}
		}
	}
	
	int actuel=0;
	for(int m=2;m<=PMAX;m++){
		if(premier[m] && m%5==1 && actuel<n){
			seq[actuel]=m;
			actuel++;
		}
	}
	for(int i=0;i<n;i++){
		cout << seq[i] << ' ';
	}
	cout << '\n';
							
		
	
	
	
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<random>
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    int n;
    cin >> n;
    vector<string> s;
    vector<string> us;
    for(int i=0;i<n;i++){
        string _s;
        cin >> _s;
        sort(_s.begin(),_s.end());
        s.push_back(_s);
    }
    sort(s.begin(),s.end());
    ll ans=0;
    ll cnt = 0;
    for(int i=1;i<n;i++){
        if(s[i-1]==s[i]){
            cnt++;
        }else{
            ans += cnt*(cnt+1)/2;
            cnt = 0;
        }
    }
    ans += cnt*(cnt+1)/2;
    cout << ans << endl;
    return 0;
}

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

int main(){
  int a,b,d,r;
  double f;
  
  cin >> a >>b;

  d = a/b;
  r = a%b;
  f =(double)a/(double)b;
  
  cout << d << " " << r << " ";
  printf("%.5lf\n",f);

  return 0;
}

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

class MainClass
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int X = int.Parse(Console.ReadLine());
        int Y = int.Parse(Console.ReadLine());
        if (K <= N)
        {
            Console.WriteLine(K*X + (N-K)*Y);
        }
        else
        {
            Console.WriteLine(N*X);
        }
    }
}

Measured memory_bytes: 27504
/// Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define PI acos(-1)
#define IOS ios::sync_with_stdio(false);
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
int main()
{
    IOS
    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++){
               sum+= __gcd(i,__gcd(j,l));
            }
        }
    }
    cout << sum << endl;
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
	FIO
	
	string s;
	cin>>s;
	int fl=1;
	for(int i=0;i<s.size();i+=2)
	{
		if(s[i]=='h'&&s[i+1]=='i')
		{
			fl*=1;
		}
		else fl*=0;
	}
	if(fl)cout<<"Yes";else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long int n, a, b;
	scanf("%lld %lld %lld", &n, &a, &b);
	long long int ans = n / (a + b) * a;
	n %= a + b;
	if (n < a)
		ans += n;
	else
		ans += a;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
import sys
X,K,D= map(int,input().split())
temp = X

if abs(X) > K*D:
    print(abs(X)-K*D)
    sys.exit()
    
for t in range(K):
    # 絶対値の小さい方に移動
    if abs(temp - D) < abs(temp + D):
        temp = temp-D
    else:
        temp = temp+D

    # 移動幅より小さくなったとき
    if abs(temp) < D:
        if (K-t-1) % 2 == 0:
            print(abs(temp))
            sys.exit()
        else:
            if abs(temp - D) < abs(temp + D):
                temp = temp-D
                print(abs(temp))
                sys.exit()
            else:
                temp = temp+D
                print(abs(temp))
                sys.exit()

print(abs(temp))



Measured memory_bytes: 63256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int N;
  cin >> N;
  vector<int> a(N + 1);
  
  for (int i = 1; i <= N; i++) {
    cin >> a.at(i);
  }
  
  int number = 1;
  int result = -1;
  int count = 0;
  
  for (int i = 1; i < N; i++) {
    number = a.at(number);
    count++;
    if (number == 2) {
      result = count;
      break;
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 640
a,b=map(int,input().split())
ans1=['.']*2500
ans2=['#']*2500
for i in range(b-1):
  ans1[2*i]='#'
for i in range(a-1):
  ans2[2*i]='.'
print(100,100)
for i in range(25):
  print(''.join(ans1[100*i:100*i+100]))
  print('.'*100)
for i in range(25):
  print('#'*100)
  print(''.join(ans2[100*i:100*i+100]))


Measured memory_bytes: 62140
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
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
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

char board[405][405];
bool visit[405][405];
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0};

void dfs(int y, int x, int h, int w, int &black, int &white) {
	if (visit[y][x])return;
	visit[y][x] = true;
	if (board[y][x] == '#')black++;
	else white++;
	REP(k, 4) {
		int ny = y + dy[k];
		int nx = x + dx[k];
		if (ny < 0 || nx < 0 || ny >= h || nx >= w)continue;
		if(board[y][x] != board[ny][nx])dfs(ny, nx, h, w, black, white);
	}
}

int main(){
	int h, w;
	LL ret = 0;
	scanf("%d%d", &h, &w);
	REP(i, h) scanf("%s", board[i]);
	REP(i, h) {
		REP(j, w) {
			if (visit[i][j] == false) {
				int black = 0;
				int white = 0;
				dfs(i, j, h, w, black, white);
				ret += (LL)black*(LL)white;
			}

		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,p=0,q=0,ans=0;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++){
        cin >> a.at(i);
        q=q+a.at(i);
    }
    for (int i=0;i<n;i++) {
        int x=p,y=q;
        p=a.at(i)+p;
        q=q-a.at(i);
        if (q-p<0) {
            ans=min(p-q,y-x);
            break;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int num2cost[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 }; // 0 is dummy.

// mapping: number => cost
// 1->2
// 2->5
// 3->5
// 4->4
// 5->5
// 6->6
// 7->3
// 8->7
// 9->6

int main(int argc, char** argv) {
  ll N, M;
  cin >> N >> M;
  vector<int> A(M);
  rep(i, M) {
    cin >> A[i];
  }
  sort(all(A));
  reverse(all(A));

  // Now, A is decreasing order.
  vector<ll> dp(N+1, -1);
  dp[0] = 0;
  rep(k, M) {
    ll num = A[k];
    ll cost = num2cost[num];
    rep(i, N+1) {
      if ((i-cost >= 0) && (dp[i-cost] >= 0)) {
        if (dp[i-cost]+1 > dp[i]) {
          dp[i] = dp[i-cost]+1;
        }
      }
    }
  }

  // Now, dp[N] is the max number of digits.

  string ans = "";
  ll match = N;
  while (match > 0) {
    rep(i, M) {
      ll num = A[i];
      ll cost = num2cost[num];
      if ((match-cost >= 0) && (dp[match] == dp[match-cost]+1)) {
        ans += (char)('0'+A[i]);
        match -= cost;
        break;
      }
    }
  }

  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

int main(){
    int N;
    string S,ANS;
    cin>>N>>S;
    for(int i=0;i<S.length();i++){
        if(int(S[i]+N)>90)ANS.push_back(S[i]+N-26);
        else ANS.push_back(S[i]+N);
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122,A=65

Measured memory_bytes: 256
# from bisect import bisect_left
import sys
input = sys.stdin.readline
H,W,m = map(int,input().split())
h = [0]*(H+1)
w = [0]*(W+1)
c = [{-1,10**6} for i in range(H+1)]
for i in range(m):
    a,b = map(int,input().split())
    h[a] += 1
    w[b] += 1
    c[a].add(b)
mh = max(h)
mw = max(w)
# hkouho = []
# wkouho = []
hkouho= [i for i in range(H+1) if h[i] == mh]
wkouho= [i for i in range(W+1) if w[i] == mw]
# for i in range(H+1):
#     if h[i] == mh:
#         hkouho.append(i)
# for i in range(W+1):
#     if w[i] == mw:
#         wkouho.append(i)
for i in hkouho:
    # c[i] = set(c[i])
    for j in wkouho:
        # if c[i][bisect_left(c[i],j)] != j:
        if j not in c[i]:
            print(mh+mw)
            exit()
print(mh+mw-1)

Measured memory_bytes: 220048
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i = a; i <= b; i++) {
        string tmp = to_string(i);
        if (tmp[0] == tmp[4] && tmp[1] == tmp[3]) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
n = int(input())
l = list(map(int, input().split()))
s = 0

for i in range(n-1):
  s += abs(l[i+1]-l[i])
  
s += abs(l[0]) + abs(l[-1])

print(s-abs(l[0]-0)-abs(l[1]-l[0])+abs(l[1]-0))
for j in range(1, n-1):
  print(s-abs(l[j-1]-l[j])-abs(l[j]-l[j+1])+abs(l[j-1]-l[j+1]))
print(s-abs(l[-1]-0)-abs(l[-1]-l[-2])+abs(l[-2]-0))



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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using TP = tuple<ll,ll,ll>;
#define all(c) (c).begin(),(c).end()
const int INF = 1e9;
const ll LINF = 1e15;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void dump() {}
template <class H, class... T>void dump(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); dump(forward<T>(tail)...);}

vector<vector<int>> G;
vector<vector<ll>> dist;
vector<ll> remain;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,m,l;
  cin >> n >> m >> l;
  G.assign(n,vector<int>());
  dist.assign(n,vector<ll>(n,LINF));
  remain.assign(n,l);
  for(int i = 0; i < m; ++i){
    int a,b,c;
    cin >> a >> b >> c; --a; --b;
    if(c <= l){
      G[a].push_back(b);
      G[b].push_back(a);
      dist[a][b] = c;
      dist[b][a] = c;
    }
  }

  vector<vector<int>> ans(n,vector<int>(n,INF));
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      for(int k = 0; k < n; ++k){
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      if(dist[i][j] <= l) ans[i][j] = 1;
    }
  }
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < n; ++j){
      for(int k = 0; k < n; ++k){
        ans[j][k] = min(ans[j][k], ans[j][i] + ans[i][k]);
      }
    }
  }
  int Q;
  cin >> Q;
  for(int i = 0; i < Q; ++i){
    int s,t;
    cin >> s >> t; --s; --t;
    cout << (ans[s][t] == INF ? -1 : ans[s][t]-1) << endl;
  }

  return 0;
}


Measured memory_bytes: 2176
N, M = map(int, input().split())
roads_count = [0 for i in range(N)]
city = [[int(i) for i in input().split()] for j in range(M)]

for road in city:
    roads_count[road[0]-1] += 1
    roads_count[road[1]-1] += 1

for i in range(N):
    print(roads_count[i])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, X, ANSWER;
	cin >> N >> X;
	vector <int> m(N);
	for (int i=0; i<N; i++){
		cin >> m.at(i); //数字の読み込み
	}
	sort(m.begin(), m.end());
	for (int i=0; i<N; i++){
		X = X - m.at(i);
	}
	ANSWER = N + X / m.at(0);

    cout << ANSWER << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

int N, M, K;

int fb[110000][2];  // 0:friend, 1:block

int id;
// 深さ優先探索
vector<int> cc_id;   // どの連結成分か
vector<int> cc_num;  // 連結成分のサイズ
void dfs(const Graph &G, int v, int &cnt) {
    cc_id[v] = id;
    cnt++;
    for (auto e : G[v]) {
        if (cc_id[e.to] == -1) {
            dfs(G, e.to, cnt);
        }
    }
}

int main() {
    cin >> N >> M >> K;
    Graph G(N);  // グラフとして考える
    vector<int> A(M), B(M);
    REP(i, M) {
        cin >> A.at(i) >> B.at(i);
        A[i]--, B[i]--;
        G[A[i]].push_back({B[i]});
        G[B[i]].push_back({A[i]});
    }
    vector<int> C(K), D(K);
    REP(i, K) {
        cin >> C.at(i) >> D.at(i);
        C[i]--, D[i]--;
    }

    // どの連結成分に属し、サイズがいくつなのかを求める
    cc_id.assign(N, -1);  // 初期化
    id = 0;
    REP(i, N) {
        if (cc_id[i] == -1) {
            int cnt = 0;
            dfs(G, i, cnt);
            cc_num.push_back(cnt);
            id++;
        }
    }

    vector<int> ans(N);
    REP(i, N) { ans[i] = cc_num[cc_id[i]] - 1 - (int)G[i].size(); }
    REP(i, K) {  // 同じ連結成分にあるブロック関係を引く
        if (cc_id[C[i]] == cc_id[D[i]]) {
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }

    REP(i, (int)ans.size()) {
        cout << ans[i];
        if (i != (int)ans.size() - 1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 9600