akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int m = ni();
    long[][] x = new long[n][8];
    for (int i = 0; i < n; i ++) {
      long a = nl();
      long b = nl();
      long c = nl();
      x[i] = new long[]{a+b+c, -a+b+c, a-b+c, a+b-c, -a-b+c,-a+b-c,a-b-c,-a-b-c};
    }

    long ret = Long.MIN_VALUE;
    for (int i = 0; i < 8; i ++) {
      final int j = i;
      Arrays.sort(x, (o1, o2) -> Long.compare(o2[j], o1[j]));
      
      long now = 0;
      for (int k = 0; k < m; k ++) {
        now += x[k][i];
      }
      ret = Math.max(now, ret);
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




Measured memory_bytes: 27860
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int a, b;
  cin >> a >> b;
  if(a > 8 || b > 8) {
    cout << ":(\n";
  } else {
    cout << "Yay!\n";
  }
  return 0;
}

Measured memory_bytes: 3636
n = int(input())
a = [int(i) for i in input().split()]
start = sum(a)
b = [int(i) for i in input().split()]

c = 0
for i in range(n):
    if b[i] >= a[i]:
        a[i+1] = max(0, a[i+1]-(b[i]-a[i]))
        a[i] = 0
    else:
        a[i] = a[i] - b[i]

end = sum(a)
print(start-end)

Measured memory_bytes: 19648
while True:
	try:
		line = input()
		if line == '0 0':
			break	
		else:
			a,b = line.split(' ')
			if int(a) > int(b):
				print('{} {}'.format(b,a))
			else:
				print('{} {}'.format(a,b))
	except EOFError:
		break


Measured memory_bytes: 5616
A, B, K = map(int, input().split())

if A >= K:
    _A = A - K
    _B = B
elif K >= A+1 and A+B >= K:
    _A = 0
    _B = A + B - K
else:
    _A = 0
    _B = 0

print(_A, _B)

Measured memory_bytes: 3060
#include<stdio.h>

#define RIGHT 0
#define LEFT 1
#define UP 2
#define DOWN 3

#define OK 1
#define NG 0

int moveR(int *x,int *y,int map[11][7],int *sit,int *side);
int moveL(int *x,int *y,int map[11][7],int *sit,int *side);
int moveU(int *x,int *y,int map[11][7],int *sit,int *side);
int moveD(int *x,int *y,int map[11][7],int *sit,int *side);


int main(){

	int i,j,map[11][7]={0},x,y,sit,side;

	for(i=1;i<9;i+=2){
		if(scanf("%1d%1d%1d%1d%1d%1d%1d%1d%1d",&map[i][1],&map[i][2],&map[i][3],&map[i][4],&map[i+1][1],&map[i+1][2],&map[i+1][3],&map[i+1][4],&map[i+1][5])==EOF) break;
	}
	scanf("%1d%1d%1d%1d",&map[9][1],&map[9][2],&map[9][3],&map[9][4]);
	x=0;
	y=0;
	x++;

	sit=RIGHT;
	side=UP;
	printf("R");
	while(x!=0 || y!=0){
		switch(sit){
			case RIGHT:
				if(side==UP){
					if(moveU(&x,&y,map,&sit,&side)==NG){
						if(moveR(&x,&y,map,&sit,&side)==NG){
							if(moveD(&x,&y,map,&sit,&side)==NG){
								sit=LEFT;
								side=DOWN;
								x--;
								printf("L");
							}
						}
					}
				}
				break;
			case LEFT:
				if(side==DOWN){
					if(moveD(&x,&y,map,&sit,&side)==NG){
						if(moveL(&x,&y,map,&sit,&side)==NG){
							if(moveU(&x,&y,map,&sit,&side)==NG){
								sit=RIGHT;
								side=UP;
								x++;
								printf("R");
							}
						}
					}
				}
				break;
			case UP:
				if(side==LEFT){
					if(moveL(&x,&y,map,&sit,&side)==NG){
						if(moveU(&x,&y,map,&sit,&side)==NG){
							if(moveR(&x,&y,map,&sit,&side)==NG){
								sit=DOWN;
								side=RIGHT;
								y++;
								printf("D");
							}
						}
					}
				}
				break;
			case DOWN:
				if(side==RIGHT){
					if(moveR(&x,&y,map,&sit,&side)==NG){
						if(moveD(&x,&y,map,&sit,&side)==NG){
							if(moveL(&x,&y,map,&sit,&side)==NG){
								sit=UP;
								side=LEFT;
								y--;
								printf("U");
							}
						}
					}
				}
				break;
		}
	}
	printf("\n");
	return 0;

}

int moveR(int *x,int *y,int map[11][7],int *sit,int *side){

	if(map[(*y)*2+1][(*x)+1]==1){
		(*x)++;
		*side=UP;
		*sit=RIGHT;
		printf("R");
		return OK;
	}
	else{
		return NG;
	}
	
}

