akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int n;
  cin >> n;
  int mi = LONG_MAX, sum = 0, minusCnt = 0;
  bool existsO = false;
  REP(i, n) {
    int tmp = read();
    chmin(mi, abs(tmp));
    sum += abs(tmp);
    if (tmp < 0)
      minusCnt++;
    if (tmp == 0)
      existsO = true;
  }
  if (existsO || (minusCnt & 1) == 0)
    print(sum);
  else
    print(sum - 2 * mi);
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {
	static Map<Long,ArrayList<String>> l=new TreeMap<Long,ArrayList<String>>();
	static long p[];
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int a[]=new int [n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int sum=0;
		for(int i=0;i<k;i++) {
			sum+=a[i];
		}
		System.out.println(sum);
	}
	
	
}

 


Measured memory_bytes: 30220
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  if (b=='A') cout << 'T';
  else if (b=='T') cout << 'A';
  else if (b=='G') cout << 'C';
  else if (b=='C') cout << 'G';
}

Measured memory_bytes: 256
x=int(input())
p=x-1
prime=False
if x==2:
    print(2)
else:
    while prime==False:
        p+=1
        prime=True
        
        for i in range(2,p-1):
            if p%i==0:
                prime=False
        
        
   
    print(p)
    


Measured memory_bytes: 2940
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, x;
    scanf("%d %d %d", &a, &b, &x);
    string ans = (a <= x && x <= a + b) ? "YES" : "NO";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
program abc161d
  use iso_fortran_env
  implicit none
  integer :: k, d, i, j, h, t
  integer(int64) :: ans, a(300000)
  read *, k
  do i = 1,9
     a(i) = i
  end do
  h = 1
  t = 10
  do i = 1,k
     ans = a(h)
     h = h + 1
     do j = -1,1
        d = mod(ans,10)
        d = d + j
        if (d >= 0 .and. d <= 9) then
           a(t) = ans * 10 + d
           t = t + 1
        end if
     end do
  end do
  print *, ans
end program abc161d


Measured memory_bytes: 2432
n=int(input())
lists=[]
for i in range(n):
    s=input()
    lists.append(s)
