akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int  ans[52][52];
int H,W;



void F( char a,int i,int j ){
	if( a == '#' ){
		if(i==0&&j==0){
			ans[i][j]=-10000;
			ans[i+1][j]+=1;
			ans[i][j+1]+=1;
			ans[i+1][j+1]+=1;
			return;
		}
		
		else if(i==0){

			ans[i][j]=-10000;
			ans[i][j-1]+=1;
			ans[i+1][j-1]+=1;
			ans[i+1][j]+=1;
			ans[i][j+1]+=1;
			ans[i+1][j+1]+=1;
			return;
		}

		else if(j==0){
			ans[i][j]=-10000;
			ans[i-1][j]+=1;
			ans[i-1][j+1]+=1;
			ans[i][j+1]+=1;
			ans[i+1][j]+=1;
			ans[i+1][j+1]+=1;
			return;
		}

		else{
			ans[i][j]=-10000;
			ans[i-1][j-1]+=1;
			ans[i-1][j]+=1;
			ans[i-1][j+1]+=1;
			ans[i][j-1]+=1;
			ans[i][j+1]+=1;
			ans[i+1][j-1]+=1;
			ans[i+1][j]+=1;
			ans[i+1][j+1]+=1;
			return;
		}
	}
}



int main(){
	for(int i=0;i<52;i++){
		for(int j=0;j<52;j++){
			ans[i][j]=0;
		}
	}

	char a;
	cin >> H >> W;
	for(int i=0 ; i < H ; i++){
		for(int j=0 ; j < W ; j++){
			cin >> a;
			F(a,i,j);
		}
	}

	for(int i=0;i<H;i++){
		for(int j=0;j < W ;j++){
			if(ans[i][j]<0)cout<<'#';
			else cout <<ans[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 256
import sys
import heapq
def input(): return sys.stdin.readline().rstrip()

def main():
    K = int(input())
    q = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    heapq.heapify(q)
    while len(q) < K:
        K -= len(q)
        new_q = []
        for i in q:
            d1 = i % 10
            if d1 > 0:
                new_q.append(i * 10 + d1 - 1)
            new_q.append(i * 10 + d1)
            if d1 < 9:
                new_q.append(i * 10 + d1 + 1)
        q = new_q
        heapq.heapify(q)
    print(q[K-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 10816
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, A, B = map(int, read().split())

if A > B:
    x = 0
elif N == 1:
    x = 1 * (A == B)
else:
    low = A * (N - 1) + B
    high = B * (N - 1) + A
    x = high - low + 1
print(x)

Measured memory_bytes: 9132
/***** ?????¬???????????¬?????? *****/

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

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int const MOD = 1000000007;

int main() {
    double n;
    while(cin >> n) {
        double t = n / 9.8;
        double y = 4.9 * t * t;
        int ret_d = ceil(y / 5.0);
        cout << ret_d + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1228
# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;

typedef long long ll;

int a, b;

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

      if((a * b) % 2)
            puts("Odd");
      else
            puts("Even");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    long H;
    cin >> H;

    int cnt = 0;
    long sum = 0;

    do {
        sum += pow(2, cnt);
        cnt++;
        H /= 2;
    } while(H > 0);

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

h, w, k = gsmi

cs = Array.new(h){ gs }
answer = 0

(2**h).times do |i|
  (2**w).times do |j|
    csc = Marshal.load(Marshal.dump(cs))
    h.times do |x|
      if (i>>x)&1==1
        csc[x] = " "*w
      end
    end
    w.times do |y|
      if (j>>y)&1==1
        h.times{|x| csc[x][y]=" " }
      end
    end
    num = csc.inject(0){|ret,n| ret + n.count('#') }
    answer+=1 if num==k
  end
end

puts answer


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()

const long long INF = 1LL<<60;
const int mod = 1000000007;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

int N;
string s;
vector<vector<ll>> dp(3010, vector<ll>(3010, 0));

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

    cin >> N;
    cin >> s;

    for (int i = 0; i < N; i++) {
        dp.at(0).at(i) = 1;
    }

    for (int i = 0; i < N - 1; i++) {
        vector<int> sum(3010, 0);
        sum.at(0) = 0;
        for (int j = 0; j <= N - i; j++) {
            sum.at(j + 1) = (sum.at(j) + dp.at(i).at(j)) % mod;
        }

        if (s.at(i) == '<') {
            for (int j = 0; j < N - i; j++) {
                dp.at(i + 1).at(j) = (sum.at(N - i) - sum.at(j + 1) + mod) % mod;
            }
        }
        if (s.at(i) == '>') {
            for (int j = 0; j < N - i; j++) {
                dp.at(i + 1).at(j) = sum.at(j + 1);
            }
        }
    }

    cout << dp.at(N - 1).at(0) << endl;

    
    return 0;
}

Measured memory_bytes: 71296
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define pair pair<int,int>
typedef long long ll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

class UnionFind{
    vector<int> par; vector<int> rank;
    public:
        UnionFind(int N) : par(N),rank(N){
            for(int i=0; i<N; ++i){ par[i] = i; rank[i] = 0; }
        }

        int find(int x){
            if(par[x] == x)return x;
            return par[x]=find(par[x]);
        }

        //xとyとが所属する集合を併呑する
        void unite(int x,int y){
            int rx = find(x); int ry = find(y);
            if(rx == ry) return;
            if(rank[x]<rank[y]){
                par[rx] = ry;
            }else{
                par[ry] = rx;
                if(rank[rx] == rank[ry])rank[rx]++;
            }
        }

        bool same(int x, int y){
            int ry = find(x); int rx = find(y);
            return rx == ry;
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k,l; cin>>n>>k>>l; int p,q;
    UnionFind road(n); rep(i,k){ cin>>p>>q; road.unite(--p,--q); }
    UnionFind rail(n); rep(i,l){ cin>>p>>q; rail.unite(--p,--q); }

    map<pair,int> ans;
    rep(i,n)ans[{road.find(i),rail.find(i)}]++;
    rep(i,n)cout<<ans[{road.find(i),rail.find(i)}]<<' '; return 0;
}

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

int main() {
    double N;
    cin >> N;
    int X;
    X = N;
    if (X % 2 == 0) cout << setprecision(10) << (N / 2) / N << endl;
    else cout << setprecision(10) << ((N + 1) / 2) / N << endl;
}

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

using namespace std;

const int MOD=1000000007;
typedef long long int ll;

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

ll mult(ll a,ll b)
{
	return (a*b)%MOD;
}

ll pot(ll n,ll k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

ll divide(ll a,ll b)
{
	return mult(a,pot(b,MOD-2));
}

ll sub(ll a,ll b)
{
	return (a-b+MOD)%MOD;
}

ll add(ll a,ll b)
{
	return (a+b)%MOD;
}

int n,ma;
int a[100001],b[100001],c[100001],d[100001];

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin>>n;
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
		if (i) b[i]=b[i-1]+a[i];
		else b[i]=a[i];
	}
	for (int i=0;i<n;++i)
	{
		cin>>c[i];
		d[i+1]=d[i]+c[i];
	}
	for (int i=0;i<n;++i)
	{
		ma=max(ma,b[i]+d[n]-d[i]);
	}
	cout<<ma<<endl;
}



Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

vc = []
for i in range(n):
    vc.append(v[i]-c[i])

vc = sorted(vc, reverse=True)
ans = 0
for i in range(n):
    if vc[i]>0:
        ans += vc[i]

print(ans)

Measured memory_bytes: 3064
// include headers{{{
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*}}}*/
# define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

template<typename integer>
integer __lcm(integer a, integer b) {
    return (a * b) / __gcd(a, b);
}

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

    if (a.back() == b[0] and b.back() == c[0]) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){
    int64_t A, B, K;
    cin >> A >> B >> K;
    int64_t a = 0;
    if(A- K > 0) a = A -K;
    int64_t b = 0;
    if(A + B -K - a > 0) b= A + B -K - a;
    cout << a << " " << b << endl;
}

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

using namespace std;

#define maxn 100005
#define ll long long int
#define db(x) cout<<#x<<" -> "<<x<<endl
#define db2(x,y) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<endl
#define db3(x,y,z) cout<<#x<<" -> "<<x<<" , "<<#y<<" -> "<<y<<" , "<<#z<<" -> "<<z<<endl
#define prt(x) for(auto it = x.begin(); it!=x.end(); it++){cout<<*it<<" " ;}cout<<endl
#define IN freopen("input.txt","r",stdin)

ll dp[105][maxn];
int weight[ maxn ] , value[ maxn ];
int W ;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
//    IN ;
    int n ;
    cin>>n>>W ;
    int S = 0 ;
    for(int i=1; i<=n; i++){
        cin>>weight[i]>>value[i];
        S+=value[ i ];
    }
    for(int i=0; i<=n; i++){
        for(int v=0; v<=S; v++){
            if(v==0){ dp[i][v] = 0;  continue ; }
            dp[i][v] = (ll)1e12;
        }
    }
    for(int i=1; i<=n; i++){
        for(int v=0; v<=S; v++){
            dp[i][v] = dp[i-1][v];
            if( v < value[ i ] ){ continue ; }
            dp[i][v] = min(dp[i][v],dp[i-1][v-value[i]]+weight[i]);
        }
    }
    int ans = -1;
    for(int i=0; i<=S; i++){
        if(dp[n][i]<=W){
            ans = max(ans,i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main() {
  int a,b;cin >> a >> b;
  int ans = -1;
  for(int i=1; i<10000; i++){
    int pa = i*8/100;
    int pb = i/10;
    if(pa == a && pb == b){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def traverse
  a = []
  length = 1
  now = 0
  @list[now] = 1
  loop do
   @n.times do |i|
     if @m[now][i] == 1 && @list[i] == 0
       a.push([i, length + 1])
       @data[i].length = length
       @list[i] = 1
     end
   end
   if a.empty?
     return nil
   end
   next_one = a.shift
   now = next_one[0]
   length = next_one[1]
  end
  return @list
end

D = Struct.new(:length)
@n = gets.chomp.to_i
@time = 0
@m = Array.new(@n){Array.new(@n){0}}
@data = Array.new(@n){D.new(-1)}
@list = Array.new(@n){0}
@n.times do
	s = gets.split.map(&:to_i)
	i = s[0] - 1
	s[1].times do |l|
		j = s[l + 2] - 1
		@m[i][j] = 1
	end
end
@data[0].length = 0
traverse

@n.times do |i|
	puts "#{ i + 1 } #{@data[i].length}"
end

Measured memory_bytes: 8680
# -*- coding: utf-8 -*-

n, m = map(int, input().split())
p = ["" for _ in range(m)]
s = ["" for _ in range(m)]
for i in range(m):
    tmp = input().split()
    p[i] = int(tmp[0])
    s[i] = tmp[1]

isACed = [[0,0] for _ in range(n)]

n_correct = 0
n_penalty = 0
for i in range(m):
    if isACed[p[i]-1][1] != 1:
        if s[i] == "WA": #"WA"の時
            isACed[p[i]-1][0] += 1
        else: #"AC"の時
            n_correct += 1
            isACed[p[i]-1][1] = 1
            n_penalty += isACed[p[i]-1][0]

print(n_correct, n_penalty)


Measured memory_bytes: 23472
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> a(n);
  vector<int> b;
  string st;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(i==j)continue;
      st=a[i]+a[j];
      //cout << st << endl;
      int num;
      num=atoi(st.c_str());
      b.push_back(num);
      sort(b.begin(),b.end());
      if(b.size()>3)b.pop_back();
    }
  }
  for(int i=0;i<3;i++){
    if(i==2)cout << b[i] << endl;
  }
  return 0;
}

      

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

ll mygcd(ll x, ll y){
    return y > 0 ? mygcd(y, x % y) : x;
}

void Main() {
    ll n, x;
    cin >> n >> x;
    ll g = mygcd(n, x);
    n /= g;
    
    cout << 3*(n-1)*g << endl;
	return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

#define inf 0x3f3f3f3f
#define endl '\n'

int dp[100005], h[100005];
int n;

int fr(int i){
  if(i>n) return inf;
  if(i==n) return 0;
  if(dp[i]!=-1) return dp[i];
  return dp[i]=min(fr(i+1) + abs(h[i]-h[i+1]), fr(i+2) + abs(h[i]-h[i+2]));
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> h[i];
    dp[i]=-1;
  }

  cout << fr(1) << endl;
}


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

int  main()
{
	int r,g,b,n;
	cin >> r >> g >> b >> n;
	long ans = 0;
	for(int i = 0; i <= n / r; i++)
	{
		for (int j = 0; j <= n / g; j++)
		{
			if (n - ((i*r) + (j * g)) == 0)
				ans++;
			else if (n - ((i*r) + (j * g)) > 0)
			{
				if ((n - ((i*r) + (j * g))) % b == 0)
					ans++;
			}
		}
	}
	cout << ans << endl;
	return (0);
}


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

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    if (x / d > k)
    {
        cout << abs(x - k * d) << endl;
        return 0;
    }

    k -= x / d;
    x = x % d;

    if (k % ll(2) == 0)
        cout << x << endl;
    else
        cout << abs(x - d) << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
map<ll,ll> dp;
ll find(ll n)
{
    if(n<0)
        return 0LL;
    if(n==0)
        return 1LL;
    if(dp.count(n))
        return dp[n];
    ll ans=0;
    fr(i,3,10)
    {
        ans+=find(n-i);
        ans%=mod;
    }
    dp[n]=ans;
    return ans;
}
void solve()
{
    ll n;
    cin>>n;
    VL dp(n+1,0);
    dp[0]=1;
    fr(i,0,n+1)
    {
        fr(j,3,n+1)
        {
            if(i-j>=0&&dp[i-j]>0)
            {
                dp[i]+=dp[i-j];
                dp[i]%=mod;
            }
        }
    }
    cout<<dp[n]<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    //cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

int main() {
    const double PI = acos(-1);
    cout << fixed << setprecision(5);

    double r;
    cin >> r;
    double area;
    double circumference;

    area          = PI * r * r;
    circumference = 2 * PI * r;
    cout << area << " " << circumference << "\n";

    return 0;
}



Measured memory_bytes: 3288
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
	int A,B,K;
	int count=0;
	cin>>A>>B>>K;
	if(A>=B){
		swap(A,B);//A<=B;
	}
	for(int i=A;i!=0;i--){
		if(A%i==0&&B%i==0){
			count++;
		}
		if(count==K){
			cout<<i<<endl;
			return 0;
		}
	}
}

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

r_list = []


min_r = 99999999999
max_profit = -999999999999

for n in range(N):
    temp_r = int(input().rstrip())
    if temp_r - min_r > max_profit:
        max_profit = temp_r - min_r
    if temp_r < min_r:
        min_r = temp_r

print(max_profit)


Measured memory_bytes: 5612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.Collator;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      StringBuilder line  = new StringBuilder();
      StringBuilder wordA = new StringBuilder();
      StringBuilder wordB = new StringBuilder();
      Collator collator = Collator.getInstance();
      int turn = Integer.parseInt(br.readLine());
      int pointA = 0;
      int pointB = 0;
      int result = 0;


      for ( int i = 0; i < turn; i++ ) {

        line.append(br.readLine());
        wordA.append(line.substring(0, line.indexOf(" ")));
        wordB.append(line.substring(line.indexOf(" ")+1, line.length()));

        result = collator.compare(wordA.toString(),wordB.toString());
        pointA += result == 0 ? 1 : result < 0 ? 0 : 3;
        pointB += result == 0 ? 1 : result < 0 ? 3 : 0;

        line.setLength(0);
        wordA.setLength(0);
        wordB.setLength(0);
      }

      System.out.println(pointA + " " + pointB);
    }
  }
}


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

ans = 0
for i in range(1, N+1):
    if i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    elif i % 3 == 0 and i % 5 == 0:
        continue
    ans += i
else:
    print(ans)


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
static const double pi = 3.141592653589793;

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

  ll ans = 0;
  ll n; cin >> n;

  for(ll i = 1; i * i < n; ++i) {
    if((n - i) % i == 0 && (n - i) / i > i) ans += (n - i) / i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static readonly Dictionary<char, string> dic = new Dictionary<char, string>()
        {
            {' ',"101" },
            {'\'',"000000" },
            {',',"000011" },
            {'-',"10010001" },
            {'.',"010001" },
            {'?',"000001" },
            {'A',"100101" },
            {'B',"10011010" },
            {'C',"0101" },
            {'D',"0001" },
            {'E',"110" },
            {'F',"01001" },
            {'G',"10011011" },
            {'H',"010000" },
            {'I',"0111" },
            {'J',"10011000" },
            {'K',"0110" },
            {'L',"00100" },
            {'M',"10011001" },
            {'N',"10011110" },
            {'O',"00101" },
            {'P',"111" },
            {'Q',"10011111" },
            {'R',"1000" },
            {'S',"00110" },
            {'T',"00111" },
            {'U',"10011100" },
            {'V',"10011101" },
            {'W',"000010" },
            {'X',"10010010" },
            {'Y',"10010011" },
            {'Z',"10010000" }
        };

        static readonly char[] ch = new char[]
        {
            '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',
            ' ','.',',','-','\'','?'
        };

        static void Main(string[] args)
        {
            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                StringBuilder sb = new StringBuilder();
                StringBuilder temp = new StringBuilder();

                for (int i = 0; i < input.Length; i++)
                {
                    temp.Append(dic[input[i]]);
                }

                string conv = temp.ToString();
                int m = conv.Length % 5;

                if (m != 0)
                {
                    for (int i = 0; i < 5 - m; i++) conv += "0";
                }

                for (int i = 0; i < conv.Length; i += 5)
                {
                    string sub = conv.Substring(i, 5);
                    int idx = Convert.ToInt32(sub, 2);
                    sb.Append(ch[idx]);
                }
                Console.WriteLine(sb);
            }
        }
    }
}

Measured memory_bytes: 9640
s = list(input())
result = []
i = 0
c = len(s)
while(i < c):
#for i in range(len(s)):
    x = s[i]
    if result == []:
        result.append(x)
    else:
        #print(x, result[-1])
        if result[-1] != x:
            result.append(x)
        else:
            if i != c - 1:
                result.append(x + s[i + 1])
            i += 1
    i += 1
    #print(result)
    #print()

print(len(result))
    
    


Measured memory_bytes: 9636
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

ll COM(ll a,ll b){
    if(a<0||b<0){
        return 0;
    }
    if(b==0){
        return 1;
    }
    return COM(a-1,b)+COM(a,b-1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N;
    cin >> N;
    vP p(N);
    rep(i,N){
        cin >> p[i].first;
        p[i].second=i+1;
    }
    sort(p.begin(),p.end());
    reverse(p.begin(),p.end());
    multiset<ll> mst;
    mst.insert(0);
    mst.insert(0);
    mst.insert(N+1);
    mst.insert(N+1);
    ll ans=0;
    ROF(i,N,1){
        auto k=mst.lower_bound(p[N-i].second);
        ll l2,l1,h1,h2,m;
        m=p[N-i].second;
        h1=*k;
        k++;
        h2=*k;
        k--;
        k--;
        l1=*k;
        k--;
        l2=*k;
        mst.insert(m);
        //cout << l2 << l1 << m << h1 << h2 << endl;
        ans+=i*((l1-l2)*(h1-m)+(h2-h1)*(m-l1));
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9508
n,q = map(int,input().split())
s = list(input())

count = [0]*n
for i in range(1,n):
  if s[i]=='C' and s[i-1]=='A': 
    count[i] = count[i-1] + 1
  else: 
    count[i] = count[i-1]

for i in range(q):
  l,r = map(int,input().split())
  l -= 1
  r -= 1
  print(count[r]-count[l])


Measured memory_bytes: 6876
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const ll MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

void solve(){
    string s;cin >> s;
    int n = s.size();
    deque<char>d;
    for(int i = 0;i<n;i++) d.push_back(s[i]);
    deque<char>d1;
    for(int i = n-1;i>=0;i--) d1.push_back(s[i]);
    int q;cin >> q;
    int b = 0;
    while(q--){
        int c;cin >> c;
        if(c==2&&b%2==0){
            int a;cin >> a;
            char cc;cin >> cc;
            if(a==1){d.push_front(cc);d1.push_back(cc);}
            else {d.push_back(cc);d1.push_front(cc);}
        }
        else if(c==2){
            int a;cin >> a;
            char cc;cin >> cc;
            if(a==1){d1.push_front(cc);d.push_back(cc);}
            else {d1.push_back(cc);d.push_front(cc);}
        }
        else{
            b++;
        }
    }
   int nn = d.size();
   if(b%2){for(int i = 0;i<nn;i++) cout << d1[i];}
   else for(int i = 0;i<nn;i++) cout << d[i];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 4408
def bubble_sort(a, n):
    # N個の要素を含む0-オリジナルの配列A
    cnt = 0
    flag = True
    while flag:
        flag = False
        for j in reversed(range(1, n)):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
                cnt += 1
                flag = True
    print(" ".join([str(x) for x in a]))
    print(cnt)


def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    bubble_sort(a, n)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    if (a >= 13) {
        cout << b;
    } else if (a >= 6) {
        cout << b / 2;
    } else {
        cout << 0;
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
cnt=0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors

for i in range(1,n+1,2):
  if len(make_divisors(i))==8:
    cnt+=1
print(cnt)


Measured memory_bytes: 3060
N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[]
for i in range(N):
    Px.append((1+P[i])/2)
temp_num = sum(Px[0:K])
temp_max = sum(Px[0:K])
#print(Px)
for j in range(N-K):
    #print(temp_num)
    temp_num = temp_num-Px[j]+Px[j+K]
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)

Measured memory_bytes: 25060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            Console.WriteLine(3*a*a);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int arr[100050];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1;i <= n;++i)
        scanf("%d", &arr[i]);
    long long ans = 0;
    for(int i = 1;i <= n;++i)
    {
        ans = ans + arr[i] / 2;
        arr[i] %= 2;
        if(arr[i] && arr[i + 1])
        {
            ++ans;
            --arr[i];
            --arr[i + 1];
        }
    }
    printf("%lld\n", ans);
    //scanf("%d", &n);
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
	fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
	ll x, k, d;
	cin>>x>>k>>d;
	x = abs(x);
	ll a = x/d;
	if(a>=k){
		cout<<x - d*k<<endl;
		return 0;
	}
	ll b = k-a;

	if(b%2 == 0){
		cout<<x - a*d<<endl;
	} else {
		cout<<abs(x - a*d - d)<<endl;
	}
}

Measured memory_bytes: 3648
S = input()
s = S.split()

N = int(s[0])
Y = int(s[1]) 
a = True

for i in range(N + 1):
    for j in range(N + 1 - i):
        k = N - i - j
        if Y == i * 10000 + j * 5000 + k * 1000:
            print(i, j, k)
            a = False
            break
    if a == False:
        break
if a == True:
    print(-1, -1, -1)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	string s; cin >> s;
	int n = s.size();
	vector<int64_t> ans(n + 1);

	int cn = 0;
	{
		int i = 0;
		while (i < n) {
			if (s[i] == '<') {
				while (s[i] == '<') {
					ans[i] = cn;
					cn++;
					i++;
				}
			}
			else {
				int c = 0;
				while (s[i + c] == '>') {
					c++;
				}

				ans[i] = max(cn, c);
				FOR_LE(j, 1, c) {
					ans[i + j] = (c - j);
				}
				cn = 0;

				i += c;
			}
		}
		if (s[i - 1] == '<') {
			//cout << i << " " << cn << endl;
			ans[i] = cn;
		}
	}

	int64_t sum = 0;
	FOR_LT(i, 0, ans.size()) {
		sum += ans[i];
		//cout << ans[i] << " ";
	}
	//cout << endl;
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 4764
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    w=LIST()
    wsum=sum(w)
    temp=0
    ct=999999999
    ans=0
    for i in range(n):
        temp+=w[i]
        ct=min(ct,abs(wsum/2-temp)*2)
    print(int(ct))
        
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
import math
N = int(input())

div = []
for i in range(1, int(math.sqrt(N))+1):
    if N % i == 0:
        div.append((i, N//i))
ans = 30
for elem in div:
    _, a = elem
    cnt = 0
    while a > 0:
        a //= 10
        cnt += 1
    ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 3060
let inf = 1010101010101010
let rec for_iter a b f = if a >= b then () else (f a; for_iter (a+1) b f)

let rec main () =
  let n, m, l, k, a, h =
    Scanf.scanf " %d %d %d %d %d %d" (fun u v w x y z -> u,v,w,x,y,z) in
  if n+m+l+k+a+h = 0 then () else

  let is_fridge = Array.make n false in
  for_iter 0 l (fun _ ->
    Scanf.scanf " %d" (fun x -> is_fridge.(x) <- true));
  is_fridge.(a) <- true; is_fridge.(h) <- true;

  let costs =
    Array.init n (fun _ -> Array.make n inf) in
  for_iter 0 n (fun i -> costs.(i).(i) <- 0);
  for_iter 0 k (fun _ ->
    Scanf.scanf " %d %d %d" (fun x y z ->
      costs.(x).(y) <- z;
      costs.(y).(x) <- z));

  for_iter 0 n (fun k ->
    for_iter 0 n (fun i ->
      for_iter 0 n (fun j ->
        costs.(i).(j) <- min costs.(i).(j) (costs.(i).(k) + costs.(k).(j))
  )));

  for_iter 0 n (fun i ->
    for_iter 0 n (fun j ->
      if i <> j && (is_fridge.(i) = false || is_fridge.(j) = false || costs.(i).(j) > m) then
        costs.(i).(j) <- inf
  ));
  for_iter 0 n (fun k ->
    for_iter 0 n (fun i ->
      for_iter 0 n (fun j ->
        costs.(i).(j) <- min costs.(i).(j) (costs.(i).(k) + costs.(k).(j))
  )));

  if costs.(a).(h) = inf then
    print_endline "Help!"
  else
    Printf.printf "%d\n%!" (costs.(a).(h) + max 0 (costs.(a).(h) - m));

  main ()

let () = main ()



Measured memory_bytes: 5084
import sys,os,io
input = sys.stdin.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N = int(input())
edge = [[] for _ in range(N)]
for i in range(N-1):
  a,b = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

def dfs(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  while stack:
    v = stack[-1]
    marker = 0
    for u in edge[v]:
      if u==parent[v]:
        continue
      if parent[u]==N: #子へ降ろす
        marker = 1
        parent[u]=v
        stack.append(u)
      else: #子から吸い上げる
        pass
        #吸い上げる際の個々の処理
        ans[v] += ans[u]+1
    if marker==0:
      stack.pop()
      if v==start:
        #根へ吸い上げる時のまとめ処理
        ans[v] /= len(edge[v])
      elif ans[v]>0:
        ans[v] /= len(edge[v])-1
  return

def dfs2(start):
  stack = [start]
  parent = [N]*N
  parent[start] = -1
  p_value = [0]*N
  while stack:
    v = stack.pop()
    for i,u in enumerate(edge[v]):
      if u==parent[v]:
        continue
      parent[u] = v
      if len(edge[v])==1:
        p_value[u] = 0
      else:
        p_value[u] = (ans[v]*len(edge[v])-(ans[u]+1))/(len(edge[v])-1)
      ans[u] *= len(edge[u])-1
      ans[u] += p_value[u]+1
      ans[u] /= len(edge[u]) 
      stack.append(u)
  return

ans = [0]*N
dfs(0)
dfs2(0)
print(*ans, sep='\n')

Measured memory_bytes: 115624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct xyz{
  int x,y,z;
  xyz(int x,int y,int z):x(x),y(y),z(z){}
};
ll a,b,c,n;
vector<xyz> v;
bool out(int x,int y,int z){
  if(x<0||x>=a||y<0||y>=b||z<0||z>=c) return true;
    return false;
}
 
int calc(int x,int y,int z){
  int r=0;
  int ax[]={1,-1,0,0,0,0};
  int ay[]={0,0,1,-1,0,0};
  int az[]={0,0,0,0,1,-1};
  for(int i=0;i<6;i++){
    if(out(x+ax[i],y+ay[i],z+az[i])) continue;
    bool f=false;
    for(int j=0;j<v.size();j++){
      if(v[j].x==x+ax[i]&&v[j].y==y+ay[i]&&v[j].z==z+az[i]) f=true;
    }
    if(!f) r++;
  }
  return r;
}
 
int main(){
  cin >> a >> b >> c >> n;
  ll ans=(a*b+b*c+c*a)*2;
  ll x,y,z;
  for(int i=0;i<n;i++){
    cin >> x >> y >> z;
    ans+=2*calc(x,y,z)-6;
    v.push_back(xyz(x,y,z));
  }
  cout << ans << endl;
  return 0;
}

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

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

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

  int n, x;
  cin >> n >> x;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  c.push_back(x);
  sort(c.begin(), c.end());

  vector<int> d(n);
  rep(i, n) {
    d[i] = c[i+1] - c[i];
  }
  
  int ans = d[0];
  for(int i = 1; i < n; ++i) {
    ans = gcd(ans, d[i]);
  }

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

Measured memory_bytes: 3964
from collections import deque

H,W=map(int,input().split())
A=["*"*(W+2) for _ in range(H+2)]

for i in range(1,H+1):
    A[i]="*"+input()+"*"

inf=float("inf")
Dist=[[inf]*(W+2) for _ in range(H+2)]
Q=deque()

for x in range(1,H+1):
    for y in range(1,W+1):
        if A[x][y]=="#":
            Dist[x][y]=0
            Q.append((x,y))

E=[(-1,0),(1,0),(0,-1),(0,1)]
while Q:
    (x,y)=Q.popleft()
    for (a,b) in E:
        if A[x+a][y+b]=="." and Dist[x+a][y+b]==inf:
            Dist[x+a][y+b]=Dist[x][y]+1
            Q.append((x+a,y+b))

Ans=0
for x in range(1,H+1):
    for y in range(1,W+1):
        Ans=max(Ans,Dist[x][y])
print(Ans)

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

int main(){

    int N;
    cin >> N;

    int x[N],y[N],h[N];
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    for(int ix=0; ix<=100; ix++){
        for(int iy=0; iy<=100; iy++){

            int h_top = 0;

            for(int ih=0; ih<N; ih++){
                if(h[ih]>0){
                    int h_tmp = h[ih] + abs(ix-x[ih]) + abs(iy-y[ih]);
                    h_top = max(h_top,h_tmp);
                }
            }

            for(int ih=0; ih<N; ih++){
                int h_cur = h[ih] + abs(ix-x[ih]) + abs(iy-y[ih]);
                if (h_top > h_cur){break;}
                
                if (ih == N-1){ cout << ix << " " << iy << " "<< h_top << endl;}
            }
        }
    }

    return 0;

}

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

int main(){
  int n, x; cin >> n >> x;
  int l[105];
  for (int i = 0; i < n; i++){
    cin >> l[i];
  }
  int dist=0, count=1;
  int i = 0;
  while (dist + l[i] <= x && count <= n){
    dist += l[i];
    count++;
    i++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
n = int(input())
 
s = input()
 
alphabet = ["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"]
 
ans = ""
for i in range(len(s)):
    num = (alphabet.index(s[i]) + n) % len(alphabet)
    ans += alphabet[num]
    
print(ans)

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

const int MAXN = 1e5 + 5;
int n, k, m;
string s;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); i++)
        n += (s[i] == '+'? 1: -1);
    cout << n;
    return 0;
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  int score = 0;
  
  if (A + B >= K && A >= K) {
    score = K;
  }
  
  if (A + B >= K && A < K) {
    score = A;
  }
  
  if (A + B < K) {
    score = A - (K - (A + B));
  }
  
  cout << score << endl;
}

Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    ans = [1,2,3]
    a = int(input())
    b = int(input())
    ans.remove(a)
    ans.remove(b)
    print(ans.pop())

if __name__ == '__main__':
    main()


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9+7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
def check(x,m):
    if m % x:
        return m % x == 1
    return check(x,m//x)

def count(n):
    cnt = 1
    f = defaultdict(int)
    for i in range(2,int(math.sqrt(n))+1):
        if n % i == 0 and f[i] == 0:
            cnt += 1
            f[i] = 1
            if f[n//i] == 0:
                cnt += 1
                f[n//i] = 1
    return cnt

def count2(n):
    cnt = 1
    f = defaultdict(int)
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            if check(i,n) and f[i] == 0:
                cnt += 1
                f[i] = 1
            if check(n//i,n) and f[n//i] == 0:
                cnt += 1
                f[n//i] = 1
    return cnt
ans = 0
if n-1 >= 2:
    ans += count(n-1)
ans += count2(n)
print(ans)


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

int gcd(int a, int b) {
  int c;
  while (b) {
    c = a % b;
    a = b;
    b = c;
  }
  return abs(a);
}

int lcm(int &a, int &b) {
  return abs(a / gcd(a, b) * b);
}

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

  int a, b, c;
  cin >> a >> b >> c;

  int l = lcm(a, b);
  string ans = "NO";
  for (int i = a; i <= l; i += a) {
    if (i % b == c) {
      ans = "YES";
      break;
    } 
  }
  cout << ans << '\n';
  return 0;

}

Measured memory_bytes: 256
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
    double a,b,h,m,hx,hy,mx,my,pi=acos(-1);
    cin>>a>>b>>h>>m;
    double r1,r2;
    r1=30*h+0.5*m;
    r2=6*m;
double rad=pi/180;
// cout<<sin(90*rad)<<" ";
    hy=a*cos(r1*rad);
    hx=a*sin(r1*rad);
    my=b*cos(r2*rad);
    mx=b*sin(r2*rad);

printf("%.9f",sqrt(pow(abs(mx-hx),2.0)+pow(abs(my-hy),2.0)));





    return 0;
  }


Measured memory_bytes: 4120
#include <bits/stdc++.h>
#define IOS                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
typedef long long ll;
using namespace std;
int main()
{

    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    long long int dp[100000];
    dp[0] = 0;
    dp[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i < n; i++)
    {
        dp[i] = min((dp[i - 2] + abs(arr[i - 2] - arr[i])), (dp[i - 1] + abs(arr[i - 1] - arr[i])));
    }
    cout << dp[n - 1];
}

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

int main(){
  int n;
  cin >> n;
  long long a, b;
  a = b = 0;
  long long f, g;
  f = g = 0;
  vector<int> c(n), d, e;
  for(int i = 0; i < n; i++)
    cin >> c[i];
  sort(c.begin(), c.end());
  if(n % 2 == 0){
    for(int i = 0; i < n; i++){
      if(i * 2 < n)
        d.push_back(c[i]);
      else
        e.push_back(c[i]);
    }
    for(int i = 0; i < n / 2; i++){
      a += e[i];
      b += d[i];
      if(i != 0)
        a += e[i];
      if(i != n / 2 - 1)
        b += d[i];
    }
    cout << a - b << endl;
    return 0;
  }
  for(int i = 0; i < n; i++){
    if(i < n / 2){
      a += c[i] * 2;
      b += c[i] * 2;
    }
    else{
      f += c[i] * 2;
      g += c[i] * 2;
    }
  }
  f -= c[n / 2];
  f -= c[n / 2 + 1];
  b -= c[n / 2 - 1];
  b += c[n / 2];
  g -= c[n / 2] * 2;
  cout << max(f - a, g - b) << endl;
}


Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25

using namespace std;

int n;
int dept = 100000;

int main()
{
	while( cin >> n, !cin.eof())
	{
		
		FOR(i, 0, n)
		{
			dept += dept*0.05;
			
			if(dept%1000 != 0)
				dept += 1000 - dept%1000;
		}
		
		cout << (int)(dept) << endl;
		
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int a, b, c;
    a = max(max(A, B), C);
    b = min(min(A, B), C);
    c = A + B + C - a - b;

    for (int i = 0; i < K; i++){
        a *= 2;
    }

    cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define N 200005
using namespace std;

typedef long long ll;
ll n, m, st, en, M = 998244353;
ll d[N], s[N], l[N], r[N];
void f() {
	ll i;
	for (i = 1; i <= n; i++) {
		s[i] = s[i - 1] + d[i];
		s[i] %= M;
	}
}

ll g(ll p, ll q) {
	return (s[q] - s[p - 1] + M) % M;
}
int main()
{
	ll i, j;
	cin >> n >> m;
	d[1] = 1;
	s[1] = 1;
	for (i = 0; i <m; i++) {
		scanf ("%lld %lld", &l[i], &r[i]);
	}
	for (i = 2; i <= n; i++) {
		for (j = 0; j < m; j++) {
			en = i - l[j];
			st = max(i - r[j], 1ll);
			if (st <= en) d[i] = (d[i] + g(st, en)) % M;
		}
		s[i] = (s[i - 1] + d[i]) % M;
	}
//	for (i = 0; i < m; i++) {
//		scanf ("%lld %lld", &l, &r);
//		f();
//		for (j = n; j >= 1; j--) {
//			en = j - l;
//			st = max(j - r, 1ll);
//			if (st <= en) d[j] = (d[j] + g(st, en)) % M;
//		}
//	}
	cout << d[n] << endl;
    return 0;
}


Measured memory_bytes: 6888