int moveL(int *x,int *y,int map[11][7],int *sit,int *side){

	if(map[(*y)*2+1][(*x)]==1){
		(*x)--;
		*side=DOWN;
		*sit=LEFT;
		printf("L");
		return OK;
	}
	else{
		return NG;
	}

	
}

int moveU(int *x,int *y,int map[11][7],int *sit,int *side){

	if(map[(*y)*2][(*x)+1]==1){
		(*y)--;
		*side=LEFT;
		*sit=UP;
		printf("U");
		return OK;
	}
	else{
		return NG;
	}

	
}

int moveD(int *x,int *y,int map[11][7],int *sit,int *side){

	if(map[(*y)*2+2][(*x)+1]==1){
		(*y)++;
		*side=RIGHT;
		*sit=DOWN;
		printf("D");
		return OK;
	}
	else{
		return NG;
	}

	
}

Measured memory_bytes: 568
H,W,N = map(int, open(0).read().split())

ans = 0
while N > 0:
    A = max(H, W)
    tmp = N // A
    N = N % A
    if tmp == 0 and N:
        N = 0
        ans += 1
        break
    if H == A:
        W -= tmp
    else:
        H -= tmp
    ans += tmp

print(ans)

Measured memory_bytes: 9008
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int r, d, x_2000;
	cin >> r >> d >> x_2000;
	vector<int> a(10);
	a[0] = x_2000*r - d;
	for (int i = 1; i <= 9; i++) {
		a[i] = a[i - 1] * r - d;
	}
	rep(i, 10) cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<deque>