is_good=[[False for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(n):
        p=lists[i][j:]+lists[i][:j]
        flag=True
        for k in range(n):
            if p[k]!=lists[(i+k)%n][j]:
                flag=False
                break
        if flag:
            is_good[i][j]=True

counter=0
for i in range(n):
    for j in range(n):
        flag=True
        for k in range(n):
                if is_good[(i+k)%n][(j+k)%n]==False:
                    flag=False
                    break
        if flag:
            
            counter+=1
print(counter)
            

Measured memory_bytes: 44252
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define eps 1e-9
#define oo 1e7+5

using namespace std;

typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	map<int,int> mp;
	int n;
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		int aux;
		cin>>aux;
		mp[aux]++;
		sum+=aux;
	}

	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int b,c;
		cin>>b>>c;
		sum = sum - mp[b]*b;
		sum = sum + mp[b]*c;
		mp[c] = mp[c] + mp[b];
		mp[b] = 0;
		cout<<sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 9568
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b)*b;
}
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main() {
	ll N;
	cin >> N;
	ll ans = 0;
	ll A[N + 10], B[N + 10];
	for (ll i = N - 1; i >= 0; i--) {
		cin >> A[i] >> B[i];
	}
  	for(ll i=0; i<N; i++){
      A[i]+=ans;
      if(A[i]%B[i]!=0){
      ll x=B[i]-(A[i]%B[i]);
      ans+=x;
      }
      }
      
	cout << ans << endl;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define pi 3.1415926535
#define endl '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll inf=1e19;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s,s1="";
    ll i,n,a,b,c,r,k;
    cin>>s;
    n=s.size();
    if(n%2)
    {
        cout<<"No"<<endl;
        return 0;
    }
    n=n/2;
    for(i=0;i<n;i++)
        s1=s1+"hi";
    if(s1==s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 256
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N,K,Q=MI()
A=[K-Q]*N
q=[0]*Q
for i in range(Q):
    q[i]=II()

for x in q:
    A[x-1] +=1
for a in A:
    if a >0:
        print('Yes')
    else:
        print('No')





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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

int main()
{    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n;

    cin>>n;

    ld tp= (ld)(n*n*n);

    cout<<fixed<<setprecision(10);

    cout<<tp/27.0;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
int64_t lcm(int64_t a, int64_t b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
  int64_t d,g;
  cin >> d >> g;
  vector<pair<int, int>> vec(d);
  REP(i,d){
    cin >> vec.at(i).first >> vec.at(i).second;
  }
  int mi = INT_MAX;
  for (int bit = 0; bit < (1<<d); ++bit){
    int t = 0;
    int c = 0;
    vector<int> s;
    for (int i=0;i<d;i++){
      if (bit & (1<<i)){
        t += vec.at(i).first * (i+1) * 100 + vec.at(i).second;
        c += vec.at(i).first;
        s.push_back(i);
      }
    }
    if (t >= g){
      mi = min(mi, c);
    }else{
      for (int i=d-1;i>=0;i--){
        if (find(ALL(s), i) == s.end()){
          for (int j=0;j<vec.at(i).first;j++){
            t += (i+1) * 100;
            c++;
            if ( t >= g ){
              mi = min(mi, c);
              break;
            }
          }
          break;
        }
      }
    }
  }
  cout << mi << endl;
  return 0;
}



Measured memory_bytes: 256
N, M = map(int, input().split())
pen = [0] * N
AC = [False] * N
for _ in range(M):
    p, s = input().split()
    if s == "AC": AC[int(p) - 1] = True
    else:
        if AC[int(p) - 1] == False : pen[int(p) - 1] += 1
ACcount = AC.count(True)
Pcount = 0
for i in range(N):
    if AC[i]: Pcount += pen[i]
print(ACcount, Pcount)

Measured memory_bytes: 4724
import std.stdio;
import std.string;
import std.conv;

int main()
{
    int n = readln().chomp().to!int();
    while (n--) {
        int times = 3;
        int Hit = 0;
        int result = 0;
        while (times) {
            string str = readln().chomp();
            if (str == "HIT") {
                if (Hit == 3)  result++;
                else Hit++;
            } else if (str == "OUT") {
                times--;
            } else {
                result += (Hit + 1);
                Hit = 0;
            }
        }
        writeln(result);
    }

    return 0;
}

Measured memory_bytes: 1048
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  if(K == 0) {
    cout << A - B << endl;
  } else if(K % 2 == 1) {
    cout << B - A << endl;
  } else {
    cout << A - B << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
unsigned long long gcd(unsigned long long a, unsigned long long b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
	return a * b / gcd(a, b);
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<int> a(n);
	int l=1;
	int cnt=0;
	rep(i,n){
	    cin>>a[i];
	    if(i){
            int it=a[i];
            int ct=0;
            while(it%2==0){
                it/=2;
                ct++;
            }
            if(ct!=cnt){
                cout<<0<<endl;
                return 0;
            }
        }
	    else{
	        int it=a[i];
	        while(it%2==0){
	            cnt++;
	            it/=2;
	        }

	    }
	    l=lcm(l,a[i]);
	    if(l/2>m){
	        cout<<0<<endl;
	        return 0;
	    }
	}
	cout<<(m*2/l-1)/2+1<<endl;
}

Measured memory_bytes: 1024
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> v(n), w(n);
  for (int i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int x, s;
    cin >> x >> s;
    vector <pair <int, int> > l, r;
    while (x) {
      auto z = make_pair(v[x - 1], w[x - 1]);
      if (l.size() > r.size()) {
        r.push_back(z);
      } else {
        l.push_back(z);
      }
      x /= 2;
    }
    auto brute = [&] (vector <pair <int, int> > e) {
      vector <pair <int, int> > x, y, z;
      x.push_back({0, 0});
      for (auto c : e) {
        y.clear();
        for (auto p : x) {
          y.push_back({p.first + c.first, p.second + c.second});
        }
        z.clear();
        z.resize(x.size() + y.size());
        merge(x.begin(), x.end(), y.begin(), y.end(), z.begin());
        x = z;
      }
      y.clear();
      for (auto c : x) {
        if (y.empty() || c.second > y.back().second) {
          y.push_back(c);
        }
      }
      return y;
    };
    l = brute(l), r = brute(r);
    int j = -1;
    int ans = 0;
    for (int i = (int) l.size() - 1; i >= 0; i--) {
      while (j + 1 < (int) r.size() && r[j + 1].first + l[i].first <= s) {
        j++;
      }
      if (j != -1) {
        ans = max(ans, l[i].second + r[j].second);
      }
    }
    cout << ans << '\n';
  }
}


Measured memory_bytes: 5300
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
ll a,b,c,d,e,f,g,ans=0;
const ll INF=99999999999999999;
int main(){
    ll n;
  bool flag=true;
    ll x[200000];
    a=0;
    cin>>n;
    rep(i,n){
        cin>>x[i];
    }

    ans=1;
    b=1;
    for(int i=1;i<n;i++){
      if(!flag){
        if(x[i-1]<x[i]&&b==-1){
          ans++;
          flag=true;
        }
        if(x[i-1]>x[i]&&b==1){
          ans++;
          flag=true;
        }
      }
      else{
        if(x[i-1]>x[i]){
          flag=false;
          b=-1;
        }
        if(x[i-1]<x[i]){
          flag=false;
          b=1;
        }
      } 
    }

    cout<<ans<<endl;
}

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

int main(){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    ll cnt=0,ans=0;
    rep(i,s.size()){
        if(s[i]=='W')cnt++;
        else ans+=cnt;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

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

        int n = sc.nextInt();
        int[] array = new int[n];

        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }

        for (int i = 0; i < n; i++) {
            if (array[i] % 2 == 0){
                if(array[i] % 3 == 0 || array[i] % 5 == 0) {
                } else {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
#define ls k<<1,l,mid
#define rs k<<1|1,mid+1,r
#define mp(x,y) make_pair(x,y)
#define r(x) read(x)
#define rr(x,y) read(x);read(y)
#define rrr(x,y,z) read(x);read(y);read(z)
#define FOR(i,l,r) for(int i=l;i<=r;i++)
#define pb(x) push_back(x)
#define sss(str) scanf("%s",str+1)
#define ssf(x) scanf("%lf",&x)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long LL;
typedef double dd;
typedef pair<int,int> pt;
const int N=1e5+5;
const int M=2e3+5;
const int INF=0x7fffffff;
const int mod=1e9+7;
const int sz=18;
const double eps=1e-10;
const double pi=acos(-1);
//***********************

//***********************
template<class T>
inline void read(T &x)
{
    char c; x=1;
    while((c=getchar())<'0'||c>'9') if(c=='-') x=-1;
    T res=c-'0';
    while((c=getchar())>='0'&&c<='9') res=res*10+c-'0';
    x*=res;
}
int main()
{
    int n,m;
    rr(n,m);
    int ans=0;
    while(n){
        ans++;
        n/=m;
    }
    cout<<ans<<endl;
    return 0;
}


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

static const long long MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    for (long long i = 0; i < n; i++) res = res * a % mod;
    return res;
}

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

    long long result = modpow(10, N, MOD) - 2 * modpow(9, N, MOD) + modpow(8, N, MOD);
    result = result % MOD;
    result = (result + MOD) % MOD;
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3640
n = int(input())
s = list(input())

list1 = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

mods = 26
list2 = []
for i in s:
    a = (list1.index(i) +n)%mods
    list2.append(list1[a])

print("".join(list2))

Measured memory_bytes: 39920
import sys
import math
import itertools

def insertionSort(A, N):
  for i in range(N):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
      A[j+1] = A[j]
      j -= 1
    A[j+1] = v
    print(*A)

def main():
  N = int(input())
  numbers = list(map(int, input().split()))

  insertionSort(numbers, N)

if __name__ == '__main__':
  main()


Measured memory_bytes: 6128
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, mny = 1e9, mxy, res;
pair<int, int>p[200007];
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
signed main()
{
	n = read();
	for (int i = 1; i <= n; i++)
	{
		p[i].first = read();
		p[i].second = read();
		if (p[i].first > p[i].second)
			swap(p[i].first, p[i].second);
		mny = min(mny, p[i].second);
		mxy = max(mxy, p[i].second);
	}
	sort(p + 1, p + n + 1);
	int tmp = mxy - p[1].first;
	res = min((p[n].first - p[1].first) * (mxy - mny), tmp * (p[n].first - p[1].first));
	mny = 1e9, mxy = 0;
	for (int i = 1; i <= n; i++)
	{
		mny = min(mny, p[i].second);
		mxy = max(mxy, p[i].second);
		res = min(res, tmp * (max(mxy, p[n].first) - min(mny, i == n ? (int)1e9 : p[i + 1].first)));
	}
	cout << res << endl;
	return 0;
}

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

using ll = long long;
const int mod = 1e9 + 7;

int cnt[11][10];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll sum = 0;
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0)
            sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3660
import java.io.*;
import java.util.*;

/******************************\
 * The solution is at the top *
 *                            *
 *   Created by : azhar556    *
\******************************/

public class Main {
    static void solve() {
		int n = ni();
		int m = ni();
		out.println(n < m ? 0 : 10);
    }    

    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        int t;// = ni();
        t = 1;
        while (t-- > 0) solve(); 
        err.println("Time elapsed : " + (System.currentTimeMillis() - time) / 1000F + " s.");
        err.close(); out.close();
    }

	static int[] radixSort(int[] f){ return radixSort(f, f.length); }
	static int[] radixSort(int[] f, int n)
	{
		int[] to = new int[n];
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(f[i]&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[f[i]&0xffff]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(f[i]>>>16)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[f[i]>>>16]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		return f;
	}

    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static PrintWriter err = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.err)));
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer token;
    
    static boolean hasMoreTokens () {
        String sample = null;
		try {
			sample = br.readLine();
		}
		catch (IOException e) {
			e.printStackTrace();
		}
		return sample == null ? false : true;
    }

    static String ns() {
        while (token == null || !token.hasMoreTokens()) {
            try {
                token = new StringTokenizer(br.readLine());
            }
            catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return token.nextToken();
    }
    static char nc() {
        return Character.valueOf(ns().charAt(0));
    }
    static int ni() {
        return Integer.parseInt(ns());
    }
    static double nd() {
        return Double.parseDouble(ns());
    }
    static long nl() {
        return Long.parseLong(ns());
    }
}
// Collections Arrays Math
// Vector HashSet TreeSet HashMap TreeMap ArrayDeque 

Measured memory_bytes: 23252
//  atcodder.xcode
//  main.cpp
//  Created by conan1024hao on 2019/11/09.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリ
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll n;
    cin>>n;
    vector<ll>a(n),b(n);
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    ll ans=0;
    vector<ll>c(n);
    vector<pair<ll,pair<ll,ll>>>m(n);
    for(ll i=0;i<n;i++){
        c[i]=a[i]+b[i];
        m.push_back(make_pair(c[i],make_pair(a[i],b[i])));
    }
    sort(m.begin(),m.end());reverse(m.begin(),m.end());
    for(ll i=0;i<n;i++){
        if(i%2==0)
        ans+=m[i].se.fi;
        else
            ans-=m[i].se.se;
    }
    
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------




Measured memory_bytes: 9216
// C - GCD on Blackboard
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b){return b? gcd(b, a%b): a;}

int main(){
	int N; cin>>N;
	vector<int> A(N), L(N), R(N);

	for(int n=0; n<N; ++n) cin>>A[n];
	for(int n=0; n<=N-1-1; ++n) L[n+1] = gcd(L[n], A[n]);
	for(int n=N-1-1; n>=0; --n) R[n] = gcd(R[n+1], A[n+1]);

	int maxi = 0;
	for(int n=0; n<N; ++n) maxi = max(maxi, gcd(L[n], R[n]));
	cout<< maxi <<endl;
}

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

int main(){
  int N;
  cin >> N;
  string S,T;
  cin >> S >> T;
  for(int i=0;i<N;i++){
    cout << S.at(i) << T.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]

c = [s.count("AC"),s.count("WA"),s.count("TLE"),s.count("RE")]

print("AC","x",c[0])
print("WA","x",c[1])
print("TLE","x",c[2])
print("RE","x",c[3])

Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9

vector<int> numcounter(100005);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a.at(i);
    int q;
    cin >> q;
    vector<int> b(q), c(q);
    REP(i, q) cin >> b.at(i) >> c.at(i);
    ll sum = 0;
    REP(i, n) sum += a.at(i);

    REP(i, n) numcounter.at(a.at(i))++;

    REP(i, q) {
        sum += numcounter.at(b.at(i)) * (c.at(i) - b.at(i));
        numcounter.at(c.at(i)) += numcounter.at(b.at(i));
        numcounter.at(b.at(i)) = 0;
        cout << sum << endl;
    }
    return 0;
}

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

using namespace std;

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

	if (n < b) {
		long long ans = a * n / b - a * (n / b);
		cout << ans << endl;
	} else {
		long long ans = a * (b - 1) / b;
		cout << ans <<  endl;
	}

	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define dl double
#define mod 1000000007
#define sz 205
#define szz 35

using namespace std;

int main()
{
    ll a;
    char b[sz];

    scanf("%lld %s",&a,b);

    ll len=strlen(b);

    for(ll i=0;i<len;i++)
    {
        a=(a*10)+(b[i]-48);
    }

    ll c=sqrt(a);

    if(c*c==a)
        printf("Yes\n");

    else
        printf("No\n");

    return (0);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 1000000007;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
int main()
{
    fast;
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll i,j,t;
    string s1,s2;
    cin >> s1 >> s2;
    if(s1 == s2.substr(0,s2.size() - 1))
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}        

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
const int mod=1e9+7;
 
ll L,R;
 
ll f[64][2][2][2][2];
int l[100],r[100];
 
ll dfs(int x,int fl,int fr,int s,int ht)
{
	if(x<0)return 1;
	// x：第x位 （二进制转十进制下权值是1的为第0位）
	// fl： y之前是否有填过小于 R的某一位的数字   例如：R:11000 y:10??? fl即为1 表示后面数字可以往大了填 
	// fr： x之前是否有填过大于 L的某一位的数字   类似fl
	// s： 之前x是否有某一位 < y的某一位 如果有，后面的位数就没有相对大小限制了 (确保 x<=y)
	//ht：确保 x，y 最高位一样都为1  （满足推导的要求） 
	ll &ans=f[x][fl][fr][s][ht];
	if(ans)return ans;
	
	for(int i=0;i<2;i++)//y
	{
		for(int j=0;j<2;j++)//x
		{
			int tl=fl,tr=fr,ts=s,tt=ht;
			if(!tt&&i)if(i!=j)continue;
			if((j&i)!=j)continue;
			if(!tl&&j<l[x])continue;
			if(!tr&&i>r[x])continue;
			if(!ts&&j>i)continue;
			if(j>l[x])tl=1;if(i<r[x])tr=1;if(j<i)ts=1;if(j)tt=1;
			ans+=dfs(x-1,tl,tr,ts,tt);
		}
	}
	ans%=mod;
	return ans;
}
 
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	cin>>L>>R;
	for(int i=63;i>=0;i--)
	{
		l[i]=(bool)((1ll<<i)&L);r[i]=(bool((1ll<<i)&R));
	}
	
	cout<<dfs(63,0,0,0,0);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n;
    cin >> n;
    unordered_map<ll,ll> um;
    ll ans = 0;
    for(ll i = 1;i<=n;i++){
        ll x;
        cin >> x;
        ans += um[i - x];
        um[x+i]++;
    }
    cout << ans;
}









Measured memory_bytes: 18536
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if math.Abs(float64(x) - float64(a)) < math.Abs(float64(x) - float64(b)) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}

}


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