#define sqr(x) (x)*(x)
using namespace std;
deque<long long> dp[200005][3];
long long n,m,i,j,fa[200005],mod=1e9+7,ans,mxd,f[200005],cnt[200005];
vector<long long> bi[200005];
void dfs(long long x,long long dep)
{
	cnt[dep]++;
	mxd=max(mxd,dep);
	int mxs=0,i,j;
	for (i=0;i<bi[x].size();i++)
	{
		dfs(bi[x][i],dep+1);
		if (dp[x][0].size()<dp[bi[x][i]][0].size())
		{
			swap(dp[x][0],dp[bi[x][i]][0]);
			swap(dp[x][1],dp[bi[x][i]][1]);
			swap(dp[x][2],dp[bi[x][i]][2]);
		}
		mxs=max(mxs,(int)dp[bi[x][i]][0].size());
		for (j=0;j<dp[bi[x][i]][0].size();j++)
		{
			f[0]=dp[x][0][j]*dp[bi[x][i]][0][j]%mod;
			f[1]=dp[x][0][j]*dp[bi[x][i]][1][j]%mod+dp[x][1][j]*dp[bi[x][i]][0][j]%mod;
			f[1]%=mod;
			f[2]=((((dp[x][0][j]+dp[x][1][j]+dp[x][2][j])%mod)*((dp[bi[x][i]][0][j]+dp[bi[x][i]][1][j]+dp[bi[x][i]][2][j])%mod)%mod-f[1]-f[0])%mod+mod)%mod;
			dp[x][0][j]=f[0];
			dp[x][1][j]=f[1];
			dp[x][2][j]=f[2];
		}
		dp[bi[x][i]][0].clear();
		dp[bi[x][i]][1].clear();
		dp[bi[x][i]][2].clear();
	}
	dp[x][0].push_front(1);
	dp[x][1].push_front(1);
	dp[x][2].push_front(0);
	for (i=0;i<=mxs;i++)
	{
		dp[x][0][i]+=dp[x][2][i];
		dp[x][2][i]=0;
	}
//	cerr<<x<<":"<<endl;
//	for (i=0;i<=mxs;i++) cerr<<dp[x][0][i]<<' '<<dp[x][1][i]<<endl; 
}
long long qp(long long x,long long y)
{
	if (y==0) return 1;
	if (y==1) return x;
	long long z=qp(x,y/2);
	z=z*z%mod;
	if (y&1) return z*x%mod; else return z;
}
int main()
{
	cin>>n;
	n++;
	for (i=2;i<=n;i++)
	{
		cin>>fa[i];
		fa[i]++;
		bi[fa[i]].push_back(i);
	}
	//cnt[1]=1;
	dfs(1,0);
	for (i=0;i<=mxd;i++)
	{
		ans+=dp[1][1][i]*qp(2,n-cnt[i]);
		ans%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 470784
($H,$W)=glob<>;
for(1..$H){
    my@s=split//,<>;
    push(@S,\@s);
}
@dh=( 0, 1, 1, 1, 0,-1,-1,-1);
@dw=( 1, 1, 0,-1,-1,-1, 0, 1);
for my$h(0..$H-1){
    for my$w(0..$W-1){
        next if $S[$h][$w]ne'.';
        $c=0;
        for(0..7){
            next if $h+$dh[$_]<0 or $h+$dh[$_]>=$H;
            next if $w+$dw[$_]<0 or $w+$dw[$_]>=$W;
            $c++ if $S[$h+$dh[$_]][$w+$dw[$_]]eq"#";
        }
        $S[$h][$w]=$c;
    }
}
print @$_ for(@S)

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-7
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

ll dijkstra(ll s, ll t, vector<vector<P>>& adj) {
	vector<ll> dir(adj.size(),INF*INF);
	dir[s]=0;
	priority_queue<P,vector<P>,greater<P>> q;
	q.push(P(0,s));
	while(!q.empty()) {
		ll d=q.top().first;
		ll p=q.top().second;
		q.pop();
		if(dir[p]!=d) continue;
		REP(i,adj[p].size()) {
			ll c=adj[p][i].second;
			ll np=adj[p][i].first;
			if(dir[np]>d+c) {
				dir[np]=d+c;
				q.push(P(dir[np],np));
			}
		}
	}
	return dir[t];
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> p(n);
	REP(i,n) cin>>p[i];
	vector<vector<P>> adj(n);
	REP(i,n) {
		if(p[i]==0) {
			FOR(j,1,7) adj[i].pb(P(min(n-1,i+j),1ll));
		} else {
			adj[i].pb(P(i+p[i],0));
		}
	}
	cout<<dijkstra(0,n-1,adj)<<endl;
}




Measured memory_bytes: 13660
#include<bits/stdc++.h>
#define For(i,a,b) for(i=(a);i<=(b);++i)
#define Forward(i,a,b) for(i=(a);i>=(b);--i)
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
using namespace std;
template<typename T>inline void read(T &x)
{
	T s=0,f=1;static char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())s=s*10+(c^48);
	x=s*f;
}
const int MAXN=1e4+7;
static int vis[27],n;
static char s[MAXN];
inline void init()
{
	scanf("%s",s+1);
	Rep(i,1,n=strlen(s+1))vis[s[i]-'a']=true;
	Rep(i,0,25)if(!vis[i])
	{
		printf("%s%c\n",s+1,i+'a');
		exit(0);
	}
	memset(vis,0,sizeof vis);
	Repe(i,n,1)
	{
		vis[s[i]-'a']=i;
		Rep(j,s[i]-'a'+1,n)if(vis[j])
		{
			swap(s[i],s[vis[j]]);s[i+1]='\0';puts(s+1);exit(0);
		}
	}
	puts("-1");
}
inline void solve()
{
}
int main()
{
	init();
	solve();
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for _ in range(m)]

for p,x in px:
    T = t.copy()
    T[p-1] = x
    print(sum(T))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
long long int n,k;
long long int ar[100005];
long long int dp[100005];
long long int call(long long int p)
{
	if(p>n-1)
		return 200005;
	if(p==n-1)
		return 0;
	if(dp[p]!=-1)
		return dp[p];
	long long int min1=fabs(ar[p+1]-ar[p])+call(p+1);
	for(long long int i=2;i<=k;i++)
	{
		min1=min(abs(ar[p+i]-ar[p])+call(p+i),min1);
	}

	dp[p]=min1;
	return dp[p];
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>ar[i];
	for(int i=0;i<n;i++)
		dp[i]=-1;
	long long int ans=call(0);
	cout<<ans<<endl;

}



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

int main() {
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
  int N;
  string S;
  cin>>N;
  cin>>S;
  int answer=1;
    rep(i,N-1){
      if(S.at(i) !=S.at(i+1))
        answer++;
    }
    cout<<answer;
  }

Measured memory_bytes: 512
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int H = nextInt();
		int W = nextInt();

		for(int w=0;w<W+2;w++){
			System.out.print("#");
		}
		System.out.println();
		for(int h=0;h<H;h++){
				System.out.print("#");
				System.out.print(nextString());
				System.out.print("#");
			System.out.println();
		}
		for(int w=0;w<W+2;w++){
			System.out.print("#");
		}
		System.out.println();




	}




	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> H(N+1);
  H[0] = 0;
  for(int i = 1; i <= N; ++i) cin >> H[i];
  if(N == K) {
    cout << 0; return 0;
  }

  vector<vector<ll>> dp(N+1, vector<ll>(N+1, INF));
  dp[0][0] = 0;
  for(int i = 1; i <= N; ++i)
    for(int j = 1; j <= N; ++j)
      for(int k = 0; k < i; ++k) dp[i][j] = min(dp[i][j], dp[k][j-1] + max(0LL, H[i] - H[k]));

  ll ans = INF;
  for(int i = 1; i <= N; ++i) ans = min(ans, dp[i][N - K]);
  cout << ans;
  return 0;
}

Measured memory_bytes: 1024
max = 0
a = []
t =Array.new(10**6+1,55)
tt =Array.new(10**6+1,50)
181.times do |n|
  max = (n*(n+1)*(n+2)/6)
  t[max] = 1
  lol = max
  next if(lol<1)
  while (lol <= 1000000)
    t[lol] = [t[lol],t[lol-max]+1].min
    lol += 1
  end
  if(max.odd?)
    tt[max] = 1
    lol = max
    while (lol <= 1000000)
      tt[lol] = [tt[lol],tt[lol-max]+1].min
      lol += 1
    end
  end
end
while ((m = gets.chomp.to_i) != 0)
  puts "#{t[m]} #{tt[m]}"
end


Measured memory_bytes: 22480
#include <cstdio>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void visit(const Graph & g, int v, int u,
    Edges& brdg, vector< vector<int> >& tecomp,
    stack<int>& roots, stack<int>& S, vector<bool>& inS,
    vector<int>& num, int& time) {
  num[v] = ++time;
  S.push(v); inS[v] = true;
  roots.push(v);
  FOR(e, g[v]) {
    int w = e->dst;
    if (num[w] == 0)
      visit(g, w, v, brdg, tecomp, roots, S, inS, num, time);
    else if (u != w && inS[w])
      while (num[roots.top()] > num[w]) roots.pop();
  }
  if (v == roots.top()) {
    brdg.push_back(Edge(u, v, 0));
    tecomp.push_back(vector<int>());
    while (1) {
      int w = S.top(); S.pop(); inS[w] = false;
      tecomp.back().push_back(w);
      if (v == w) break;
    }
    roots.pop();
  }
}
void bridge(const Graph& g, Edges& brdg, vector< vector<int> >& tecomp) {
  const int n = g.size();
  vector<int> num(n);
  vector<bool> inS(n);
  stack<int> roots, S;
  int time = 0;
  REP(u, n) if (num[u] == 0) {
    visit(g, u, n, brdg, tecomp, roots, S, inS, num, time);
    brdg.pop_back();
  }
}

int main(){
	int V,E,s,t;
	scanf("%d%d",&V,&E);
	Graph g(V);
	Edges brdg;
	vector<vector<int> > tecomp;
	for(;E--;)scanf("%d%d",&s,&t),g[s].push_back(Edge(s,t,0)),g[t].push_back(Edge(t,s,0));
	bridge(g,brdg,tecomp);
	FOR(e, brdg)if(e->src>e->dst)swap(e->src,e->dst);
	sort(ALL(brdg));
	FOR(e, brdg)printf("%d %d\n",e->src,e->dst);
}