int main () {
	int n; cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) cin >> a[i];

	int f[n]; f[0] = a[0]; f[1] = abs (a[0] - a[1]); f[2] = min (abs (a[0] - a[2]), f[1] + abs (a[1] - a[2]));
	for (int i = 3; i < n; i++) 
		f[i] = min (f[i - 2] + abs (a[i - 2] - a[i]), f[i - 1] + abs (a[i - 1] - a[i]));

	cout << f[n - 1];
	return 0;
}

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

const int mod = 1e9 + 7;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  long long res = 1;
  for (int i = 0; i < n; ++i) {
    res = (res * 10) % mod;
  }
  long long wrong1 = 1;
  long long wrong2 = 1;
  for (int i = 0; i < n; ++i) {
    wrong1 = (wrong1 * 9) % mod;
    wrong2 = (wrong2 * 8) % mod;
  }
  long long q = wrong1 + wrong1;
  if (q >= mod) {
    q -= mod;
  }
  q -= wrong2;
  if (q < 0) {
    q += mod;
  }
  res -= q;
  if (res < 0) {
    res += mod;
  }
    
  cout << res << "\n";
  


}



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

#define int long long
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; }

signed main(){
	double l;
	cin >> l;
	double tmp = l/3.0;

	printf("%.12lf\n", tmp*tmp*tmp);

	return 0;
}


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