Measured memory_bytes: 4896
"use strict"
 
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const H = input[1].trim().split(' ').map(Number);

  let ret = 0;
  let move = 0;
  
  for(let i=0; i<N; i++){
    if (H[i] >= H[i+1]) {
      move += 1;
    } else {
      ret = Math.max(ret, move);
      move = 0;
    }
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17816
# the uppercase letters are encoded as 65 to 90
# I want to put A as 0, so Z is 25

def letter_to_int(letter):
    return ord(letter)-65


def int_to_letter(encoded_value):
    return chr(encoded_value+65)


def shift_string(N, string):
    shifted_string = ""
    for char in string:
        encoding = letter_to_int(char)
        # mod ensures it wraps around, eg N=3 sends Z to C
        shifted = (encoding+N)%26
        decoded_to_letter = int_to_letter(shifted)
        shifted_string = shifted_string + decoded_to_letter
    return shifted_string


if __name__ == "__main__":
    test1 = \
"""2
ABCXYZ"""
    test2 = \
"""0
ABCXYZ"""
    test3 = \
"""13
ABCDEFGHIJKLMNOPQRSTUVWXYZ"""
    various_tests = [test1, test2, test3]
    """for test in various_tests:
        lines = test.split("\n")
        N = int(lines[0])
        string = lines[1]
        print(shift_string(N, string))"""
    N = int(input())
    string = input()
    print(shift_string(N, string))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll a, b;

int main() {
	cin >> a >> b;
	ll ans = 0;
	for (int i = a; i <= b; i++) {
		string s;
		stringstream ss;
		ss << i;
		ss >> s;
		string t = s;
		reverse(ALL(s));
		if (t == s)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int N;
	scanf("%d", &N);
	int A[N];
	int i;
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	int max = 0;
	int sub = 0;
	for (i = 0; i < N; i++) {
		if (A[i] == 1) {
			sub += 1;
			if (sub > max) {
				max = sub;
			}
		}
		else {
			sub = 0;
		}
	}

	printf("%d\n", max+1);
	return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    string tmp = "";
    rep(i, n) {
        char ch;
        cin >> ch;
        tmp += ch;
    }
    rep(i, 1000+1) {
        if (tmp.find(to_string(i)) == string::npos) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

vi segs;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	int lst = -1, len = -1;
	rep(i, 0, sz(s)) {
		int num = s[i] - '0';
		if (num != lst) {
			if (len != -1) {
				segs.push_back(len);
			}
			lst = num;
			len = 1;
		} else len++;
		if (i == sz(s) - 1) segs.push_back(len);
	}
	
	if (sz(segs) == 1) {
		cout << segs[0];
		return 0;
	}
	
	int ans = 1e6;
	int l = segs[0];
	rep(i, 1, sz(segs)) {
		int mx = max(l, sz(s) - l);
		ans = min(ans, mx);
		l += segs[i];
	}
	cout << ans;
}


Measured memory_bytes: 3788
#include<iostream>
#include<string.h>
#define max 1000000

using namespace std;

void gerar_crivo(bool[]);

bool primos[max];

int main(){
    int numero;

    memset(primos, true, sizeof(primos));

    gerar_crivo(primos);

    cin >> numero;

    if(primos[numero])cout << numero;
    else{
        while(primos[numero] == false)numero++;

        cout << numero;
    }
}

void gerar_crivo(bool v[]){
    int i, j;

    for(i = 2; i * i <= max; i++){
        if(v[i]){
            for(j = i * i; j <= max; j+=i){
                v[j] = false;
            }
        }
    }

}

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

int main(){
    int a,b;
    cin>>a>>b;
    
    int d,r;
    double f;
    
    d=a/b;
    r=a%b;
    f=1.0*a/b;

    printf("%d %d %6lf\n",d,r,f);
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	unsigned int H, W;
	char c, prev;
	cin >> H >> W;

	int s[H][W];

	for(int i = 0; i < H; i++) {
		prev = 't';
		for(int j = 0; j < W; j++) {
			cin >> c;
			if(c == '#' && c == prev) {
				s[i][j] = 2;
				s[i][j - 1] = 2; 
			}else if(c == '#')
				s[i][j] = 1;
			else
				s[i][j] = -1;
			prev = c;
		}
	}

	bool flag = false;
	int pr = -1;
	for(int j = 0; j < W; j++) {
		pr = -1;
		flag = false;
		for(int i = 0; i < H; i++) {
			if(s[i][j] == 1 && pr > 0) {
				s[i][j] = 2;
				s[i - 1][j] = 2;
				flag = false;
			} else if(flag && s[i][j] < 0) {
				cout << "No";
				return 0;
			} else if(s[i][j] == 1) {
				flag = true;
			}else
				flag = false;
			pr = s[i][j];
		}
	}

	cout << "Yes";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;


int main(){
    int n;
    int x = 0;
    string s;
    cin >> n >> s;
    int temp_max = 0;
    for(size_t i = 0; i < n; i++)
    {
        if(s[i] == 'I'){
            x++;
            if(x>temp_max) temp_max = x;
        }
        else x--;
    }
    cout << temp_max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N;
    long long ans=0;
    cin >> N;

    for(int i=1; i<=N; i++){
      if(i % 3 != 0 && i % 5 != 0)
        ans += i;
    }

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<ll> v;
set<int> s;
vector<int> to;
int solve(int n){
    if(s.find(n) != s.end()) return n;
    else{
        s.insert(n);
        to.push_back(n);
        solve(v[n]);
    }
}
int main(){
    cout << fixed << setprecision(10);
    ll n,k;
    cin >> n >> k;
    rep(i,n){
        int x;
        cin >> x;
        x--;
        v.push_back(x);
    }
    int num = solve(0);
    int beg = 0;
    rep(i,int(to.size())){
        if(to[i] == num){
            beg = i;
        }
    }
    if(k < int(to.size())){
        cout << to[k] + 1 << endl;
        return 0;
    }
    vector<int> loop;
    for(int i = beg; i < int(to.size()); i++){
        loop.push_back(to[i]);
    }
    ll div = k - to.size();
    cout << loop[div%(loop.size())] + 1 << endl;
    return 0;
}


Measured memory_bytes: 21108
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n, tmp;
    cin >> n;
    vector<Pii> a(3*n);
    rep(3*n){
        cin >> tmp;
        a[i] = Pii(tmp, 2-i/n);
    }
    sort(all(a));

    ll dp[3*n][3];
    fill(dp[0], dp[3*n], 0LL);

    if(a[0].second == 2) dp[0][2] = 1;


    reppp(i, 1, 3*n-1){
        for(int j=2; j>=0; j--){
            if(a[i].second != j){
                dp[i][j] = dp[i-1][j];
            }else{
                if(j == 2){
                    dp[i][2] = dp[i-1][2] + 1;
                }else{
                    dp[i][a[i].second] = dp[i-1][a[i].second] + dp[i][a[i].second+1];
                }
            }
        }
    }
    cout << dp[3*n-1][0];
}  


Measured memory_bytes: 9600
#include <stdio.h>
int main(){
int h[3][2],m[3][2],s[3][2],i,k,koh[3],kom[3],kos[3],da=0,de=0;

for(k=0;k<3;k++){
scanf("%d %d %d %d %d %d",&h[k][0],&m[k][0],&s[k][0],&h[k][1],&m[k][1],&s[k][1]);
}
for(i=0;i<3;i++){



    if(s[i][0]<=s[i][1]){
        kos[i]=s[i][1]-s[i][0];
    }
    else{kos[i]=s[i][1]+60-s[i][0]; m[i][1]--;}

    if(m[i][0]<=m[i][1]){
        kom[i]=m[i][1]-m[i][0];
    }
    else{kom[i]=m[i][1]+60-m[i][0]; h[i][1]--;}


    koh[i]=h[i][1]-h[i][0];

printf("%d %d %d\n",koh[i]-de,kom[i]-da,kos[i]);
}




return 0;
}

Measured memory_bytes: 1796
#include<stdio.h>
int main(){
  int n, i, data[10]={0}, x=0;
  while((scanf("%d", &n)) != EOF){
    if(n == 0){
      printf("%d\n", data[x]);
      x--;
    }else if(1<=n && n<=10){
      x++;
      data[x] = n;
    }
  }
  return 0;
}

Measured memory_bytes: 1828
N,A,B = gets.split.map &:to_i
rest = A+B
os = B
gets.chomp.chars{ |c|
  v = case c
  when "a"
    if rest > 0
      rest -= 1
      true
    else
      false
    end
  when "b"
    if rest > 0 && os > 0
      rest -= 1
      os -= 1
      true
    else
      false
    end
  when "c"
    false
  end
  puts v ? "Yes": "No"
}

Measured memory_bytes: 4348
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N;
    vector<int> A;
    cin >> N;
    int a;
    string ans = "APPROVED";
    for(int i = 0;i < N;i++){
        cin >> a;
        A.push_back(a);
    }

    for(int i = 0;i < N;i++){
        int n = A.at(i);
        if(n % 2 == 0){
            if(n % 3 != 0 & n % 5 != 0){
                ans = "DENIED";
                break;
            }
        }
    }

    cout << ans << endl;
            
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
#define MOD 998244353
#define INV_10 299473306
#define INF 1000000000
using namespace std;
long long power(long long x, long long y, long long m) 
{ 
    if (y == 0) 
        return 1; 
    long long p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
  
    return (y%2 == 0)? p : (x * p) % m; 
} 
long long modInverse(long long a, long long m) 
{ 
	return (long long)(power(a, m-2, m)); 
} 
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	long long ans=0;
	long long p[n], c[n];
	p[0]=1;
	for(int i = 1; i <= n; i++)
		p[i]=(p[i-1]*(m-1))%MOD;
	long long pr=1;
	for(int i = 1; i < n; i++)
	{
		if(n-i <= k)
		{
			long long cu;
			cu=m;
			cu*=p[i-1];
			cu%=MOD;
			cu*=pr;
			cu%=MOD;
			ans+=cu;
			ans%=MOD;
			
			//cout << i << ' ' << cu << '\n';
		}
		pr*=(n-i);
		pr%=MOD;
		pr*=modInverse(i, MOD);
		pr%=MOD;
	}
	ans+=(m*p[n-1]);
	ans%=MOD;
	cout << ans << '\n';
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class t, class u> bool cmax(t& a, u b) { if (a<b) {a = b; return true;} else return false; }
template<class t, class u> bool cmin(t& a, u b) { if (a>b) {a = b; return true;} else return false; }

ll modpow(ll a, ll n, ll p) {
  ll res = 1;
  while (n) {
    if (n&1) {
      res *= a;
      res %= p;
    }
    a *= a;
    a %= p;
    n >>= 1;
  }
  return res;
}

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

  string l;
  cin >> l;
  int n = l.size();

  const ll mod = 1e9+7;
  ll ans = 0;
  int bit_cnt = 0;

  rep(i, n) {
    if (l[i] == '1') {
      ans = (ans + modpow(2, bit_cnt, mod)*modpow(3, n-(i+1), mod)) % mod;
      bit_cnt++;
    }
  }
  ans = (ans + modpow(2, bit_cnt, mod)) % mod;
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long long X, Y;
    cin >> X >> Y;
    long long ans = 0;

    for(long long n = X; n <= Y; n *= 2){
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

vecll AS(200001);
int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  map<ll, ll> MP;
  REP(i, N) {
    cin >> AS[i];
    auto itr = MP.find(AS[i]);
    if (itr != MP.end()) {
      itr->second += 1;
    } else {
      MP.insert(pair<ll, ll>(AS[i], 1LL));
    }
  }
  ll SM = 0;
  for (const auto &pr : MP) {
    SM += pr.second*(pr.second-1)/2;
  }
  REP(i, N) {
    ll cnt = MP.find(AS[i])->second;
    ll res = SM - cnt*(cnt-1)/2 + (cnt-1)*(cnt-2)/2;
    cout << res << endl;
  }
  return 0;
}


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

int main()
{
  int n, abssum = 0, firstplus;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    abssum += abs(a.at(i));
  }
  sort(a.begin(), a.end());
  if (a.at(0) > 0) {
    firstplus = 1;
    abssum -= 2 * a.at(0);
  } else if (a.at(n - 1) < 0) {
    firstplus = n - 1;
    abssum += 2 * a.at(n - 1);
  } else {
    for (int i = 1; i < n; i++) {
      if (a.at(i) >= 0) {
        firstplus = i;
        break;
      }
    }
  }
  cout << abssum << endl;
  for (int i = firstplus; i < n - 1; i++) {
    cout << a.at(0) << " " << a.at(i) << endl;
    a.at(0) -= a.at(i);
  }
  for (int i = 1; i < firstplus; i++) {
    cout << a.at(n - 1) << " " << a.at(i) << endl;
    a.at(n - 1) -= a.at(i);
  }
  cout << a.at(n - 1) << " " << a.at(0) << endl;
}


Measured memory_bytes: 2304
import sys
from collections import defaultdict, deque
from heapq import *
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

s = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        s += 1

print(s / N)

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

A, B = map(int, input().split())
S = input().strip()

t = S.split("-")
if len(t) != 2:
    print("No")
else:
    if len(t[0]) == A and len(t[1]) == B:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060
dummy = input()

s_list = list(map(int,input().split()))

#print(s_list)

count = 0
if len(s_list) == 1:
    for i,row in enumerate(s_list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    print()
    print(count)

else:
    for i in range(len(s_list)-1):

        min_i = i

        for j in range(i,len(s_list)):

            if s_list[j] < s_list[min_i]:
                min_i = j

        if s_list[i] != s_list[min_i]:
            count += 1
            min_num = s_list[min_i]

            s_list[min_i] = s_list[i]
            s_list[i]     = min_num

    for i,row in enumerate(s_list):
        if i == 0:
            print(row,end='')
        else:
            print('',row,end='')
    print()
    print(count)

    

        

Measured memory_bytes: 7696
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var (T, A) = Slice2<long>();
            var Hi = Sarray();
            WriteLine(Hi.Select((h, i) => (Abs(A - (T - h * 0.006)), i + 1)).OrderBy(h => h.Item1).First().Item2);
        }


        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
        static public (T a, T b, T c, T d) Slice4<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)),
            (T)Convert.ChangeType(t[3], typeof(T)));
        }
    }
}

Measured memory_bytes: 28764
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#include <functional>
#include <algorithm>

using namespace std;

template<typename T, int VALUE_N>
class SegmentTree {
	const T INIT_VALUE;
	const function<T(T, T)> mergeFunc;
	const function<T(T, T)> updateFunc;
	const int LEAF_N = 1 << (int)(ceil(log2(VALUE_N)));
	const int NODES_N = LEAF_N * 2 - 1;
	vector<T> nodes;
	inline int leafIndex(int i) { return LEAF_N - 1 + i; }
	inline int parentIndex(int i) { return (i - 1) / 2; }
	inline int childLIndex(int i) { return 2 * i + 1; }
	inline int childRIndex(int i) { return 2 * i + 2; }
	// [a,b) query. current k node == [l,r)
	T query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return INIT_VALUE;
		if (a <= l && r <= b) return nodes[k];
		int mid = (l + r) / 2;
		return mergeFunc(query(a, b, childLIndex(k), l, mid), query(a, b, childRIndex(k), mid, r));
	}
public:
	SegmentTree(T iniValue, function<T(T, T)> mergeF, function<T(T,T)> updateF) : 
		nodes(NODES_N), 
		INIT_VALUE(iniValue), 
		mergeFunc(mergeF),
		updateFunc(updateF){
		for (int i = leafIndex(0); i < leafIndex(LEAF_N); i++) {
			nodes[i] = INIT_VALUE;
		}
		for (int i = parentIndex(leafIndex(LEAF_N - 1)); i >= 0; i--) {
			nodes[i] = mergeFunc(nodes[childLIndex(i)], nodes[childRIndex(i)]);
		}
	}
	void update(int valueI, T newValue) {
		int nodeI = leafIndex(valueI);
		T oldValue = nodes[nodeI];
		nodes[nodeI] = updateFunc(oldValue, newValue);
		while (nodeI > 0) {
			nodeI = parentIndex(nodeI);
			nodes[nodeI] = mergeFunc(nodes[childLIndex(nodeI)], nodes[childRIndex(nodeI)]);
		}
	}
	// [a,b) query
	T query(int a, int b) {
		return query(a, b, 0, 0, LEAF_N);
	}
};