void swap(int *a,int *b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
}

void InsertionSort(int n,int a[]){
  for(int j=0;j<n;j++){
    if(j!=n-1)
      cout << a[j] << " ";
    else
      cout << a[j];
  }
  cout << endl;
  for(int i=1;i<n;i++){
    for(int j=i;j>0;j--){
      if(a[j-1]<a[j])
	break;
      swap(&a[j-1],&a[j]);
    }
    for(int j=0;j<n;j++){
      if(j!=n-1)
	cout << a[j] << " ";
      else
	cout << a[j];
    }
    cout << endl;
  }
}

int main(){

  int n;
  cin >> n;
  int *array=new int[100];
  for(int i=0;i<n;i++)
    cin >> array[i];

  InsertionSort(n,array);

  return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
long long binpow(long long a,long long b)
{
    if (b == 1) return a;
    long long res = binpow(a, b/2)%MOD;
    if (b % 2) return (res*((res*a)%MOD))%MOD;
    else return (res * res)%MOD;
}

long long int fact(long long int a)
{
    if(a==0||a==1)
        return 1;
    long long int ans = 1;
    for(int i=a;i>=1;i--)
        ans = (ans * i)% MOD;
    return ans;
}

long long int ivmod(long long int a)
{
    return binpow(a,MOD-2);
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
        // freopen("input.txt","r",stdin);
        // freopen("output.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    char grid[502][502];
    int white = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>grid[i][j];
            if(grid[i][j]=='.')
                white++;
        }
    }
    if(white == n*n)
    {
        cout<<-1<<endl;
        return 0;
    }
    bool whitecol[n]={0};
    bool blackcol[n]={0};
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(grid[i][j]=='#')
                blackcol[j]=1;
            else
                whitecol[j]=1;
        }
    }
    int ans = 99999999;
    int blackcols = 0;
    for(int i=0;i<n;i++)
    {
        if(whitecol[i]==0)
            blackcols++;
    }
    for(int i=0;i<n;i++)
    {
        int temp = 0;
        if(blackcol[i]==0)
            temp++;
        for(int j=0;j<n;j++)
            if(grid[i][j]=='.')
                temp++;
        temp+=n-blackcols;
        ans = min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
vector<ll> ret;

int main(){
    int n,k;
    cin>>n>>k;
    double ret = 0;
    for(int i=1;i<=n;++i){
        double tmp = 1.;
        int j = i;
        while(j < k){
            j *= 2;
            tmp /= 2;
        }
        ret += tmp;
    }
    ret /= n;
    cout << fixed;
    cout << setprecision(15) << ret << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    int A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    if (B - A == C - B) {
        cout << "YES" << "\n";
    } else{
        cout << "NO" << "\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[] isNotPrimes = new boolean[1000001];
        isNotPrimes[0] = true;
        isNotPrimes[1] = true;
        for (int i = 2; i < isNotPrimes.length; i++) {
            if (isNotPrimes[i]) {
                continue;
            }
            for (int j = 2; j * i < isNotPrimes.length; j++) {
                isNotPrimes[i * j] = true;
            }
        }
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        int[][] dp = new int[n][2];
        if (!isNotPrimes[arr[0]]) {
            dp[0][0] = 1;
        }
        for (int i = 1; i < n; i++) {
            dp[i][1] += dp[i - 1][0];
            dp[i][1] %= MOD;
            if (!isNotPrimes[arr[i]]) {
                if (i >= 2 && arr[i - 2] < arr[i]) {
                    dp[i][0] += dp[i - 1][1];
                    dp[i][0] %= MOD;
                }
                if (arr[i - 1] < arr[i]) {
                    dp[i][0] += dp[i - 1][0];
                    dp[i][0] %= MOD;
                }
            }
        }
        System.out.println((dp[n - 1][0] + dp[n - 1][1]) % MOD);
    }
}



Measured memory_bytes: 71640
import collections
import sys

l = collections.deque(sys.stdin.readlines())
l.pop()
result = ""
while l:
    n = int(l.popleft())
    dict = {}
    s = ""
    for i in range(n):
        key, value = l.popleft().split()
        dict[key] = value
    for i in range(int(l.popleft())):
        key = l.popleft().strip()
        if key in dict:
            s += dict[key]
        else:
            s += key
    result += s + "\n"

print(result, end="")

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

int main() {
  string s;
  cin >> s;
  int flag = 1;
  int ans = 0;
  s.erase(s.size() - 1);

  while (flag) {
    int n = s.size();
    string t = s.substr(0, n / 2);
    string u = s.substr(n / 2, n / 2);
    if (t == u) {
      flag = 0;
      ans = s.size() / 2 * 2;
    }
    s.erase(n - 1);
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

typedef vector<vector<lli> > matrix ;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

lli ans[N], X[N];
lli n, q;
vector<lli> g[N];

void dfs(lli u, lli p, lli cnt = 0) {

    ans[u] += cnt;
    for(auto it : g[u]) {
        if(it != p) {
            dfs(it, u, cnt + X[u]);
        }
    }
    return ;
}

void solve()
{

    cin>>n>>q;
    for(int i = 0; i < n - 1; i ++) {
        lli a, b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    for(int i = 0; i < q; i ++) {
        lli p, x;
        cin>>p>>x;
        X[p] += x;
        ans[p] += x;
    }

//    cout<<"YES"<<endl;

    dfs(1, -1);

    for(int i = 1; i <= n; i ++) {
        cout<<ans[i]<<' ';
    }

    cout<<"\n";
    return ;
}

/*
*/

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

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


Measured memory_bytes: 29056
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
        int m=sc.nextInt();
        long o=0;
      PriorityQueue<Long> a=new PriorityQueue<>(Collections.reverseOrder());
      for(int i=0;i<n;i++){
            long k=sc.nextLong();
        	a.add(k);
      }
      for(int j=0;j<m;j++){
      	long a_max=a.poll();
        a.add(a_max/2);
      }
      for(int i=0;i<n;i++){
                o+=a.poll();
            }
		System.out.println(o);
    }  

}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		String str = br.readLine();
		String temp = br.readLine();

		if (str.contains(temp)) {
			for (int i = 0; i + temp.length() <= str.length(); i++) {
				if (str.substring(i, i + temp.length()).equals(temp)) {
					sb.append(i + "\n");
				}
			}
			System.out.print(sb.toString());
		}
	}
}

Measured memory_bytes: 24544
#include <bits/stdc++.h>
using namespace std;
#define test() int t; cin>>t; while(t--)
#define ll long long int
int mod = 1e9 + 7;

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int m1 = 0; m1 < (1 << h); m1++) {
		for (int m2 = 0; m2 < (1 << w); m2++) {
			int b = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (((m1 >> i) & 1) == 0 && ((m2 >> j) & 1) == 0 && a[i][j] == '#')	b++;
				}
			}
			if (b == k)	ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3656
n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt1, cnt2 = 0, 0
for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            cnt1 += 1

for i in range(n):
    for j in range(n):
        if a[i] > a[j]:
            cnt2 += 1
print(((cnt1 * k + cnt2 * k * (k - 1) // 2)) % (10 ** 9 + 7))

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

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

#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<lli> vli;

//static bool comp(){
//    if(){
//        return true;
//    }
//    return false;
//}


void solve(){
    string s1, s2;
    cin >> s1 >> s2;

    for(int i = 0; i< s1.length(); i++){
        if(s1[i] != s2[i]){
            cout<<"No";
            return;
        }
    }
    
    cout<<"Yes";
    return;
}




int main(){
    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif


    int t = 1;
    while(t--){
        solve();
        cout<<endl;
    }

}

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

int main()
{
    int i = 1;
    int tmp;

    while(1)
    {
        cin >> tmp;
        if(tmp == 0){
            break;
        }
        else{
            cout << "Case " << i << ": " << tmp << endl;
            i++;
        }
    }

    return 0;
}



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

int main(){
    int k, n; cin >> k >> n;
    int a[n];
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    int sec[n];
    for(int i = 1;i < n;i++){
        sec[i] = a[i] - a[i - 1];
    }
    sec[0] = a[0] + k - a[n - 1];
    int ans = k;
    for(int i = 0;i < n;i++){
        ans = min(ans,k - sec[i]);
    }
    cout << ans << endl;
}
 

Measured memory_bytes: 1792