int main() {
	using IntType = long long;
	constexpr int MAX_ELEM_NUM = 100001;
	auto addfunc = [](IntType a, IntType b) {return a + b; };
	SegmentTree<IntType, MAX_ELEM_NUM> s(0, addfunc, addfunc);
	int elemNum, queryNum;
	int com;
	IntType x, y;
	cin >> elemNum >> queryNum;
	for (int qI = 0; qI < queryNum; qI++) {
		cin >> com >> x >> y;
		switch (com) {
		case 0:
			s.update(x, y);
			break;
		case 1:
			IntType ret = s.query(x, y + 1);
			cout << ret << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 4792
using System;

namespace String
{
    class Shuffle
    {
        static void Main(string[] args)
        {
            var line="";
            while((line = Console.ReadLine())!="-"){
                var m = int.Parse(Console.ReadLine());
                for (int i = 0; i < m; i++)
                {
                    var h = int.Parse(Console.ReadLine());
                    line = line.Substring(h, line.Length - h) + line.Substring(0, h);
                }
                Console.WriteLine(line);
            }
        }
    }
}

Measured memory_bytes: 8888
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, x, t;
	cin>>n>>x>>t;
	if(n%x==0){
		cout<<(n/x)*t;
	}
	else{
		cout<<((n/x)+1)*t;
	}
	return 0;
}

Measured memory_bytes: 3640
from enum import Enum
from queue import Queue

import numpy as np

import collections
import bisect
import sys
import math

from scipy.sparse.csgraph import floyd_warshall

S = input()

Weather = []
Weather.append('Sunny')
Weather.append('Cloudy')
Weather.append('Rainy')
print(Weather[(Weather.index(S)+1)%3])


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

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

  if(a == 1) a += 100;
  if(b == 1) b += 100;

  if(a > b) cout << "Alice" << endl;
  else if(a < b) cout << "Bob" << endl;
  else cout << "Draw" << endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define PI (4*atan(1.0))
using namespace std;
int main()
{
	double a,b,x;
	scanf("%lf%lf%lf",&a,&b,&x);
	double s=x/a;
	double check=a*a*b/2;
	double angle=0;
	if(x>=check)
	{
		double i=2*(a*b-s)/(a*a);
		angle=atan(i)/PI*180;
	}
	else
	{
		double j=b*b/(2*s);
		angle=atan(j)/PI*180;
	}
	printf("%lf",angle);
	return 0;
} 

Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := readInt(), readInt()

	if (a+b)%2 == 0 {
		fmt.Println((a + b) / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
   long long int a , b , c , ans=0;
    cin>>a>>b>>c;
    if ( a == b && a == c )
    {
        if ( a % 2 == 1 )
        {
            cout<<0<<endl;
        }
        else 
        {
            cout<<-1<<endl;
        }
    }   
    else
    {
        while ( a%2 != 1  &&  b%2 != 1  &&  c%2 !=1)
        {
            long long int  x = a , y = b , z = c;
            a = ( y + z )/2;
            b = ( x + z )/2;
            c = ( x + y )/2;
            ans++;
        }
        cout<<ans<<endl;
    }
}

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

ans = None
for h in range(1, 3501):
  for n in range(1, 3501):
    if 4*h*n - n*N - h*N != 0:
      w = (N * h * n) / (4*h*n - n*N - h*N)
      if w > 0 and w.is_integer() and 4/N == 1/h + 1/n + 1/w:
        ans = [h, n, int(w)]
        break
  if ans:
    break
print(" ".join(map(str, ans)))

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

#define all(v) v.begin(), v.end()
typedef long long ll;


int main() {
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int x = abs(tx - sx);
    int y = abs(ty - sy);
    vector<char> ans;
    for(int i = 0; i < y; i++) ans.push_back('U');
    for(int i = 0; i < x; i++) ans.push_back('R');
    for(int i = 0; i < y; i++) ans.push_back('D');
    for(int i = 0; i < x; i++) ans.push_back('L');
    ans.push_back('L');
    for(int i = 0; i < y + 1; i++) ans.push_back('U');
    for(int i = 0; i < x + 1; i++) ans.push_back('R');
    ans.push_back('D');
    ans.push_back('R');
    for(int i = 0; i < y + 1; i++) ans.push_back('D');
    for(int i = 0; i < x + 1; i++) ans.push_back('L');
    ans.push_back('U');
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i];
    }
    cout << endl;

}


Measured memory_bytes: 256
n = gets.to_i
bs = gets.to_s.split(' ').map(&:to_i)

ans = []
ans[0] = bs[0]
bs.each_with_index do |b, i|
  prev = ans[i]
  idx = i + 1
  ans[idx] = b
  ans[i] = b if prev > b
end

puts ans.inject(:+)


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<cstdlib>
#include<stack>
#include<string>
#include<vector>
using namespace std;

int main(){
    stack<int> S;
    int a, b;
    string s;

    while( cin >> s ){
        if(s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a + b);
        }else if(s[0] == '-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        }else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a * b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }   
    cout << S.top() << endl;
    return 0;
}


Measured memory_bytes: 3196
def main():
    N = int(input())
    c = input()
    num_of_w = 0
    for i in range(N):
        if c[i] == 'W':
            num_of_w += 1

    num_of_w2 = 0
    for j in range(N-1,N-1-num_of_w,-1):
        if c[j] == 'W':
            num_of_w2 += 1

    judge = num_of_w - num_of_w2
    if judge <= 0:
        return 0
    else:
        return judge

print(main())


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

signed main()
{ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,t;
    cin>>n>>k;
    vector<int> arr;
    for(int i=0;i<n;i++)
    {
        cin>>t;
        arr.push_back(t);
    }
    sort(arr.begin(),arr.end());
    //if(n>1)
    cout<<accumulate(arr.begin(),arr.begin()+k,0);
    //if(n==1 && k==1)
   // cout<<arr[0];
    return 0;
}


Measured memory_bytes: 3620
import sys
from collections import Counter
from string import ascii_lowercase

INF = 50

n = int(sys.stdin.readline().rstrip())
strings = sys.stdin.read().split()

def main():
    shared = set(ascii_lowercase)
    for s in strings:
        shared &= set(s)
    
    cnts = [Counter(s) for s in strings]
    
    res = dict([(char, INF) for char in shared])
    
    for char in shared:
        for c in cnts:
            res[char] = min(res[char], c[char])

    ans = ''
    for char, c in sorted(res.items()):
        ans += char * c

    return ans
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3768